Mercurial > wow > reaction
view ExtraActionButton.lua @ 304:c63d74f26c22
Added tag 1.1 beta 12 for changeset 86f99ec6d3e5
author | Flick |
---|---|
date | Wed, 14 Nov 2012 16:46:54 -0800 |
parents | e337b39dc491 |
children |
line wrap: on
line source
local _, ns = ... local ReAction = ns.ReAction local L = ReAction.L local format = string.format -- -- ExtraAction Button class -- local buttonTypeID = "ExtraAction" local Super = ReAction.Button.Action local ExtraAction = setmetatable( { defaultBarConfig = { type = buttonTypeID , btnWidth = 52, btnHeight = 52, btnRows = 1, btnColumns = 1, spacing = 3, buttons = { } }, barType = L["Special Action Button"], buttonTypeID = buttonTypeID }, { __index = Super } ) ReAction.Button.ExtraAction = ExtraAction ReAction:RegisterBarType(ExtraAction) function ExtraAction:New( config, bar, idx, idHint ) -- don't invoke the base ActionButton constructor, since it does a bunch of stuff that -- we don't need. Instead, call the Button base constructor directly instead and -- re-implement the bits of the ActionButton constructor that we actually need. self = ReAction.Button.New(self, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) self.barConfig = bar:GetConfig() local f = self:GetFrame() local barFrame = bar:GetFrame() self.rangeTimer = TOOLTIP_UPDATE_TIME self:SetActionIDPool("special-action",1) config.actionID = self:AcquireActionID(config.actionID, idHint, true) self.nPages = 1 -- compute the actual game action-ID from the extra bar offset page local actionID = config.actionID + (GetExtraBarIndex() - 1)*NUM_ACTIONBAR_BUTTONS self.actionID = actionID f.action = actionID -- attribute setup f:SetAttribute("type","action") f:SetAttribute("checkselfcast", true) f:SetAttribute("checkfocuscast", true) f:SetAttribute("action", actionID) f:SetAttribute("default-action", actionID) f:SetAttribute("bar-idx",idx) -- non secure scripts f:SetScript("OnEvent", function(frame, ...) self:OnEvent(...) end) f:SetScript("OnEnter", function(frame) self:OnEnter() end) f:SetScript("OnLeave", function(frame) self:OnLeave() end) f:SetScript("OnAttributeChanged", function(frame, attr, value) self:OnAttributeChanged(attr, value) end) f:SetScript("PostClick", function(frame, ...) self:PostClick(...) end) f:SetScript("OnUpdate", function(frame, elapsed) self:OnUpdate(elapsed) end) -- event registration for _, evt in pairs(self.eventList) do f:RegisterEvent(evt) end -- register to use the C cooldown implementation SetActionUIButton(f, actionID, f.cooldown) -- attach to skinner bar:SkinButton(self) self:Refresh() return self end function ExtraAction:Destroy() -- similarly, don't call the ActionButton destructor function, call the Button destructor function ReAction.Button.Destroy(self) end function ExtraAction:SetupBar(bar) -- again don't call the ActionButton:SetupBar method, because it does a lot of things we don't need/want. -- however the Button base class SetupBar method does need to be called. ReAction.Button.SetupBar(self,bar) -- show/hide the bar based on whether we have an extrabar. Hook into the unitexists mechanism that the pet bar uses. RegisterStateDriver(bar:GetFrame(), "unitexists", "[extrabar] show ; hide") end function ExtraAction:ShowGrid() -- override: do nothing end function ExtraAction:ShowGridTemp( show ) -- override: do nothing end function ExtraAction:SetActionID() -- override: action ID never changes end function ExtraAction:RefreshPages() -- override: action ID never changes end