Mercurial > wow > reaction
comparison classes/VehicleExitButton.lua @ 234:0e20f65375d5
Reworked button creation to not use goofy event driven semantics.
author | Flick |
---|---|
date | Tue, 22 Mar 2011 17:05:51 -0700 |
parents | 158c9299185b |
children |
comparison
equal
deleted
inserted
replaced
233:9b9f5fc84d34 | 234:0e20f65375d5 |
---|---|
26 { __index = Super } ) | 26 { __index = Super } ) |
27 | 27 |
28 ReAction.Button.VehicleExit = VExitButton | 28 ReAction.Button.VehicleExit = VExitButton |
29 ReAction:RegisterBarType(VExitButton) | 29 ReAction:RegisterBarType(VExitButton) |
30 | 30 |
31 function VExitButton:New( idx, config, bar ) | 31 function VExitButton:New( config, bar, idx ) |
32 local name = format("ReAction_%s_VehicleExit_%d",bar:GetName(),idx) | 32 local name = format("ReAction_%s_VehicleExit_%d",bar:GetName(),idx) |
33 | 33 |
34 self = Super.New(self, name, config, bar, idx, "SecureFrameTemplate, ActionButtonTemplate", "Button") | 34 self = Super.New(self, name, config, bar, idx, "SecureFrameTemplate, ActionButtonTemplate", "Button") |
35 | 35 |
36 -- frame setup | 36 -- frame setup |
59 self:UpdateHotkey() | 59 self:UpdateHotkey() |
60 | 60 |
61 return self | 61 return self |
62 end | 62 end |
63 | 63 |
64 function VExitButton:SetupBar(bar) | |
65 Super.SetupBar(self,bar) | |
66 self:UpdateRegistration(bar) | |
67 end | |
68 | |
64 function VExitButton:GetActionID() | 69 function VExitButton:GetActionID() |
65 return 1 | 70 return 1 |
66 end | 71 end |
67 | 72 |
68 function VExitButton:Refresh() | 73 function VExitButton:Refresh() |
78 end | 83 end |
79 | 84 |
80 function VExitButton:UPDATE_BINDINGS() | 85 function VExitButton:UPDATE_BINDINGS() |
81 self:UpdateHotkey() | 86 self:UpdateHotkey() |
82 end | 87 end |
88 | |
89 function VExitButton:UpdateRegistration(bar) | |
90 -- auto show/hide when on a vehicle | |
91 local config = bar:GetConfig() | |
92 local f = bar:GetFrame() | |
93 if config.withControls then | |
94 if bar.vehicleExitStateRegistered then | |
95 UnregisterStateDriver(f, "unitexists") | |
96 bar.vehicleExitStateRegistered = false | |
97 end | |
98 bar:RegisterUnitWatch("vehicle",true) | |
99 else | |
100 bar:RegisterUnitWatch("vehicle",false) | |
101 if not bar.vehicleExitStateRegistered then | |
102 f:SetAttribute("unit","vehicle") | |
103 RegisterStateDriver(f, "unitexists", "[target=vehicle,exists,novehicleui] show; hide") -- spoof onstate-unitexists | |
104 bar.vehicleExitStateRegistered = true | |
105 end | |
106 end | |
107 end | |
108 |