Mercurial > wow > buffalo2
comparison ObjectiveCore.lua @ 16:880828018bf4
ObjectiveEvents
- trim down the number of events that fire full updates
- begin the general outline for determining which trackers need to refresh
- handlers for accepting and completing auto-popup quests
ObjectiveFrame
- correct variables for money reward calculation
- make sure everythign is scaling to the font strings and that the font strings aren't being pinned by SetSize
ObjectiveInfo
- implementation of autoquest popups
- discern between internal and client bonus objective indexes
- acquire the correct data set from bonus objective query
ObjectiveStyle
- look for a style table under the previously interpreted set before deferring standard options
- horizontal/vertical options in gradient
- remove height-fixing for font strings
| author | Nenue |
|---|---|
| date | Tue, 05 Apr 2016 00:39:12 -0400 |
| parents | ed642234f017 |
| children | 605e8f0e46db |
comparison
equal
deleted
inserted
replaced
| 15:f660f1c1e0aa | 16:880828018bf4 |
|---|---|
| 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 pairs, setmetatable, type, tostring = pairs, setmetatable, type, tostring | 7 local pairs, setmetatable, type, tostring = pairs, setmetatable, type, tostring |
| 8 local format = string.format | 8 local format = string.format |
| 9 local M = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') | 9 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') |
| 10 local print = B.print('Objectives') | 10 local print = B.print('Objectives') |
| 11 local ObjectiveTrackerFrame = ObjectiveTrackerFrame | 11 local ObjectiveTrackerFrame, VeneerObjectiveScroll, CreateFrame = ObjectiveTrackerFrame, VeneerObjectiveScroll, CreateFrame |
| 12 | 12 |
| 13 --[[ | 13 --[[ |
| 14 Full quest info is available if: | 14 Full quest info is available if: |
| 15 - It's in the player quest log, or is available from the Gossip interface | 15 - It's in the player quest log, or is available from the Gossip interface |
| 16 - It's being shared from another player and is acceptible | 16 - It's being shared from another player and is acceptible |
| 23 - Its availability to the player | 23 - Its availability to the player |
| 24 - Its relation with the currently engaged NPC | 24 - Its relation with the currently engaged NPC |
| 25 - Its binary completion status | 25 - Its binary completion status |
| 26 | 26 |
| 27 ]] | 27 ]] |
| 28 --- Global Frames | 28 |
| 29 local Wrapper = _G.VeneerObjectiveWrapper | 29 |
| 30 local Scroller = Wrapper.scrollArea | 30 --- Performance values |
| 31 local Scroll = _G.VeneerObjectiveScroll | 31 --[[ |
| 32 self:RegisterEvent("QUEST_LOG_UPDATE"); | |
| 33 self:RegisterEvent("TRACKED_ACHIEVEMENT_LIST_CHANGED"); | |
| 34 self:RegisterEvent("QUEST_WATCH_LIST_CHANGED"); | |
| 35 self:RegisterEvent("QUEST_AUTOCOMPLETE"); | |
| 36 self:RegisterEvent("QUEST_ACCEPTED"); | |
| 37 self:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED"); | |
| 38 self:RegisterEvent("SCENARIO_UPDATE"); | |
| 39 self:RegisterEvent("SCENARIO_CRITERIA_UPDATE"); | |
| 40 self:RegisterEvent("TRACKED_ACHIEVEMENT_UPDATE"); | |
| 41 self:RegisterEvent("ZONE_CHANGED_NEW_AREA"); | |
| 42 self:RegisterEvent("ZONE_CHANGED"); | |
| 43 self:RegisterEvent("QUEST_POI_UPDATE"); | |
| 44 self:RegisterEvent("VARIABLES_LOADED"); | |
| 45 self:RegisterEvent("QUEST_TURNED_IN"); | |
| 46 self:RegisterEvent("PLAYER_MONEY"); | |
| 47 ]] | |
| 48 mod.Reason ={ | |
| 49 UPDATE_MASK_AUTOQUEST = 0x00000001, | |
| 50 UPDATE_MASK_QUEST = 0x00000002, | |
| 51 UPDATE_MASK_BONUS = 0x00000004, | |
| 52 UPDATE_MASK_CHEEVS = 0x00000008, | |
| 53 UPDATE_MASK_ALL = 0x00000017, | |
| 54 | |
| 55 QUEST_LOG_UPDATE = 0x00000003, | |
| 56 TRACKED_ACHIEVEMENT_LIST_CHANGED = 0x00000008, | |
| 57 QUEST_WATCH_LIST_CHANGED = 0x00000003, | |
| 58 QUEST_AUTOCOMPLETE = 0x00000003, | |
| 59 QUEST_ACCEPTED = 0x00000003, | |
| 60 SUPER_TRACKED_QUEST_CHANGED = 0x00000002, | |
| 61 SCENARIO_UPDATE = 0x00000004, | |
| 62 SCENARIO_CRITERIA_UPDATE = 0x00000004, | |
| 63 TRACKED_ACHIEVEMENT_UPDATE = 0x00000008, | |
| 64 ZONE_CHANGED_NEW_AREA = 0x00000017, | |
| 65 ZONE_CHANGED = 0x00000017, | |
| 66 QUEST_POI_UPDATE = 0x00000003, | |
| 67 QUEST_TURNED_IN = 0x00000003, | |
| 68 } | |
| 69 mod.MoneyReasons = 0 | |
| 32 | 70 |
| 33 --- Baseline defaults | 71 --- Baseline defaults |
| 34 M.defaults = { | 72 mod.defaults = {} |
| 35 | |
| 36 } | |
| 37 | 73 |
| 38 --- list used to make things happen | 74 --- list used to make things happen |
| 39 M.orderedNames = {'Bonus', 'AutoQuest', 'Quest', 'Cheevs'} | 75 mod.orderedNames = {'Bonus', 'AutoQuest', 'Quest', 'Cheevs'} |
| 40 | 76 |
| 41 --- ipairs() list of handlers for wrapper update | 77 --- ipairs() list of handlers for wrapper update |
| 42 M.orderedHandlers = {} | 78 mod.orderedHandlers = {} |
| 43 M.orderedTrackers = {} | 79 mod.orderedTrackers = {} |
| 44 M.indexedTrackers = {} | 80 mod.indexedTrackers = {} |
| 45 --- pairs() list of handler frames for tracker updates | 81 --- pairs() list of handler frames for tracker updates |
| 46 M.namedTrackers = {} | 82 mod.namedTrackers = {} |
| 47 | 83 |
| 48 --- Handler stubs | 84 --- Handler stubs |
| 49 M.AutoQuest = { | 85 mod.AutoQuest = { |
| 50 name = "AutoQuest", | 86 name = "AutoQuest", |
| 51 displayName = "Local Quests", | 87 displayName = "Notice", |
| 52 } | 88 } |
| 53 M.Quest = { | 89 mod.Quest = { |
| 54 name = "Quest", | 90 name = "Quest", |
| 55 displayName = "Quests", | 91 displayName = "Quests", |
| 56 } | 92 } |
| 57 M.Cheevs = { | 93 mod.Cheevs = { |
| 58 name = "Cheevs", | 94 name = "Cheevs", |
| 59 displayName = "Achievements", | 95 displayName = "Achievements", |
| 60 } | 96 } |
| 61 M.Bonus = { | 97 mod.Bonus = { |
| 62 name = "Bonus", | 98 name = "Bonus", |
| 63 displayName = "Bonus Objectives", | 99 displayName = "Bonus Objectives", |
| 64 } | 100 } |
| 65 | 101 |
| 66 | |
| 67 --- Temp values set during updates | |
| 68 local wrapperWidth, wrapperHeight | |
| 69 local scrollWidth, scrollHeight | |
| 70 local previousBlock | |
| 71 local currentBlock | |
| 72 | |
| 73 local frame_guide_init = function(self) | |
| 74 self.testU = self.testU or self:CreateTexture('TestU', 'OVERLAY', 'VnTestLine') | |
| 75 self.testB = self.testB or self:CreateTexture('TestB', 'OVERLAY', 'VnTestLine') | |
| 76 self.testL = self.testL or self:CreateTexture('TestL', 'OVERLAY', 'VnTestLine') | |
| 77 self.testR = self.testR or self:CreateTexture('TestR', 'OVERLAY', 'VnTestLine') | |
| 78 end | |
| 79 local frame_guide = function(self, target) | |
| 80 if not target then return end | |
| 81 if target:IsDragging() then return end | |
| 82 local thickness = 1 | |
| 83 local midX, midY = target:GetCenter() | |
| 84 local width, height = target:GetWidth() * 1.5, target:GetHeight() * 1.5 | |
| 85 --print('frame', target:GetLeft(), target:GetTop(), target:GetRight(), target:GetBottom()) | |
| 86 self.testB:ClearAllPoints() | |
| 87 self.testB:SetPoint('TOP', UIParent, 'BOTTOMLEFT', midX, target:GetBottom()) | |
| 88 self.testB:SetSize(width,thickness) | |
| 89 | |
| 90 self.testU:ClearAllPoints() | |
| 91 self.testU:SetPoint('BOTTOM', UIParent, 'BOTTOMLEFT', midX, target:GetTop()) | |
| 92 self.testU:SetSize(width,thickness) | |
| 93 | |
| 94 self.testL:ClearAllPoints() | |
| 95 self.testL:SetPoint('RIGHT', UIParent, 'BOTTOMLEFT', target:GetLeft(), midY) | |
| 96 self.testL:SetSize(thickness,height) | |
| 97 | |
| 98 self.testR:ClearAllPoints() | |
| 99 self.testR:SetPoint('LEFT', UIParent, 'BOTTOMLEFT', target:GetRight(), midY) | |
| 100 self.testR:SetSize(thickness,height) | |
| 101 end | |
| 102 | |
| 103 --- Handler template | 102 --- Handler template |
| 104 local CreateHandler = function (self, name, index) | 103 local CreateHandler = function (self, name, index) |
| 105 print(self, name) | 104 print(self, name) |
| 106 local handler = setmetatable({}, { | 105 |
| 106 local handler = setmetatable(mod[name] or {}, { | |
| 107 __tostring = function() return name end, | 107 __tostring = function() return name end, |
| 108 __call = function (self) M.UpdateTracker(self) end | 108 __call = function (self) mod.UpdateTracker(self) end |
| 109 }) | 109 }) |
| 110 if type(M.orderedHandlers[index]) == 'table' then | 110 if type(mod.orderedHandlers[index]) == 'table' then |
| 111 return M.orderedHandlers[index] | 111 return mod.orderedHandlers[index] |
| 112 end | 112 end |
| 113 | 113 |
| 114 print('take up locals first') | 114 print('take up locals first') |
| 115 local preset = {} | 115 local preset = {} |
| 116 for k,v in pairs(M[name]) do | 116 for k,v in pairs(mod[name]) do |
| 117 preset[k] = true | 117 preset[k] = true |
| 118 if type(v) == 'table' then | 118 if type(v) == 'table' then |
| 119 handler[k] = {} | 119 handler[k] = {} |
| 120 else | 120 else |
| 121 handler[k] = v | 121 handler[k] = v |
| 122 end | 122 end |
| 123 end | 123 end |
| 124 | 124 |
| 125 | |
| 125 print('resulting handler contents') | 126 print('resulting handler contents') |
| 126 for k, v in pairs(self) do | 127 for k, v in pairs(self) do |
| 127 if not handler[k] then | 128 if not handler[k] then |
| 128 if type(v) == 'table' then | 129 if type(v) == 'table' then |
| 129 -- assume all tables to be local data; don't inherit or ref | 130 -- assume all tables to be local data; don't inherit or ref |
| 130 handler[k] = {} | 131 handler[k] = {} |
| 131 else | 132 else |
| 132 handler[k] = M.Tracker[k] | 133 handler[k] = mod.Tracker[k] |
| 133 end | 134 end |
| 134 else | 135 else |
| 135 print(name, 'has its own', k) | 136 print(name, 'has its own', k) |
| 136 end | 137 end |
| 137 end | 138 end |
| 138 print('|cFFFF4400'..tostring(name)..'|r:') | 139 print('|cFFFF4400'..tostring(name)..'|r:') |
| 139 for k, v in pairs(handler) do | 140 for k, v in pairs(handler) do |
| 140 print(string.format("%24s %8s %s", (preset[k] and '|cFFFFFFFF' or '|cFFFFFF00') .. k .. '|r', type(v), tostring(v))) | 141 print(format("%24s %8s %s", (preset[k] and '|cFFFFFFFF' or '|cFFFFFF00') .. k .. '|r', type(v), tostring(v))) |
| 141 end | 142 end |
| 142 M[name] = handler | 143 |
| 143 M.orderedHandlers[index] = handler | 144 mod[name] = handler |
| 145 | |
| 146 mod.orderedHandlers[index] = handler | |
| 144 return true | 147 return true |
| 145 end | 148 end |
| 146 | 149 |
| 147 M.Tracker = setmetatable({}, { | 150 mod.Tracker = setmetatable({}, { |
| 148 __call = CreateHandler, | 151 __call = CreateHandler, |
| 149 __tostring = function() return 'DEFAULT_TRACKING_HANDLER' end | 152 __tostring = function() return 'DEFAULT_TRACKING_HANDLER' end |
| 150 }) | 153 }) |
| 151 local Tracker = M.Tracker | 154 local Tracker = mod.Tracker |
| 152 Tracker.numWatched = 0 --- number of entries being handled | 155 Tracker.numWatched = 0 --- number of entries being handled |
| 153 Tracker.numBlocks = 0 --- number of blocks created | 156 Tracker.numBlocks = 0 --- number of blocks created |
| 154 Tracker.actualBlocks = 0 --- number of blocks in use | 157 Tracker.actualBlocks = 0 --- number of blocks in use |
| 155 | 158 |
| 156 Tracker.freeBlocks = {} --- block heap | 159 Tracker.freeBlocks = {} --- block heap |
| 157 Tracker.usedBlocks = {} | 160 Tracker.usedBlocks = {} |
| 158 | 161 |
| 159 Tracker.Watched = {} -- find by watchIndex | 162 Tracker.Watched = {} -- find by watchIndex |
| 160 Tracker.Info = {} -- find by data ID | 163 Tracker.Info = {} -- find by data ID |
| 161 Tracker.BlockInfo = {} -- find by block ID | 164 Tracker.BlockInfo = {} -- find by block ID |
| 162 Tracker.LogInfo = {} -- find by log ID (quest log mainly) | 165 Tracker.WatchInfo = {} -- find data by watch index |
| 163 Tracker.WatchInfo = {} | 166 Tracker.WatchBlock = {} -- find block by watch index |
| 164 Tracker.LogBlock = {} | |
| 165 Tracker.WatchBlock = {} | |
| 166 | 167 |
| 167 | 168 |
| 168 | 169 |
| 169 Tracker.GetBlock = function(handler, blockIndex) | 170 Tracker.GetBlock = function(handler, blockIndex) |
| 170 local block = handler.usedBlocks[blockIndex] | 171 local block = handler.usedBlocks[blockIndex] |
| 171 if not handler.usedBlocks[blockIndex] then | 172 if not handler.usedBlocks[blockIndex] then |
| 172 if #handler.freeBlocks >= 1 then | 173 if #handler.freeBlocks >= 1 then |
| 173 block = handler.freeBlocks[#handler.freeBlocks] | 174 block = handler.freeBlocks[#handler.freeBlocks] |
| 174 handler.freeBlocks[#handler.freeBlocks] = nil | 175 handler.freeBlocks[#handler.freeBlocks] = nil |
| 175 else | 176 else |
| 176 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock') | 177 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, VeneerObjectiveScroll, 'VeneerTrackerBlock') |
| 177 block.SetStyle = M.SetBlockStyle | 178 block.SetStyle = mod.SetBlockStyle |
| 178 block.Select = handler.Select | 179 block.Select = handler.Select |
| 179 block.Open = handler.Open | 180 block.Open = handler.Open |
| 180 block.Remove = handler.Remove | 181 block.Remove = handler.Remove |
| 181 block.Link = handler.Link | 182 block.Link = handler.Link |
| 182 block:SetScript('OnMouseUp', handler.OnMouseUp) | 183 block:SetScript('OnMouseUp', handler.OnMouseUp) |
| 187 handler.usedBlocks[blockIndex] = block | 188 handler.usedBlocks[blockIndex] = block |
| 188 end | 189 end |
| 189 return handler.usedBlocks[blockIndex] | 190 return handler.usedBlocks[blockIndex] |
| 190 end | 191 end |
| 191 | 192 |
| 192 function M:OnInitialize() | 193 function mod:OnInitialize() |
| 193 self.InitializeWrapper() | 194 self.InitializeWrapper() |
| 194 self.InitializeXPTracker() | 195 self.InitializeXPTracker() |
| 195 M.SetEvents() | 196 mod.SetEvents() |
| 196 ObjectiveTrackerFrame:UnregisterAllEvents() | 197 ObjectiveTrackerFrame:UnregisterAllEvents() |
| 197 ObjectiveTrackerFrame:Hide() | 198 ObjectiveTrackerFrame:Hide() |
| 198 | |
| 199 end | 199 end |
| 200 | |
| 201 --[[ | |
| 202 QUESTLINE_UPDATE This event is not yet documented | |
| 203 QUESTTASK_UPDATE This event is not yet documented | |
| 204 QUEST_ACCEPTED Fires when a new quest is added to the player's quest log (which is what happens after a player accepts a quest). | |
| 205 QUEST_ACCEPT_CONFIRM Fires when certain kinds of quests (e.g. NPC escort quests) are started by another member of the player's group | |
| 206 QUEST_AUTOCOMPLETE Fires when a quest is automatically completed (remote handin available) | |
| 207 QUEST_BOSS_EMOTE This event is not yet documented | |
| 208 QUEST_CHOICE_CLOSE This event is not yet documented | |
| 209 QUEST_CHOICE_UPDATE This event is not yet documented | |
| 210 QUEST_COMPLETE Fires when the player is looking at the "Complete" page for a quest, at a questgiver. | |
| 211 QUEST_DETAIL Fires when details of an available quest are presented by a questgiver | |
| 212 QUEST_FINISHED Fires when the player ends interaction with a questgiver or ends a stage of the questgiver dialog | |
| 213 QUEST_GREETING Fires when a questgiver presents a greeting along with a list of active or available quests | |
| 214 QUEST_ITEM_UPDATE Fires when information about items in a questgiver dialog is updated | |
| 215 QUEST_LOG_UPDATE Fires when the game client receives updates relating to the player's quest log (this event is not just related to the quests inside it) | |
| 216 QUEST_POI_UPDATE This event is not yet documented | |
| 217 QUEST_PROGRESS Fires when interacting with a questgiver about an active quest | |
| 218 QUEST_REMOVED This event is not yet documented | |
| 219 QUEST_TURNED_IN Fired when a quest is turned in | |
| 220 QUEST_WATCH_LIST_CHANGED This event is not yet documented | |
| 221 QUEST_WATCH_OBJECTIVES_CHANGED This event is not yet documented | |
| 222 QUEST_WATCH_UPDATE Fires when the player's status regarding a quest's objectives changes, for instance picking up a required object or killing a mob for that quest. All forms of (quest objective) progress changes will trigger this event.] | |
| 223 | |
| 224 TRACKED_ACHIEVEMENT_LIST_CHANGED This event is not yet documented | |
| 225 TRACKED_ACHIEVEMENT_UPDATE Fires when the player's progress changes on an achievement marked for watching in the objectives tracker | |
| 226 ]] |
