view classes/VehicleExitButton.lua @ 175:df68b5a40490

Remove ReAction global in favor of built in addon table (drycoded)
author Flick <flickerstreak@gmail.com>
date Wed, 20 Oct 2010 17:11:50 +0000
parents 8cc187143acd
children e63aefb8a555
line wrap: on
line source
local addonName, addonTable = ...
local ReAction = addonTable.ReAction
local format = string.format

--
-- 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