annotate classes/VehicleExitButton.lua @ 223:c4b134512c50

Move RegisterBarType from modules to button classes
author Flick <flickerstreak@gmail.com>
date Mon, 22 Nov 2010 10:25:18 -0800
parents d08a74e86c96
children 158c9299185b
rev   line source
flickerstreak@175 1 local addonName, addonTable = ...
flickerstreak@175 2 local ReAction = addonTable.ReAction
flickerstreak@218 3 local L = ReAction.L
flickerstreak@159 4 local format = string.format
flickerstreak@159 5
flickerstreak@159 6 --
flickerstreak@159 7 -- VExitButton Button class
flickerstreak@159 8 --
flickerstreak@218 9 local buttonTypeID = "VehicleExit"
flickerstreak@159 10 local Super = ReAction.Button
flickerstreak@218 11 local VExitButton = setmetatable(
flickerstreak@218 12 {
flickerstreak@218 13 defaultBarConfig = {
flickerstreak@218 14 type = buttonTypeID ,
flickerstreak@218 15 btnWidth = 36,
flickerstreak@218 16 btnHeight = 36,
flickerstreak@218 17 btnRows = 1,
flickerstreak@218 18 btnColumns = 1,
flickerstreak@222 19 spacing = 3,
flickerstreak@222 20 buttons = { }
flickerstreak@218 21 },
flickerstreak@218 22
flickerstreak@218 23 barType = L["Exit Vehicle Floater"],
flickerstreak@218 24 },
flickerstreak@218 25 { __index = Super } )
flickerstreak@223 26
flickerstreak@159 27 ReAction.Button.VehicleExit = VExitButton
flickerstreak@223 28 ReAction:RegisterBarType(VExitButton)
flickerstreak@159 29
flickerstreak@159 30 function VExitButton:New( idx, config, bar )
flickerstreak@159 31 local name = format("ReAction_%s_VehicleExit_%d",bar:GetName(),idx)
flickerstreak@159 32
flickerstreak@159 33 self = Super.New(self, name, config, bar, idx, "SecureFrameTemplate, ActionButtonTemplate", "Button")
flickerstreak@159 34
flickerstreak@159 35 -- frame setup
flickerstreak@159 36 local f = self:GetFrame()
flickerstreak@159 37 self.frames.icon:SetTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up")
flickerstreak@159 38 self.frames.icon:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375)
flickerstreak@159 39
flickerstreak@159 40 -- attribute setup
flickerstreak@159 41 -- (none)
flickerstreak@159 42
flickerstreak@159 43 -- non secure scripts
flickerstreak@159 44 f:SetScript("OnClick", VehicleExit)
flickerstreak@159 45 f:SetScript("OnEnter", function(frame) GameTooltip_AddNewbieTip(frame, LEAVE_VEHICLE, 1.0, 1.0, 1.0, nil) end)
flickerstreak@159 46 f:SetScript("OnLeave", GameTooltip_Hide)
flickerstreak@159 47 f:SetScript("OnEvent", function(frame, evt, ...) self:OnEvent(evt,...) end)
flickerstreak@159 48
flickerstreak@159 49 -- event registration
flickerstreak@159 50 f:EnableMouse(true)
flickerstreak@159 51 f:RegisterForClicks("AnyUp")
flickerstreak@159 52 f:RegisterEvent("UPDATE_BINDINGS")
flickerstreak@159 53
flickerstreak@159 54 -- attach to skinner
flickerstreak@159 55 bar:SkinButton(self)
flickerstreak@159 56
flickerstreak@159 57 self:Refresh()
flickerstreak@159 58 self:UpdateHotkey()
flickerstreak@159 59
flickerstreak@159 60 return self
flickerstreak@159 61 end
flickerstreak@159 62
flickerstreak@159 63 function VExitButton:GetActionID()
flickerstreak@159 64 return 1
flickerstreak@159 65 end
flickerstreak@159 66
flickerstreak@159 67 function VExitButton:Refresh()
flickerstreak@159 68 Super.Refresh(self)
flickerstreak@159 69 -- it seems that setscale kills the texcoord, have to refresh it
flickerstreak@159 70 self.frames.icon:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375)
flickerstreak@159 71 end
flickerstreak@159 72
flickerstreak@159 73 function VExitButton:OnEvent(event, ...)
flickerstreak@159 74 if self[event] then
flickerstreak@159 75 self[event](self, event, ...)
flickerstreak@159 76 end
flickerstreak@159 77 end
flickerstreak@159 78
flickerstreak@159 79 function VExitButton:UPDATE_BINDINGS()
flickerstreak@159 80 self:UpdateHotkey()
flickerstreak@159 81 end