Mercurial > wow > buffalo2
view ObjectiveUI.lua @ 2:a2396b03ce63
- identify action buttons by the associated QuestID instead of QuestLogIndex
- deferred button placement in general to a self-destructing OnUpdate
-- and defer self-destruct to a end of combat event if InCombatLockdown
- tracker wrapper has an experience/reputation bar; the two elements "feel" related and it's a very simple info display
author | Nenue |
---|---|
date | Thu, 31 Mar 2016 01:38:47 -0400 |
parents | b0447b382f36 |
children | 3397aae1f44d |
line wrap: on
line source
--- ${PACKAGE_NAME} -- @file-author@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 3/29/2016 7:07 PM local B = select(2,...).frame local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') local print = B.print('Objectives') local Tracker, AutoQuest, Quest, Cheevs = mod.Tracker, mod.AutoQuest, mod.Quest, mod.Cheevs -------------------------------------------------------------------- --- Tracker-specific widget functions -------------------------------------------------------------------- Tracker.Select = function(self) end Tracker.Open = function(self) end Tracker.Remove = function(self) end Tracker.Report = function(self) print('Stats:', self.numWatched,'items tracked,', self.numBlocks,'blocks assigned.') end Tracker.OnMouseUp = function(self, button) if self.initialButton == 'LeftButton' then self:Select() mod.UpdateWrapper() if self.modShift then self:Remove() end elseif button == 'RightButton' then self:Open() end self.initialButton = nil self.modShift = nil print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r ->',self.info.trackingID) end Tracker.OnMouseDown = function(self, button) self.initialButton = button self.modShift = IsShiftKeyDown() if button == 'LeftButton' then self:SetStyle('Active') end print(self.info.title) end ----------------------------- --- AUTO_QUEST AutoQuest.name = "Remote Quests" AutoQuest.GetNumWatched = GetNumAutoQuestPopUps ----------------------------- --- QUEST Quest.name = "Quests" Quest.Select = function(self) SetSuperTrackedQuestID(self.info.questID) end Quest.Open = function(self) QuestMapFrame_OpenToQuestDetails(self.info.questID) end Quest.Remove = function(self) RemoveQuestWatch(self.info.questIndex) QuestPOIUpdateIcons() end ----------------------------- --- CHEEVS Cheevs.Select = function(self) end Cheevs.Open = function(self) end ---------------------------------------------------------------------------------------- --- frame template and scripts lifted from "QuestKing 2" by Barjack --- url: http://mods.curse.com/addons/wow/questking ---------------------------------------------------------------------------------------- local usedButtons = mod.Quest.itemButtons local freeButtons = mod.Quest.freeButtons mod.SetItemButton = function(block, info) local itemInfo = info.specialItem if not itemInfo then return end --- .specialItem :: {link = link, charges = charges, icon = icon, start = start, duration = duration, enable = enable} local itemButton if not info.itemButton then if #freeButtons >= 1 then print(' |cFF00FFFFfound a free button') itemButton = freeButtons[#freeButtons] freeButtons[#freeButtons] = nil if itemButton.block then itemButton.block.itemButton = nil itemButton.block = nil end else print(' |cFFFF4400starting new button') local buttonIndex = mod.Quest.numButtons + #freeButtons + 1 itemButton = CreateFrame('Button', 'VeneerQuestItemButton' .. buttonIndex, UIParent, 'VeneerItemButtonTemplate') itemButton.buttonIndex = buttonIndex itemButton:SetSize(48, 48) itemButton:GetNormalTexture():SetSize(80,80) end mod.Quest.numButtons = mod.Quest.numButtons + 1 else print(' |cFF00FF00found assigned button') itemButton = info.itemButton if itemButton.block then print(' - moving from old block') itemButton.block.itemButton = nil end end -- set values info.itemButton = itemButton block.itemButton = itemButton usedButtons[info.questID] = itemButton itemButton:SetAttribute("type", "item") itemButton:SetAttribute("item", itemInfo.link) itemButton.questID = info.questID itemButton.questLogIndex = info.questLogIndex itemButton.charges = itemInfo.charges itemButton.rangeTimer = -1 itemButton.block = block SetItemButtonTexture(itemButton, itemInfo.icon) SetItemButtonCount(itemButton, itemInfo.charges) Veneer_QuestObjectiveItem_UpdateCooldown(itemButton); return itemButton end --- Clear an itemButton from the given block mod.FreeItemButtons = function(block) if block.itemButton then local itemButton = block.itemButton itemButton.block = nil itemButton:Hide() usedButtons[itemButton.questID] = nil freeButtons[#freeButtons + 1] = itemButton mod.Quest.numButtons = mod.Quest.numButtons - 1 print('|cFFFF0088released', itemButton:GetName(),'and', block:GetName()) end end function Veneer_QuestObjectiveItem_OnUpdate (self, elapsed) -- Handle range indicator local rangeTimer = self.rangeTimer if (rangeTimer) then rangeTimer = rangeTimer - elapsed if (rangeTimer <= 0) then local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.questLogIndex) if ((not charges) or (charges ~= self.charges)) then mod.UpdateWrapper() return end local count = self.HotKey local valid = IsQuestLogSpecialItemInRange(self.questLogIndex) if (valid == 0) then count:Show() count:SetVertexColor(1.0, 0.1, 0.1) elseif (valid == 1) then count:Show() count:SetVertexColor(0.6, 0.6, 0.6) else count:Hide() end rangeTimer = TOOLTIP_UPDATE_TIME end self.rangeTimer = rangeTimer end end function Veneer_QuestObjectiveItem_UpdateCooldown (itemButton) local start, duration, enable = GetQuestLogSpecialItemCooldown(itemButton.questLogIndex) if (start) then CooldownFrame_SetTimer(itemButton.Cooldown, start, duration, enable) if (duration > 0 and enable == 0) then SetItemButtonTextureVertexColor(itemButton, 0.4, 0.4, 0.4) else SetItemButtonTextureVertexColor(itemButton, 1, 1, 1) end end end