# HG changeset patch
# User Flick
# Date 1352939933 28800
# Node ID e337b39dc491690bc51fbf4a6e72139bdd76e72b
# Parent d1a56601267baefc039049d17204ebc95255d524
Add ExtraActionButton support
diff -r d1a56601267b -r e337b39dc491 ActionButton.lua
--- a/ActionButton.lua Wed Nov 14 16:35:18 2012 -0800
+++ b/ActionButton.lua Wed Nov 14 16:38:53 2012 -0800
@@ -187,7 +187,8 @@
},
barType = L["Action Bar"],
- buttonTypeID = buttonTypeID
+ buttonTypeID = buttonTypeID,
+ eventList = eventList
},
{ __index = Super } )
diff -r d1a56601267b -r e337b39dc491 Button.lua
--- a/Button.lua Wed Nov 14 16:35:18 2012 -0800
+++ b/Button.lua Wed Nov 14 16:38:53 2012 -0800
@@ -204,6 +204,10 @@
if not poolID or not maxID then
error("AcquireActionID: must setup pool first with SetActionIDPool")
end
+ hint = tonumber(hint)
+ if hint and (hint < 1 or hint > maxID) then
+ hint = nil
+ end
local pool = idPools[poolID]
if not pool then
pool = { nWraps = 0, useCount = { } }
@@ -216,19 +220,19 @@
if id == nil then
repeat
local nWraps = pool.nWraps or 0
- if hint and (useCount[hint] == nil or useCount[hint] == nWraps) then
+ if hint and (useCount[hint] == 0 or useCount[hint] == nWraps) then
id = hint
else
local start = hint or 1
for i = start, maxID do
- if useCount[i] == nil or useCount[i] == nWraps then
+ if useCount[i] == 0 or useCount[i] == nWraps then
id = i
break
end
end
if not id then
for i = 1, start do
- if useCount[i] == nil or useCount[i] == nWraps then
+ if useCount[i] == 0 or useCount[i] == nWraps then
id = i
break
end
diff -r d1a56601267b -r e337b39dc491 ExtraActionButton.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ExtraActionButton.lua Wed Nov 14 16:38:53 2012 -0800
@@ -0,0 +1,114 @@
+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
+
diff -r d1a56601267b -r e337b39dc491 ReAction.xml
--- a/ReAction.xml Wed Nov 14 16:35:18 2012 -0800
+++ b/ReAction.xml Wed Nov 14 16:38:53 2012 -0800
@@ -15,6 +15,7 @@
+
diff -r d1a56601267b -r e337b39dc491 VehicleExitButton.lua
--- a/VehicleExitButton.lua Wed Nov 14 16:35:18 2012 -0800
+++ b/VehicleExitButton.lua Wed Nov 14 16:38:53 2012 -0800
@@ -28,7 +28,7 @@
ReAction.Button.VehicleExit = VExitButton
ReAction:RegisterBarType(VExitButton)
-function VExitButton:New( config, bar, idx )
+function VExitButton:New( config, bar, idx, idHint )
self = Super.New(self, config, bar, idx, "SecureFrameTemplate, ActionButtonTemplate", "Button")
-- frame setup
@@ -36,6 +36,9 @@
self.frames.icon:SetTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up")
self.frames.icon:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375)
+ self:SetActionIDPool("vehicle-exit",1)
+ self:AcquireActionID(nil, idHint, true)
+
-- attribute setup
-- (none)
@@ -66,14 +69,6 @@
return 1
end
-function VExitButton:AcquireActionID()
- -- don't use pool
-end
-
-function VExitButton:ReleaseActionID()
- -- don't use pool
-end
-
function VExitButton:Refresh()
Super.Refresh(self)
-- it seems that setscale kills the texcoord, have to refresh it
diff -r d1a56601267b -r e337b39dc491 locale/enUS.lua
--- a/locale/enUS.lua Wed Nov 14 16:35:18 2012 -0800
+++ b/locale/enUS.lua Wed Nov 14 16:38:53 2012 -0800
@@ -243,6 +243,9 @@
-- VehicleExitButton.lua
"Exit Vehicle Floater",
+-- ExtraActionButton.lua
+"Special Action Button",
+
}) do
L[s] = true
end