comparison classes/ActionButton.lua @ 123:943eed2c7def

Fixes for new ActionButton implementation
author Flick <flickerstreak@gmail.com>
date Mon, 23 Feb 2009 19:41:11 +0000
parents a2d2f23137c8
children 0c5017f6062d
comparison
equal deleted inserted replaced
122:a2d2f23137c8 123:943eed2c7def
153 local Super = ReAction.Button 153 local Super = ReAction.Button
154 local Action = setmetatable( { }, { __index = Super } ) 154 local Action = setmetatable( { }, { __index = Super } )
155 ReAction.Button.Action = Action 155 ReAction.Button.Action = Action
156 156
157 function Action:New( idx, config, bar, idHint ) 157 function Action:New( idx, config, bar, idHint )
158 self = Super.New( 158 local name = format("ReAction_%s_Action_%d",bar:GetName(),idx)
159 self, 159
160 format("ReAction_%s_Action_%d",bar:GetName(),idx), 160 self = Super.New(self, name, config, bar, idx, "ActionButtonTemplate, SecureActionButtonTemplate" )
161 config,
162 bar,
163 idx,
164 "ActionButtonTemplate, SecureActionButtonTemplate" )
165 161
166 local f = self:GetFrame() 162 local f = self:GetFrame()
167 local barFrame = bar:GetFrame() 163 local barFrame = bar:GetFrame()
168 164
169 local frames = { } 165 local frames = { }
205 f:SetScript("OnLeave", function(frame) self:OnLeave() end) 201 f:SetScript("OnLeave", function(frame) self:OnLeave() end)
206 f:SetScript("OnAttributeChanged", function(frame, attr, value) self:OnAttributeChanged(attr, value) end) 202 f:SetScript("OnAttributeChanged", function(frame, attr, value) self:OnAttributeChanged(attr, value) end)
207 f:SetScript("PostClick", function(frame, ...) self:PostClick(...) end) 203 f:SetScript("PostClick", function(frame, ...) self:PostClick(...) end)
208 f:SetScript("OnUpdate", function(frame, elapsed) self:OnUpdate(elapsed) end) 204 f:SetScript("OnUpdate", function(frame, elapsed) self:OnUpdate(elapsed) end)
209 f:SetScript("OnDragStart", function(frame) self:OnDragStart() end) 205 f:SetScript("OnDragStart", function(frame) self:OnDragStart() end)
210 f:SetScript("OnReceiveDrag", function(frame), self:OnReceiveDrag() end) 206 f:SetScript("OnReceiveDrag", function(frame) self:OnReceiveDrag() end)
211 207
212 -- secure handlers 208 -- secure handlers
213 f:SetAttribute("_childupate", _childupdate) 209 f:SetAttribute("_childupate", _childupdate)
214 f:SetAttribute("_childupdate-showgrid",_childupdate_showgrid) 210 f:SetAttribute("_childupdate-showgrid",_childupdate_showgrid)
215 barFrame:WrapScript(f, "OnDragStart", _onDragStart) 211 barFrame:WrapScript(f, "OnDragStart", _onDragStart)
232 228
233 -- attach to skinner 229 -- attach to skinner
234 bar:SkinButton(self) 230 bar:SkinButton(self)
235 231
236 -- initial display 232 -- initial display
237 self:ShowGrid(not barFrame:GetConfig().hideEmpty) 233 self:ShowGrid(not bar:GetConfig().hideEmpty)
238 if ReAction:GetConfigMode() then 234 if ReAction:GetConfigMode() then
239 self:ShowGrid(true) 235 self:ShowGrid(true)
240 end 236 end
241 237
238 f:Show()
239
242 self:Refresh() 240 self:Refresh()
241
242 return self
243 end 243 end
244 244
245 function Action:Destroy() 245 function Action:Destroy()
246 local f = self:GetFrame() 246 local f = self:GetFrame()
247 247
297 self.showgridPending = false 297 self.showgridPending = false
298 -- check if each action has an action or not, and flag an attribute 298 -- check if each action has an action or not, and flag an attribute
299 -- so that the showgrid secure handler can make decisions accordingly 299 -- so that the showgrid secure handler can make decisions accordingly
300 local f = self:GetFrame() 300 local f = self:GetFrame()
301 f:SetAttribute("hasaction-"..self.config.actionID, HasAction(self.config.actionID)) 301 f:SetAttribute("hasaction-"..self.config.actionID, HasAction(self.config.actionID))
302 for i = 1, self.nPages do 302 if self.config.pageactions then
303 f:SetAttribute("hasaction-"..self.config.pageactions[i], HasAction(self.config.pageactions[i]) 303 for i = 1, self.nPages do
304 f:SetAttribute("hasaction-"..self.config.pageactions[i], HasAction(self.config.pageactions[i]))
305 end
304 end 306 end
305 -- the following is an out-of-combat show/hide to supplement the secure 307 -- the following is an out-of-combat show/hide to supplement the secure
306 -- handling and clean up after it when it guesses 308 -- handling and clean up after it when it guesses
307 if HasAction(self.actionID) then 309 if HasAction(self.actionID) then
308 f:Show() 310 f:Show()
328 icon:Hide() 330 icon:Hide()
329 self.frames.cooldown:Hide() 331 self.frames.cooldown:Hide()
330 self.rangeTimer = nil 332 self.rangeTimer = nil
331 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot") 333 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot")
332 hotkey:SetVertexColor(0.6, 0.6, 0.6) 334 hotkey:SetVertexColor(0.6, 0.6, 0.6)
333 end
334 end 335 end
335 end 336 end
336 337
337 function Action:UpdateBorder() 338 function Action:UpdateBorder()
338 local action = self.actionID 339 local action = self.actionID
453 if IsActionInRange(self.actionID) == 0 then 454 if IsActionInRange(self.actionID) == 0 then
454 self.frames.icon:SetVertexColor(1.0,0.1,0.1) 455 self.frames.icon:SetVertexColor(1.0,0.1,0.1)
455 else 456 else
456 self:UpdateUsable() 457 self:UpdateUsable()
457 end 458 end
458 frame.rangeTimer = TOOLTIP_UPDATE_TIME 459 self.rangeTimer = TOOLTIP_UPDATE_TIME
459 end 460 end
460 end 461 end
461 end 462 end
462 463
463 function Action:GetActionID(page) 464 function Action:GetActionID(page)
524 end 525 end
525 self.nPages = nPages 526 self.nPages = nPages
526 end 527 end
527 end 528 end
528 529
529 function Action:SetupBarHeader( bar ) -- call this as a static method 530 function Action.SetupBarHeader( bar ) -- call this as a static method
530 local f = bar:GetFrame() 531 local f = bar:GetFrame()
531 local c = bar:GetConfig() 532 local c = bar:GetConfig()
532 f:SetAttribute("mindcontrol",c.mindcontrol) 533 f:SetAttribute("mindcontrol",c.mindcontrol)
533 f:SetAttribute("vehicle",c.vehicle) 534 f:SetAttribute("vehicle",c.vehicle)
534 f:Execute( 535 f:Execute(
541 f:SetAttribute("_onstate-mc", _onstate_mc) 542 f:SetAttribute("_onstate-mc", _onstate_mc)
542 RegisterStateDriver(f, "mc", "[target=vehicle,exists] vehicle; [bonusbar:5] mc; none") 543 RegisterStateDriver(f, "mc", "[target=vehicle,exists] vehicle; [bonusbar:5] mc; none")
543 544
544 f:SetAttribute("lockbuttons",c.lockButtons) 545 f:SetAttribute("lockbuttons",c.lockButtons)
545 f:SetAttribute("lockbuttonscombat",c.lockButtonsCombat) 546 f:SetAttribute("lockbuttonscombat",c.lockButtonsCombat)
547 f:Execute(
548 [[
549 lockButtons = self:GetAttribute("lockbuttons")
550 lockButtonsCombat = self:GetAttribute("lockbuttonscombat")
551 ]])
552 end
553
554
555 function Action.SetButtonLock( bar, lock, lockCombat ) -- call this as a static method
556 local f = bar:GetFrame()
557 f:SetAttribute("lockbuttons",lock)
558 f:SetAttribute("lockbuttonscombat",lockCombat)
546 f:Execute( 559 f:Execute(
547 [[ 560 [[
548 lockButtons = self:GetAttribute("lockbuttons") 561 lockButtons = self:GetAttribute("lockbuttons")
549 lockButtonsCombat = self:GetAttribute("lockbuttonscombat") 562 lockButtonsCombat = self:GetAttribute("lockbuttonscombat")
550 ]]) 563 ]])