diff classes/VehicleExitButton.lua @ 159:799c6ea9da7b

added vehicle exit floater some fixes for vehicle exit button on main bars still some lingering settexcoords issues on the vehicle exit icon
author Flick <flickerstreak@gmail.com>
date Mon, 29 Jun 2009 17:43:16 +0000
parents
children 8cc187143acd
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/classes/VehicleExitButton.lua	Mon Jun 29 17:43:16 2009 +0000
@@ -0,0 +1,64 @@
+local ReAction = ReAction
+local format = string.format
+
+ReAction:UpdateRevision("$Revision: 154 $")
+
+--
+-- VExitButton Button class
+--
+local Super = ReAction.Button
+local VExitButton = setmetatable( { }, { __index = Super } )
+ReAction.Button.VehicleExit = VExitButton
+
+function VExitButton:New( idx, config, bar )
+  local name = format("ReAction_%s_VehicleExit_%d",bar:GetName(),idx)
+ 
+  self = Super.New(self, name, 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:EnableMouse(true)
+  f:RegisterForClicks("AnyUp")
+  f:RegisterEvent("UPDATE_BINDINGS")
+
+  -- attach to skinner
+  bar:SkinButton(self)
+
+  self:Refresh()
+  self:UpdateHotkey()
+
+  return self
+end
+
+function VExitButton:GetActionID()
+  return 1
+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