Mercurial > wow > reaction
comparison modules/ReAction_PossessBar/ReAction_PossessBar.lua @ 57:b85118b61564
Added possess bar control buttons (no configurability yet)
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 25 Apr 2008 23:42:33 +0000 |
parents | 8b81d4b3e73d |
children | 7430a8dd4e90 |
comparison
equal
deleted
inserted
replaced
56:88283658fec4 | 57:b85118b61564 |
---|---|
54 | 54 |
55 function module:ApplyToBar(bar) | 55 function module:ApplyToBar(bar) |
56 if bar.config.type == moduleID then | 56 if bar.config.type == moduleID then |
57 bar:GetFrame():SetParent(PossessBarFrame) | 57 bar:GetFrame():SetParent(PossessBarFrame) |
58 bar.config.parent = "PossessBarFrame" | 58 bar.config.parent = "PossessBarFrame" |
59 self:CreatePossessControlButtons(bar) | |
59 end | 60 end |
60 self:RefreshBar(bar) | 61 self:RefreshBar(bar) |
61 end | 62 end |
62 | 63 |
63 function module:RefreshBar(bar) | 64 function module:RefreshBar(bar) |
178 button.actionIDLabel:Hide() | 179 button.actionIDLabel:Hide() |
179 end | 180 end |
180 end | 181 end |
181 | 182 |
182 | 183 |
184 -- possess-bar control buttons (shows buff, cancel buff) | |
185 function module:CreatePossessControlButton(bar,id,name) | |
186 -- guard against taint by reusing global variable frames | |
187 -- instead of nilling them out (e.g. create bar, delete bar, create bar with same name) | |
188 name = name or ("ReAction_%s_PossessCtrlButton%d"):format(bar:GetName(),id) | |
189 local b = name and _G[name] | |
190 if b then | |
191 b:SetParent(bar:GetFrame()) | |
192 else | |
193 b = CreateFrame("CheckButton", name, bar:GetFrame(), "PossessButtonTemplate") | |
194 end | |
195 b:SetID(id) | |
196 | |
197 b:RegisterEvent("PLAYER_AURAS_CHANGED"); | |
198 | |
199 local icon = _G[("%sIcon"):format(name)] | |
200 local cooldown = _G[("%sCooldown"):format(name)] | |
201 local nTex = _G[("%sNormalTexture"):format(name)] | |
202 nTex:SetWidth(54) | |
203 nTex:SetHeight(54) | |
204 | |
205 local function update() | |
206 local texture = GetPossessInfo(id); | |
207 icon:SetTexture(texture); | |
208 icon:Show() | |
209 cooldown:Hide(); | |
210 b:SetChecked(0); | |
211 icon:SetVertexColor(1.0, 1.0, 1.0); | |
212 end | |
213 update() | |
214 | |
215 b:HookScript("OnClick", function() b:SetChecked(0) end) | |
216 b:SetScript("OnEvent", update) | |
217 b:SetScript("OnShow", update) | |
218 | |
219 return b | |
220 end | |
221 | |
222 function module:CreatePossessControlButtons(bar) | |
223 if not bar.possessButtons then | |
224 bar.possessButtons = { } | |
225 bar.config.possessFrameNames = bar.config.possessFrameNames or { } | |
226 local previous | |
227 local n = NUM_POSSESS_SLOTS | |
228 for i = 1, n do | |
229 local name = bar.config.possessFrameNames[i] | |
230 local f = self:CreatePossessControlButton(bar,i,name) | |
231 bar.possessButtons[i] = f | |
232 bar.config.possessFrameNames[i] = f:GetName() | |
233 | |
234 local r, c, s = bar:GetButtonGrid() | |
235 local w, h = bar:GetButtonSize() | |
236 | |
237 local scale = ((h - (n-1)*s)/n)/30 | |
238 f:SetScale(scale) | |
239 | |
240 if previous then | |
241 f:SetPoint("TOP", previous, "BOTTOM", 0, -s/scale) | |
242 else | |
243 f:SetPoint("TOPRIGHT", bar:GetFrame(), "TOPLEFT", -s/scale, 0) | |
244 end | |
245 f:Show() | |
246 previous = f | |
247 end | |
248 end | |
249 end | |
250 | |
251 | |
183 | 252 |
184 -- use-count of action IDs | 253 -- use-count of action IDs |
185 local minActionID = 121 | 254 local minActionID = 121 |
186 local maxActionID = 132 | 255 local maxActionID = 132 |
187 local ActionIDList = setmetatable( {}, { | 256 local ActionIDList = setmetatable( {}, { |
222 local function Constructor( self, bar, idx, config ) | 291 local function Constructor( self, bar, idx, config ) |
223 self.bar, self.idx, self.config = bar, idx, config | 292 self.bar, self.idx, self.config = bar, idx, config |
224 | 293 |
225 local barFrame = bar:GetFrame() | 294 local barFrame = bar:GetFrame() |
226 | 295 |
227 config.name = config.name or "ReAction_"..bar:GetName().."_Possess_"..idx | 296 config.name = config.name or ("ReAction_%s_Possess_%d"):format(bar:GetName(),idx) |
228 self.name = config.name | 297 self.name = config.name |
229 config.actionID = ActionIDList[config.actionID] -- gets a free one if none configured | 298 config.actionID = ActionIDList[config.actionID] -- gets a free one if none configured |
230 | 299 |
231 local f = CreateFrame("CheckButton", self.name, barFrame, "BonusActionButtonTemplate") | 300 local f = CreateFrame("CheckButton", self.name, barFrame, "BonusActionButtonTemplate") |
232 | 301 |