Mercurial > wow > buffalo2
diff ObjectiveStyle.lua @ 19:605e8f0e46db
ObjectiveCore / Style / Events / Frame
- polishing the execution path for better performance
- make use of the Blizzard_ObjectiveTracker bitfield values to ensure compatibility in possible secure hooks
- avoid full updates when possible (using said bitfield values to indicate targeted sections)
- extreme streamlining of event handling layout: specific reason updates are invoked from API hooks; broader updates are invoked by when the event listener catches something vague like 'QUEST_LOG_UPDATE'
author | Nenue |
---|---|
date | Wed, 06 Apr 2016 07:38:35 -0400 |
parents | d1812fb10ae6 |
children | d5ee940de273 |
line wrap: on
line diff
--- a/ObjectiveStyle.lua Tue Apr 05 02:38:01 2016 -0400 +++ b/ObjectiveStyle.lua Wed Apr 06 07:38:35 2016 -0400 @@ -15,19 +15,6 @@ local headerOutline, headerSpacing = 'OUTLINE', 2 -mod.defaults.Wrapper = { - WrapperPoint = 'TOPRIGHT', - WrapperFloatX = -25, - WrapperFloatV = 'TOP', - WrapperFloatY = -200, - - WrapperWidth = 270, - WrapperHeight = 600, -} -mod.defaults.Tracker = { - HeaderHeight = 24, -} - mod.defaults.Style = { Format = { Frame = { @@ -56,23 +43,17 @@ Indent = 2, }, titlebg = { - Background = {0, 0, 0, 1}, - Width = 270, }, status = { Width = 270, Spacing = 0, }, statusbg = { - Width = 270, }, Frame = { - Width = 270, } }, Wrapper = { - Frame = { - 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,} @@ -96,12 +77,12 @@ Gradient = { 'HORIZONTAL', MinColor = {0.7, 0, 0.9, 0}, MaxColor = {.7, 0, 0.9, .25}}, }, title = { - TextColor = {1,1,1,0.8}, + TextColor = {1,1,1,1}, Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, }, status = { - TextColor = {1,1,1,0.8}, + TextColor = {1,1,1,1}, Font = {textFont, textSize, textOutline}, Spacing = textSpacing, }, @@ -122,7 +103,7 @@ Spacing = titleSpacing, }, status = { - TextColor = {1,1,1,0.5}, + TextColor = {1,1,1,1}, Font = {textFont, textSize, textOutline}, Spacing = textSpacing, }, @@ -163,14 +144,14 @@ }, Complete = { title = { - TextColor = {1,1,1,0.5}, + TextColor = {1,1,1,1}, Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, }, titlebg = { Gradient = {'HORIZONTAL', MinColor = {0, 1, 0, 0}, MaxColor = {0, 1, 0, 0.34}, }, }, status = { - TextColor = {1,1,1,0.5}, + TextColor = {1,1,1,1}, Font = {textFont, textSize, textOutline}, Spacing = textSpacing, }, statusbg = { @@ -257,23 +238,40 @@ local c = mod.defaults.Normal local style_list = {... } local styleName = frameType .. '-' .. table.concat(style_list,'') - local previousClass = mod.Conf.Style[frameType] + local previousClass = {mod.Conf.Style[frameType] } + local previousClassString = {'frame' } + local parentName 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 + print('|cFF00FF00'..i..'|r', className) local class = normal - if previousClass and previousClass[className] then - class = previousClass[className] - print(' ChildClass |cFFFF0088'.. className .. '|r') + local childClass + if previousClass then + for i = #previousClass, 1, -1 do + print('checking if '..className..' child of '.. previousClassString[i]) + if previousClass[i][className] then + print(' it is!') + childClass = previousClass[i][className] + parentName = previousClassString[i] + break + end + end + end + if childClass then + class = childClass + print(' ChildClass '..parentName..'.|cFFFF0088'.. className .. '|r') elseif root[className] then class = root[className] print(' SubClass |cFF0088FF'.. className .. '|r') @@ -281,19 +279,20 @@ class = normal[className] print(' SubClass Normal.|cFFFF0088'..className..'|r') else - print(' SubClass not found '..className..'') + --print(' SubClass not found '..className..'') end - previousClass = class + tinsert(previousClass, class) + tinsert(previousClassString, className) for elementName, element in pairs(class) do if not elementName:match('^%u') then - print(' scanning Element |cFF8800FF'.. elementName ..'|r') + --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))) + --print(' |cFF00FF00'..elementName..'|r.|cFF00FFFF'..key..' =', (type(value) == 'table' and ('{'..table.concat(value,', ')..'}') or tostring(value))) style[elementName][key] = value end @@ -310,17 +309,22 @@ end - print('result for: ', frame:GetName()) + --[[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 =', (type(vv) == 'table' and ('{'..table.concat(vv,', ')..'}') or tostring(vv))) + --print(' |cFFFFFF00'..k..'|r.|cFF00FF00'..kk..'|r =', (type(vv) == 'table' and ('{'..table.concat(vv,', ')..'}') or tostring(vv))) end else - print(' |cFFFFFFFF' .. k ..'|r =', tostring(v)) + --print(' |cFFFFFFFF' .. k ..'|r =', tostring(v)) end end + --]] + print('saving |cFFFFFF00'..styleName) style_cache[styleName] = style + else + + print('using |cFFFF00FF'..styleName) end local style = style_cache[styleName] @@ -338,7 +342,7 @@ for attributeName, value in pairs(styleset) do if mod.SetBlockAttribute[attributeName] then - print(' add function '..elementName..':'.. attributeName ..'(', (type(value) == 'table' and ('{'..table.concat(value,', ')..'}') or tostring(value)), ')') + --print(' add function '..elementName..':'.. attributeName ..'(', (type(value) == 'table' and ('{'..table.concat(value,', ')..'}') or tostring(value)), ')') --mod.SetBlockAttribute[attributeName](region, value) @@ -349,9 +353,9 @@ --- Set any frame.blah variables used in Updates if block_vars[elementName .. attributeName] then - print('|cFF008800BVar|r', elementName..attributeName) + --print('|cFF008800BVar|r', elementName..attributeName) for i, blockKey in ipairs(block_vars[elementName .. attributeName]) do - print(' assigning |cFF008800'..blockKey..'|r') + --print(' assigning |cFF008800'..blockKey..'|r') frame[blockKey] = (type(value) == 'table') and value[i] or value end end @@ -365,20 +369,25 @@ end code = code .. "\nend" local result = assert(loadstring(code)) - print('storing style func', styleName, result()) + --print('storing style func', styleName, result()) style_cache_func[styleName] = result() end style_cache_func[styleName](frame) --- Hardcoding the sizing vars for sanity + local defaultWidth = mod.Conf.Wrapper.Width local normalSettings = mod.defaults.Style.Format - frame.width = normalSettings.Frame.Width - frame.statusWidth = frame.width - normalSettings.status.Indent - frame.titleWidth = frame.width - normalSettings.title.Indent + frame.width = defaultWidth + frame.statusWidth = defaultWidth - normalSettings.status.Indent + frame.titleWidth = defaultWidth - normalSettings.title.Indent if frame.title then - frame.titleHeight = frame.title and (frame.title:GetStringHeight() + (frame.title.spacing or 0)*2) or 0 + frame.titleHeight = frame.title and frame.title:GetStringHeight() or 0 + if frame.titleHeight > 0 then + frame.titleHeight = frame.titleHeight + (frame.title.spacing or 0)*2 + end + frame.title.spacing = frame.title.spacing or frame.title:GetSpacing() frame.title:SetPoint('LEFT', frame, 'LEFT', normalSettings.title.Indent) frame.title:SetPoint('TOP', frame, 'TOP', 0, -frame.title.spacing) @@ -387,36 +396,35 @@ frame.titlebg:SetHeight(frame.titleHeight) frame.titlebg:SetWidth(frame.width) end - print(' title, textHeight', frame.titleHeight, 'indent', normalSettings.title.Indent, 'spacing', frame.title.spacing) + print(' titleHeight', frame.titleHeight, 'indent', normalSettings.title.Indent, 'spacing', frame.title.spacing) else frame.titleHeight = 0 end if frame.status then - frame.statusHeight = frame.status and (frame.status:GetStringHeight() + (frame.status.spacing or 0)*2) or 0 + frame.statusHeight = frame.status and frame.status:GetStringHeight() or 0 + if frame.statusHeight > 0 then + frame.statusHeight = frame.statusHeight + (frame.status.spacing or 0)*2 + end + frame.status.spacing = frame.status.spacing or frame.status:GetSpacing() frame.status:SetWidth(frame.width) frame.status:SetPoint('LEFT', frame, 'LEFT', normalSettings.status.Indent, 0) - frame.status:SetPoint('TOPLEFT', frame.titlebg, 'BOTTOMLEFT', normalSettings.status.Indent, -frame.status.spacing) - --frame.status:SetHeight(frame.statusHeight) + frame.status:SetPoint('TOP', frame.titlebg, 'BOTTOM', 0, 0) + frame.status:SetHeight(frame.statusHeight) if frame.statusbg then - frame.statusbg:SetHeight(frame.statusHeight) + frame.statusbg:SetHeight(frame.statusHeight + (frame.attachmentHeight or 0)) frame.statusbg:SetWidth(frame.width) end - print(' status, textHeight', frame.statusHeight, 'indent', normalSettings.status.Indent, 'spacing', frame.status.spacing) + print(' status tHeight', frame.statusHeight, 'indent', normalSettings.status.Indent, 'spacing', frame.status.spacing) else frame.statusHeight = 0 end frame.height = frame.titleHeight + frame.statusHeight + (frame.attachmentHeight or 0) frame:SetSize(frame.width, frame.height) - print(' sizing frame', frame.width, frame.height) -end -mod.UpdateWrapperStyle = function() - local c = mod.Conf.Wrapper - --Wrapper:ClearAllPoints() - --Wrapper:SetPoint(c.WrapperPoint, UIParent, c.WrapperPoint, c.WrapperFloatX, c.WrapperFloatY) + print(' |cFF0088FFsizing frame', frame.width, frame.height) end --- Argument containers