Mercurial > wow > reaction
view VehicleExitButton.lua @ 294:30c9bdaad7a3 stable
merge 1.1 beta 10 to stable
author | Flick |
---|---|
date | Fri, 05 Aug 2011 16:28:13 -0700 |
parents | 5b9c0164a491 |
children | e337b39dc491 |
line wrap: on
line source
local _, ns = ... local ReAction = ns.ReAction local L = ReAction.L local format = string.format -- -- VExitButton Button class -- local buttonTypeID = "VehicleExit" local Super = ReAction.Button local VExitButton = setmetatable( { defaultBarConfig = { type = buttonTypeID , btnWidth = 36, btnHeight = 36, btnRows = 1, btnColumns = 1, spacing = 3, buttons = { } }, barType = L["Exit Vehicle Floater"], buttonTypeID = buttonTypeID }, { __index = Super } ) ReAction.Button.VehicleExit = VExitButton ReAction:RegisterBarType(VExitButton) function VExitButton:New( config, bar, idx ) self = Super.New(self, config, bar, idx, "SecureFrameTemplate, ActionButtonTemplate", "Button") -- frame setup local f = self:GetFrame() self.frames.icon:SetTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up") self.frames.icon:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375) -- attribute setup -- (none) -- non secure scripts f:SetScript("OnClick", VehicleExit) f:SetScript("OnEnter", function(frame) GameTooltip_AddNewbieTip(frame, LEAVE_VEHICLE, 1.0, 1.0, 1.0, nil) end) f:SetScript("OnLeave", GameTooltip_Hide) f:SetScript("OnEvent", function(frame, evt, ...) self:OnEvent(evt,...) end) -- event registration f:RegisterEvent("UPDATE_BINDINGS") -- attach to skinner bar:SkinButton(self) self:Refresh() self:UpdateHotkey() return self end function VExitButton:SetupBar(bar) Super.SetupBar(self,bar) self:UpdateRegistration(bar) end function VExitButton:GetActionID() return 1 end function VExitButton:AcquireActionID() -- don't use pool end function VExitButton:ReleaseActionID() -- don't use pool end function VExitButton:Refresh() Super.Refresh(self) -- it seems that setscale kills the texcoord, have to refresh it self.frames.icon:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375) end function VExitButton:OnEvent(event, ...) if self[event] then self[event](self, event, ...) end end function VExitButton:UPDATE_BINDINGS() self:UpdateHotkey() end function VExitButton:UpdateRegistration(bar) -- auto show/hide when on a vehicle local config = bar:GetConfig() local f = bar:GetFrame() if config.withControls or ReAction:GetConfigMode() then if bar.vehicleExitStateRegistered then UnregisterStateDriver(f, "unitexists") bar.vehicleExitStateRegistered = false end bar:RegisterUnitWatch("vehicle",not ReAction:GetConfigMode()) else bar:RegisterUnitWatch("vehicle",false) if not bar.vehicleExitStateRegistered then f:SetAttribute("unit","vehicle") RegisterStateDriver(f, "unitexists", "[target=vehicle,exists,novehicleui] show; hide") -- spoof onstate-unitexists bar.vehicleExitStateRegistered = true end end end