Mercurial > wow > buffalo2
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 1:b0447b382f36 | 2:a2396b03ce63 |
|---|---|
| 88 | 88 |
| 89 | 89 |
| 90 local itemButton | 90 local itemButton |
| 91 if not info.itemButton then | 91 if not info.itemButton then |
| 92 if #freeButtons >= 1 then | 92 if #freeButtons >= 1 then |
| 93 print('|cFF00FFFFfound a free button') | 93 print(' |cFF00FFFFfound a free button') |
| 94 itemButton = freeButtons[#freeButtons] | 94 itemButton = freeButtons[#freeButtons] |
| 95 freeButtons[#freeButtons] = nil | 95 freeButtons[#freeButtons] = nil |
| 96 if itemButton.block then | |
| 97 itemButton.block.itemButton = nil | |
| 98 itemButton.block = nil | |
| 99 end | |
| 96 else | 100 else |
| 97 print('|cFFFF4400starting new button') | 101 print(' |cFFFF4400starting new button') |
| 98 local buttonIndex = mod.Quest.numButtons + #freeButtons + 1 | 102 local buttonIndex = mod.Quest.numButtons + #freeButtons + 1 |
| 99 itemButton = CreateFrame('Button', 'VeneerQuestItemButton' .. buttonIndex, UIParent, 'VeneerItemButtonTemplate') | 103 itemButton = CreateFrame('Button', 'VeneerQuestItemButton' .. buttonIndex, UIParent, 'VeneerItemButtonTemplate') |
| 100 itemButton.buttonIndex = buttonIndex | 104 itemButton.buttonIndex = buttonIndex |
| 101 itemButton:SetSize(48, 48) | 105 itemButton:SetSize(48, 48) |
| 102 itemButton:GetNormalTexture():SetSize(80,80) | 106 itemButton:GetNormalTexture():SetSize(80,80) |
| 103 end | 107 end |
| 104 mod.Quest.numButtons = mod.Quest.numButtons + 1 | 108 mod.Quest.numButtons = mod.Quest.numButtons + 1 |
| 105 else | 109 else |
| 106 print('|cFF00FF00found assigned button') | 110 print(' |cFF00FF00found assigned button') |
| 107 itemButton = info.itemButton | 111 itemButton = info.itemButton |
| 112 if itemButton.block then | |
| 113 print(' - moving from old block') | |
| 114 itemButton.block.itemButton = nil | |
| 115 end | |
| 116 | |
| 108 end | 117 end |
| 109 -- set values | 118 -- set values |
| 119 | |
| 120 | |
| 110 info.itemButton = itemButton | 121 info.itemButton = itemButton |
| 111 block.itemButton = itemButton | 122 block.itemButton = itemButton |
| 112 usedButtons[info.questLogIndex] = itemButton | 123 usedButtons[info.questID] = itemButton |
| 113 | 124 |
| 114 itemButton:SetAttribute("type", "item") | 125 itemButton:SetAttribute("type", "item") |
| 115 itemButton:SetAttribute("item", itemInfo.link) | 126 itemButton:SetAttribute("item", itemInfo.link) |
| 116 | 127 |
| 128 itemButton.questID = info.questID | |
| 117 itemButton.questLogIndex = info.questLogIndex | 129 itemButton.questLogIndex = info.questLogIndex |
| 118 itemButton.charges = itemInfo.charges | 130 itemButton.charges = itemInfo.charges |
| 119 itemButton.rangeTimer = -1 | 131 itemButton.rangeTimer = -1 |
| 120 itemButton.block = block | 132 itemButton.block = block |
| 121 | 133 |
| 124 Veneer_QuestObjectiveItem_UpdateCooldown(itemButton); | 136 Veneer_QuestObjectiveItem_UpdateCooldown(itemButton); |
| 125 | 137 |
| 126 return itemButton | 138 return itemButton |
| 127 end | 139 end |
| 128 --- Clear an itemButton from the given block | 140 --- Clear an itemButton from the given block |
| 129 mod.FreeItemButton = function(block, itemButton) | 141 mod.FreeItemButtons = function(block) |
| 130 if block.itemButton ~= itemButton then | 142 |
| 131 print('|cFFFF0088trying to release mismatched action button') | 143 if block.itemButton then |
| 132 return | 144 local itemButton = block.itemButton |
| 145 itemButton.block = nil | |
| 146 itemButton:Hide() | |
| 147 | |
| 148 usedButtons[itemButton.questID] = nil | |
| 149 freeButtons[#freeButtons + 1] = itemButton | |
| 150 mod.Quest.numButtons = mod.Quest.numButtons - 1 | |
| 151 print('|cFFFF0088released', itemButton:GetName(),'and', block:GetName()) | |
| 133 end | 152 end |
| 134 | |
| 135 block.itemButton = nil | |
| 136 block.icon:Hide() | |
| 137 | |
| 138 itemButton.block = nil | |
| 139 itemButton:Hide() | |
| 140 | |
| 141 usedButtons[itemButton.questLogIndex] = nil | |
| 142 freeButtons[#freeButtons + 1] = itemButton | |
| 143 mod.Quest.numButtons = mod.Quest.numButtons - 1 | |
| 144 print('|cFFFF0088released', itemButton:GetName(),'from', block:GetName()) | |
| 145 end | 153 end |
| 146 | 154 |
| 147 function Veneer_QuestObjectiveItem_OnUpdate (self, elapsed) | 155 function Veneer_QuestObjectiveItem_OnUpdate (self, elapsed) |
| 148 -- Handle range indicator | 156 -- Handle range indicator |
| 149 local rangeTimer = self.rangeTimer | 157 local rangeTimer = self.rangeTimer |
| 150 if (rangeTimer) then | 158 if (rangeTimer) then |
| 151 rangeTimer = rangeTimer - elapsed | 159 rangeTimer = rangeTimer - elapsed |
| 152 if (rangeTimer <= 0) then | 160 if (rangeTimer <= 0) then |
| 153 local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.questLogIndex) | 161 local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.questLogIndex) |
| 154 if ((not charges) or (charges ~= self.charges)) then | 162 if ((not charges) or (charges ~= self.charges)) then |
| 155 QuestKing:UpdateTracker() | 163 mod.UpdateWrapper() |
| 156 return | 164 return |
| 157 end | 165 end |
| 158 | 166 |
| 159 local count = self.HotKey | 167 local count = self.HotKey |
| 160 local valid = IsQuestLogSpecialItemInRange(self.questLogIndex) | 168 local valid = IsQuestLogSpecialItemInRange(self.questLogIndex) |
