annotate classes/VehicleExitButton.lua @ 165:5257073138e8

Updates for WoW 3.3
author Flick <flickerstreak@gmail.com>
date Sat, 12 Dec 2009 21:56:32 +0000
parents 799c6ea9da7b
children 8cc187143acd
rev   line source
flickerstreak@159 1 local ReAction = ReAction
flickerstreak@159 2 local format = string.format
flickerstreak@159 3
flickerstreak@159 4 ReAction:UpdateRevision("$Revision: 154 $")
flickerstreak@159 5
flickerstreak@159 6 --
flickerstreak@159 7 -- VExitButton Button class
flickerstreak@159 8 --
flickerstreak@159 9 local Super = ReAction.Button
flickerstreak@159 10 local VExitButton = setmetatable( { }, { __index = Super } )
flickerstreak@159 11 ReAction.Button.VehicleExit = VExitButton
flickerstreak@159 12
flickerstreak@159 13 function VExitButton:New( idx, config, bar )
flickerstreak@159 14 local name = format("ReAction_%s_VehicleExit_%d",bar:GetName(),idx)
flickerstreak@159 15
flickerstreak@159 16 self = Super.New(self, name, config, bar, idx, "SecureFrameTemplate, ActionButtonTemplate", "Button")
flickerstreak@159 17
flickerstreak@159 18 -- frame setup
flickerstreak@159 19 local f = self:GetFrame()
flickerstreak@159 20 self.frames.icon:SetTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up")
flickerstreak@159 21 self.frames.icon:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375)
flickerstreak@159 22
flickerstreak@159 23 -- attribute setup
flickerstreak@159 24 -- (none)
flickerstreak@159 25
flickerstreak@159 26 -- non secure scripts
flickerstreak@159 27 f:SetScript("OnClick", VehicleExit)
flickerstreak@159 28 f:SetScript("OnEnter", function(frame) GameTooltip_AddNewbieTip(frame, LEAVE_VEHICLE, 1.0, 1.0, 1.0, nil) end)
flickerstreak@159 29 f:SetScript("OnLeave", GameTooltip_Hide)
flickerstreak@159 30 f:SetScript("OnEvent", function(frame, evt, ...) self:OnEvent(evt,...) end)
flickerstreak@159 31
flickerstreak@159 32 -- event registration
flickerstreak@159 33 f:EnableMouse(true)
flickerstreak@159 34 f:RegisterForClicks("AnyUp")
flickerstreak@159 35 f:RegisterEvent("UPDATE_BINDINGS")
flickerstreak@159 36
flickerstreak@159 37 -- attach to skinner
flickerstreak@159 38 bar:SkinButton(self)
flickerstreak@159 39
flickerstreak@159 40 self:Refresh()
flickerstreak@159 41 self:UpdateHotkey()
flickerstreak@159 42
flickerstreak@159 43 return self
flickerstreak@159 44 end
flickerstreak@159 45
flickerstreak@159 46 function VExitButton:GetActionID()
flickerstreak@159 47 return 1
flickerstreak@159 48 end
flickerstreak@159 49
flickerstreak@159 50 function VExitButton:Refresh()
flickerstreak@159 51 Super.Refresh(self)
flickerstreak@159 52 -- it seems that setscale kills the texcoord, have to refresh it
flickerstreak@159 53 self.frames.icon:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375)
flickerstreak@159 54 end
flickerstreak@159 55
flickerstreak@159 56 function VExitButton:OnEvent(event, ...)
flickerstreak@159 57 if self[event] then
flickerstreak@159 58 self[event](self, event, ...)
flickerstreak@159 59 end
flickerstreak@159 60 end
flickerstreak@159 61
flickerstreak@159 62 function VExitButton:UPDATE_BINDINGS()
flickerstreak@159 63 self:UpdateHotkey()
flickerstreak@159 64 end