Mercurial > wow > reaction
comparison classes/StanceButton.lua @ 179:bf64e71701e2
Remove support for hunter aspects in stance bar. Remove option to disable DK/paladin auras in stance bar. (drycoded)
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Wed, 20 Oct 2010 23:40:41 +0000 |
parents | df68b5a40490 |
children | e63aefb8a555 |
comparison
equal
deleted
inserted
replaced
178:2e2abdaad2e5 | 179:bf64e71701e2 |
---|---|
16 -- | 16 -- |
17 -- private | 17 -- private |
18 -- | 18 -- |
19 local playerClass = select(2,UnitClass("player")) | 19 local playerClass = select(2,UnitClass("player")) |
20 | 20 |
21 local aspects = { | |
22 -- All rank one, so that the usable check works | |
23 GetSpellInfo(13163), -- monkey | |
24 GetSpellInfo(13165), -- hawk | |
25 GetSpellInfo(5118), -- cheetah | |
26 GetSpellInfo(34074), -- viper | |
27 GetSpellInfo(13161), -- beast | |
28 GetSpellInfo(13159), -- pack | |
29 GetSpellInfo(20043), -- wild | |
30 GetSpellInfo(61846), -- dragonhawk | |
31 } | |
32 | |
33 local aspectLinks = { } | |
34 | |
35 local eventList = { | 21 local eventList = { |
36 "PLAYER_REGEN_ENABLED", | 22 "PLAYER_REGEN_ENABLED", |
37 "PLAYER_ENTERING_WORLD", | 23 "PLAYER_ENTERING_WORLD", |
38 "UPDATE_SHAPESHIFT_FORM", | 24 "UPDATE_SHAPESHIFT_FORM", |
39 "UPDATE_SHAPESHIFT_FORMS", | 25 "UPDATE_SHAPESHIFT_FORMS", |
40 "UPDATE_SHAPESHIFT_USABLE", | 26 "UPDATE_SHAPESHIFT_USABLE", |
41 "UPDATE_SHAPESHIFT_COOLDOWN", | 27 "UPDATE_SHAPESHIFT_COOLDOWN", |
42 "UPDATE_BINDINGS", | 28 "UPDATE_BINDINGS", |
43 } | 29 } |
44 | |
45 local eventListHunter = { | |
46 "PLAYER_REGEN_ENABLED", | |
47 "PLAYER_ENTERING_WORLD", | |
48 "SPELL_UPDATE_COOLDOWN", | |
49 "SPELL_UPDATE_USABLE", | |
50 "UNIT_AURA", | |
51 "SPELLS_CHANGED", | |
52 "UPDATE_BINDINGS", | |
53 } | |
54 | |
55 if playerClass == "HUNTER" then | |
56 eventList = eventListHunter | |
57 end | |
58 | 30 |
59 -- | 31 -- |
60 -- Stance Button class | 32 -- Stance Button class |
61 -- | 33 -- |
62 local Super = ReAction.Button | 34 local Super = ReAction.Button |
66 function Stance:New( idx, moduleConfig, bar, idHint ) | 38 function Stance:New( idx, moduleConfig, bar, idHint ) |
67 local name = format("ReAction_%s_Stance_%d",bar:GetName(),idx) | 39 local name = format("ReAction_%s_Stance_%d",bar:GetName(),idx) |
68 | 40 |
69 self = Super.New(self, name, moduleConfig.buttons[bar:GetName()][idx], bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) | 41 self = Super.New(self, name, moduleConfig.buttons[bar:GetName()][idx], bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) |
70 self.moduleConfig = moduleConfig | 42 self.moduleConfig = moduleConfig |
71 self.hunterIdx = 1 | |
72 | 43 |
73 local f = self:GetFrame() | 44 local f = self:GetFrame() |
74 local barFrame = bar:GetFrame() | 45 local barFrame = bar:GetFrame() |
75 local config = self:GetConfig() | 46 local config = self:GetConfig() |
76 | 47 |
108 self:Refresh() | 79 self:Refresh() |
109 | 80 |
110 return self | 81 return self |
111 end | 82 end |
112 | 83 |
113 function Stance:GetModuleConfig() | |
114 -- this is the Stance module config structure, | |
115 -- not the config structure of the bar itself | |
116 return self.moduleConfig | |
117 end | |
118 | |
119 function Stance:GetActionID() | 84 function Stance:GetActionID() |
120 return self.config.stanceID | 85 return self.config.stanceID |
121 end | 86 end |
122 | 87 |
123 function Stance:UpdateAction() | 88 function Stance:UpdateAction() |
125 self.updatePending = true | 90 self.updatePending = true |
126 else | 91 else |
127 self.updatePending = false | 92 self.updatePending = false |
128 local idx = self:GetActionID() | 93 local idx = self:GetActionID() |
129 local f = self:GetFrame() | 94 local f = self:GetFrame() |
130 local c = self:GetModuleConfig() | 95 if idx > GetNumShapeshiftForms() then |
131 if playerClass == "HUNTER" then | |
132 if c.showHunterAspects then | |
133 -- re-map the index in the case of "hide monkey/hawk" | |
134 if c.hideMonkeyHawk then | |
135 local usable, outOfMana = IsUsableSpell(aspects[8]) | |
136 if usable or outOfMana then | |
137 idx = idx + 2 | |
138 if idx > 8 then | |
139 f:Hide() | |
140 return | |
141 end | |
142 end | |
143 end | |
144 self.hunterIdx = idx | |
145 -- cache the highest rank spellID | |
146 if not aspectLinks[aspects[idx]] then | |
147 aspectLinks[aspects[idx]] = GetSpellLink(aspects[idx],"") | |
148 end | |
149 local usable, outOfMana = IsUsableSpell(aspects[idx]) | |
150 if usable or outOfMana then | |
151 f:SetAttribute("spell",aspects[idx]) | |
152 f:Show() | |
153 self:Update() | |
154 else | |
155 -- haven't learned this spell yet | |
156 f:Hide() | |
157 end | |
158 else | |
159 f:Hide() | |
160 end | |
161 elseif idx > GetNumShapeshiftForms() or | |
162 playerClass == "PALADIN" and c.hidePaladinAuras or | |
163 playerClass == "DEATHKNIGHT" and c.hideDKPresences then | |
164 f:Hide() | 96 f:Hide() |
165 else | 97 else |
166 f:SetAttribute("spell", select(2,GetShapeshiftFormInfo(idx))) | 98 f:SetAttribute("spell", select(2,GetShapeshiftFormInfo(idx))) |
167 f:Show() | 99 f:Show() |
168 self:Update() | 100 self:Update() |
175 self:UpdateHotkey() | 107 self:UpdateHotkey() |
176 self:UpdateAction() | 108 self:UpdateAction() |
177 end | 109 end |
178 | 110 |
179 function Stance:Update() | 111 function Stance:Update() |
180 local texture, isActive, isCastable | 112 local texture, _, isActive, isCastable = GetShapeshiftFormInfo(self:GetActionID()) |
181 if playerClass == "HUNTER" then | |
182 local name, rank | |
183 local spell = aspects[self.hunterIdx] | |
184 name, rank, texture = GetSpellInfo(spell) | |
185 isCastable = IsUsableSpell(spell) | |
186 for i = 1, 40 do | |
187 local buff = UnitBuff("player",i,true) | |
188 if not buff then break end | |
189 if buff == spell then | |
190 isActive = true | |
191 texture = "Interface\\Icons\\Spell_Nature_WispSplode" | |
192 break | |
193 end | |
194 end | |
195 else | |
196 local _ | |
197 texture, _, isActive, isCastable = GetShapeshiftFormInfo(self:GetActionID()) | |
198 end | |
199 | 113 |
200 local icon = self.frames.icon | 114 local icon = self.frames.icon |
201 icon:SetTexture(texture) | 115 icon:SetTexture(texture) |
202 self:GetFrame():SetChecked( isActive and 1 or 0 ) | 116 self:GetFrame():SetChecked( isActive and 1 or 0 ) |
203 if isCastable then | 117 if isCastable then |
209 | 123 |
210 self:UpdateCooldown() | 124 self:UpdateCooldown() |
211 end | 125 end |
212 | 126 |
213 function Stance:UpdateCooldown() | 127 function Stance:UpdateCooldown() |
214 local start, duration, enabled | 128 local start, duration, enabled = GetShapeshiftFormCooldown(self:GetActionID()) |
215 if playerClass == "HUNTER" then | |
216 local spell = aspects[self.hunterIdx] | |
217 if spell then | |
218 start, duration, enabled = GetSpellCooldown(spell) | |
219 end | |
220 else | |
221 start, duration, enabled = GetShapeshiftFormCooldown(self:GetActionID()) | |
222 end | |
223 if start then | 129 if start then |
224 CooldownFrame_SetTimer(self.frames.cooldown, start, duration, enabled) | 130 CooldownFrame_SetTimer(self.frames.cooldown, start, duration, enabled) |
225 end | 131 end |
226 end | 132 end |
227 | 133 |
229 if GetCVar("UberTooltips") == "1" then | 135 if GetCVar("UberTooltips") == "1" then |
230 GameTooltip_SetDefaultAnchor(GameTooltip, self:GetFrame()) | 136 GameTooltip_SetDefaultAnchor(GameTooltip, self:GetFrame()) |
231 else | 137 else |
232 GameTooltip:SetOwner(self:GetFrame(), "ANCHOR_RIGHT") | 138 GameTooltip:SetOwner(self:GetFrame(), "ANCHOR_RIGHT") |
233 end | 139 end |
234 if playerClass == "HUNTER" then | 140 GameTooltip:SetShapeshift(self:GetActionID()) |
235 local aspect = aspects[self.hunterIdx] | |
236 if aspect and aspectLinks[aspect] then | |
237 GameTooltip:SetHyperlink(aspectLinks[aspect]) | |
238 end | |
239 else | |
240 GameTooltip:SetShapeshift(self:GetActionID()) | |
241 end | |
242 end | 141 end |
243 | 142 |
244 function Stance:OnEnter() | 143 function Stance:OnEnter() |
245 self:SetTooltip() | 144 self:SetTooltip() |
246 end | 145 end |
259 if self.updatePending then | 158 if self.updatePending then |
260 self:UpdateAction() | 159 self:UpdateAction() |
261 end | 160 end |
262 elseif event == "UPDATE_SHAPESHIFT_COOLDOWN" then | 161 elseif event == "UPDATE_SHAPESHIFT_COOLDOWN" then |
263 self:UpdateCooldown() | 162 self:UpdateCooldown() |
264 elseif event == "UPDATE_SHAPESHIFT_FORMS" or | 163 elseif event == "UPDATE_SHAPESHIFT_FORMS" then |
265 event == "SPELLS_CHANGED" then | |
266 aspectLinks = { } -- force repopulate of the spellIDs | |
267 self:UpdateAction() | 164 self:UpdateAction() |
268 elseif event == "UNIT_AURA" then | 165 elseif event == "UNIT_AURA" then |
269 if arg == "player" then | 166 if arg == "player" then |
270 self:Update() | 167 self:Update() |
271 end | 168 end |