very basic and hack'ish support for page swapping, hopefully doesnt break :D
This commit is contained in:
@@ -134,6 +134,7 @@ function ActionBar:UpdateStates()
|
|||||||
|
|
||||||
self:SetAttribute("_onstate-page", [[
|
self:SetAttribute("_onstate-page", [[
|
||||||
self:SetAttribute("state", newstate)
|
self:SetAttribute("state", newstate)
|
||||||
|
_G["newBTState"] = newstate
|
||||||
return true
|
return true
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ function Bartender4.Button:Create(id, parent)
|
|||||||
button.id = absid
|
button.id = absid
|
||||||
button.parent = parent
|
button.parent = parent
|
||||||
button.stateactions = {}
|
button.stateactions = {}
|
||||||
|
button.stateconfig = {}
|
||||||
|
|
||||||
button:SetFrameStrata("MEDIUM")
|
button:SetFrameStrata("MEDIUM")
|
||||||
button:SetFrameLevel(parent:GetFrameLevel() + 2)
|
button:SetFrameLevel(parent:GetFrameLevel() + 2)
|
||||||
@@ -94,7 +95,7 @@ function Bartender4.Button:Create(id, parent)
|
|||||||
|
|
||||||
parent:SetAttribute('_adopt', button)
|
parent:SetAttribute('_adopt', button)
|
||||||
button:SetAttribute('_childupdate', [[
|
button:SetAttribute('_childupdate', [[
|
||||||
--self:SetAttribute("state", )
|
self:SetAttribute("state", newBTState)
|
||||||
]]
|
]]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -117,7 +118,6 @@ function Bartender4.Button:Create(id, parent)
|
|||||||
}
|
}
|
||||||
group:AddButton(button.Proxy, button.LBFButtonData)
|
group:AddButton(button.Proxy, button.LBFButtonData)
|
||||||
end
|
end
|
||||||
|
|
||||||
return button
|
return button
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -204,6 +204,7 @@ function Button:ClearStateAction()
|
|||||||
self:SetAttribute(("*macrotext-S%dRight"):format(state), nil)
|
self:SetAttribute(("*macrotext-S%dRight"):format(state), nil)
|
||||||
|
|
||||||
self.stateactions = {}
|
self.stateactions = {}
|
||||||
|
self.stateconfig = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -213,16 +214,30 @@ function Button:SetStateAction(state, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Button:RefreshAllStateActions()
|
function Button:RefreshAllStateActions()
|
||||||
|
self.stateconfig = {}
|
||||||
for state in pairs(self.stateactions) do
|
for state in pairs(self.stateactions) do
|
||||||
self:RefreshStateAction(state)
|
self:RefreshStateAction(state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Button:RebuildStateFunction()
|
||||||
|
local newFunc = "local config = newtable()\n"
|
||||||
|
for state, config in pairs(self.stateconfig) do
|
||||||
|
newFunc = newFunc .. ("local config_part = newtable(); config_part.type = %q; config_part.action = %d; config_part.macrotext = %q; config[%d] = config_part;\n"):format(config.type, config.action, config.macrotext, state)
|
||||||
|
end
|
||||||
|
newFunc = newFunc .. [[
|
||||||
|
local state = tonumber(newBTState)
|
||||||
|
self:SetAttribute("type", config[state].type)
|
||||||
|
self:SetAttribute("action", config[state].action)
|
||||||
|
self:SetAttribute("macrotext", config[state].macrotext)
|
||||||
|
]]
|
||||||
|
self:SetAttribute('_childupdate', newFunc)
|
||||||
|
end
|
||||||
|
|
||||||
function Button:RefreshStateAction(state)
|
function Button:RefreshStateAction(state)
|
||||||
local state = tonumber(state or self:GetAttribute("state-parent"))
|
local state = tonumber(state or self:GetAttribute("state"))
|
||||||
local action = self.stateactions[state]
|
local action = self.stateactions[state]
|
||||||
self:SetAttribute(("*type-S%d"):format(state), "action")
|
local config = { type = "action", action = action, macrotext = action }
|
||||||
self:SetAttribute(("*type-S%dRight"):format(state), "action")
|
|
||||||
|
|
||||||
if self.parent.config.autoassist then
|
if self.parent.config.autoassist then
|
||||||
local type, id, subtype = GetActionInfo(action)
|
local type, id, subtype = GetActionInfo(action)
|
||||||
@@ -247,18 +262,13 @@ function Button:RefreshStateAction(state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if macroText then
|
if macroText then
|
||||||
self:SetAttribute(("*type-S%d"):format(state), "macro")
|
config.type = "macro"
|
||||||
self:SetAttribute(("*type-S%dRight"):format(state), "macro")
|
config.macrotext = ("%s%s(%s)"):format(macroText, spellName, spellRank)
|
||||||
macroText = ("%s%s(%s)"):format(macroText, spellName, spellRank)
|
|
||||||
|
|
||||||
self:SetAttribute(("*macrotext-S%d"):format(state), macroText)
|
|
||||||
self:SetAttribute(("*macrotext-S%dRight"):format(state), macroText)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self.stateconfig[state] = config
|
||||||
self:SetAttribute(("*action-S%d"):format(state), action)
|
self:RebuildStateFunction()
|
||||||
self:SetAttribute(("*action-S%dRight"):format(state), action)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:CalculateAction()
|
function Button:CalculateAction()
|
||||||
|
|||||||
Reference in New Issue
Block a user