Mercurial > wow > buffalo2
changeset 24:66b927b46776
Refine the XML data logic, and sort out some EnableMouse inconsistencies.
author | Nenue |
---|---|
date | Mon, 11 Apr 2016 09:07:40 -0400 |
parents | e837384ac363 |
children | 4b3da1b221de |
files | BuffAnchors.lua Config.lua Init.lua ObjectiveTracker/ObjectiveCore.lua ObjectiveTracker/ObjectiveFrame.lua ObjectiveTracker/ObjectiveTracker.xml ObjectiveTracker/ObjectiveWidgets.lua ObjectiveTracker/QuestTracker.lua |
diffstat | 8 files changed, 334 insertions(+), 233 deletions(-) [+] |
line wrap: on
line diff
--- a/BuffAnchors.lua Sun Apr 10 04:35:32 2016 -0400 +++ b/BuffAnchors.lua Mon Apr 11 09:07:40 2016 -0400 @@ -79,6 +79,7 @@ end end + frame:EnableMouse(B.Conf.ConfigMode and B.Conf.ConfigMode or false) frame:SetScript('OnMouseDown', Anchor_OnMouseDown) frame:SetScript("OnMouseUp", Anchor_OnMouseUp) -- table addition
--- a/Config.lua Sun Apr 10 04:35:32 2016 -0400 +++ b/Config.lua Mon Apr 11 09:07:40 2016 -0400 @@ -19,6 +19,10 @@ return (("%%.%df"):format(decimals)):format(number) end +M.defaults = { + enable = true +} + --- STATE VARIABLES local configInit --- Dummies for addon table upvalues @@ -377,6 +381,7 @@ end M.OnEnable = function() + print('|cFFFF0088config module', B.Conf.ConfigMode) M.Command(B.Conf.ConfigMode) end
--- a/Init.lua Sun Apr 10 04:35:32 2016 -0400 +++ b/Init.lua Mon Apr 11 09:07:40 2016 -0400 @@ -125,7 +125,7 @@ --- localize for speed local layers, refs, displays = B.configLayers, B.configLayersRef, B.displays -local ModulesCall = function(func) +local ModulesCall = function(func, flag) local n = 0 for i = 1, #moduleStack do @@ -134,11 +134,19 @@ for name, module in pairs(stackset) do n = n + 1 - print(n..' '..name..'.'..func..'()') if module[func] then - module[func](module) + -- nil = pass + if not flag or module.Conf[flag] then + if (flag) then + print(' check', flag, '=', module.Conf[flag]) + end + + print(' ',n..' '..name..'.'..func..'()') + module[func](module, module.Conf) + end + end end end @@ -161,6 +169,8 @@ if not VeneerData then VeneerData = {} for k,v in pairs(defaults) do + + VeneerData[k] = v end print('Veneer defaults being used.') @@ -238,6 +248,10 @@ for level, batch in ipairs(moduleStack) do print('config level', level) for name, module in pairs(batch) do + if not VeneerData[name] then + VeneerData[name] = {} + end + if module.defaults then print('setting defaults for module', name) --[===[@non-debug@ @@ -253,6 +267,10 @@ module.Conf = VeneerData[name] end + if VeneerData[name].enabled == nil then + VeneerData[name].enabled = true + end + end end @@ -272,7 +290,7 @@ local lastUpdate function B.UpdateAll(...) lastUpdate = GetTime() - ModulesCall('OnUpdate', lastUpdate) + ModulesCall('OnUpdate') end B:RegisterEvent('PLAYER_ENTERING_WORLD') @@ -285,16 +303,20 @@ C_Timer.After(1, function() if GetSpecialization() then print(GetSpecialization(), 'enabling') - ModulesCall('OnEnable') + + ModulesCall('OnEnable', 'enabled') B:SetScript('OnUpdate', nil) end - end) end - end B.UpdateAll() + + if event == 'PLAYER_ENTERING_WORLD' then + B.UpdateConfigLayers() + end + end) --- Modulizer method @@ -333,10 +355,10 @@ B.SetConfigLayers = function(frame) local print = B.fprint() if not frame.config then - print(frame:GetName(), 'has no config layers') + --print(frame:GetName(), 'has no config layers') return end - print('Registering config layers from', frame:GetName()) + --print('Registering config layers from', frame:GetName()) for i, subframe in ipairs(frame.config) do -- make sure there are no duplicates @@ -345,7 +367,7 @@ layers[key] = subframe refs[subframe] = key end - print(' ', i, subframe:GetName()) + --print(' ', i, subframe:GetName()) end end @@ -380,7 +402,8 @@ end end - + print(B.Conf.ConfigMode) + display.anchor:EnableMouse(B.Conf.ConfigMode) end for id, region in pairs(layers) do print(id, region:GetName(), func) @@ -390,24 +413,66 @@ print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') end +local XMLFrame_SetEnabled = function(self, value) + local name = self:GetName() + + + if not B.Conf[name] then + B.Conf[name] = { + enabled = true + } + end + + print() + local enabled + if value == nil then + if B.Conf[name].enabled == nil then + print('toggle based on visibility') + enabled = (not self:IsVisible()) and true or false + else + print('toggle a config value =', B.Conf[name].enabled) + enabled = B.Conf[name].enabled + end + + enabled = (enabled ~= true) and true or false + else + print('use argument value', value) + enabled = value + end + + print('arg =', value, 'conf =', B.Conf[name].enabled, 'result=', enabled) + + B.Conf[name].enabled = enabled + + local stateFunc = enabled and 'Show' or 'Hide' + local eventFunc = enabled and 'OnToggle' or 'OnToggle' + for i, region in pairs(self.toggled) do + region[stateFunc](region) + end + if self.OnToggle then + self:OnToggle(B.Conf[name].enabled) + end + if B.Conf[name].enabled then + if self.OnEnable then + self:OnEnable() + end + else + if self.OnDisable then + self:OnDisable() + end + end + + +end --- Generic handlers for keeping track of XML-defined frames B.OnLoad = function(self) tinsert(checkForConfig, self) - self.Minimize = function(self, forceDown) - if not self:IsVisible() then - return - end - local state = (forceDown and 1 or (B.Conf.FrameState[self:GetName()] == 1 and 2 or 1)) - local stateFunc = (state == 1) and 'Hide' or 'Show' - for i, region in pairs(self.minimizeFrames) do - region[stateFunc](region) - end - B.Conf.FrameState[self:GetName()] = state - end + self.SetEnabled = XMLFrame_SetEnabled end B.InitXMLFrame = function(self) - print('|cFF00FF00hello from '..self:GetName()) + local name = self:GetName() + print('|cFF00FF00hello from '.. name) if self.drag then self:RegisterForDrag('LeftButton') @@ -415,28 +480,25 @@ self:EnableMouse(false) end - if not B.Conf.FramePosition then - B.Conf.FramePosition = {} + if not B.Conf[name] then + B.Conf[name] = { + enabled = true, + } end - if not B.Conf.FrameState then - B.Conf.FrameState = {} + local c = B.Conf[name] + + if c.position then + print('restoring frame position', unpack(c.position)) + self:ClearAllPoints() + local anchorTo, relativePoint, x, y = unpack(c.position) + self:SetPoint(anchorTo, UIParent, relativePoint, x, y) + else + local a, _, b, c, d = self:GetPoint(1) + print('seeding default position', a, b, c, d) + c.position = {a, b, c, d} end - - if B.Conf.FramePosition[self:GetName()] then - print('restoring frame position', unpack(B.Conf.FramePosition[self:GetName()])) - self:ClearAllPoints() - local anchorTo, relativePoint, x, y = unpack(B.Conf.FramePosition[self:GetName()]) - self:SetPoint(anchorTo, UIParent, relativePoint, x, y) - end - local state = B.Conf.FrameState[self:GetName()] and B.Conf.FrameState[self:GetName()] or 2 - if state == 0 then - self:Hide() - elseif state == 1 then - self.Minimize(self, true) - elseif state == 2 then - self:Show() - end - B.Conf.FrameState[self:GetName()] = state + local state = c.enabled + self:SetEnabled(state) end B.OnDragStart = function(self) @@ -449,13 +511,13 @@ end B.OnDragStop = function(self) - print(self:GetName(), 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')') + local name = self:GetName() + print(name, 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')') local xB = self:GetLeft() - self.xA local yB = self:GetBottom() - self.yA print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB) self:StopMovingOrSizing() - B.Conf.FramePosition[self:GetName()] = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB} + B.Conf[name].position = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB} B.InitXMLFrame(self) - end \ No newline at end of file
--- a/ObjectiveTracker/ObjectiveCore.lua Sun Apr 10 04:35:32 2016 -0400 +++ b/ObjectiveTracker/ObjectiveCore.lua Mon Apr 11 09:07:40 2016 -0400 @@ -10,7 +10,7 @@ local AddQuestWatch, SetSuperTrackedQuestID, GetNumQuestWatches, AUTO_QUEST_WATCH, MAX_WATCHABLE_QUESTS = AddQuestWatch, SetSuperTrackedQuestID, GetNumQuestWatches, AUTO_QUEST_WATCH, MAX_WATCHABLE_QUESTS local QuestPOIUpdateIcons, GetCVar, IsPlayerInMicroDungeon, WorldMapFrame, GetCVarBool, SetMapToCurrentZone = QuestPOIUpdateIcons, GetCVar, IsPlayerInMicroDungeon, WorldMapFrame, GetCVarBool, SetMapToCurrentZone local AddAutoQuestPopUp = AddAutoQuestPopUp -local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') +local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') local print = B.print('Objectives') local ObjectiveTrackerFrame, VeneerObjectiveScroll, CreateFrame = _G.ObjectiveTrackerFrame, _G.VeneerObjectiveScroll, _G.CreateFrame local Wrapper = _G.VeneerObjectiveWrapper @@ -61,21 +61,56 @@ local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_ALL -- default --- Used to determine which trackers are listening for money events -mod.watchMoneyReasons = 0 + +T.strings = {} +T.strings.CLICK_TO_ACCCEPT = 'Click to Accept' +T.strings.CLICK_TO_COMPLETE = 'Click to complete' +T.colors ={ + enable = true, + default = { + titlebg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125}, + textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }, + selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}, + }, + daily = { + titlebg = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125}, + textbg = {'HORIZONTAL', 0, .7, 1, .1, 0, 1, .7, .075 }, + }, + weekly = { + titlebg = {'HORIZONTAL', 0, .35, .7, .25, 0, .35, .7, .125}, + textbg = {'HORIZONTAL', 0, .35, .7, .1, 0, .35, .7, .075 }, + }, + account = { + titlebg = {'HORIZONTAL', .1, .1, .1, .25, .1, .1, .1, .125}, + textbg = {'HORIZONTAL', .1, .1, .1, 0.4, .1, .1, .1, .085 }, + }, + -- alliance + faction_1 = { + titlebg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 }, + textbg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 }, + }, + -- horde + faction_2 = { + titlebg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 }, + textbg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 }, + } +} + +T.watchMoneyReasons = 0 --- Baseline defaults table; values defined in the files that they pertain to -mod.defaults = {} +T.defaults = {} --- Tracker display order -mod.orderedNames = {'Bonus', 'AutoQuest', 'Quest', 'Cheevs'} +T.orderedNames = {'Bonus', 'AutoQuest', 'Quest', 'Cheevs'} --- ipairs() argument tables -mod.orderedHandlers = setmetatable({}, {__mode = "k"}) -mod.orderedTrackers = setmetatable({}, {__mode = "k"}) -mod.indexedTrackers = setmetatable({}, {__mode = "k"}) +T.orderedHandlers = setmetatable({}, {__mode = "k"}) +T.orderedTrackers = setmetatable({}, {__mode = "k"}) +T.indexedTrackers = setmetatable({}, {__mode = "k"}) --- pairs() argument tables -mod.namedTrackers = setmetatable({}, {__mode = "k"}) +T.namedTrackers = setmetatable({}, {__mode = "k"}) local WRAPPER_ANCHOR_POINT = 'TOPRIGHT' local WRAPPER_OFFSET_X = 0 @@ -84,7 +119,7 @@ local WRAPPER_WIDTH = 280 local WRAPPER_HEADER_HEIGHT = 24 -mod.defaults.Wrapper = { +T.defaults.Wrapper = { AnchorPoint = WRAPPER_ANCHOR_POINT, OffsetX = WRAPPER_OFFSET_X, OffsetY = WRAPPER_OFFSET_Y, @@ -98,7 +133,7 @@ --- Tracker module definitions begin here; innards dealing with data retreival and output are defined further in -mod.DefaultHandler = { +T.DefaultHandler = { previousHeight = 0, name = "temp", @@ -120,28 +155,30 @@ WatchBlock = {}, -- find block by watch index } -mod.AutoQuest = { +T.AutoQuest = { name = "AutoQuest", displayName = "Notice", updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_QUEST + OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, } -mod.Quest = { +T.Quest = { name = "Quest", displayName = "Quests", updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_QUEST + OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, + itemButtons = {}, + freeButtons = {}, } -mod.Cheevs = { +T.Cheevs = { name = "Cheevs", displayName = "Achievements", updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT, updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT + OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED, } -mod.Bonus = { +T.Bonus = { name = "Bonus", displayName = "Bonus Objectives", updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE, @@ -157,12 +194,12 @@ local Handler_Initialize = function (self, name, index) print('Initializing |cFF00FFFF'..name..'|r module...') - local handler = setmetatable(mod[name] or {}, { + local handler = setmetatable(T[name] or {}, { __tostring = Tracker_string, __call = Tracker_call }) - if type(mod.orderedHandlers[index]) == 'table' then - return mod.orderedHandlers[index] + if type(T.orderedHandlers[index]) == 'table' then + return T.orderedHandlers[index] end print('|cFFFFFF00Acquiring locals') @@ -189,22 +226,22 @@ print(format("%32s %8s %s", (preset[k] and '|cFFFFFFFF' or '|cFFFFFF00') .. k .. '|r', type(v), tostring(v))) end - mod[name] = handler + T[name] = handler local trackerName = 'Veneer'..name..'Tracker' - local handler = mod[name] + local handler = T[name] local frame = CreateFrame('Frame', trackerName, _G.VeneerObjectiveScroll, 'VeneerTrackerTemplate') frame.title:SetText(handler.displayName) - mod.SetBlockStyle(frame, 'Tracker', 'Normal') + T.SetBlockStyle(frame, 'Tracker', 'Normal') handler.frame = frame handler.trackerName = trackerName handler.lines = {} - mod.orderedTrackers[index] = frame - mod.namedTrackers[name] = frame - mod.indexedTrackers[handler] = frame + T.orderedTrackers[index] = frame + T.namedTrackers[name] = frame + T.indexedTrackers[handler] = frame print('|cFFFF0088' .. trackerName .. '|r created for |cFF00FFFF' .. handler.displayName .. '|r module') - mod.orderedHandlers[index] = handler + T.orderedHandlers[index] = handler return true end @@ -247,12 +284,12 @@ Event.ZONE_CHANGED = function() local inMicroDungeon = IsPlayerInMicroDungeon(); - if ( inMicroDungeon ~= mod.inMicroDungeon ) then + if ( inMicroDungeon ~= T.inMicroDungeon ) then if ( not WorldMapFrame:IsShown() and GetCVarBool("questPOI") ) then SetMapToCurrentZone(); -- update the zone to get the right POI numbers for the tracker end --SortQuestWatches(); - mod.inMicroDungeon = inMicroDungeon; + T.inMicroDungeon = inMicroDungeon; end end Event.QUEST_AUTOCOMPLETE = function(questId) @@ -284,8 +321,8 @@ SetMapToCurrentZone(); -- update the zone to get the right POI numbers for the tracker end SortQuestWatches(); - mod.currentZoneArea = GetCurrentMapAreaID() - print('Updating zone ID to', mod.currentZoneArea, '=', GetZoneText(), GetMinimapZoneText()) + T.currentZoneArea = GetCurrentMapAreaID() + print('Updating zone ID to', T.currentZoneArea, '=', GetZoneText(), GetMinimapZoneText()) return OBJECTIVE_TRACKER_UPDATE_TASK_ADDED @@ -293,8 +330,8 @@ Event.PLAYER_MONEY = function() - if mod.watchMoneyReasons > 0 then - return mod.watchMoneyReasons + if T.watchMoneyReasons > 0 then + return T.watchMoneyReasons end end Event.CRITERIA_COMPLETE = function() @@ -302,14 +339,14 @@ end Event.QUEST_TURN_IN = function(questID, xp, money) if ( IsQuestTask(questID) ) then - mod.Bonus:OnTurnIn(questID, xp, money) + T.Bonus:OnTurnIn(questID, xp, money) print('updating bonus modules (code', OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE, ',', questID, xp, money) return OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE, questID, xp, money else return OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, questID, xp, money end end -mod.Event = Event +T.Event = Event --- Done once per ui load local BlizzHooks = { @@ -325,67 +362,33 @@ } local VeneerData -mod.SetWatchMoney = function(watchMoney, reason) +T.SetWatchMoney = function(watchMoney, reason) if watchMoney then - if band(mod.watchMoneyReasons, reason) == 0 then - mod.watchMoneyReasons = mod.watchMoneyReasons + reason; + if band(T.watchMoneyReasons, reason) == 0 then + T.watchMoneyReasons = T.watchMoneyReasons + reason; end else - if band(mod.watchMoneyReasons, reason) > 0 then - mod.watchMoneyReasons = mod.watchMoneyReasons - reason; + if band(T.watchMoneyReasons, reason) > 0 then + T.watchMoneyReasons = T.watchMoneyReasons - reason; end end end -mod.animateReasons = 0 -mod.SetAnimate = function(animate, reason) +T.animateReasons = 0 +T.SetAnimate = function(animate, reason) if animate then - if band(mod.animateReasons, reason) == 0 then - mod.animateReasons = mod.animateReasons + reason + if band(T.animateReasons, reason) == 0 then + T.animateReasons = T.animateReasons + reason end else - if band(mod.animateReasons, reason) > 0 then - mod.animateReasons = mod.animateReasons - reason + if band(T.animateReasons, reason) > 0 then + T.animateReasons = T.animateReasons - reason end end end - -function mod:OnInitialize() - local c = mod.Conf.Wrapper - VeneerData = _G.VeneerData - VeneerData.CallLog = VeneerData.CallLog or {} - if not mod.isHooked then - mod.isHooked = true - for blizzFunc, veneerFunc in pairs(BlizzHooks) do - if mod[veneerFunc] then - hooksecurefunc(blizzFunc, mod[veneerFunc]) - else - hooksecurefunc(blizzFunc, function(...) - print('|cFFFF0088securehook('..tostring(blizzFunc)..')|r args:', ...) - tinsert(VeneerData.CallLog, {blizzFunc, ...}) - end) - end - end - end - - mod.Conf.TasksLog = mod.Conf.TasksLog or {} - - Scroller:SetScrollChild(Scroll) - Scroller:SetWidth(c.Width) - Scroll:SetWidth(c.Width) - Scroll:ClearAllPoints() - Scroll:SetPoint('TOP', Scroller, 'TOP') - ObjectiveTrackerFrame:UnregisterAllEvents() - ObjectiveTrackerFrame:Hide() - - if B.Conf.FrameState[Wrapper:GetName()] == 0 then - Scroller:Hide() - end -end - local Play = function(file) if Devian and Devian.InWorkspace() then PlaySoundFile(file) end end -function mod:OnEvent (event, ...) +function T:OnEvent (event, ...) local isHandled print('OnEvent(|cFF00FF00'.. event ..'|r):', ...) local reason, arg1, arg2, arg3 @@ -403,7 +406,7 @@ end if reason then - mod:Update(reason, arg1, arg2, arg3) + T:Update(reason, arg1, arg2, arg3) end end else @@ -414,19 +417,54 @@ Play([[Interface\Addons\SharedMedia_MyMedia\sound\Quack.ogg]]) end if reason then - mod:Update(reason, arg1, arg2, arg3) + T:Update(reason, arg1, arg2, arg3) else print('no reason value returned') Play([[Interface\Addons\SharedMedia_MyMedia\sound\Quack.ogg]]) end + +end + + +function T:OnInitialize() + local c = T.Conf.Wrapper + VeneerData = _G.VeneerData + VeneerData.CallLog = VeneerData.CallLog or {} + if not T.isHooked then + T.isHooked = true + for blizzFunc, veneerFunc in pairs(BlizzHooks) do + if T[veneerFunc] then + hooksecurefunc(blizzFunc, T[veneerFunc]) + else + hooksecurefunc(blizzFunc, function(...) + print('|cFFFF0088securehook('..tostring(blizzFunc)..')|r args:', ...) + tinsert(VeneerData.CallLog, {blizzFunc, ...}) + end) + end + end + end + + T.Conf.TasksLog = T.Conf.TasksLog or {} + + ObjectiveTrackerFrame:UnregisterAllEvents() + ObjectiveTrackerFrame:Hide() + + + for id, name in ipairs(T.orderedNames) do + if not T.orderedHandlers[id] then + Handler_Initialize(T.DefaultHandler, name, id) + end + end + self:SetSize(c.Width, 40) + T.InitializeWidgets() end --- Done any time the the minimize button is toggled up -function mod:OnEnable() - for id, name in ipairs(mod.orderedNames) do - if not mod.orderedHandlers[id] then - Handler_Initialize(mod.DefaultHandler, name, id) - end +function T:OnEnable() + + print(B.Conf.VeneerObjectiveWrapper.enabled) + if not B.Conf.VeneerObjectiveWrapper.enabled then + return end for event, action in pairs(Event) do @@ -434,18 +472,28 @@ Wrapper:RegisterEvent(event) end - Wrapper:SetScript('OnEvent', mod.OnEvent) - local c = mod.Conf.Wrapper - Wrapper:SetWidth(c.Width) + local c = T.Conf.Wrapper - mod.InitializeWidgets() - mod:Update() + Scroller:SetScrollChild(Scroll) + Scroller:SetWidth(c.Width) + Scroll:SetWidth(c.Width) + Scroll:ClearAllPoints() + Scroll:SetPoint('TOP', Scroller, 'TOP') + self:SetScript('OnEvent', T.OnEvent) + Scroller:Show() + local from, target, to, x, y = Wrapper:GetPoint(1) + print(from, target:GetName(), to, x,y) + + T:Update() + + -- run once to prime the data structure + T.UpdateActionButtons() end -function mod:OnDisable() - Wrapper:UnregisterAllEvents() +function T:OnDisable() + self:UnregisterAllEvents() + Scroller:Hide() end -
--- a/ObjectiveTracker/ObjectiveFrame.lua Sun Apr 10 04:35:32 2016 -0400 +++ b/ObjectiveTracker/ObjectiveFrame.lua Mon Apr 11 09:07:40 2016 -0400 @@ -56,35 +56,7 @@ local currentPosition, anchorFrame, anchorPoint -T.colors ={ - default = { - titlebg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125}, - textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }, - selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}, - }, - daily = { - titlebg = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125}, - textbg = {'HORIZONTAL', 0, .7, 1, .1, 0, 1, .7, .075 }, - }, - weekly = { - titlebg = {'HORIZONTAL', 0, .35, .7, .25, 0, .35, .7, .125}, - textbg = {'HORIZONTAL', 0, .35, .7, .1, 0, .35, .7, .075 }, - }, - account = { - titlebg = {'HORIZONTAL', .1, .1, .1, .25, .1, .1, .1, .125}, - textbg = {'HORIZONTAL', .1, .1, .1, 0.4, .1, .1, .1, .085 }, - }, - -- alliance - faction_1 = { - titlebg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 }, - textbg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 }, - }, - -- horde - faction_2 = { - titlebg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 }, - textbg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 }, - } -} + T.AddBlock = function(handler, block) local print = bprint @@ -178,7 +150,7 @@ block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) block.titlebg:SetTexture(1,1,1,1) - block.titlebg:SetGradientAlpha(unpack(colors.default.titlebg)) + block.titlebg:SetGradientAlpha(unpack(T.colors.default.titlebg)) block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0) block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing) @@ -189,9 +161,9 @@ block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0) block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0) block.statusbg:SetTexture(1,1,1,1) - block.statusbg:SetGradientAlpha(unpack(colors.default.textbg)) + block.statusbg:SetGradientAlpha(unpack(T.colors.default.textbg)) - block.SelectionOverlay:SetGradientAlpha(unpack(colors.default.selectionbg)) + block.SelectionOverlay:SetGradientAlpha(unpack(T.colors.default.selectionbg)) block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0) block.SelectionOverlay:SetPoint('BOTTOMRIGHT') @@ -751,11 +723,13 @@ Scroll:Show() end Quest.GetClosest() - + --T.UpdateActionButtons(reason) end --- Queue any active item buttons for update for that frame +local iprint = B.print('ItemButton') T.UpdateActionButtons = function(updateReason) + local print = iprint Scroller.snap_upper = 0 Scroller.snap_lower = 0 local print = B.print('ItemButton') @@ -764,7 +738,7 @@ end local previousItem - for questID, itemButton in pairs(usedButtons) do + for questID, itemButton in pairs(Quest.itemButtons) do local info= T.Quest.Info[questID] print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName()) @@ -799,6 +773,7 @@ end T.UpdateBlockAction = function (block, itemButton) + local print = iprint print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()') if itemButton.questID ~= block.info.questID then print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
--- a/ObjectiveTracker/ObjectiveTracker.xml Sun Apr 10 04:35:32 2016 -0400 +++ b/ObjectiveTracker/ObjectiveTracker.xml Mon Apr 11 09:07:40 2016 -0400 @@ -1,6 +1,6 @@ <Ui> - <Frame name="VeneerObjectiveWrapper" parent="UIParent" enableMouse="false" frameStrata="LOW"> + <Frame name="VeneerObjectiveWrapper" parent="UIParent" movable="true" frameStrata="LOW"> <TitleRegion> <Size x="300" y="30" /> <Anchors> @@ -86,7 +86,7 @@ </Layers> <Frames> - <ScrollFrame name="$parentScrollFrame" enableMouseWheel="true" parentKey="scrollArea" parentArray="minimizeFrames"> + <ScrollFrame name="$parentScrollFrame" enableMouseWheel="true" parentKey="scrollArea" parentArray="toggled" hidden="true"> <Anchors> <Anchor point="TOP" /> </Anchors> @@ -139,7 +139,7 @@ </Anchors> </Button> - <Button name="$parentQuestMapButton" parentArray="minimizeFrames" parentKey="QuestMapButton" frameStrata="MEDIUM"> + <Button name="$parentQuestMapButton" parentArray="toggled" parentKey="QuestMapButton" frameStrata="MEDIUM"> <Size x="42" y="16" /> <HighlightTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Highlight" alphaMode="ADD"/> <Anchors> @@ -471,16 +471,16 @@ <Include file="ObjectiveWidgets.xml" /> <Script file="ObjectiveCore.lua" /> - <Script file="ObjectiveInfo.lua" /> - <Script file="ObjectiveUI.lua" /> - <Script file="ObjectiveStyle.lua" /> <Script file="ObjectiveFrame.lua" /> - <Script file="ObjectiveEvents.lua" /> - <Script file="ObjectiveWidgets.lua" /> <Script file="QuestTracker.lua" /> <Script file="AchievementsTracker.lua" /> <Script file="AutoQuestPopUpTracker.lua" /> <Script file="BonusObjectiveTracker.lua" /> <Script file="ScenarioTracker.lua" /> <Script file="XPTracker.lua" /> + <Script file="ObjectiveInfo.lua" /> + <Script file="ObjectiveUI.lua" /> + <Script file="ObjectiveStyle.lua" /> + <Script file="ObjectiveEvents.lua" /> + <Script file="ObjectiveWidgets.lua" /> </Ui> \ No newline at end of file
--- a/ObjectiveTracker/ObjectiveWidgets.lua Sun Apr 10 04:35:32 2016 -0400 +++ b/ObjectiveTracker/ObjectiveWidgets.lua Mon Apr 11 09:07:40 2016 -0400 @@ -1,19 +1,23 @@ local B = select(2,...).frame -local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') +local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') local print = B.print('WidgetFactory') -local UIParent = UIParent +local _G, UIParent = _G, UIParent local GetQuestLogSpecialItemInfo, IsQuestLogSpecialItemInRange, GetQuestLogSpecialItemCooldown = GetQuestLogSpecialItemInfo, IsQuestLogSpecialItemInRange, GetQuestLogSpecialItemCooldown local CooldownFrame_SetTimer, SetItemButtonTextureVertexColor, CreateFrame, VeneerObjectiveScroll = CooldownFrame_SetTimer, SetItemButtonTextureVertexColor, CreateFrame, VeneerObjectiveScroll -local tremove, tinsert, tContains, pairs, setmetatable = tremove, tinsert, tContains, pairs, setmetatable - +local tremove, tContains, pairs, ipairs, setmetatable, floor = tremove, tContains, pairs, ipairs, setmetatable, floor +local SetItemButtonTexture, SetItemButtonCount = SetItemButtonTexture, SetItemButtonCount +local ToggleWorldMap, GetTrackedAchievements, GetTasksTable = ToggleWorldMap, GetTrackedAchievements, GetTasksTable +-- GLOBALS: Veneer_QuestObjectiveItem_UpdateCooldown, Veneer_QuestObjectiveItem_OnUpdate --- frame refs local Wrapper = _G.VeneerObjectiveWrapper local Scroller = Wrapper.scrollArea local CloseButton = Wrapper.CloseButton local QuestMapButton = Wrapper.QuestMapButton local Scroll = _G.VeneerObjectiveScroll +local usedButtons = T.Quest.itemButtons +local freeButtons = T.Quest.freeButtons -local panelButtons = { +T.buttons = { CloseButton = { closedSwatch = { [[Interface\Buttons\UI-Panel-QuestHideButton]], @@ -47,8 +51,8 @@ local Scroller_OnShow = function() Wrapper.watchMoneyReasons = 0; - --mod:Update() - --mod:OnInitialize() + --T:Update() + --T:OnInitialize() for i, region in ipairs(Wrapper.headerComplex) do region:Show() end @@ -77,12 +81,13 @@ B.Conf.ObjectiveScroll = s print('|cFF00FF00OnMouseWheel', 'from = ', from, 'scroll =', s, ' range =', r, 'current =', self:GetVerticalScroll()) - mod.UpdateActionButtons('SCROLLING') + T.UpdateActionButtons('SCROLLING') end local UpdatePanelButton = function (self, state) - state = state and B.Conf.FrameState[state] or 1 - local swatch = (state == 1) and self.openSwatch or self.closedSwatch + state = state or true + local swatch = (state == true) and self.openSwatch or self.closedSwatch + print((state ~= true) and 'closedSwatch' or 'openSwatch') self:SetNormalTexture(swatch[1]) self:SetPushedTexture(swatch[2]) if #swatch >= 6 then @@ -96,8 +101,8 @@ local OnClick = {} OnClick.CloseButton = function(self) - Wrapper:Minimize() - UpdatePanelButton(self, self.parent) + T:SetEnabled() + UpdatePanelButton(self, T.Conf.enabled) end OnClick.QuestMapButton = function() @@ -105,7 +110,8 @@ end -mod.InitializeWidgets = function() +T.InitializeWidgets = function() + local panelButtons = T.buttons --- tracker scroll Scroller:SetScript('OnMouseWheel', Scroller_OnMouseWheel) Scroller:SetScript('OnShow', Scroller_OnShow) @@ -119,25 +125,20 @@ if OnClick[name] then button:SetScript('OnClick', OnClick[name]) end - UpdatePanelButton(button, button.parent) + UpdatePanelButton(button, T.Conf.enabled) end end ---------------------------------------------------------------------------------------- ---- XML and script code lifted from "QuestKing 2" by Barjack, ---- found at http://mods.curse.com/addons/wow/questking +--- modified version of the itemButton initializer used by Barjack's 'QuestKing 2' addon, +--- url: http://mods.curse.com/addons/wow/questking ---------------------------------------------------------------------------------------- -local usedButtons = mod.Quest.itemButtons -local freeButtons = mod.Quest.freeButtons -mod.SetItemButton = function(block, info) +T.SetItemButton = function(block, info) local itemInfo = info.specialItem if not itemInfo then return end - --- Quest.GetInfo().specialItem :: {link = link, charges = charges, icon = icon, start = start, duration = duration, enable = enable} - - local itemButton if not info.itemButton then if #freeButtons >= 1 then @@ -149,14 +150,14 @@ itemButton.block = nil end else - local buttonIndex = mod.Quest.numButtons + #freeButtons + 1 + local buttonIndex = T.Quest.numButtons + #freeButtons + 1 itemButton = CreateFrame('Button', 'VeneerQuestItemButton' .. buttonIndex, UIParent, 'VeneerItemButtonTemplate') itemButton.buttonIndex = buttonIndex itemButton:SetSize(36, 36) itemButton:GetNormalTexture():SetSize(36 * (5/3), 36 * (5/3)) print(' |cFFFF4400starting new button', itemButton:GetName()) end - mod.Quest.numButtons = mod.Quest.numButtons + 1 + T.Quest.numButtons = T.Quest.numButtons + 1 else itemButton = info.itemButton print(' |cFF00FF00found assigned button', itemButton:GetName()) @@ -188,20 +189,20 @@ return itemButton end --- Clear an itemButton from the given block -mod.FreeItemButtons = function(block) +T.FreeItemButtons = function(block) if block.itemButton then local itemButton = block.itemButton if itemButton.questID ~= block.info.questID then block.itemButton = nil - itemButton.block = mod.Quest.InfoBlock[itemButton.questID] + itemButton.block = T.Quest.InfoBlock[itemButton.questID] else itemButton.block = nil itemButton:Hide() usedButtons[itemButton.questID] = nil freeButtons[#freeButtons + 1] = itemButton - mod.Quest.numButtons = mod.Quest.numButtons - 1 + T.Quest.numButtons = T.Quest.numButtons - 1 print('|cFFFF0088released', itemButton:GetName(),'and', block:GetName()) end end @@ -215,7 +216,7 @@ if (rangeTimer <= 0) then local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.questLogIndex) if ((not charges) or (charges ~= self.charges)) then - mod:Update() + T:Update() return end @@ -265,12 +266,12 @@ criteriaID = criteriaID, ]] local newWidgetID = 0 -mod.WidgetRegistry = {} -local wr = mod.WidgetRegistry +T.WidgetRegistry = {} +local wr = T.WidgetRegistry --- Get a usable widget for the given achievement criteria set. -- Returns a frame object with dimensioning parameters needed to size the receiving tracker block -mod.SetWidget = function(line, data, objectiveType, objectiveKey) +T.SetWidget = function(line, data, objectiveType, objectiveKey) local print = B.print('ObjectiveWidgets') local widgetType = objectiveType local widget @@ -291,12 +292,12 @@ widget.line = line widget.objective = data widget.key = objectiveKey - mod.InitializeWidget(widget) + T.InitializeWidget(widget) return widget end --- WidgetTemplate 'OnLoad' -mod.RegisterWidget = function(frame) +T.RegisterWidget = function(frame) local print = B.print('ObjectiveWidgets') local widgetType = frame.widgetType if not wr[frame.widgetType] then @@ -309,24 +310,24 @@ end --- WidgetTemplate 'OnShow' -mod.InitializeWidget = setmetatable({}, { +T.InitializeWidget = setmetatable({}, { __call = function(t, frame) -- todo: config pull - frame:SetWidth(mod.Conf.Wrapper.Width - mod.Conf.Style.Format.status.Indent * 2) - frame:SetScript('OnEvent', mod.UpdateWidget[frame.widgetType]) + frame:SetWidth(T.Conf.Wrapper.Width - T.Conf.Style.Format.status.Indent * 2) + frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType]) frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE') frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED') frame:RegisterEvent('CRITERIA_UPDATE') frame:RegisterEvent('CRITERIA_COMPLETE') frame:RegisterEvent('CRITERIA_EARNED') t[frame.widgetType](frame) - mod.UpdateWidget[frame.widgetType](frame) + T.UpdateWidget[frame.widgetType](frame) end, }) --- WidgetTemplate 'OnEvent' -mod.UpdateWidget = setmetatable({}, { +T.UpdateWidget = setmetatable({}, { __call = function(t, frame) if not frame.widgetType then error('Invalid widget template, needs .widgetType') @@ -338,7 +339,7 @@ }) --- WidgetTemplate 'OnHide' -mod.ReleaseWidget = function(frame) +T.ReleaseWidget = function(frame) --[[ local print = B.print('ObjectiveWidgets') local reg = wr[frame.widgetType] @@ -354,11 +355,11 @@ end --- RemoveTrackedAchievement post-hook -mod.CleanWidgets = function() +T.CleanWidgets = function() local print = B.print('ObjectiveWidgets') local tracked = {GetTrackedAchievements() } local tasks = GetTasksTable() - for type, reg in pairs(mod.WidgetRegistry) do + for type, reg in pairs(T.WidgetRegistry) do print('collecting', type) for key, frame in pairs(reg.used) do if frame.objective.cheevID then @@ -378,7 +379,7 @@ -mod.defaults.WidgetStyle = { +T.defaults.WidgetStyle = { } @@ -388,8 +389,8 @@ local progressFont = _G.VeneerCriteriaFontNormal -mod.InitializeWidget.ProgressBar = function(self) - local c = mod.Conf.Wrapper +T.InitializeWidget.ProgressBar = function(self) + local c = T.Conf.Wrapper self.height = progressHeight + c.TextSpacing self.width = c.Width - c.TextSpacing self.indent = progressIndent @@ -404,7 +405,7 @@ self.status:SetText(self.objective.quantityString) end -mod.UpdateWidget.ProgressBar = function (self) +T.UpdateWidget.ProgressBar = function (self) local quantity, requiredQuantity = self.objective.value, self.objective.maxValue print('update vals:') for k,v in pairs(self.line) do @@ -431,9 +432,9 @@ end -mod.InitializeWidget.Hidden = function (self) +T.InitializeWidget.Hidden = function (self) self.height = 0 end -mod.UpdateWidget.Hidden = function (self) +T.UpdateWidget.Hidden = function (self) self.height= 0 end \ No newline at end of file
--- a/ObjectiveTracker/QuestTracker.lua Sun Apr 10 04:35:32 2016 -0400 +++ b/ObjectiveTracker/QuestTracker.lua Mon Apr 11 09:07:40 2016 -0400 @@ -6,8 +6,18 @@ local format = format local print = B.print('Tracker') local lprint = B.print('Line') +local iprint = B.print('Info') local colors = T.colors + +local tprint = B.print('Tracker') +Quest.Update = function(self, reason, ...) + local print = tprint + print('QuestTracker:Update() received') + T.UpdateActionButtons() + Default.Update(self, reason, ...) +end + Quest.UpdateObjectives = function(handler, block) local print = lprint print('|cFF00FFFFUpdateObjectives()') @@ -40,7 +50,7 @@ local questID, popupType = GetAutoQuestPopUp(info.questLogIndex) if popupType == 'COMPLETE' then print(' :: auto-complete quest :: set the message') - info.completionText = CLICK_TO_COMPLETE + info.completionText = T.strings.CLICK_TO_COMPLETE end end if info.isComplete then @@ -82,8 +92,6 @@ ----------------------------- --- QUEST -Quest.itemButtons = {} -Quest.freeButtons = {} Quest.POI = {} Quest.QuestBlock = {} Quest.LogBlock = {} @@ -96,9 +104,10 @@ return self.numWatched, self.numAll end Quest.GetInfo = function (self, watchIndex) + local print = iprint print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)') - local questID, title, questIndex, numObjectives, requiredMoney, isComplete, - startEvent, isAutoComplete, failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex) + local questID, title, questIndex, numObjectives, requiredMoney, _, + _, isAutoComplete, failureTime, timeElapsed, questType, _, _, _, _ = GetQuestWatchInfo(watchIndex) if not questIndex then return