comparison classes/ActionButton.lua @ 124:0c5017f6062d

More fixes for new action button implementation
author Flick <flickerstreak@gmail.com>
date Tue, 03 Mar 2009 22:10:45 +0000
parents 943eed2c7def
children 729232aeeb5e
comparison
equal deleted inserted replaced
123:943eed2c7def 124:0c5017f6062d
69 ]] 69 ]]
70 70
71 local _childupdate_vehicleExit = -- function(self, snippetid, message) 71 local _childupdate_vehicleExit = -- function(self, snippetid, message)
72 [[ 72 [[
73 local show = (mcVehicleState == "vehicle") 73 local show = (mcVehicleState == "vehicle")
74 if show then 74 if show and doVehicle then
75 self:SetAttribute("type","macro") 75 self:SetAttribute("type","macro")
76 self:SetAttribute("macrotext","/run VehicleExit()") 76 self:SetAttribute("macrotext","/run VehicleExit()")
77 self:Show() 77 self:Show()
78 else 78 else
79 self:SetAttribute("type","action") 79 self:SetAttribute("type","action")
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 local name = format("ReAction_%s_Action_%d",bar:GetName(),idx) 158 local name = format("ReAction_%s_Action_%d",bar:GetName(),idx)
159 159
160 self = Super.New(self, name, config, bar, idx, "ActionButtonTemplate, SecureActionButtonTemplate" ) 160 self = Super.New(self, name, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
161 161
162 local f = self:GetFrame() 162 local f = self:GetFrame()
163 local barFrame = bar:GetFrame() 163 local barFrame = bar:GetFrame()
164 164
165 local frames = { } 165 local frames = { }
179 self.rangeTimer = TOOLTIP_UPDATE_TIME 179 self.rangeTimer = TOOLTIP_UPDATE_TIME
180 180
181 -- set up the base action ID 181 -- set up the base action ID
182 self:SetActionIDPool("action",120) 182 self:SetActionIDPool("action",120)
183 config.actionID = self:AcquireActionID(config.actionID, idHint) 183 config.actionID = self:AcquireActionID(config.actionID, idHint)
184 self.actionID = config.actionID
185 self.nPages = 1 184 self.nPages = 1
186 185
187 -- attribute setup 186 -- attribute setup
188 f:SetAttribute("type","action") 187 f:SetAttribute("type","action")
189 f:SetAttribute("checkselfcast", true) 188 f:SetAttribute("checkselfcast", true)
208 -- secure handlers 207 -- secure handlers
209 f:SetAttribute("_childupate", _childupdate) 208 f:SetAttribute("_childupate", _childupdate)
210 f:SetAttribute("_childupdate-showgrid",_childupdate_showgrid) 209 f:SetAttribute("_childupdate-showgrid",_childupdate_showgrid)
211 barFrame:WrapScript(f, "OnDragStart", _onDragStart) 210 barFrame:WrapScript(f, "OnDragStart", _onDragStart)
212 barFrame:WrapScript(f, "OnReceiveDrag", _onReceiveDrag) 211 barFrame:WrapScript(f, "OnReceiveDrag", _onReceiveDrag)
213 if idx == 7 then
214 -- install vehicle-exit button on 7th button (only)
215 f:SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit)
216 local button = self
217 function barFrame:ShowVehicleExit(show)
218 button:ShowVehicleExit(show)
219 end
220 end
221 212
222 -- event registration 213 -- event registration
214 f:EnableMouse(true)
223 f:RegisterForDrag("LeftButton", "RightButton") 215 f:RegisterForDrag("LeftButton", "RightButton")
224 f:RegisterForClicks("AnyUp") 216 f:RegisterForClicks("AnyUp")
225 for _, evt in pairs(eventList) do 217 for _, evt in pairs(eventList) do
226 f:RegisterEvent(evt) 218 f:RegisterEvent(evt)
227 end 219 end
260 end 252 end
261 253
262 function Action:Refresh() 254 function Action:Refresh()
263 self.bar:PlaceButton(self, 36, 36) 255 self.bar:PlaceButton(self, 36, 36)
264 self:RefreshPages() 256 self:RefreshPages()
257 self:InstallVehicle()
265 self:UpdateAction() 258 self:UpdateAction()
259 end
260
261 function Action:InstallVehicle()
262 if self.idx == 7 and self.bar:GetConfig().vehicle then
263 -- install vehicle-exit button on 7th button (only)
264 f:SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit)
265 barFrame.ShowVehicleExit = function(bar,show)
266 self:ShowVehicleExit(show)
267 end
268 else
269 f:SetAttribute("_childupdate-vehicle",nil)
270 end
266 end 271 end
267 272
268 function Action:UpdateAll() 273 function Action:UpdateAll()
269 self:UpdateActionIDLabel(ReAction:GetConfigMode()) 274 self:UpdateActionIDLabel(ReAction:GetConfigMode())
270 self:UpdateHotkey() 275 self:UpdateHotkey()
565 570
566 571
567 function Action:ShowVehicleExit(show) 572 function Action:ShowVehicleExit(show)
568 local f = self:GetFrame() 573 local f = self:GetFrame()
569 local tx = f.vehicleExitTexture 574 local tx = f.vehicleExitTexture
570 if show then 575 if show and self.bar:GetConfig().vehicle then
571 if not tx then 576 if not tx then
572 tx = f:CreateTexture(nil,"ARTWORK") 577 tx = f:CreateTexture(nil,"ARTWORK")
573 tx:SetAllPoints() 578 tx:SetAllPoints()
574 -- copied from Blizzard/VehicleMenuBar.lua SkinsData 579 -- copied from Blizzard/VehicleMenuBar.lua SkinsData
575 tx:SetTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up") 580 tx:SetTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up")
649 end 654 end
650 655
651 function Action:ACTIONBAR_UPDATE_STATE() 656 function Action:ACTIONBAR_UPDATE_STATE()
652 self:UpdateCheckedState() 657 self:UpdateCheckedState()
653 end 658 end
654 Action.TRADE_SKILL_SHOW = Action.ACTIONBAR_UPDATE_STATE 659
655 Action.TRADE_SKILL_CLOSE = Action.ACTIONBAR_UPDATE_STATE 660 function Action:TRADE_SKILL_SHOW()
661 self:UpdateCheckedState()
662 end
663 Action.TRADE_SKILL_CLOSE = Action.TRADE_SKILL_CLOSE
656 664
657 function Action:UNIT_ENTERED_VEHICLE(event,unit) 665 function Action:UNIT_ENTERED_VEHICLE(event,unit)
658 if unit == "player" then 666 if unit == "player" then
659 self:UpdateCheckedState() 667 self:UpdateCheckedState()
660 end 668 end