annotate ObjectiveCore.lua @ 13:9455693fc290

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