Nenue@0: --- ${PACKAGE_NAME} Nenue@0: -- @file-author@ Nenue@0: -- @project-revision@ @project-hash@ Nenue@0: -- @file-revision@ @file-hash@ Nenue@0: -- Created: 3/29/2016 7:07 PM Nenue@0: local B = select(2,...).frame Nenue@0: local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') Nenue@0: local print = B.print('Objectives') Nenue@0: local Tracker, AutoQuest, Quest, Cheevs = mod.Tracker, mod.AutoQuest, mod.Quest, mod.Cheevs Nenue@0: Nenue@0: -------------------------------------------------------------------- Nenue@3: --- Tracker-specific widgets and their handlers Nenue@0: -------------------------------------------------------------------- Nenue@0: Nenue@0: Tracker.Select = function(self) end Nenue@0: Tracker.Open = function(self) end Nenue@0: Tracker.Remove = function(self) end Nenue@0: Tracker.Report = function(self) Nenue@0: print('Stats:', self.numWatched,'items tracked,', self.numBlocks,'blocks assigned.') Nenue@0: end Nenue@0: Nenue@0: Tracker.OnMouseUp = function(self, button) Nenue@1: Nenue@1: if self.initialButton == 'LeftButton' then Nenue@0: self:Select() Nenue@0: mod.UpdateWrapper() Nenue@1: if self.modShift then Nenue@1: self:Remove() Nenue@1: end Nenue@0: elseif button == 'RightButton' then Nenue@0: self:Open() Nenue@0: end Nenue@1: self.initialButton = nil Nenue@1: self.modShift = nil Nenue@0: print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r ->',self.info.trackingID) Nenue@0: end Nenue@0: Nenue@0: Tracker.OnMouseDown = function(self, button) Nenue@1: self.initialButton = button Nenue@1: self.modShift = IsShiftKeyDown() Nenue@0: if button == 'LeftButton' then Nenue@0: self:SetStyle('Active') Nenue@0: end Nenue@0: print(self.info.title) Nenue@0: end Nenue@0: Nenue@0: ----------------------------- Nenue@0: --- AUTO_QUEST Nenue@0: AutoQuest.name = "Remote Quests" Nenue@0: AutoQuest.GetNumWatched = GetNumAutoQuestPopUps Nenue@0: Nenue@0: ----------------------------- Nenue@0: --- QUEST Nenue@0: Quest.name = "Quests" Nenue@0: Quest.Select = function(self) Nenue@0: SetSuperTrackedQuestID(self.info.questID) Nenue@0: end Nenue@0: Quest.Open = function(self) Nenue@1: QuestMapFrame_OpenToQuestDetails(self.info.questID) Nenue@1: end Nenue@1: Nenue@1: Quest.Remove = function(self) Nenue@5: print('removing', self.info.questLogIndex, 'from watcher') Nenue@5: RemoveQuestWatch(self.info.questLogIndex) Nenue@5: Nenue@5: mod.Quest.LogBlock[self.info.questLogIndex] = nil Nenue@5: mod.Quest.QuestBlock[self.info.questID] = nil Nenue@1: QuestPOIUpdateIcons() Nenue@5: mod.UpdateWrapper() Nenue@0: end Nenue@0: Nenue@0: Nenue@0: ----------------------------- Nenue@0: --- CHEEVS Nenue@0: Cheevs.Select = function(self) Nenue@0: end Nenue@0: Nenue@0: Cheevs.Open = function(self) Nenue@3: if ( not AchievementFrame ) then Nenue@3: AchievementFrame_LoadUI(); Nenue@3: end Nenue@3: if ( not AchievementFrame:IsShown() ) then Nenue@3: AchievementFrame_ToggleAchievementFrame(); Nenue@3: end Nenue@3: AchievementFrame_SelectAchievement(self.info.cheevID); Nenue@0: end Nenue@0: Nenue@1: ---------------------------------------------------------------------------------------- Nenue@1: --- frame template and scripts lifted from "QuestKing 2" by Barjack Nenue@1: --- url: http://mods.curse.com/addons/wow/questking Nenue@1: ---------------------------------------------------------------------------------------- Nenue@1: local usedButtons = mod.Quest.itemButtons Nenue@1: local freeButtons = mod.Quest.freeButtons Nenue@1: mod.SetItemButton = function(block, info) Nenue@1: local itemInfo = info.specialItem Nenue@1: if not itemInfo then Nenue@1: return Nenue@1: end Nenue@1: --- .specialItem :: {link = link, charges = charges, icon = icon, start = start, duration = duration, enable = enable} Nenue@1: Nenue@1: Nenue@1: local itemButton Nenue@1: if not info.itemButton then Nenue@1: if #freeButtons >= 1 then Nenue@2: print(' |cFF00FFFFfound a free button') Nenue@1: itemButton = freeButtons[#freeButtons] Nenue@1: freeButtons[#freeButtons] = nil Nenue@2: if itemButton.block then Nenue@2: itemButton.block.itemButton = nil Nenue@2: itemButton.block = nil Nenue@2: end Nenue@1: else Nenue@1: local buttonIndex = mod.Quest.numButtons + #freeButtons + 1 Nenue@1: itemButton = CreateFrame('Button', 'VeneerQuestItemButton' .. buttonIndex, UIParent, 'VeneerItemButtonTemplate') Nenue@1: itemButton.buttonIndex = buttonIndex Nenue@1: itemButton:SetSize(48, 48) Nenue@1: itemButton:GetNormalTexture():SetSize(80,80) Nenue@5: print(' |cFFFF4400starting new button', itemButton:GetName()) Nenue@1: end Nenue@1: mod.Quest.numButtons = mod.Quest.numButtons + 1 Nenue@1: else Nenue@1: itemButton = info.itemButton Nenue@5: print(' |cFF00FF00found assigned button', itemButton:GetName()) Nenue@2: Nenue@1: end Nenue@1: -- set values Nenue@2: Nenue@5: info.itemButton = itemButton Nenue@5: usedButtons[info.questID] = itemButton Nenue@5: print(' |cFF8800FFassigning|r', itemButton:GetName(), 'to quest|cFF00FF00', info.questID, '|rat|cFFFFFF00', block:GetName(),'|r') Nenue@2: Nenue@5: for k,v in pairs(usedButtons) do Nenue@5: print('|cFFFF44DD'..k..'|r', v:GetName()) Nenue@5: end Nenue@1: Nenue@1: itemButton:SetAttribute("type", "item") Nenue@1: itemButton:SetAttribute("item", itemInfo.link) Nenue@1: Nenue@2: itemButton.questID = info.questID Nenue@1: itemButton.questLogIndex = info.questLogIndex Nenue@1: itemButton.charges = itemInfo.charges Nenue@1: itemButton.rangeTimer = -1 Nenue@1: itemButton.block = block Nenue@1: Nenue@1: SetItemButtonTexture(itemButton, itemInfo.icon) Nenue@1: SetItemButtonCount(itemButton, itemInfo.charges) Nenue@1: Veneer_QuestObjectiveItem_UpdateCooldown(itemButton); Nenue@1: Nenue@1: return itemButton Nenue@1: end Nenue@1: --- Clear an itemButton from the given block Nenue@2: mod.FreeItemButtons = function(block) Nenue@2: Nenue@2: if block.itemButton then Nenue@2: local itemButton = block.itemButton Nenue@5: if itemButton.questID ~= block.info.questID then Nenue@5: block.itemButton = nil Nenue@5: itemButton.block = mod.Quest.InfoBlock[itemButton.questID] Nenue@5: else Nenue@5: itemButton.block = nil Nenue@5: itemButton:Hide() Nenue@2: Nenue@5: usedButtons[itemButton.questID] = nil Nenue@5: freeButtons[#freeButtons + 1] = itemButton Nenue@5: mod.Quest.numButtons = mod.Quest.numButtons - 1 Nenue@5: print('|cFFFF0088released', itemButton:GetName(),'and', block:GetName()) Nenue@5: end Nenue@1: end Nenue@1: end Nenue@1: Nenue@1: function Veneer_QuestObjectiveItem_OnUpdate (self, elapsed) Nenue@1: -- Handle range indicator Nenue@1: local rangeTimer = self.rangeTimer Nenue@1: if (rangeTimer) then Nenue@1: rangeTimer = rangeTimer - elapsed Nenue@1: if (rangeTimer <= 0) then Nenue@1: local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.questLogIndex) Nenue@1: if ((not charges) or (charges ~= self.charges)) then Nenue@2: mod.UpdateWrapper() Nenue@1: return Nenue@1: end Nenue@1: Nenue@1: local count = self.HotKey Nenue@1: local valid = IsQuestLogSpecialItemInRange(self.questLogIndex) Nenue@1: if (valid == 0) then Nenue@1: count:Show() Nenue@1: count:SetVertexColor(1.0, 0.1, 0.1) Nenue@1: elseif (valid == 1) then Nenue@1: count:Show() Nenue@1: count:SetVertexColor(0.6, 0.6, 0.6) Nenue@1: else Nenue@1: count:Hide() Nenue@1: end Nenue@1: rangeTimer = TOOLTIP_UPDATE_TIME Nenue@1: end Nenue@1: Nenue@1: self.rangeTimer = rangeTimer Nenue@1: end Nenue@1: end Nenue@1: Nenue@1: function Veneer_QuestObjectiveItem_UpdateCooldown (itemButton) Nenue@1: local start, duration, enable = GetQuestLogSpecialItemCooldown(itemButton.questLogIndex) Nenue@1: if (start) then Nenue@1: CooldownFrame_SetTimer(itemButton.Cooldown, start, duration, enable) Nenue@1: if (duration > 0 and enable == 0) then Nenue@1: SetItemButtonTextureVertexColor(itemButton, 0.4, 0.4, 0.4) Nenue@1: else Nenue@1: SetItemButtonTextureVertexColor(itemButton, 1, 1, 1) Nenue@1: end Nenue@1: end Nenue@3: end Nenue@3: Nenue@3: ----------------------------------------- Nenue@3: -- Progress slider for achievements, and area objecitves Nenue@3: -- Stored by criteria ID to account for multiple bars in one cheev Nenue@3: Tracker.SetProgress = function(criteria, info) Nenue@3: end Nenue@3: Nenue@3: mod.WidgetRegistry = {} Nenue@3: local wr = mod.WidgetRegistry Nenue@3: mod.SetWidget = function(criteria, info) Nenue@3: local widget Nenue@3: if not wr[criteria.type] then Nenue@3: print('|cFFFF4400[[WidgetTemplate]]|r', criteria.type) Nenue@3: wr[criteria.type] = { free = {}, used = {}, } Nenue@3: end Nenue@3: if #wr[criteria.type].free == 0 then Nenue@3: Nenue@3: local frameID = #wr[criteria.type].free + #wr[criteria.type].used Nenue@3: widget = CreateFrame('Frame', 'VeneerCriteria' .. criteria.type .. frameID, VeneerObjectiveWrapper, 'VeneerObjectiveCriteria' .. criteria.type) Nenue@3: end Nenue@3: end Nenue@3: mod.RegisterWidget = function(frame) Nenue@3: tinsert(wr[frame.widgetType].free, frame) Nenue@3: end Nenue@3: mod.InitializeWidget = function(frame) Nenue@3: Nenue@3: end Nenue@3: mod.ReleaseWidget = function(frame) Nenue@3: Nenue@3: if tContains(wr[frame.widgetType], frame) then Nenue@3: end Nenue@1: end