Mercurial > wow > buffalo2
changeset 49:16465f3fd919
- remove UpdateAnchorAnchors and use hardlink for the one frame that this applied to
author | Nenue |
---|---|
date | Fri, 29 Apr 2016 10:50:27 -0400 |
parents | 9837069e366a |
children | d7655c4e6e06 |
files | BuffFrame/BuffAnchors.lua BuffFrame/BuffFrame.lua BuffFrame/RaidBuffTray.lua Config/Config.lua Veneer.lua Veneer.toc |
diffstat | 6 files changed, 210 insertions(+), 213 deletions(-) [+] |
line wrap: on
line diff
--- a/BuffFrame/BuffAnchors.lua Thu Apr 28 06:58:13 2016 -0400 +++ b/BuffFrame/BuffAnchors.lua Fri Apr 29 10:50:27 2016 -0400 @@ -134,43 +134,6 @@ end --- Handles placement of anchors embedded within anchors (consolidated buffs, maybe temp enchant) -buffFrame.UpdateAnchorAnchors = function() - local displays = buffFrame.displays - local c = buffFrame.Conf - local guides = buffFrame.guides - local print = fprint() - for buttonName, d in pairs(displays) do - local c = displays[buttonName].conf - local frame = buffFrame.anchors[buttonName] - local parent, child = c.Parent, c.Position - - frame.parent = nil - if c[buttonName .. 'Parent'] and _G[c[buttonName .. 'Parent']..'Anchor'] then - - local anchorAnchor = _G[c[buttonName .. 'Parent']..'Anchor'] - local anchorTarget = guides[parent][child] - if anchorTarget then - print('link', buttonName, 'to', parent, child) - print(parent, child, displays[parent].guides[child]) - local ac = displays[parent].conf - local anchorFrom, anchorTo = unpack(ac.Point) - frame:ClearAllPoints() - frame:SetPoint(anchorFrom, anchorTarget, anchorTo) - frame.parent = anchorTarget - anchorTarget.contains = frame - anchorAnchor.contains = frame - anchorAnchor.containPosition = child - else - frame.parent = anchorAnchor - anchorAnchor.contains = frame - anchorAnchor.containPosition = nil - end - else - frame.parent = nil - end - - end -end -- if facing key direction, anchor point [1] to parent's point [2] local childFacing = {
--- a/BuffFrame/BuffFrame.lua Thu Apr 28 06:58:13 2016 -0400 +++ b/BuffFrame/BuffFrame.lua Fri Apr 29 10:50:27 2016 -0400 @@ -9,11 +9,11 @@ local B = select(2,...).frame local M = B:RegisterModule('BuffFrame') +M.PlayerBuffsActive = {} function M:OnInitialize() local displays = M.displays - local c= M.Conf + -- suffix tables - M.drawn = B.Abstract(displays, 'drawn', M.drawn ) -- Lesser extent of guide frames that have been positioned M.positioned = B.Abstract(displays, 'positioned', M.positioned) @@ -31,10 +31,10 @@ display.conf = setmetatable({}, { __index = function(_, k) --print('config check '.. name .. k) - return c[name .. k] or c['BuffButton' .. k] + return M.Conf[name .. k] or M.Conf['BuffButton' .. k] end, __newindex = function(_, k , v) - c[name..k] = v + M.Conf[name..k] = v end, }) end @@ -54,11 +54,10 @@ for name, auraType in pairs(displays) do M.UpdateBuffs(auraType.buffName, true) - print(name, auraType) + --print(name, auraType) _G[name..'Anchor']:EnableMouse(B.Conf.ConfigMode) end - M.UpdateAnchorAnchors() M.UpdateRaidBuffs() M.UpdateBuffsTodo() end \ No newline at end of file
--- a/BuffFrame/RaidBuffTray.lua Thu Apr 28 06:58:13 2016 -0400 +++ b/BuffFrame/RaidBuffTray.lua Fri Apr 29 10:50:27 2016 -0400 @@ -5,26 +5,25 @@ -- Created: 3/20/2016 10:00 PM local _, A = ... -local B = A.frame +local vn = A.frame local MODULE = 'BuffFrame' -local M = B:RegisterModule(MODULE) -local displays = B.displays - +local Aura = vn:RegisterModule(MODULE) local parentAnchor, parentFrame, raidbuffsFrame -local band, lshift, CreateFrame = bit.band, bit.lshift, CreateFrame +local unpack, band, lshift, CreateFrame = unpack,bit.band, bit.lshift, CreateFrame local raidBuffs = {} local raidBuffSymbols = {'St', 'HP', 'AP', 'Ha', 'SP', 'Cr', 'Ma', 'MS', 'V' } local missingBuffs = {} local playerBuffing, playerCurrentBuff local playerBuffs = {} local c, ac, frameSize, frameSpacing, framePosition -local fprint = B.fprint +local fprint = vn.fprint +local xprint = vn.print('XML') local NUM_LE_MISSING_RAID_BUFFS = 0 local missingBuffsAnchor --- Takes a given icon texture and calls the pre-defined function set -M.UpdateBuffStyle = function(buff, style, path) +Aura.UpdateBuffStyle = function(buff, style, path) local print = fprint() local icon = buff.icon local symbol = buff.symbol @@ -39,7 +38,7 @@ --print('|cFF00FF88UpdateBuffStyle(|r', icon:GetName(), style, path, ') same values, ignore') return end - local styleset = B.BuffStyles[style] + local styleset = Aura.BuffStyles[style] if not path or path == '' then print('path is nil/empty') icon:SetTexture(1, 1, 1, 1) @@ -63,12 +62,11 @@ local PlayerBuffStatus = {} local UnitClass, IsInGroup, GetNumGroupMembers, UnitAura = UnitClass, IsInGroup, GetNumGroupMembers, UnitAura local GetTalentInfoByID, GetActiveSpecGroup, GetStablePetInfo, GetSpecialization = GetTalentInfoByID, GetActiveSpecGroup, GetStablePetInfo, GetSpecialization -M.UpdateBuffStatus = function(aura, filters) +Aura.UpdateBuffStatus = function(aura, filters) + local print = xprint if not PlayerBuffStatus[aura] then PlayerBuffStatus[aura] = {} end - - print(UnitClass('player')) if IsInGroup() then local numBuffed = 0 @@ -99,7 +97,7 @@ return true, true else if c.spec then - if not (result and c.spec == B.PlayerSpec) then + if not (result and c.spec == vn.PlayerSpec) then return false end end @@ -131,7 +129,7 @@ end --- events: PLAYER_SPECIALIZATION_CHANGED -function M:UpdateBuffsTodo (unit) +function Aura:UpdateBuffsTodo (unit) -- buffs vs. auras if unit ~= 'player' then -- look for changes in the GIST manifest and sort them out @@ -143,22 +141,22 @@ if not class or not spec or not IsInGroup() or - not B.PlayerBuffStatus[class] then + not Aura.PlayerBuffStatus[class] then -- if just logging in, info won't be available for several seconds -- if not grouped, don't calc -- hide frame - B.PlayerBuffsActive = function() return false end + Aura.PlayerBuffsActive = function() return false end return end -- verify change - if B.PlayerCurrentSpec == spec or B.PlayerClass == class then + if vn.PlayerCurrentSpec == spec or vn.PlayerClass == class then return end - B.PlayerCurrentSpec = spec - B.PlayerClass = class + vn.PlayerCurrentSpec = spec + vn.PlayerClass = class - local test = B.ClassRaidBuffs + local test = vn.ClassRaidBuffs local buffTypes = {} local auraTypes = {} for i = 1, NUM_LE_RAID_BUFF_TYPES do @@ -170,21 +168,21 @@ end if name then - B.UpdateBuffStatus(name, filters) + vn.UpdateBuffStatus(name, filters) end end end -- Called once to setup the ConsolidatedBuffs stencil -local consolidatedBuffsLoaded -M.SetConsolidatedBuffs = function() - local displays = M.displays +local consolidatedBuffsLoaded, displays +Aura.SetConsolidatedBuffs = function() local print = fprint() + displays = Aura.displays c = displays.ConsolidatedBuff.conf - parentFrame = M.guides[c.Parent][c.Position] - raidbuffsFrame = M.anchors.ConsolidatedBuff + parentFrame = Aura.guides[c.Parent][c.Position] + raidbuffsFrame = Aura.anchors.ConsolidatedBuff - B.SetConfigLayers(raidbuffsFrame) + vn.SetConfigLayers(raidbuffsFrame) consolidatedBuffsLoaded = true ConsolidatedBuffs:ClearAllPoints() ConsolidatedBuffs:SetAllPoints(parentFrame.icon) @@ -198,39 +196,49 @@ ConsolidatedBuffsCount:Hide() end +local CanShowConsolidated = function() + return IsInGroup() and GetCVarBool("consolidateBuffs") +end + local missingTypes = {} local raidBuffsInitialized -M.UpdateRaidBuffs = function() - local print = fprint() +Aura.UpdateRaidBuffs = function() + local print = xprint if not consolidatedBuffsLoaded then - M.SetConsolidatedBuffs() + Aura.SetConsolidatedBuffs() end - if not M.ShowConsolidated or not parentFrame.contains then - print(' hiding raid buffs square') - if raidBuffsInitialized then - for i = 1, 9 do - if raidBuffs[i] then - raidBuffs[i]:Hide() + if not CanShowConsolidated() then + + if parentFrame.contains then + print((CanShowConsolidated() and '|cFF88FF88' or '|cFF444444')..'showConsolidated|r', (parentFrame.contains and '|cFF88FF88' or '|cFF444444') .. 'parent.contains|r') + if raidBuffsInitialized then + for i = 1, 9 do + if raidBuffs[i] then + raidBuffs[i]:Hide() + end end + raidBuffsInitialized = nil end - raidBuffsInitialized = nil + if parentFrame then + print(c.Parent, c.Position) + print('de-flagging parent') + parentFrame.contains = nil + end + raidbuffsFrame:Hide() end - if parentFrame then - print(c.Parent, c.Position) - print('de-flagging parent') - parentFrame.contains = nil - end - raidbuffsFrame:Hide() + return + --- ENDS HERE IF NOT SHOWING CONSOLIDATED FRAME end - local c = B.displays.ConsolidatedBuff.conf - if parentFrame and not parentFrame.contains then + local c = Aura.displays.ConsolidatedBuff.conf + if CanShowConsolidated() and not parentFrame.contains then raidBuffsInitialized = true print('re-flagging parent', parentFrame:GetName()) parentFrame.contains = parentFrame - B.decors[c.Parent][c.Position]:Hide() + Aura.decors[c.Parent][c.Position]:Hide() + raidbuffsFrame:SetPoint('TOPRIGHT', parentFrame, 'TOPRIGHT') raidbuffsFrame:Show() -- make sure parent icon is updated @@ -239,14 +247,14 @@ parentFrame.icon:SetSize(w - c.Border*2, w - c.Border*2) parentFrame.contains = raidbuffsFrame - M.UpdateBuffs(c.Parent) + Aura.UpdateBuffs(c.Parent) end -- have to loop again due to tainting restrictions -- could compare the tooltip font object pointers, but that may change local buffStack = GetRaidBuffInfo() print(GetRaidBuffInfo()) - local guides = B.guides.ConsolidatedBuff + local guides = vn.guides.ConsolidatedBuff local numBuffs = 0 local numAvailable = 0 local mask = 1 @@ -296,7 +304,7 @@ end mask = lshift(mask, 1) - M.UpdateBuffStyle(buff, buffStyle, icon) + Aura.UpdateBuffStyle(buff, buffStyle, icon) end -- todo: filter by castable and suppress for non-overlapping auras @@ -304,8 +312,8 @@ raidbuffsFrame.label:SetText(numBuffs..'/'..numAvailable) print(parentFrame:GetName(), parentFrame:GetSize()) - if B.ShowMissingBuffs then - B.UpdateMissingBuffs() + if vn.ShowMissingBuffs then + vn.UpdateMissingBuffs() elseif missingBuffsAnchor and missingBuffsAnchor:IsVisible() then for i = 1, NUM_LE_MISSING_RAID_BUFFS do missingBuffs[i]:Hide() @@ -313,8 +321,8 @@ end end -B.UpdateMissingBuffs = function() - local print = B.fprint() +vn.UpdateMissingBuffs = function() + local print = vn.fprint() local numMissing = 0 local firstMissing, lastMissing @@ -325,7 +333,7 @@ numMissing = numMissing + 1 print('missing buff', i, numMissing) - B.UpdateBuffStyle(raidBuffs[i].icon, 'missing', "") + vn.UpdateBuffStyle(raidBuffs[i].icon, 'missing', "") missingBuffs[numMissing] = missingBuffs[numMissing] or CreateFrame('Button', 'VeneerMissingBuff' .. numMissing, raidbuffsFrame, 'VeneerMissingBuffTemplate')
--- a/Config/Config.lua Thu Apr 28 06:58:13 2016 -0400 +++ b/Config/Config.lua Fri Apr 29 10:50:27 2016 -0400 @@ -3,14 +3,13 @@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 3/12/2016 12:49 AM -local B, _G = select(2,...).frame, _G -local M = B:RegisterModule("Options") -local tostring, tonumber, floor, format = tostring, tonumber, floor, string.format -local unpack, select, pairs, ipairs, type, wipe = unpack, select, pairs, ipairs, type, table.wipe +local vn, _G = select(2,...).frame, _G +local M = vn:RegisterModule("Options") +local tostring, tonumber, floor, max, assert = tostring, tonumber, floor, math.max, assert +local unpack, setmetatable, pairs, ipairs, type, wipe = unpack, setmetatable, pairs, ipairs, type, table.wipe local CreateFrame, IsControlKeyDown = _G.CreateFrame, _G.IsControlKeyDown -local max = math.max local OpacitySliderFrame, ColorPickerFrame = _G.OpacitySliderFrame, _G.ColorPickerFrame -local print = B.print('Cfgl') +local print = vn.print('Cfgl') local function round(number, decimals) if floor(number) == number then return ('%d'):format(number) @@ -19,27 +18,43 @@ return (("%%.%df"):format(decimals)):format(number) end +--- Set up this way to ensure that all the necessary data exists before things domino into something inscrutable +M.prototypes = { + value = setmetatable({}, {__call = function(self, frame) + assert(frame, 'Expected table (received '..type(frame.OptInfo)..')') + assert(frame.OptRoot, 'Invalid config table for frame '.. frame:GetName().. '') + return self[frame.ValueType](frame.OptTab, frame.OptKey, frame.OptRoot) + end}), + reset = setmetatable({}, {__call = function(self, frame) + assert(frame.GetName, 'Invalid frame reference (received '..type(frame.OptInfo)..')') + assert(frame.OptInfo, 'Expecting a table (received '..type(frame.OptInfo)..')') + return self[frame.OptType](frame, frame.OptInfo) + end}) +} +M.config = {} M.defaults = { enable = true } - +local GetValue = M.prototypes.value +local ResetField = M.prototypes.reset --- STATE VARIABLES local configInit --- Dummies for addon table upvalues local configFrames = {} -- actual frame objects -local displays = B.displays -- anchor objects dummy +local displays = vn.displays -- anchor objects dummy --- Returns a value retreival function and the current value stored in config -- @paramsig value, previousValue = configInteger(key) -- @param key Name of the config field being represented. local defaultGroup = 'BuffButton' -local configInteger = function(group, key) - return function(self ,display) + +GetValue.Integer = function(group, key, parent) + return function(self) return floor(tonumber(self:GetValue()) + 0.5) - end, (B.Conf[group ..key] or B.Conf[defaultGroup..key]) + end, (parent[group ..key] or parent[defaultGroup..key]) end -local configPercent = function(group, key) +GetValue.Percent = function(group, key, parent) return function(self, display) local value = self:GetValue() if display then @@ -47,9 +62,9 @@ else return floor((value*100+0.5))/100 end - end, (B.Conf[group ..key] or B.Conf[defaultGroup..key]) + end, (parent[group ..key] or parent[defaultGroup..key]) end -local configColor = function(group, key) +GetValue.Color = function(group, key, parent) -- table for config, color value list for text return function(self, display) if display then @@ -58,70 +73,71 @@ else return self.rgba end - end, (B.Conf[group ..key] or B.Conf[defaultGroup..key]) + end, (parent[group ..key] or parent[defaultGroup..key]) end -local configCheck = function(group, key) - return function(self) return self:GetChecked() end, B.Conf[group ..key] or B.Conf[defaultGroup..key] +GetValue.Check = function(group, key, parent) + return function(self) return self:GetChecked() end, parent[group ..key] or vn.Conf[defaultGroup..key] end -- initializes the corresponding type of config field local frameTypeConv = { Color = 'Button', Font = 'Frame', } -local configTypeParams = { - Slider = function(frame, optionInfo) + + +ResetField.Slider = function(frame, optionInfo) frame:SetMinMaxValues(optionInfo[5], optionInfo[6]) frame:SetValueStep(optionInfo[7]) frame:SetStepsPerPage(optionInfo[8]) print(frame.OptName, '\n {', optionInfo[5], optionInfo[6], optionInfo[7], optionInfo[8], '}') - end, - CheckButton = function(frame, optionInfo) + end +ResetField.CheckButton = function(frame, optionInfo) frame.SetValue = function(self, ...) self:SetChecked(...) - B.Conf[self.OptName] = self:GetChecked() + self.OptRoot[self.OptName] = self:GetChecked() print(self.OptTab) - B.UpdateAll() + vn.UpdateAll() end frame:SetScript("OnClick",function(self) - B.Conf[self.OptName] = self:GetChecked() - print(B.Conf[self.OptName], self:GetChecked()) - B.UpdateAll() + self.OptRoot[self.OptName] = self:GetChecked() + print(self.OptRoot[self.OptName], self:GetChecked()) + vn.UpdateAll() end) - end, - Color = function(frame, optionInfo) - frame.rgba = { frame.current:GetVertexColor() } - local colorPickerCallback = function(restore) - local newR, newG, newB, newA - if restore then - newR, newG, newB, newA = unpack(restore) - else - newA, newR, newG, newB = OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() - print('not cancel', newA, newR, newB, newG) - end - frame:SetValue({newR, newG, newB, newA}) - B.UpdateBuffs(frame.OptTab) + end +ResetField.Color = function(frame, optionInfo) + frame.rgba = { frame.current:GetVertexColor() } + local colorPickerCallback = function(restore) + local newR, newG, newB, newA + if restore then + newR, newG, newB, newA = unpack(restore) + else + newA, newR, newG, newB = OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() + print('not cancel', newA, newR, newB, newG) end - frame:SetScript("OnClick", function(self) - print('got a click') - local r, g, b, a = frame.current:GetVertexColor() - ColorPickerFrame:SetColorRGB(r, g, b) - ColorPickerFrame.hasOpacity = (a ~= nil) - ColorPickerFrame.opacity = a - ColorPickerFrame.previousValues = {r,g,b,a} - ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = - colorPickerCallback, colorPickerCallback,colorPickerCallback - ColorPickerFrame:Hide() - ColorPickerFrame:Show() - end) - frame.SetValue = function(self, rgba) - print(rgba) - frame.rgba = rgba - B.Conf[self.OptName] = rgba - frame.current:SetVertexColor(unpack(rgba)) - frame.fieldvalue:SetText(frame.OptValue(frame, true)) - end + frame:SetValue({newR, newG, newB, newA}) + vn.UpdateBuffs(frame.OptTab) end -} + frame:SetScript("OnClick", function(self) + print('got a click') + local r, g, b, a = frame.current:GetVertexColor() + ColorPickerFrame:SetColorRGB(r, g, b) + ColorPickerFrame.hasOpacity = (a ~= nil) + ColorPickerFrame.opacity = a + ColorPickerFrame.previousValues = {r,g,b,a} + ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = + colorPickerCallback, colorPickerCallback,colorPickerCallback + ColorPickerFrame:Hide() + ColorPickerFrame:Show() + end) + frame.SetValue = function(self, rgba) + print(rgba) + frame.rgba = rgba + self.OptRoot[self.OptName] = rgba + frame.current:SetVertexColor(unpack(rgba)) + frame.fieldvalue:SetText(frame.OptValue(frame, true)) + end +end + --- configDialog -- @usage tinsert(configDialog, {prefix, row, [...] }) -- Each top level member defines a group of config value handlers, structured as an iterative table where the @@ -130,48 +146,48 @@ -- the string literal widget suffix. -- widget table: ... {'suffix', 'description', valueCallback, 'template', [widget parameters]} -- widget copy: ... 'suffix', ... -local configDialog = { +M.config.BuffFrame = { {'BuffButton', 1, - {'Max', 'Max', configInteger, 'Slider', + {'Max', 'Max', 'Integer', 'Slider', 1, _G.BUFF_MAX_DISPLAY, 1, 1}, -- valueMin, valueMax, valueStep, stepsPerPage - {'PerRow', 'Per Row', configInteger, 'Slider', + {'PerRow', 'Per Row', 'Integer', 'Slider', 1, _G.BUFF_MAX_DISPLAY, 1, 1}, -- valueMin, valueMax, valueStep, stepsPerPage, - {'Size', 'Icon Size', configInteger, 'Slider', + {'Size', 'Icon Size', 'Integer', 'Slider', 1, 256, 1, 1}, - {'Spacing', 'Icon Spacing', configInteger, 'Slider', + {'Spacing', 'Icon Spacing', 'Integer', 'Slider', 1, 50, 1, 1}, - {'DurationSize', 'Duration Text Height', configInteger, 'Slider', + {'DurationSize', 'Duration Text Height', 'Integer', 'Slider', 1, 72, 1, 1}, - {'Zoom', 'Icon Zoom', configInteger, 'Slider', + {'Zoom', 'Icon Zoom', 'Integer', 'Slider', 0, 100, 1, 1}, - {'Border', 'Border', configInteger, 'Slider', + {'Border', 'Border', 'Integer', 'Slider', 1, 16, 1, 1}, - {'Color', 'Default Border', configColor, 'Color'}, - {'RaidColor', 'RaidBuff Border', configColor, 'Color'}, - {'PlayerColor', 'Player Buffs', configColor, 'Color'}, - {'BossColor', 'Encounter Buffs', configColor, 'Color'}, - {'ShowSelfCast', 'Show name for self-casts', configCheck, 'CheckButton'} + {'Color', 'Default Border', 'Color', 'Color'}, + {'RaidColor', 'RaidBuff Border', 'Color', 'Color'}, + {'PlayerColor', 'Player Buffs', 'Color', 'Color'}, + {'BossColor', 'Encounter Buffs', 'Color', 'Color'}, + {'ShowSelfCast', 'Show name for self-casts', 'Check', 'CheckButton'} }, { 'DebuffButton', 1, - {'Max', 'Max', configInteger, 'Slider', + {'Max', 'Max', 'Integer', 'Slider', 1, _G.DEBUFF_MAX_DISPLAY, 1, 1 } , - {'PerRow', 'Per Row', configInteger, 'Slider', + {'PerRow', 'Per Row', 'Integer', 'Slider', 1, _G.DEBUFF_MAX_DISPLAY, 1, 1 }, 'Size', 'Spacing', 'DurationSize', 'Zoom', 'Border', 'Color', 'RaidColor', 'PlayerColor', 'BossColor', }, { 'TempEnchant', 1, - {'Max', 'Max', configInteger, 'Slider', + {'Max', 'Max', 'Integer', 'Slider', 1, _G.NUM_TEMP_ENCHANT_FRAMES, 1, 1 }, - {'PerRow', 'Per Row', configInteger, 'Slider', + {'PerRow', 'Per Row', 'Integer', 'Slider', 1, _G.NUM_TEMP_ENCHANT_FRAMES, 1, 1}, 'Size', 'Spacing', 'DurationSize', 'Zoom', 'Border', 'Color', 'RaidColor', 'PlayerColor', 'BossColor', }, { 'ConsolidatedBuff', 2, - {'Position', 'Slot Position', configInteger, 'Slider', + {'Position', 'Slot Position', 'Integer', 'Slider', 1, _G.BUFF_MAX_DISPLAY, 1, 1 } }, @@ -179,7 +195,7 @@ 'Size' }, { 'Raid', 3, - {'ShowMissing', 'Verbose missing raid buffs', configCheck, 'CheckButton'} + {'ShowMissing', 'Verbose missing raid buffs', 'Check', 'CheckButton'} } } @@ -193,7 +209,7 @@ --- Walks the structure table to generate a pretty config panel local InitConfig = function() configInit = true - local configWidth = B:GetWidth() + local configWidth = vn:GetWidth() local optionWidth = (configWidth - configPadding) / 3 - configSpacing local configHeight = 0 local bottom_extent = 0 @@ -202,7 +218,8 @@ local lastCluster local cluster = 1 local col = 0 - for t, taboptions in ipairs(configDialog) do + for moduleName, moduleOpts in pairs(M.config) do + for t, taboptions in ipairs(moduleOpts) do local group = taboptions[1] cluster = taboptions[2] col = col + 1 @@ -230,7 +247,9 @@ if type(optionInfo) == 'string' then optionInfo = optionTemplates[optionInfo] end - local key, fieldname, valueFuncGenerator, configType = unpack(optionInfo) + local key, fieldname, valueType, configType = unpack(optionInfo) + assert(GetValue[valueType], 'Invalid valueType \''..tostring(valueType)..'\' ('..type(valueType)..')') + assert(ResetField[configType], 'Invalid fieldType \''..tostring(configType)..'\' ('..type(configType)..')') if not optionTemplates[key] then optionTemplates[key] = optionInfo @@ -243,14 +262,19 @@ print('building frame', t, group, row) local frameTemplate = 'VeneerConfig'..configType local frameType = frameTypeConv[configType] or configType - configFrames[t][row] = CreateFrame(frameType, fullkey, B, frameTemplate) + configFrames[t][row] = CreateFrame(frameType, 'Vn_'.. moduleName ..'_'.. fullkey, vn, frameTemplate) local f = configFrames[t][row] + f.ValueType = valueType + f.OptType = configType + f.FrameType = frameType f.OptKey = key + f.OptRoot = vn.Conf[moduleName] f.OptTab = group f.OptName = fullkey - local valueFunc, initialValue = valueFuncGenerator(group, key) - print(' value getter', fullkey,'->', valueFunc,initialValue) - configTypeParams[configType](f, optionInfo) + f.OptInfo = optionInfo + local valueFunc, initialValue = GetValue(f) + print(' value getter', '|cFFFFFF00'..moduleName..'|r.|cFF00FFFF'.. tostring(fullkey),'|r->', valueFunc,initialValue) + ResetField(f) f.OptValue = valueFunc --- Enclosing these to @@ -276,14 +300,13 @@ configInit = nil end local newValue = valueFunc(self) - if newValue ~= B.Conf[fullkey] then + if newValue ~= self.OptRoot[fullkey] then print(newValue, fullkey) f.fieldvalue:SetText(valueFunc(self, true)) - B.Conf[fullkey] = valueFunc(self) + self.OptRoot[fullkey] = valueFunc(self) -- prepare to update - wipe(B.drawn[f.OptTab]) - B.UpdateBuffs(self.OptTab) - B.UpdateConfigLayers() + vn[moduleName]:OnUpdate() + vn.UpdateConfigLayers() end end @@ -303,7 +326,7 @@ local base if (row == 1) then bottom_extent = 0 - base = B.header + base = vn.header x = (col-1) * (optionWidth+configSpacing) y = -configPadding else @@ -328,66 +351,68 @@ --print('y', floor(yBuffer+0.5), 'f:H', floor(f:GetHeight()+0.5), 'hTally', floor(bottom_extent+0.5), 'hMax', floor(configHeight+0.5)) end end + end end + -- grab the last cluster if lastCluster == cluster then print('|cFF00FF00##scooping up last cluster info') configHeight = configHeight + clusterHeight end - if not B.configFramesCreated then - B.configFramesCreated = true - B:SetHeight(B.header:GetStringHeight() + configSpacing*3 + configHeight) + if not vn.configFramesCreated then + vn.configFramesCreated = true + vn:SetHeight(vn.header:GetStringHeight() + configSpacing*3 + configHeight) end if configInit then configInit = nil end end M.Command = function(enable, editbox) - displays = B.displays + displays = vn.displays if type(enable) == 'boolean' then - B.Conf.ConfigMode = enable + vn.Conf.ConfigMode = enable else - B.Conf.ConfigMode = (B.Conf.ConfigMode == false) and true or false + vn.Conf.ConfigMode = (vn.Conf.ConfigMode == false) and true or false end - print('/BUFF', B.Conf.ConfigMode, type(B.Conf.ConfigMode)) - if B.Conf.ConfigMode then - if not B.configFramesCreated then + print('/BUFF', vn.Conf.ConfigMode, type(vn.Conf.ConfigMode)) + if vn.Conf.ConfigMode then + if not vn.configFramesCreated then InitConfig() end print('Veneer config') - B:Show() + vn:Show() else - B:Hide() + vn:Hide() end - B.UpdateAll() - B.UpdateConfigLayers() + vn.UpdateAll() + vn.UpdateConfigLayers() end -B.Close = function () +vn.Close = function () M.Command() end -B.ToggleGuides = function(_, self) - B.Conf.GuidesMode = (not B.Conf.GuidesMode) - if B.Conf.GuidesMode then +vn.ToggleGuides = function(_, self) + vn.Conf.GuidesMode = (not vn.Conf.GuidesMode) + if vn.Conf.GuidesMode then self:GetNormalTexture():SetTexture(0.94, 0.21, 0.21, 1) else self:GetNormalTexture():SetTexture(0, 0, 0, 1) end - B.UpdateConfigLayers() + vn.UpdateConfigLayers() end M.OnEnable = function() - print('|cFFFF0088config module', B.Conf.ConfigMode) - M.Command(B.Conf.ConfigMode) + print('|cFFFF0088config module', vn.Conf.ConfigMode) + M.Command(vn.Conf.ConfigMode) end M.OnInitialize = function() - DEFAULT_CHAT_FRAME:AddMessage("|cFF22D822Veneer|r") - SLASH_BUFFALO1, SLASH_BUFFALO2 = "/buffalo", "/buff" - SlashCmdList.BUFFALO = M.Command + DEFAULT_CHAT_FRAME:AddMessage("|cFF22D822Veneer|r confogulator loaded. Type |cFF00FFFF/vn|r to begin.") + SLASH_VENEER1, SLASH_VENEER2 = "/veneer", "/vn" + SlashCmdList.VENEER = M.Command end \ No newline at end of file
--- a/Veneer.lua Thu Apr 28 06:58:13 2016 -0400 +++ b/Veneer.lua Fri Apr 29 10:50:27 2016 -0400 @@ -491,6 +491,8 @@ end end +local XMLFrame_OnDragStart = function() end +local XMLFrame_OnDragStop = function() end B.UpdateXMLFrame = function(self) local print = B.print('XML')
--- a/Veneer.toc Thu Apr 28 06:58:13 2016 -0400 +++ b/Veneer.toc Fri Apr 29 10:50:27 2016 -0400 @@ -10,7 +10,7 @@ ## OptionalDeps: Devian Veneer.xml -#Config\Config.xml +Config\Config.xml BuffFrame\BuffFrame.xml -#ObjectiveTracker\ObjectiveTracker.xml -#TimeManager\TimeManager.xml \ No newline at end of file +ObjectiveTracker\ObjectiveTracker.xml +TimeManager\TimeManager.xml \ No newline at end of file