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