Nenue@10: local B = select(2,...).frame Nenue@10: local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') Nenue@10: local print = B.print('SetStyle') Nenue@10: ------------------------------------------------------------- Nenue@10: --- Deals with swapping between different color palettes Nenue@10: --- Nenue@10: Nenue@10: local itemButtonSize, itemButtonSpacing = 36, 1 Nenue@10: local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} Nenue@10: local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]] Nenue@10: local titleSize, textSize = 15, 15 Nenue@10: local titleOutline, textOutline = "OUTLINE", "OUTLINE" Nenue@10: local titleSpacing, textSpacing = 4, 3 Nenue@13: local unpack, type, pairs, tconcat = unpack, type, pairs, table.concat Nenue@10: local wrapperMaxWidth, wrapperMaxHeight = 280, 490 -- these are the hard bounds, actual *Height variables are changed Nenue@10: local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' Nenue@10: local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 Nenue@10: local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 Nenue@10: Nenue@13: Nenue@10: mod.defaults.ObjectiveWrapper = { Nenue@10: ObjectiveTrackerFloat = {'BOTTOM', 'RIGHT'}, Nenue@10: ObjectiveTrackerParent = 'DebuffButton', Nenue@10: ObjectiveTrackerSize = {250, 600}, Nenue@10: ObjectiveWrapperParent = '', Nenue@10: } Nenue@10: mod.defaults.Style = { Nenue@13: Format = { Nenue@13: Frame = { Nenue@13: Width = 270, Nenue@13: }, Nenue@13: title = { Nenue@13: Indent = 0 Nenue@13: }, Nenue@13: status = { Nenue@13: Indent = 5 Nenue@13: } Nenue@13: }, Nenue@13: FontBank = { Nenue@10: ['Normal'] = _G.VeneerCriteriaFontNormal, Nenue@10: ['Progress'] = _G.VeneerCriteriaFontProgress, Nenue@10: ['Complete'] = _G.VeneerCriteriaFontComplete, Nenue@10: ['Failed'] = _G.VeneerCriteriaFontFailed, Nenue@10: }, Nenue@10: Normal = { Nenue@10: title = { Nenue@10: TextColor = {1, 1, 1, 1}, Nenue@10: Width = 270, Nenue@10: }, Nenue@10: titlebg = { Nenue@10: Background = {0, 0, 0, 1}, Nenue@10: Width = 270, Nenue@10: }, Nenue@10: status = { Nenue@10: Width = 270, Nenue@10: }, Nenue@10: statusbg = { Nenue@10: Width = 270, Nenue@10: }, Nenue@10: Frame = { Nenue@10: Width = 270, Nenue@10: } Nenue@10: }, Nenue@10: Wrapper = { Nenue@10: Frame = { Nenue@10: Point = {wrapperPosition}, Nenue@10: MaxSize = {wrapperMaxWidth, wrapperMaxHeight}, Nenue@10: BackgroundComplex = {Left = {'', 0, 0.4, 0,1, 100}, Right={'', 0.6,1,0,1}, Tile = {'', 0.4,.6,0,1, 100}}, }, Nenue@10: title = { Nenue@10: Font = {wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline}, Nenue@10: Spacing = 4,} Nenue@10: }, Nenue@10: Tracker = { Nenue@10: Normal = { Nenue@10: title = { Nenue@10: Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing, Nenue@10: }, Nenue@10: titlebg = { Nenue@10: Gradient = {MinColor = {0,0,0,0.7}, MaxColor = {0,0,0,.35}}, Nenue@10: } Nenue@10: } Nenue@10: }, Nenue@10: TrackerBlock = { Nenue@10: Normal = { Nenue@10: titlebg = { Nenue@10: Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, Nenue@10: }, Nenue@10: title = { Nenue@10: Font = {titleFont, titleSize, titleOutline}, Nenue@10: Spacing = titleSpacing, Nenue@10: }, Nenue@10: status = { Nenue@10: Font = {textFont, textSize, textOutline}, Spacing = textSpacing, Nenue@10: }, Nenue@10: statusbg = { Nenue@10: Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, Nenue@10: } Nenue@10: }, Nenue@10: Super = { Nenue@10: title = { Nenue@10: Font = {titleFont, titleSize, titleOutline}, Nenue@10: Spacing = titleSpacing, BackgroundFullWidth = true Nenue@10: }, Nenue@10: titlebg = { Nenue@10: Gradient = { MinColor = {0, .7, .6, .8}, MaxColor = {0, .7, .6, 0.2}}, Nenue@10: }, Nenue@10: status = { Nenue@10: Font = {textFont, textSize, textOutline}, Spacing = textSpacing, Nenue@10: }, Nenue@10: statusbg = { Nenue@10: Gradient = { MinColor = {0, .7, .6, 0.5}, MaxColor = {0, .7, .6, 0.1} }, Nenue@10: }, Nenue@10: }, Nenue@10: MouseDown = { Nenue@10: title = { Nenue@10: Font = {titleFont, titleSize, titleOutline}, Nenue@10: Spacing = titleSpacing, Nenue@10: }, Nenue@10: titlebg = { Nenue@10: Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .4}, }, Nenue@10: }, Nenue@10: status = { Nenue@10: Font = {textFont, textSize, textOutline}, Nenue@10: Spacing = textSpacing, Nenue@10: }, Nenue@10: statusbg = { Nenue@10: Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .2}, }, Nenue@10: } Nenue@10: }, Nenue@10: Complete = { Nenue@10: title = { Nenue@10: Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, Nenue@10: }, Nenue@10: titlebg = { Nenue@10: Gradient = { MinColor = {0, 1, 0, 0.34}, MaxColor = {0, 1, 0, .17}, }, Nenue@10: }, Nenue@10: status = { Nenue@10: Font = {textFont, textSize, textOutline}, Spacing = textSpacing, Nenue@10: }, Nenue@10: statusbg = { Nenue@10: Gradient = { MinColor = {0, 1, 0, .25}, MaxColor = {0, 1, 0, 0.12}, }, Nenue@10: } Nenue@10: }, Nenue@13: Daily = { Nenue@13: titlebg = { Nenue@13: Gradient = { MinColor = {0, .4, 1, 0.34}, MaxColor = {0, 0.4, 1, .17}, }, Nenue@13: }, Nenue@13: statusbg = { Nenue@13: Gradient = { MinColor = {0, .4, 1, 0.25}, MaxColor = {0, 0.4, 1, .12}, }, Nenue@13: }, Nenue@13: }, Nenue@10: Cheev = { Nenue@10: Normal = { Nenue@10: Nenue@10: title = { Nenue@10: Font = {titleFont, titleSize, titleOutline}, Nenue@10: Spacing = titleSpacing, Nenue@10: }, Nenue@10: titlebg = { Nenue@10: Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, Nenue@10: Nenue@10: }, Nenue@10: status = { Nenue@10: Font = {textFont, textSize, textOutline}, Nenue@10: Spacing = textSpacing, Nenue@10: }, Nenue@10: statusbg = { Nenue@10: Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, Nenue@10: }, Nenue@10: }, Nenue@10: Complete = { Nenue@10: title = { Nenue@10: Font = {titleFont, titleSize, titleOutline}, Nenue@10: Spacing = titleSpacing, Nenue@10: }, Nenue@10: titlebg = { Nenue@10: Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, Nenue@10: }, Nenue@10: status = { Nenue@10: Font = {textFont, textSize, textOutline}, Nenue@10: Spacing = textSpacing, Nenue@10: }, Nenue@10: statusbg = { Nenue@10: Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, Nenue@10: }, Nenue@10: }, Nenue@10: } Nenue@10: } Nenue@10: } Nenue@10: Nenue@10: local style_cache_func = {} Nenue@10: local block_vars = { Nenue@10: ['titleSize'] = {'titleWidth', 'titleHeight'}, Nenue@10: ['FrameSize'] = {'width', 'height'} Nenue@10: } Nenue@10: local attrib_vars = { Nenue@10: ['Font'] = {'height'}, Nenue@10: } Nenue@10: Nenue@10: mod.BlockStyleCache = {} Nenue@10: local style_cache = mod.BlockStyleCache Nenue@10: mod.regions = {} Nenue@10: mod.regionStyles = {} Nenue@10: mod.SetBlockStyle = function(frame, frameType, ...) Nenue@10: -- var names intended to reflect argument order Nenue@10: --@debug@ Nenue@10: local c = mod.defaults.Normal Nenue@10: local style_list = {... } Nenue@10: local styleName = frameType .. '-' .. table.concat(style_list,'') Nenue@10: Nenue@10: if not style_cache[styleName] then Nenue@10: local style = {} Nenue@10: Nenue@10: if mod.defaults.Style[frameType] then Nenue@10: print(' setting style class |cFF00FFFF'..frameType) Nenue@10: else Nenue@10: print(' resorting to class Normal (missing |cFFFF8800'.. frameType..'|r)') Nenue@10: end Nenue@10: local normal = mod.defaults.Style.Normal Nenue@10: local root = mod.defaults.Style[frameType] or normal Nenue@10: for i, className in ipairs(style_list) do Nenue@10: local class = root[className] or normal[className] or root Nenue@10: if root[className] then Nenue@10: Nenue@10: print(' SubClass |cFF0088FF'.. className .. '|r') Nenue@10: elseif normal[className] then Nenue@10: print(' SubClass Normal.|cFFFF0088'..className..'|r') Nenue@10: else Nenue@10: print(' SubClass Normal') Nenue@10: end Nenue@10: for elementName, element in pairs(class) do Nenue@10: if not elementName:match('^%u') then Nenue@10: print(' scanning Element |cFF8800FF'.. elementName ..'|r') Nenue@10: if not style[elementName] then Nenue@10: style[elementName] = {} Nenue@10: end Nenue@10: for key, value in pairs(element) do Nenue@10: if mod.SetBlockAttribute[key] then Nenue@10: print(' |cFF00FF00'..elementName..'|r.|cFF00FFFF'..key..' =', (type(value) == 'table' and ('{'..table.concat(value,', ')..'}') or tostring(value))) Nenue@10: style[elementName][key] = value Nenue@10: end Nenue@10: Nenue@10: end Nenue@10: end Nenue@10: Nenue@10: end Nenue@10: Nenue@10: end Nenue@10: Nenue@10: for k, elements in pairs(mod.defaults.Style.Normal) do Nenue@10: if not style[k] and type(elements) ~= 'table' then Nenue@10: style[k] = elements Nenue@10: end Nenue@10: end Nenue@10: Nenue@10: Nenue@10: print('result for: ', frame:GetName()) Nenue@10: for k,v in pairs(style) do Nenue@10: if type(v) == 'table' and not k:match('^%u') then Nenue@10: for kk, vv in pairs(v) do Nenue@10: print(' |cFFFFFF00'..k..'|r.|cFF00FF00'..kk..'|r =', tostring(vv)) Nenue@10: end Nenue@10: else Nenue@10: print(' |cFFFFFFFF' .. k ..'|r =', tostring(v)) Nenue@10: end Nenue@10: end Nenue@10: style_cache[styleName] = style Nenue@10: else Nenue@10: print('Cache hit: ', styleName) Nenue@10: end Nenue@10: Nenue@10: local style = style_cache[styleName] Nenue@10: Nenue@10: if not style_cache_func[styleName] then Nenue@10: local code = Nenue@10: "return function (frame)\n".. Nenue@10: " local func = Veneer.ObjectiveTracker.SetBlockAttribute\n".. Nenue@11: " local cache = Veneer.ObjectiveTracker.BlockStyleCache" Nenue@11: --.. " print('CacheFunc', '|cFFFFFF00SET|r "..styleName.." |cFFFFFF00ON|r', frame:GetName()) " Nenue@10: Nenue@10: for elementName, styleset in pairs(style) do Nenue@10: code = code .. Nenue@10: "\n if frame['"..elementName.."'] then" Nenue@10: Nenue@10: for attributeName, value in pairs(styleset) do Nenue@10: if mod.SetBlockAttribute[attributeName] then Nenue@10: print(' '..elementName..':'.. attributeName ..'(', value, ')') Nenue@10: Nenue@10: Nenue@10: --mod.SetBlockAttribute[attributeName](region, value) Nenue@11: code = code Nenue@11: --.. "\n print('CacheFunc', ' applying', '|cFF00FFFF" .. attributeName .. "|r to', '|cFF0088FF"..elementName.."|r', cache['"..styleName.."']['"..elementName.."']['".. attributeName .."'])" Nenue@11: .. "\n\n func['" .. attributeName .. "'](frame['"..elementName.."'],".. Nenue@10: " cache['"..styleName.."']['"..elementName.."']['".. attributeName .."'])" Nenue@10: Nenue@10: --- Set any frame.blah variables used in Updates Nenue@10: if block_vars[elementName .. attributeName] then Nenue@10: print('|cFF008800BVar|r', elementName..attributeName) Nenue@10: for i, blockKey in ipairs(block_vars[elementName .. attributeName]) do Nenue@10: print(' assigning |cFF008800'..blockKey..'|r') Nenue@10: frame[blockKey] = (type(value) == 'table') and value[i] or value Nenue@10: end Nenue@10: end Nenue@10: Nenue@10: end Nenue@10: end Nenue@10: code = code .. Nenue@10: "\n else".. Nenue@11: --"\n print('CacheFunc', ' |cFFFF4400missing', frame:GetName()..'."..elementName.."')".. Nenue@10: "\n end" Nenue@10: end Nenue@10: code = code .. "\nend" Nenue@10: local result = assert(loadstring(code)) Nenue@10: print('storing style func', styleName, result()) Nenue@10: style_cache_func[styleName] = result() Nenue@10: Nenue@10: else Nenue@10: print('Cache function hit:', styleName) Nenue@10: end Nenue@10: style_cache_func[styleName](frame) Nenue@10: Nenue@13: --- Hardcoding the sizing vars for sanity Nenue@13: local normalSettings = mod.defaults.Style.Format Nenue@10: frame.titleHeight = frame.title and (frame.title:GetStringHeight() + frame.title.spacing*2) or 0 Nenue@10: frame.statusHeight = frame.status and (frame.status:GetStringHeight() + frame.status.spacing*2 + frame.attachmentHeight) or 0 Nenue@10: frame.height = frame.titleHeight + frame.statusHeight Nenue@13: frame.width = normalSettings.Frame.Width Nenue@13: frame.statusWidth = frame.width - normalSettings.status.Indent Nenue@13: frame.titleWidth = frame.width - normalSettings.title.Indent Nenue@10: Nenue@10: if frame.status then Nenue@13: print('status ', frame.statusHeight, normalSettings.status.Indent, 0) Nenue@13: frame.status:SetPoint('LEFT', frame, 'LEFT', normalSettings.status.Indent, 0) Nenue@10: frame.status:SetHeight(frame.statusHeight) Nenue@10: if frame.statusbg then Nenue@10: Nenue@10: print('statusbg', frame.statusHeight) Nenue@10: frame.statusbg:SetHeight(frame.statusHeight) Nenue@10: frame.statusbg:SetWidth(frame.width) Nenue@10: end Nenue@10: end Nenue@10: if frame.title then Nenue@13: print('title ',frame.titleHeight, normalSettings.title.Indent) Nenue@13: frame.title:SetPoint('LEFT', frame, 'LEFT', normalSettings.title.Indent) Nenue@10: frame.title:SetHeight(frame.titleHeight) Nenue@10: if frame.titlebg then Nenue@10: print('titlebg',frame.titleHeight) Nenue@10: frame.titlebg:SetHeight(frame.titleHeight) Nenue@10: frame.titlebg:SetWidth(frame.width) Nenue@10: end Nenue@10: end Nenue@10: print('sizing frame', frame.width, frame.height) Nenue@10: frame:SetSize(frame.width, frame.height) Nenue@10: print(frame:GetSize()) Nenue@10: --[[ Nenue@10: local titleSpacing, titleSpacing2 = c.Title.Spacing, (c.Title.Spacing * 2) Nenue@10: local textSpacing, textSpacing2 = c.Text.Spacing, (c.Text.Spacing * 2) Nenue@10: Nenue@10: block.title:SetSpacing(titleSpacing) Nenue@10: block.objectives:SetSpacing(textSpacing) Nenue@10: block.objectives:SetWordWrap(true) Nenue@10: Nenue@10: local titleHeight, textHeight = block.title:GetStringHeight(), block.objectives:GetStringHeight() + block.attachmentHeight Nenue@10: local blockHeight = titleHeight + titleSpacing2 + textHeight + textSpacing2 Nenue@10: local blockWidth = wrapperMaxWidth Nenue@10: Nenue@10: block.titlebg:SetSize(min(w1, w2), titleHeight + titleSpacing2) Nenue@10: block.bg:SetSize(w1, textHeight + textSpacing2) Nenue@10: block:SetSize(blockWidth, blockHeight) Nenue@10: Nenue@10: block.title:SetPoint('TOPLEFT', block.titlebg, 'TOPLEFT', 0, -titleSpacing) Nenue@10: block.objectives:SetPoint('TOPLEFT', block.titlebg, 'BOTTOMLEFT', textIndent, -textSpacing) Nenue@10: Nenue@10: -- store Nenue@10: block.titleHeight = titleHeight Nenue@10: block.textHeight = textHeight Nenue@10: block.width = blockWidth Nenue@10: block.height = blockHeight Nenue@10: --]] Nenue@10: --print(' |cFF00FFFF'..block:GetName()..'|r:|cFF0088FFSetStyle|r(', blockWidth, 'x', blockHeight, '(textH', textHeight,', titleH', titleHeight, ')') Nenue@10: end Nenue@10: Nenue@10: --- Argument containers Nenue@10: local o = "" -- text flag Nenue@10: local a1, a2, a3, a4, b1, b2, b3, b4 = 0,0,0,1, 0,0,0,1 -- color1, color2 Nenue@10: local f1, f2, f3 = "", 0, "" -- font Nenue@10: local w1, w2 = 0, 0 -- size Nenue@10: local p1, p2, p3, x, y = "", "", "", 0, 0 -- path/point args Nenue@10: mod.SetBlockAttribute = {} Nenue@10: local sb = mod.SetBlockAttribute Nenue@10: local print = B.print('Attribute') Nenue@10: sb.Gradient = function(region, value) Nenue@10: print('|cFF8844FFGradient|r', region:GetName(), unpack(value)) Nenue@10: o = 'HORIZONTAL' Nenue@10: a1, a2, a3, a4 = unpack(value.MinColor) Nenue@10: b1, b2, b3, b4 = unpack(value.MaxColor) Nenue@10: region:SetVertexColor(1,1,1) Nenue@10: region:SetTexture(1,1,1,1) Nenue@10: region:SetGradientAlpha(o, a1, a2, a3, a4, b1, b2, b3, b4) Nenue@10: end Nenue@10: Nenue@10: sb.Background = function(region, value) Nenue@10: print('|cFF0088FFBackground|r', unpack(value)) Nenue@10: region:SetVertexColor(1,1,1) -- reset Nenue@10: region:SetTexture(unpack(value)) Nenue@10: end Nenue@10: sb.BackgroundComplex = function (region, value) Nenue@10: local left, tile, right = value.Left, value.Tile, value.Right Nenue@10: Nenue@10: end Nenue@10: sb.Font = function(region, value) Nenue@10: f1, f2, f3 = unpack(value) Nenue@10: print('|cFFFFFF00Font|r', f1, f2, f3) Nenue@10: region:SetFont(f1, f2, f3) Nenue@10: end Nenue@10: Nenue@10: sb.Spacing = function(region, value) Nenue@10: print('FontSpacing', value) Nenue@10: region:SetSpacing(value) Nenue@10: region.spacing = value Nenue@10: end Nenue@10: Nenue@10: sb.TextColor = function(region, value) Nenue@10: a1, a2, a3, a4 = unpack(value) Nenue@10: print('TextColor', a1, a2, a3, a4) Nenue@10: region:SetTextColor(a1, a2, a3, a4) Nenue@10: end Nenue@10: sb.Texture = function(region, value) Nenue@10: Nenue@10: p1, a1, a2, a3, a4 = unpack(value) Nenue@10: print('Texture', p1, a1, a2, a3, a4) Nenue@10: region:SetTexture(p1) Nenue@10: if a1 then Nenue@10: region:SetTexCoord(a1, a2, a3, a4) Nenue@10: end Nenue@10: end Nenue@10: sb.Width = function(region, value) Nenue@10: w1 = value Nenue@10: region:SetWidth(w1) Nenue@10: end Nenue@10: Nenue@10: sb.Height = function(region, value) Nenue@10: w2 = value Nenue@10: region:SetHeight(w2) Nenue@10: end Nenue@10: sb.Size = function(region, value) Nenue@10: w1, w2 = unpack(value) Nenue@10: region:SetSize(w1, w2) Nenue@10: end