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