comparison ObjectiveCore.lua @ 14:ed642234f017

ObjectiveFrame - implement proper tracker name text - expanded tracker prototypes to cover "objective lines" formatting and accommodation of widget variables - implement the progress bars for bonus objectives ObjectiveStyle - moved `UpdateWrapperStyle` over and renamed it to fit semantics - change the formula for block.`height` to measure non-widget content only - allows widgets to position relative to text - size FontString `status` to match block.`height` - full block height is acquired by adding block.`height` and block.`attachmentHeight` which is calculated during objective parsing ObjectiveWidgets - use string keys for generated widgets to deal with multiple objectives under the same questID, and maybe dungeon objectives - wrapper buttons use a common code path - specialized handlers for wheel scrolling moved over to fit semantics
author Nenue
date Mon, 04 Apr 2016 03:16:22 -0400
parents 9455693fc290
children 880828018bf4
comparison
equal deleted inserted replaced
13:9455693fc290 14:ed642234f017
2 -- @file-author@ 2 -- @file-author@
3 -- @project-revision@ @project-hash@ 3 -- @project-revision@ @project-hash@
4 -- @file-revision@ @file-hash@ 4 -- @file-revision@ @file-hash@
5 -- Created: 3/26/2016 1:51 AM 5 -- Created: 3/26/2016 1:51 AM
6 local B = select(2,...).frame 6 local B = select(2,...).frame
7 local wipe, pairs, ipairs, min, max, unpack = table.wipe, pairs, ipairs, min, max, unpack 7 local pairs, setmetatable, type, tostring = pairs, setmetatable, type, tostring
8 local setmetatable, type = setmetatable, type 8 local format = string.format
9 local GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo = GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo 9 local M = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
10 local GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo = GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo
11 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
12 local print = B.print('Objectives') 10 local print = B.print('Objectives')
13 local ObjectiveTrackerFrame = ObjectiveTrackerFrame 11 local ObjectiveTrackerFrame = ObjectiveTrackerFrame
14 12
15 --[[ 13 --[[
16 Full quest info is available if: 14 Full quest info is available if:
31 local Wrapper = _G.VeneerObjectiveWrapper 29 local Wrapper = _G.VeneerObjectiveWrapper
32 local Scroller = Wrapper.scrollArea 30 local Scroller = Wrapper.scrollArea
33 local Scroll = _G.VeneerObjectiveScroll 31 local Scroll = _G.VeneerObjectiveScroll
34 32
35 --- Baseline defaults 33 --- Baseline defaults
36 mod.defaults = { 34 M.defaults = {
37 35
38 } 36 }
39 37
40 --- list used to make things happen 38 --- list used to make things happen
41 mod.orderedNames = {[1] = 'AutoQuest', [2] = 'Quest', [3] = 'Cheevs'} 39 M.orderedNames = {'Bonus', 'AutoQuest', 'Quest', 'Cheevs'}
42 40
43 --- ipairs() list of handlers for wrapper update 41 --- ipairs() list of handlers for wrapper update
44 mod.orderedHandlers = {} 42 M.orderedHandlers = {}
45 mod.orderedTrackers = {} 43 M.orderedTrackers = {}
46 mod.indexedTrackers = {} 44 M.indexedTrackers = {}
47 --- pairs() list of handler frames for tracker updates 45 --- pairs() list of handler frames for tracker updates
48 mod.namedTrackers = {} 46 M.namedTrackers = {}
49 47
50 --- Handler stubs 48 --- Handler stubs
51 mod.AutoQuest = { 49 M.AutoQuest = {
52 name = "AutoQuest" 50 name = "AutoQuest",
53 } 51 displayName = "Local Quests",
54 mod.Quest = { 52 }
55 name = "Quest" 53 M.Quest = {
56 } 54 name = "Quest",
57 mod.Cheevs = { 55 displayName = "Quests",
58 name = "Cheevs" 56 }
57 M.Cheevs = {
58 name = "Cheevs",
59 displayName = "Achievements",
60 }
61 M.Bonus = {
62 name = "Bonus",
63 displayName = "Bonus Objectives",
59 } 64 }
60 65
61 66
62 --- Temp values set during updates 67 --- Temp values set during updates
63 local wrapperWidth, wrapperHeight 68 local wrapperWidth, wrapperHeight
98 --- Handler template 103 --- Handler template
99 local CreateHandler = function (self, name, index) 104 local CreateHandler = function (self, name, index)
100 print(self, name) 105 print(self, name)
101 local handler = setmetatable({}, { 106 local handler = setmetatable({}, {
102 __tostring = function() return name end, 107 __tostring = function() return name end,
103 __call = function (self) mod.UpdateTracker(self) end 108 __call = function (self) M.UpdateTracker(self) end
104 }) 109 })
105 if type(mod.orderedHandlers[index]) == 'table' then 110 if type(M.orderedHandlers[index]) == 'table' then
106 return mod.orderedHandlers[index] 111 return M.orderedHandlers[index]
107 end 112 end
108 113
109 print('take up locals first') 114 print('take up locals first')
110 local preset = {} 115 local preset = {}
111 for k,v in pairs(mod[name]) do 116 for k,v in pairs(M[name]) do
112 preset[k] = true 117 preset[k] = true
113 if type(v) == 'table' then 118 if type(v) == 'table' then
114 handler[k] = {} 119 handler[k] = {}
115 else 120 else
116 handler[k] = v 121 handler[k] = v
122 if not handler[k] then 127 if not handler[k] then
123 if type(v) == 'table' then 128 if type(v) == 'table' then
124 -- assume all tables to be local data; don't inherit or ref 129 -- assume all tables to be local data; don't inherit or ref
125 handler[k] = {} 130 handler[k] = {}
126 else 131 else
127 handler[k] = mod.Tracker[k] 132 handler[k] = M.Tracker[k]
128 end 133 end
129 else 134 else
130 print(name, 'has its own', k) 135 print(name, 'has its own', k)
131 end 136 end
132 end 137 end
133 print('|cFFFF4400'..tostring(name)..'|r:') 138 print('|cFFFF4400'..tostring(name)..'|r:')
134 for k, v in pairs(handler) do 139 for k, v in pairs(handler) do
135 print(string.format("%24s %8s %s", (preset[k] and '|cFFFFFFFF' or '|cFFFFFF00') .. k .. '|r', type(v), tostring(v))) 140 print(string.format("%24s %8s %s", (preset[k] and '|cFFFFFFFF' or '|cFFFFFF00') .. k .. '|r', type(v), tostring(v)))
136 end 141 end
137 mod[name] = handler 142 M[name] = handler
138 mod.orderedHandlers[index] = handler 143 M.orderedHandlers[index] = handler
139 return true 144 return true
140 end 145 end
141 146
142 mod.Tracker = setmetatable({}, { 147 M.Tracker = setmetatable({}, {
143 __call = CreateHandler, 148 __call = CreateHandler,
144 __tostring = function() return 'DEFAULT_TRACKING_HANDLER' end 149 __tostring = function() return 'DEFAULT_TRACKING_HANDLER' end
145 }) 150 })
146 local Tracker = mod.Tracker 151 local Tracker = M.Tracker
147 Tracker.numWatched = 0 --- number of entries being handled 152 Tracker.numWatched = 0 --- number of entries being handled
148 Tracker.numBlocks = 0 --- number of blocks created 153 Tracker.numBlocks = 0 --- number of blocks created
149 Tracker.actualBlocks = 0 --- number of blocks in use 154 Tracker.actualBlocks = 0 --- number of blocks in use
150 155
151 Tracker.freeBlocks = {} --- block heap 156 Tracker.freeBlocks = {} --- block heap
167 if #handler.freeBlocks >= 1 then 172 if #handler.freeBlocks >= 1 then
168 block = handler.freeBlocks[#handler.freeBlocks] 173 block = handler.freeBlocks[#handler.freeBlocks]
169 handler.freeBlocks[#handler.freeBlocks] = nil 174 handler.freeBlocks[#handler.freeBlocks] = nil
170 else 175 else
171 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock') 176 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock')
172 block.SetStyle = mod.SetBlockStyle 177 block.SetStyle = M.SetBlockStyle
173 block:ClearAllPoints() -- making sure the anchors are clear in case they get added for some other template usage 178 block.Select = handler.Select
179 block.Open = handler.Open
180 block.Remove = handler.Remove
181 block.Link = handler.Link
182 block:SetScript('OnMouseUp', handler.OnMouseUp)
183 block:SetScript('OnMouseDown', handler.OnMouseDown)
184 block:ClearAllPoints()
174 end 185 end
175 186
176 handler.usedBlocks[blockIndex] = block 187 handler.usedBlocks[blockIndex] = block
177 end 188 end
178 return handler.usedBlocks[blockIndex] 189 return handler.usedBlocks[blockIndex]
179 end 190 end
180 191
181 function mod:OnInitialize() 192 function M:OnInitialize()
182 self.InitializeTrackers() 193 self.InitializeWrapper()
183 self.InitializeXPTracker() 194 self.InitializeXPTracker()
184 mod.SetEvents() 195 M.SetEvents()
185 ObjectiveTrackerFrame:UnregisterAllEvents() 196 ObjectiveTrackerFrame:UnregisterAllEvents()
186 ObjectiveTrackerFrame:Hide() 197 ObjectiveTrackerFrame:Hide()
187 198
188 end 199 end
189 200