annotate ObjectiveUI.lua @ 4:18eee961038e

- more action button debug
author Nenue
date Thu, 31 Mar 2016 14:28:40 -0400
parents 3397aae1f44d
children e9b61fd5f607
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/29/2016 7:07 PM
Nenue@0 6 local B = select(2,...).frame
Nenue@0 7 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@0 8 local print = B.print('Objectives')
Nenue@0 9 local Tracker, AutoQuest, Quest, Cheevs = mod.Tracker, mod.AutoQuest, mod.Quest, mod.Cheevs
Nenue@0 10
Nenue@0 11 --------------------------------------------------------------------
Nenue@3 12 --- Tracker-specific widgets and their handlers
Nenue@0 13 --------------------------------------------------------------------
Nenue@0 14
Nenue@0 15 Tracker.Select = function(self) end
Nenue@0 16 Tracker.Open = function(self) end
Nenue@0 17 Tracker.Remove = function(self) end
Nenue@0 18 Tracker.Report = function(self)
Nenue@0 19 print('Stats:', self.numWatched,'items tracked,', self.numBlocks,'blocks assigned.')
Nenue@0 20 end
Nenue@0 21
Nenue@0 22 Tracker.OnMouseUp = function(self, button)
Nenue@1 23
Nenue@1 24 if self.initialButton == 'LeftButton' then
Nenue@0 25 self:Select()
Nenue@0 26 mod.UpdateWrapper()
Nenue@1 27 if self.modShift then
Nenue@1 28 self:Remove()
Nenue@1 29 end
Nenue@0 30 elseif button == 'RightButton' then
Nenue@0 31 self:Open()
Nenue@0 32 end
Nenue@1 33 self.initialButton = nil
Nenue@1 34 self.modShift = nil
Nenue@0 35 print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r ->',self.info.trackingID)
Nenue@0 36 end
Nenue@0 37
Nenue@0 38 Tracker.OnMouseDown = function(self, button)
Nenue@1 39 self.initialButton = button
Nenue@1 40 self.modShift = IsShiftKeyDown()
Nenue@0 41 if button == 'LeftButton' then
Nenue@0 42 self:SetStyle('Active')
Nenue@0 43 end
Nenue@0 44 print(self.info.title)
Nenue@0 45 end
Nenue@0 46
Nenue@0 47 -----------------------------
Nenue@0 48 --- AUTO_QUEST
Nenue@0 49 AutoQuest.name = "Remote Quests"
Nenue@0 50 AutoQuest.GetNumWatched = GetNumAutoQuestPopUps
Nenue@0 51
Nenue@0 52 -----------------------------
Nenue@0 53 --- QUEST
Nenue@0 54 Quest.name = "Quests"
Nenue@0 55 Quest.Select = function(self)
Nenue@0 56 SetSuperTrackedQuestID(self.info.questID)
Nenue@0 57 end
Nenue@0 58 Quest.Open = function(self)
Nenue@1 59 QuestMapFrame_OpenToQuestDetails(self.info.questID)
Nenue@1 60 end
Nenue@1 61
Nenue@1 62 Quest.Remove = function(self)
Nenue@1 63 RemoveQuestWatch(self.info.questIndex)
Nenue@1 64 QuestPOIUpdateIcons()
Nenue@0 65 end
Nenue@0 66
Nenue@0 67
Nenue@0 68 -----------------------------
Nenue@0 69 --- CHEEVS
Nenue@0 70 Cheevs.Select = function(self)
Nenue@0 71 end
Nenue@0 72
Nenue@0 73 Cheevs.Open = function(self)
Nenue@3 74 if ( not AchievementFrame ) then
Nenue@3 75 AchievementFrame_LoadUI();
Nenue@3 76 end
Nenue@3 77 if ( not AchievementFrame:IsShown() ) then
Nenue@3 78 AchievementFrame_ToggleAchievementFrame();
Nenue@3 79 end
Nenue@3 80 AchievementFrame_SelectAchievement(self.info.cheevID);
Nenue@0 81 end
Nenue@0 82
Nenue@1 83 ----------------------------------------------------------------------------------------
Nenue@1 84 --- frame template and scripts lifted from "QuestKing 2" by Barjack
Nenue@1 85 --- url: http://mods.curse.com/addons/wow/questking
Nenue@1 86 ----------------------------------------------------------------------------------------
Nenue@1 87 local usedButtons = mod.Quest.itemButtons
Nenue@1 88 local freeButtons = mod.Quest.freeButtons
Nenue@1 89 mod.SetItemButton = function(block, info)
Nenue@1 90 local itemInfo = info.specialItem
Nenue@1 91 if not itemInfo then
Nenue@1 92 return
Nenue@1 93 end
Nenue@1 94 --- .specialItem :: {link = link, charges = charges, icon = icon, start = start, duration = duration, enable = enable}
Nenue@1 95
Nenue@1 96
Nenue@1 97 local itemButton
Nenue@1 98 if not info.itemButton then
Nenue@1 99 if #freeButtons >= 1 then
Nenue@2 100 print(' |cFF00FFFFfound a free button')
Nenue@1 101 itemButton = freeButtons[#freeButtons]
Nenue@1 102 freeButtons[#freeButtons] = nil
Nenue@2 103 if itemButton.block then
Nenue@2 104 itemButton.block.itemButton = nil
Nenue@2 105 itemButton.block = nil
Nenue@2 106 end
Nenue@1 107 else
Nenue@2 108 print(' |cFFFF4400starting new button')
Nenue@1 109 local buttonIndex = mod.Quest.numButtons + #freeButtons + 1
Nenue@1 110 itemButton = CreateFrame('Button', 'VeneerQuestItemButton' .. buttonIndex, UIParent, 'VeneerItemButtonTemplate')
Nenue@1 111 itemButton.buttonIndex = buttonIndex
Nenue@1 112 itemButton:SetSize(48, 48)
Nenue@1 113 itemButton:GetNormalTexture():SetSize(80,80)
Nenue@1 114 end
Nenue@1 115 mod.Quest.numButtons = mod.Quest.numButtons + 1
Nenue@1 116 else
Nenue@2 117 print(' |cFF00FF00found assigned button')
Nenue@1 118 itemButton = info.itemButton
Nenue@2 119 if itemButton.block then
Nenue@2 120 print(' - moving from old block')
Nenue@2 121 itemButton.block.itemButton = nil
Nenue@2 122 end
Nenue@2 123
Nenue@1 124 end
Nenue@1 125 -- set values
Nenue@2 126
Nenue@2 127
Nenue@1 128 info.itemButton = itemButton
Nenue@1 129 block.itemButton = itemButton
Nenue@2 130 usedButtons[info.questID] = itemButton
Nenue@1 131
Nenue@1 132 itemButton:SetAttribute("type", "item")
Nenue@1 133 itemButton:SetAttribute("item", itemInfo.link)
Nenue@1 134
Nenue@2 135 itemButton.questID = info.questID
Nenue@1 136 itemButton.questLogIndex = info.questLogIndex
Nenue@1 137 itemButton.charges = itemInfo.charges
Nenue@1 138 itemButton.rangeTimer = -1
Nenue@1 139 itemButton.block = block
Nenue@1 140
Nenue@1 141 SetItemButtonTexture(itemButton, itemInfo.icon)
Nenue@1 142 SetItemButtonCount(itemButton, itemInfo.charges)
Nenue@1 143 Veneer_QuestObjectiveItem_UpdateCooldown(itemButton);
Nenue@1 144
Nenue@1 145 return itemButton
Nenue@1 146 end
Nenue@1 147 --- Clear an itemButton from the given block
Nenue@2 148 mod.FreeItemButtons = function(block)
Nenue@2 149
Nenue@2 150 if block.itemButton then
Nenue@2 151 local itemButton = block.itemButton
Nenue@2 152 itemButton.block = nil
Nenue@2 153 itemButton:Hide()
Nenue@2 154
Nenue@2 155 usedButtons[itemButton.questID] = nil
Nenue@2 156 freeButtons[#freeButtons + 1] = itemButton
Nenue@2 157 mod.Quest.numButtons = mod.Quest.numButtons - 1
Nenue@2 158 print('|cFFFF0088released', itemButton:GetName(),'and', block:GetName())
Nenue@1 159 end
Nenue@1 160 end
Nenue@1 161
Nenue@1 162 function Veneer_QuestObjectiveItem_OnUpdate (self, elapsed)
Nenue@1 163 -- Handle range indicator
Nenue@1 164 local rangeTimer = self.rangeTimer
Nenue@1 165 if (rangeTimer) then
Nenue@1 166 rangeTimer = rangeTimer - elapsed
Nenue@1 167 if (rangeTimer <= 0) then
Nenue@1 168 local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.questLogIndex)
Nenue@1 169 if ((not charges) or (charges ~= self.charges)) then
Nenue@2 170 mod.UpdateWrapper()
Nenue@1 171 return
Nenue@1 172 end
Nenue@1 173
Nenue@1 174 local count = self.HotKey
Nenue@1 175 local valid = IsQuestLogSpecialItemInRange(self.questLogIndex)
Nenue@1 176 if (valid == 0) then
Nenue@1 177 count:Show()
Nenue@1 178 count:SetVertexColor(1.0, 0.1, 0.1)
Nenue@1 179 elseif (valid == 1) then
Nenue@1 180 count:Show()
Nenue@1 181 count:SetVertexColor(0.6, 0.6, 0.6)
Nenue@1 182 else
Nenue@1 183 count:Hide()
Nenue@1 184 end
Nenue@1 185 rangeTimer = TOOLTIP_UPDATE_TIME
Nenue@1 186 end
Nenue@1 187
Nenue@1 188 self.rangeTimer = rangeTimer
Nenue@1 189 end
Nenue@1 190 end
Nenue@1 191
Nenue@1 192 function Veneer_QuestObjectiveItem_UpdateCooldown (itemButton)
Nenue@1 193 local start, duration, enable = GetQuestLogSpecialItemCooldown(itemButton.questLogIndex)
Nenue@1 194 if (start) then
Nenue@1 195 CooldownFrame_SetTimer(itemButton.Cooldown, start, duration, enable)
Nenue@1 196 if (duration > 0 and enable == 0) then
Nenue@1 197 SetItemButtonTextureVertexColor(itemButton, 0.4, 0.4, 0.4)
Nenue@1 198 else
Nenue@1 199 SetItemButtonTextureVertexColor(itemButton, 1, 1, 1)
Nenue@1 200 end
Nenue@1 201 end
Nenue@3 202 end
Nenue@3 203
Nenue@3 204 -----------------------------------------
Nenue@3 205 -- Progress slider for achievements, and area objecitves
Nenue@3 206 -- Stored by criteria ID to account for multiple bars in one cheev
Nenue@3 207 Tracker.SetProgress = function(criteria, info)
Nenue@3 208 end
Nenue@3 209
Nenue@3 210 mod.WidgetRegistry = {}
Nenue@3 211 local wr = mod.WidgetRegistry
Nenue@3 212 mod.SetWidget = function(criteria, info)
Nenue@3 213 local widget
Nenue@3 214 if not wr[criteria.type] then
Nenue@3 215 print('|cFFFF4400[[WidgetTemplate]]|r', criteria.type)
Nenue@3 216 wr[criteria.type] = { free = {}, used = {}, }
Nenue@3 217 end
Nenue@3 218 if #wr[criteria.type].free == 0 then
Nenue@3 219
Nenue@3 220 local frameID = #wr[criteria.type].free + #wr[criteria.type].used
Nenue@3 221 widget = CreateFrame('Frame', 'VeneerCriteria' .. criteria.type .. frameID, VeneerObjectiveWrapper, 'VeneerObjectiveCriteria' .. criteria.type)
Nenue@3 222 end
Nenue@3 223 end
Nenue@3 224 mod.RegisterWidget = function(frame)
Nenue@3 225 tinsert(wr[frame.widgetType].free, frame)
Nenue@3 226 end
Nenue@3 227 mod.InitializeWidget = function(frame)
Nenue@3 228
Nenue@3 229 end
Nenue@3 230 mod.ReleaseWidget = function(frame)
Nenue@3 231
Nenue@3 232 if tContains(wr[frame.widgetType], frame) then
Nenue@3 233 end
Nenue@1 234 end