Mercurial > wow > buffalo2
comparison ObjectiveCore.lua @ 6:589de8ea05b9
- validate tracked objects' existence by use of those handler.Info tables we made
- apply collision checking to action buttons when their corresponding entry has scrolled out
| author | Nenue |
|---|---|
| date | Fri, 01 Apr 2016 01:30:42 -0400 |
| parents | ObjectiveTracker.lua@3397aae1f44d |
| children | 7923243ae972 |
comparison
equal
deleted
inserted
replaced
| 5:e9b61fd5f607 | 6:589de8ea05b9 |
|---|---|
| 1 --- ${PACKAGE_NAME} | |
| 2 -- @file-author@ | |
| 3 -- @project-revision@ @project-hash@ | |
| 4 -- @file-revision@ @file-hash@ | |
| 5 -- Created: 3/26/2016 1:51 AM | |
| 6 local B = select(2,...).frame | |
| 7 local wipe, pairs, ipairs, min, max, unpack = table.wipe, pairs, ipairs, min, max, unpack | |
| 8 local setmetatable, type = setmetatable, type | |
| 9 local GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo = GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo | |
| 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') | |
| 13 local ObjectiveTrackerFrame = ObjectiveTrackerFrame | |
| 14 | |
| 15 --[[ | |
| 16 Full quest info is available if: | |
| 17 - It's in the player quest log, or is available from the Gossip interface | |
| 18 - It's being shared from another player and is acceptible | |
| 19 - It's an auto-quest that is available in the current location | |
| 20 Partial quest info is availabe if: | |
| 21 - It's already completed (i.e. it appears in CompletedQuestInfo()). | |
| 22 - It's an scheduled interval quest (daily, weekly, etc.) | |
| 23 - It's contained in a quest link received from chat | |
| 24 Under any other circumstances, only minimal info can be pulled: | |
| 25 - Its availability to the player | |
| 26 - Its relation with the currently engaged NPC | |
| 27 - Its binary completion status | |
| 28 | |
| 29 ]] | |
| 30 --- Global Frames | |
| 31 local Wrapper = _G.VeneerObjectiveWrapper | |
| 32 local Scroller = Wrapper.scrollArea | |
| 33 local Scroll = _G.VeneerObjectiveScroll | |
| 34 | |
| 35 --- list used to make things happen | |
| 36 mod.orderedNames = {[1] = 'AutoQuest', [2] = 'Quest', [3] = 'Cheevs'} | |
| 37 | |
| 38 --- ipairs() list of handlers for wrapper update | |
| 39 mod.orderedHandlers = {} | |
| 40 mod.orderedTrackers = {} | |
| 41 mod.indexedTrackers = {} | |
| 42 --- pairs() list of handler frames for tracker updates | |
| 43 mod.namedTrackers = {} | |
| 44 | |
| 45 --- Handler stubs | |
| 46 mod.AutoQuest = { | |
| 47 name = "AutoQuest" | |
| 48 } | |
| 49 mod.Quest = { | |
| 50 name = "Quest" | |
| 51 } | |
| 52 mod.Cheevs = { | |
| 53 name = "Cheevs" | |
| 54 } | |
| 55 | |
| 56 | |
| 57 --- Temp values set during updates | |
| 58 local wrapperWidth, wrapperHeight | |
| 59 local scrollWidth, scrollHeight | |
| 60 local previousBlock | |
| 61 local currentBlock | |
| 62 | |
| 63 local frame_guide_init = function(self) | |
| 64 self.testU = self.testU or self:CreateTexture('TestU', 'OVERLAY', 'VnTestLine') | |
| 65 self.testB = self.testB or self:CreateTexture('TestB', 'OVERLAY', 'VnTestLine') | |
| 66 self.testL = self.testL or self:CreateTexture('TestL', 'OVERLAY', 'VnTestLine') | |
| 67 self.testR = self.testR or self:CreateTexture('TestR', 'OVERLAY', 'VnTestLine') | |
| 68 end | |
| 69 local frame_guide = function(self, target) | |
| 70 if not target then return end | |
| 71 if target:IsDragging() then return end | |
| 72 local thickness = 1 | |
| 73 local midX, midY = target:GetCenter() | |
| 74 local width, height = target:GetWidth() * 1.5, target:GetHeight() * 1.5 | |
| 75 --print('frame', target:GetLeft(), target:GetTop(), target:GetRight(), target:GetBottom()) | |
| 76 self.testB:ClearAllPoints() | |
| 77 self.testB:SetPoint('TOP', UIParent, 'BOTTOMLEFT', midX, target:GetBottom()) | |
| 78 self.testB:SetSize(width,thickness) | |
| 79 | |
| 80 self.testU:ClearAllPoints() | |
| 81 self.testU:SetPoint('BOTTOM', UIParent, 'BOTTOMLEFT', midX, target:GetTop()) | |
| 82 self.testU:SetSize(width,thickness) | |
| 83 | |
| 84 self.testL:ClearAllPoints() | |
| 85 self.testL:SetPoint('RIGHT', UIParent, 'BOTTOMLEFT', target:GetLeft(), midY) | |
| 86 self.testL:SetSize(thickness,height) | |
| 87 | |
| 88 self.testR:ClearAllPoints() | |
| 89 self.testR:SetPoint('LEFT', UIParent, 'BOTTOMLEFT', target:GetRight(), midY) | |
| 90 self.testR:SetSize(thickness,height) | |
| 91 end | |
| 92 | |
| 93 --- Handler template | |
| 94 local CreateHandler = function (self, name, index) | |
| 95 print(self, name) | |
| 96 local handler = setmetatable({}, { | |
| 97 __tostring = function() return name end, | |
| 98 __call = function (self) mod.UpdateTracker(self) end | |
| 99 }) | |
| 100 if type(mod.orderedHandlers[index]) == 'table' then | |
| 101 return mod.orderedHandlers[index] | |
| 102 end | |
| 103 | |
| 104 print('take up locals first') | |
| 105 local preset = {} | |
| 106 for k,v in pairs(mod[name]) do | |
| 107 preset[k] = true | |
| 108 if type(v) == 'table' then | |
| 109 handler[k] = {} | |
| 110 else | |
| 111 handler[k] = v | |
| 112 end | |
| 113 end | |
| 114 | |
| 115 print('resulting handler contents') | |
| 116 for k, v in pairs(self) do | |
| 117 if not handler[k] then | |
| 118 if type(v) == 'table' then | |
| 119 -- assume all tables to be local data; don't inherit or ref | |
| 120 handler[k] = {} | |
| 121 else | |
| 122 handler[k] = mod.Tracker[k] | |
| 123 end | |
| 124 else | |
| 125 print(name, 'has its own', k) | |
| 126 end | |
| 127 end | |
| 128 print('|cFFFF4400'..tostring(name)..'|r:') | |
| 129 for k, v in pairs(handler) do | |
| 130 print(string.format("%24s %8s %s", (preset[k] and '|cFFFFFFFF' or '|cFFFFFF00') .. k .. '|r', type(v), tostring(v))) | |
| 131 end | |
| 132 mod[name] = handler | |
| 133 mod.orderedHandlers[index] = handler | |
| 134 return true | |
| 135 end | |
| 136 | |
| 137 mod.Tracker = setmetatable({}, { | |
| 138 __call = CreateHandler, | |
| 139 __tostring = function() return 'DEFAULT_TRACKING_HANDLER' end | |
| 140 }) | |
| 141 local Tracker = mod.Tracker | |
| 142 Tracker.numWatched = 0 --- number of entries being handled | |
| 143 Tracker.numBlocks = 0 --- number of blocks created | |
| 144 Tracker.actualBlocks = 0 --- number of blocks in use | |
| 145 | |
| 146 Tracker.freeBlocks = {} --- block heap | |
| 147 Tracker.usedBlocks = {} | |
| 148 | |
| 149 Tracker.Watched = {} -- find by watchIndex | |
| 150 Tracker.Info = {} -- find by data ID | |
| 151 Tracker.BlockInfo = {} -- find by block ID | |
| 152 Tracker.LogInfo = {} -- find by log ID (quest log mainly) | |
| 153 Tracker.WatchBlock = {} | |
| 154 Tracker.WatchInfo = {} | |
| 155 Tracker.LogBlock = {} | |
| 156 | |
| 157 | |
| 158 | |
| 159 Tracker.GetBlock = function(handler, blockIndex) | |
| 160 local block = handler.usedBlocks[blockIndex] | |
| 161 if not handler.usedBlocks[blockIndex] then | |
| 162 if #handler.freeBlocks >= 1 then | |
| 163 block = handler.freeBlocks[#handler.freeBlocks] | |
| 164 handler.freeBlocks[#handler.freeBlocks] = nil | |
| 165 else | |
| 166 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock') | |
| 167 block.SetStyle = mod.SetBlockStyle | |
| 168 block:ClearAllPoints() -- making sure the anchors are clear in case they get added for some other template usage | |
| 169 end | |
| 170 | |
| 171 handler.usedBlocks[blockIndex] = block | |
| 172 end | |
| 173 return handler.usedBlocks[blockIndex] | |
| 174 end | |
| 175 | |
| 176 function mod:OnInitialize() | |
| 177 self.InitializeTrackers() | |
| 178 self.InitializeXPTracker() | |
| 179 mod.SetEvents() | |
| 180 ObjectiveTrackerFrame:UnregisterAllEvents() | |
| 181 ObjectiveTrackerFrame:Hide() | |
| 182 end | |
| 183 | |
| 184 --[[ | |
| 185 QUESTLINE_UPDATE This event is not yet documented | |
| 186 QUESTTASK_UPDATE This event is not yet documented | |
| 187 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). | |
| 188 QUEST_ACCEPT_CONFIRM Fires when certain kinds of quests (e.g. NPC escort quests) are started by another member of the player's group | |
| 189 QUEST_AUTOCOMPLETE Fires when a quest is automatically completed (remote handin available) | |
| 190 QUEST_BOSS_EMOTE This event is not yet documented | |
| 191 QUEST_CHOICE_CLOSE This event is not yet documented | |
| 192 QUEST_CHOICE_UPDATE This event is not yet documented | |
| 193 QUEST_COMPLETE Fires when the player is looking at the "Complete" page for a quest, at a questgiver. | |
| 194 QUEST_DETAIL Fires when details of an available quest are presented by a questgiver | |
| 195 QUEST_FINISHED Fires when the player ends interaction with a questgiver or ends a stage of the questgiver dialog | |
| 196 QUEST_GREETING Fires when a questgiver presents a greeting along with a list of active or available quests | |
| 197 QUEST_ITEM_UPDATE Fires when information about items in a questgiver dialog is updated | |
| 198 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) | |
| 199 QUEST_POI_UPDATE This event is not yet documented | |
| 200 QUEST_PROGRESS Fires when interacting with a questgiver about an active quest | |
| 201 QUEST_REMOVED This event is not yet documented | |
| 202 QUEST_TURNED_IN Fired when a quest is turned in | |
| 203 QUEST_WATCH_LIST_CHANGED This event is not yet documented | |
| 204 QUEST_WATCH_OBJECTIVES_CHANGED This event is not yet documented | |
| 205 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.] | |
| 206 | |
| 207 TRACKED_ACHIEVEMENT_LIST_CHANGED This event is not yet documented | |
| 208 TRACKED_ACHIEVEMENT_UPDATE Fires when the player's progress changes on an achievement marked for watching in the objectives tracker | |
| 209 ]] |
