Mercurial > wow > buffalo2
view ObjectiveCore.lua @ 18:d1812fb10ae6
ObjectiveStyle
- move tag/template logic into the corresponding GetInfo
author | Nenue |
---|---|
date | Tue, 05 Apr 2016 02:38:01 -0400 |
parents | 880828018bf4 |
children | 605e8f0e46db |
line wrap: on
line source
--- ${PACKAGE_NAME} -- @file-author@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 3/26/2016 1:51 AM local B = select(2,...).frame local pairs, setmetatable, type, tostring = pairs, setmetatable, type, tostring local format = string.format local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') local print = B.print('Objectives') local ObjectiveTrackerFrame, VeneerObjectiveScroll, CreateFrame = ObjectiveTrackerFrame, VeneerObjectiveScroll, CreateFrame --[[ Full quest info is available if: - It's in the player quest log, or is available from the Gossip interface - It's being shared from another player and is acceptible - It's an auto-quest that is available in the current location Partial quest info is availabe if: - It's already completed (i.e. it appears in CompletedQuestInfo()). - It's an scheduled interval quest (daily, weekly, etc.) - It's contained in a quest link received from chat Under any other circumstances, only minimal info can be pulled: - Its availability to the player - Its relation with the currently engaged NPC - Its binary completion status ]] --- Performance values --[[ self:RegisterEvent("QUEST_LOG_UPDATE"); self:RegisterEvent("TRACKED_ACHIEVEMENT_LIST_CHANGED"); self:RegisterEvent("QUEST_WATCH_LIST_CHANGED"); self:RegisterEvent("QUEST_AUTOCOMPLETE"); self:RegisterEvent("QUEST_ACCEPTED"); self:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED"); self:RegisterEvent("SCENARIO_UPDATE"); self:RegisterEvent("SCENARIO_CRITERIA_UPDATE"); self:RegisterEvent("TRACKED_ACHIEVEMENT_UPDATE"); self:RegisterEvent("ZONE_CHANGED_NEW_AREA"); self:RegisterEvent("ZONE_CHANGED"); self:RegisterEvent("QUEST_POI_UPDATE"); self:RegisterEvent("VARIABLES_LOADED"); self:RegisterEvent("QUEST_TURNED_IN"); self:RegisterEvent("PLAYER_MONEY"); ]] mod.Reason ={ UPDATE_MASK_AUTOQUEST = 0x00000001, UPDATE_MASK_QUEST = 0x00000002, UPDATE_MASK_BONUS = 0x00000004, UPDATE_MASK_CHEEVS = 0x00000008, UPDATE_MASK_ALL = 0x00000017, QUEST_LOG_UPDATE = 0x00000003, TRACKED_ACHIEVEMENT_LIST_CHANGED = 0x00000008, QUEST_WATCH_LIST_CHANGED = 0x00000003, QUEST_AUTOCOMPLETE = 0x00000003, QUEST_ACCEPTED = 0x00000003, SUPER_TRACKED_QUEST_CHANGED = 0x00000002, SCENARIO_UPDATE = 0x00000004, SCENARIO_CRITERIA_UPDATE = 0x00000004, TRACKED_ACHIEVEMENT_UPDATE = 0x00000008, ZONE_CHANGED_NEW_AREA = 0x00000017, ZONE_CHANGED = 0x00000017, QUEST_POI_UPDATE = 0x00000003, QUEST_TURNED_IN = 0x00000003, } mod.MoneyReasons = 0 --- Baseline defaults mod.defaults = {} --- list used to make things happen mod.orderedNames = {'Bonus', 'AutoQuest', 'Quest', 'Cheevs'} --- ipairs() list of handlers for wrapper update mod.orderedHandlers = {} mod.orderedTrackers = {} mod.indexedTrackers = {} --- pairs() list of handler frames for tracker updates mod.namedTrackers = {} --- Handler stubs mod.AutoQuest = { name = "AutoQuest", displayName = "Notice", } mod.Quest = { name = "Quest", displayName = "Quests", } mod.Cheevs = { name = "Cheevs", displayName = "Achievements", } mod.Bonus = { name = "Bonus", displayName = "Bonus Objectives", } --- Handler template local CreateHandler = function (self, name, index) print(self, name) local handler = setmetatable(mod[name] or {}, { __tostring = function() return name end, __call = function (self) mod.UpdateTracker(self) end }) if type(mod.orderedHandlers[index]) == 'table' then return mod.orderedHandlers[index] end print('take up locals first') local preset = {} for k,v in pairs(mod[name]) do preset[k] = true if type(v) == 'table' then handler[k] = {} else handler[k] = v end end print('resulting handler contents') for k, v in pairs(self) do if not handler[k] then if type(v) == 'table' then -- assume all tables to be local data; don't inherit or ref handler[k] = {} else handler[k] = mod.Tracker[k] end else print(name, 'has its own', k) end end print('|cFFFF4400'..tostring(name)..'|r:') for k, v in pairs(handler) do print(format("%24s %8s %s", (preset[k] and '|cFFFFFFFF' or '|cFFFFFF00') .. k .. '|r', type(v), tostring(v))) end mod[name] = handler mod.orderedHandlers[index] = handler return true end mod.Tracker = setmetatable({}, { __call = CreateHandler, __tostring = function() return 'DEFAULT_TRACKING_HANDLER' end }) local Tracker = mod.Tracker Tracker.numWatched = 0 --- number of entries being handled Tracker.numBlocks = 0 --- number of blocks created Tracker.actualBlocks = 0 --- number of blocks in use Tracker.freeBlocks = {} --- block heap Tracker.usedBlocks = {} Tracker.Watched = {} -- find by watchIndex Tracker.Info = {} -- find by data ID Tracker.BlockInfo = {} -- find by block ID Tracker.WatchInfo = {} -- find data by watch index Tracker.WatchBlock = {} -- find block by watch index Tracker.GetBlock = function(handler, blockIndex) local block = handler.usedBlocks[blockIndex] if not handler.usedBlocks[blockIndex] then if #handler.freeBlocks >= 1 then block = handler.freeBlocks[#handler.freeBlocks] handler.freeBlocks[#handler.freeBlocks] = nil else block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, VeneerObjectiveScroll, 'VeneerTrackerBlock') block.SetStyle = mod.SetBlockStyle block.Select = handler.Select block.Open = handler.Open block.Remove = handler.Remove block.Link = handler.Link block:SetScript('OnMouseUp', handler.OnMouseUp) block:SetScript('OnMouseDown', handler.OnMouseDown) block:ClearAllPoints() end handler.usedBlocks[blockIndex] = block end return handler.usedBlocks[blockIndex] end function mod:OnInitialize() self.InitializeWrapper() self.InitializeXPTracker() mod.SetEvents() ObjectiveTrackerFrame:UnregisterAllEvents() ObjectiveTrackerFrame:Hide() end