more fixes to stance code
This commit is contained in:
+5
-18
@@ -126,20 +126,17 @@ function ActionBar:UpdateStates()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table_insert(statedriver, tostring(self:GetDefaultState() or 0))
|
|
||||||
|
|
||||||
RegisterStateDriver(self, "page", table_concat(statedriver, ";"))
|
|
||||||
|
|
||||||
self:ApplyStateButton()
|
|
||||||
|
|
||||||
self:SetAttribute("_onstate-page", [[
|
self:SetAttribute("_onstate-page", [[
|
||||||
self:SetAttribute("state", newstate)
|
self:SetAttribute("state", newstate)
|
||||||
_G["newBTState"] = newstate
|
_G["newBTState"] = newstate
|
||||||
return true
|
return true
|
||||||
]])
|
]])
|
||||||
|
|
||||||
local newState = self:GetAttribute("state-page")
|
table_insert(statedriver, tostring(self:GetDefaultState() or 0))
|
||||||
self:SetAttribute("state", newState)
|
RegisterStateDriver(self, "page", table_concat(statedriver, ";"))
|
||||||
|
|
||||||
|
--local newState = self:GetAttribute("state-page")
|
||||||
|
--self:SetAttribute("state", newState)
|
||||||
|
|
||||||
self:ApplyVisibilityDriver()
|
self:ApplyVisibilityDriver()
|
||||||
end
|
end
|
||||||
@@ -189,16 +186,6 @@ function ActionBar:AddRightClickState(state)
|
|||||||
self:SetAttribute("unit-S" .. state .. "Right", target)
|
self:SetAttribute("unit-S" .. state .. "Right", target)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ActionBar:ApplyStateButton()
|
|
||||||
local states1, states2 = {}, {}
|
|
||||||
for _,v in pairs(self.statebutton) do
|
|
||||||
table_insert(states1, fmt("%s:S%s;", v, v))
|
|
||||||
table_insert(states2, fmt("%s:S%sRight;", v, v))
|
|
||||||
end
|
|
||||||
self:SetAttribute("statebutton", table_concat(states1, ""))
|
|
||||||
self:SetAttribute("statebutton2", table_concat(states2, ""))
|
|
||||||
end
|
|
||||||
|
|
||||||
function ActionBar:GetStateOption(key)
|
function ActionBar:GetStateOption(key)
|
||||||
return self.config.states[key]
|
return self.config.states[key]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -90,14 +90,9 @@ function Bartender4.Button:Create(id, parent)
|
|||||||
button:SetAttribute("action", absid)
|
button:SetAttribute("action", absid)
|
||||||
|
|
||||||
button:SetAttribute("useparent-unit", true)
|
button:SetAttribute("useparent-unit", true)
|
||||||
button:SetAttribute("useparent-statebutton", true)
|
|
||||||
--button:SetAttribute("hidestates", "-1")
|
--button:SetAttribute("hidestates", "-1")
|
||||||
|
|
||||||
parent:SetAttribute('_adopt', button)
|
parent:SetAttribute('_adopt', button)
|
||||||
button:SetAttribute('_childupdate', [[
|
|
||||||
self:SetAttribute("state", newBTState)
|
|
||||||
]]
|
|
||||||
)
|
|
||||||
|
|
||||||
button:RegisterForDrag("LeftButton", "RightButton")
|
button:RegisterForDrag("LeftButton", "RightButton")
|
||||||
button:RegisterForClicks("AnyUp")
|
button:RegisterForClicks("AnyUp")
|
||||||
@@ -197,12 +192,6 @@ end
|
|||||||
|
|
||||||
function Button:ClearStateAction()
|
function Button:ClearStateAction()
|
||||||
for state in pairs(self.stateactions) do
|
for state in pairs(self.stateactions) do
|
||||||
self:SetAttribute(("*type-S%d"):format(state), nil)
|
|
||||||
self:SetAttribute(("*action-S%d"):format(state), nil)
|
|
||||||
self:SetAttribute(("*action-S%dRight"):format(state), nil)
|
|
||||||
self:SetAttribute(("*macrotext-S%d"):format(state), nil)
|
|
||||||
self:SetAttribute(("*macrotext-S%dRight"):format(state), nil)
|
|
||||||
|
|
||||||
self.stateactions = {}
|
self.stateactions = {}
|
||||||
self.stateconfig = {}
|
self.stateconfig = {}
|
||||||
end
|
end
|
||||||
@@ -223,10 +212,11 @@ end
|
|||||||
function Button:RebuildStateFunction()
|
function Button:RebuildStateFunction()
|
||||||
local newFunc = "local config = newtable()\n"
|
local newFunc = "local config = newtable()\n"
|
||||||
for state, config in pairs(self.stateconfig) do
|
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)
|
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 or "", state)
|
||||||
end
|
end
|
||||||
newFunc = newFunc .. [[
|
newFunc = newFunc .. [[
|
||||||
local state = tonumber(newBTState)
|
local state = tonumber(newBTState)
|
||||||
|
self:SetAttribute("state", state)
|
||||||
self:SetAttribute("type", config[state].type)
|
self:SetAttribute("type", config[state].type)
|
||||||
self:SetAttribute("action", config[state].action)
|
self:SetAttribute("action", config[state].action)
|
||||||
self:SetAttribute("macrotext", config[state].macrotext)
|
self:SetAttribute("macrotext", config[state].macrotext)
|
||||||
@@ -237,7 +227,7 @@ end
|
|||||||
function Button:RefreshStateAction(state)
|
function Button:RefreshStateAction(state)
|
||||||
local state = tonumber(state or self:GetAttribute("state"))
|
local state = tonumber(state or self:GetAttribute("state"))
|
||||||
local action = self.stateactions[state]
|
local action = self.stateactions[state]
|
||||||
local config = { type = "action", action = action, macrotext = action }
|
local config = { type = "action", action = action, macrotext = nil }
|
||||||
|
|
||||||
if self.parent.config.autoassist then
|
if self.parent.config.autoassist then
|
||||||
local type, id, subtype = GetActionInfo(action)
|
local type, id, subtype = GetActionInfo(action)
|
||||||
|
|||||||
Reference in New Issue
Block a user