Mercurial > wow > buffalo2
comparison ObjectiveUI.lua @ 1:b0447b382f36
sorting client events from maintenance logic
implemented all that action buttons entail for quest items
| author | Nenue |
|---|---|
| date | Wed, 30 Mar 2016 16:30:49 -0400 |
| parents | 3dbcad2b387d |
| children | a2396b03ce63 |
comparison
equal
deleted
inserted
replaced
| 0:3dbcad2b387d | 1:b0447b382f36 |
|---|---|
| 18 Tracker.Report = function(self) | 18 Tracker.Report = function(self) |
| 19 print('Stats:', self.numWatched,'items tracked,', self.numBlocks,'blocks assigned.') | 19 print('Stats:', self.numWatched,'items tracked,', self.numBlocks,'blocks assigned.') |
| 20 end | 20 end |
| 21 | 21 |
| 22 Tracker.OnMouseUp = function(self, button) | 22 Tracker.OnMouseUp = function(self, button) |
| 23 if button == 'LeftButton' then | 23 |
| 24 if self.initialButton == 'LeftButton' then | |
| 24 self:Select() | 25 self:Select() |
| 25 mod.UpdateWrapper() | 26 mod.UpdateWrapper() |
| 27 if self.modShift then | |
| 28 self:Remove() | |
| 29 end | |
| 26 elseif button == 'RightButton' then | 30 elseif button == 'RightButton' then |
| 27 self:Open() | 31 self:Open() |
| 28 end | 32 end |
| 33 self.initialButton = nil | |
| 34 self.modShift = nil | |
| 29 print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r ->',self.info.trackingID) | 35 print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r ->',self.info.trackingID) |
| 30 end | 36 end |
| 31 | 37 |
| 32 Tracker.OnMouseDown = function(self, button) | 38 Tracker.OnMouseDown = function(self, button) |
| 39 self.initialButton = button | |
| 40 self.modShift = IsShiftKeyDown() | |
| 33 if button == 'LeftButton' then | 41 if button == 'LeftButton' then |
| 34 self:SetStyle('Active') | 42 self:SetStyle('Active') |
| 35 end | 43 end |
| 36 print(self.info.title) | 44 print(self.info.title) |
| 37 end | 45 end |
| 46 Quest.name = "Quests" | 54 Quest.name = "Quests" |
| 47 Quest.Select = function(self) | 55 Quest.Select = function(self) |
| 48 SetSuperTrackedQuestID(self.info.questID) | 56 SetSuperTrackedQuestID(self.info.questID) |
| 49 end | 57 end |
| 50 Quest.Open = function(self) | 58 Quest.Open = function(self) |
| 51 print('something something quest log') | 59 QuestMapFrame_OpenToQuestDetails(self.info.questID) |
| 52 QuestMapFrame_ShowQuestDetails(self.info.questID) | 60 end |
| 53 ToggleQuestLog() | 61 |
| 62 Quest.Remove = function(self) | |
| 63 RemoveQuestWatch(self.info.questIndex) | |
| 64 QuestPOIUpdateIcons() | |
| 54 end | 65 end |
| 55 | 66 |
| 56 | 67 |
| 57 ----------------------------- | 68 ----------------------------- |
| 58 --- CHEEVS | 69 --- CHEEVS |
| 60 end | 71 end |
| 61 | 72 |
| 62 Cheevs.Open = function(self) | 73 Cheevs.Open = function(self) |
| 63 end | 74 end |
| 64 | 75 |
| 76 ---------------------------------------------------------------------------------------- | |
| 77 --- frame template and scripts lifted from "QuestKing 2" by Barjack | |
| 78 --- url: http://mods.curse.com/addons/wow/questking | |
| 79 ---------------------------------------------------------------------------------------- | |
| 80 local usedButtons = mod.Quest.itemButtons | |
| 81 local freeButtons = mod.Quest.freeButtons | |
| 82 mod.SetItemButton = function(block, info) | |
| 83 local itemInfo = info.specialItem | |
| 84 if not itemInfo then | |
| 85 return | |
| 86 end | |
| 87 --- .specialItem :: {link = link, charges = charges, icon = icon, start = start, duration = duration, enable = enable} | |
| 88 | |
| 89 | |
| 90 local itemButton | |
| 91 if not info.itemButton then | |
| 92 if #freeButtons >= 1 then | |
| 93 print('|cFF00FFFFfound a free button') | |
| 94 itemButton = freeButtons[#freeButtons] | |
| 95 freeButtons[#freeButtons] = nil | |
| 96 else | |
| 97 print('|cFFFF4400starting new button') | |
| 98 local buttonIndex = mod.Quest.numButtons + #freeButtons + 1 | |
| 99 itemButton = CreateFrame('Button', 'VeneerQuestItemButton' .. buttonIndex, UIParent, 'VeneerItemButtonTemplate') | |
| 100 itemButton.buttonIndex = buttonIndex | |
| 101 itemButton:SetSize(48, 48) | |
| 102 itemButton:GetNormalTexture():SetSize(80,80) | |
| 103 end | |
| 104 mod.Quest.numButtons = mod.Quest.numButtons + 1 | |
| 105 else | |
| 106 print('|cFF00FF00found assigned button') | |
| 107 itemButton = info.itemButton | |
| 108 end | |
| 109 -- set values | |
| 110 info.itemButton = itemButton | |
| 111 block.itemButton = itemButton | |
| 112 usedButtons[info.questLogIndex] = itemButton | |
| 113 | |
| 114 itemButton:SetAttribute("type", "item") | |
| 115 itemButton:SetAttribute("item", itemInfo.link) | |
| 116 | |
| 117 itemButton.questLogIndex = info.questLogIndex | |
| 118 itemButton.charges = itemInfo.charges | |
| 119 itemButton.rangeTimer = -1 | |
| 120 itemButton.block = block | |
| 121 | |
| 122 SetItemButtonTexture(itemButton, itemInfo.icon) | |
| 123 SetItemButtonCount(itemButton, itemInfo.charges) | |
| 124 Veneer_QuestObjectiveItem_UpdateCooldown(itemButton); | |
| 125 | |
| 126 return itemButton | |
| 127 end | |
| 128 --- Clear an itemButton from the given block | |
| 129 mod.FreeItemButton = function(block, itemButton) | |
| 130 if block.itemButton ~= itemButton then | |
| 131 print('|cFFFF0088trying to release mismatched action button') | |
| 132 return | |
| 133 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 | |
| 146 | |
| 147 function Veneer_QuestObjectiveItem_OnUpdate (self, elapsed) | |
| 148 -- Handle range indicator | |
| 149 local rangeTimer = self.rangeTimer | |
| 150 if (rangeTimer) then | |
| 151 rangeTimer = rangeTimer - elapsed | |
| 152 if (rangeTimer <= 0) then | |
| 153 local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.questLogIndex) | |
| 154 if ((not charges) or (charges ~= self.charges)) then | |
| 155 QuestKing:UpdateTracker() | |
| 156 return | |
| 157 end | |
| 158 | |
| 159 local count = self.HotKey | |
| 160 local valid = IsQuestLogSpecialItemInRange(self.questLogIndex) | |
| 161 if (valid == 0) then | |
| 162 count:Show() | |
| 163 count:SetVertexColor(1.0, 0.1, 0.1) | |
| 164 elseif (valid == 1) then | |
| 165 count:Show() | |
| 166 count:SetVertexColor(0.6, 0.6, 0.6) | |
| 167 else | |
| 168 count:Hide() | |
| 169 end | |
| 170 rangeTimer = TOOLTIP_UPDATE_TIME | |
| 171 end | |
| 172 | |
| 173 self.rangeTimer = rangeTimer | |
| 174 end | |
| 175 end | |
| 176 | |
| 177 function Veneer_QuestObjectiveItem_UpdateCooldown (itemButton) | |
| 178 local start, duration, enable = GetQuestLogSpecialItemCooldown(itemButton.questLogIndex) | |
| 179 if (start) then | |
| 180 CooldownFrame_SetTimer(itemButton.Cooldown, start, duration, enable) | |
| 181 if (duration > 0 and enable == 0) then | |
| 182 SetItemButtonTextureVertexColor(itemButton, 0.4, 0.4, 0.4) | |
| 183 else | |
| 184 SetItemButtonTextureVertexColor(itemButton, 1, 1, 1) | |
| 185 end | |
| 186 end | |
| 187 end |
