Added Custom Conditionals support and Config options

You can now enter any macro conditions into an editbox in the Config GUI which will feed the state driver. The syntax is not validated, so its your own responsibility to know how macro syntax works!
Example:
[form:1]9;0 -- Page to Bar 9 in Form 1, otherwise don't page at all (id 0)
This commit is contained in:
Hendrik Leppkes
2008-09-28 14:32:38 +02:00
parent 0b6b233ab0
commit 250f3d8a5b
2 changed files with 98 additions and 38 deletions
+53 -38
View File
@@ -43,7 +43,7 @@ local DefaultStanceMap = setmetatable({}, { __index = function(t,k)
} }
elseif k == "WARLOCK" then elseif k == "WARLOCK" then
newT = { newT = {
{ id = "metamorphosis", name = GetSpellInfo(59672), index = 2, type = "stance"}, { id = "metamorphosis", name = GetSpellInfo(59672), index = 2, type = "form"},
} }
end end
rawset(t, k, newT) rawset(t, k, newT)
@@ -55,7 +55,7 @@ Bartender4.StanceMap = DefaultStanceMap
local searchFunc = function(h, n) return (h.match == n or h.match2 == n or h.id == n) end local searchFunc = function(h, n) return (h.match == n or h.match2 == n or h.id == n) end
local stancemap local stancemap
function ActionBar:UpdateStates() function ActionBar:UpdateStates(returnOnly)
if not self.buttons then return end if not self.buttons then return end
self.statebutton = {} self.statebutton = {}
if not stancemap and DefaultStanceMap[playerclass] then if not stancemap and DefaultStanceMap[playerclass] then
@@ -63,51 +63,59 @@ function ActionBar:UpdateStates()
end end
self:ForAll("ClearStateAction") self:ForAll("ClearStateAction")
for i=0,10 do for i=0,11 do
self:AddButtonStates(i) self:AddButtonStates(i)
end end
local statedriver = {} local statedriver
if self:GetStateOption("possess") then
self:AddButtonStates(11)
table_insert(statedriver, "[bonusbar:5]11")
end
local stateconfig = self.config.states if returnOnly or not self:GetStateOption("customEnabled") then
if self:GetStateOption("enabled") then statedriver = {}
-- arguments will be parsed from left to right, so we have a priority here if self:GetStateOption("possess") then
table_insert(statedriver, "[bonusbar:5]11")
-- highest priority have our temporary quick-swap keys
for _,v in pairs(modifiers) do
local page = self:GetStateOption(v)
if page and page ~= 0 then
table_insert(statedriver, fmt("[modifier:%s]%s", v, page))
end
end end
-- second priority the manual changes using the actionbar options local stateconfig = self.config.states
if self:GetStateOption("actionbar") then if self:GetStateOption("enabled") then
for i=2,6 do -- arguments will be parsed from left to right, so we have a priority here
table_insert(statedriver, fmt("[actionbar:%s]%s", i, i))
-- highest priority have our temporary quick-swap keys
for _,v in pairs(modifiers) do
local page = self:GetStateOption(v)
if page and page ~= 0 then
table_insert(statedriver, fmt("[mod:%s]%s", v, page))
end
end end
end
-- second priority the manual changes using the actionbar options
-- third priority the stances if self:GetStateOption("actionbar") then
if stancemap then for i=2,6 do
if not stateconfig.stance[playerclass] then stateconfig.stance[playerclass] = {} end table_insert(statedriver, fmt("[bar:%s]%s", i, i))
for i,v in pairs(stancemap) do end
local state = self:GetStanceState(v) end
if state and state ~= 0 and v.index then
if playerclass == "DRUID" and v.id == "cat" then -- third priority the stances
local prowl = self:GetStanceState("prowl") if stancemap then
if prowl then if not stateconfig.stance[playerclass] then stateconfig.stance[playerclass] = {} end
table_insert(statedriver, fmt("[bonusbar:%s,stealth:1]%s", v.index, prowl)) for i,v in pairs(stancemap) do
local state = self:GetStanceState(v)
if state and state ~= 0 and v.index then
if playerclass == "DRUID" and v.id == "cat" then
local prowl = self:GetStanceState("prowl")
if prowl then
table_insert(statedriver, fmt("[bonusbar:%s,stealth:1]%s", v.index, prowl))
end
end end
table_insert(statedriver, fmt("[%s:%s]%s", v.type or "bonusbar", v.index, state))
end end
table_insert(statedriver, fmt("[%s:%s]%s", v.type or "bonusbar", v.index, state))
end end
end end
end end
table_insert(statedriver, tostring(self:GetDefaultState() or 0))
statedriver = table_concat(statedriver, ";")
else
statedriver = self:GetStateOption("custom")
end end
self:SetAttribute("_onstate-page", [[ self:SetAttribute("_onstate-page", [[
@@ -115,8 +123,9 @@ function ActionBar:UpdateStates()
control:ChildUpdate("state", newstate) control:ChildUpdate("state", newstate)
]]) ]])
table_insert(statedriver, tostring(self:GetDefaultState() or 0)) if not returnOnly then
RegisterStateDriver(self, "page", table_concat(statedriver, ";")) RegisterStateDriver(self, "page", statedriver or "")
end
self:SetAttribute("_onstate-assist-help", [[ self:SetAttribute("_onstate-assist-help", [[
local state = (newstate ~= "nil") and newstate or nil local state = (newstate ~= "nil") and newstate or nil
@@ -130,11 +139,13 @@ function ActionBar:UpdateStates()
local pre = "" local pre = ""
if Bartender4.db.profile.selfcastmodifier then if Bartender4.db.profile.selfcastmodifier then
pre = "[mod:"..GetModifiedClick("SELFCAST").."]player;" pre = "[mod:SELFCAST]player;"
end end
-- TODO: fix rightclick selfcast -- TODO: fix rightclick selfcast
RegisterStateDriver(self, "assist-help", ("%s[help]nil; [target=targettarget, help]targettarget; nil"):format(pre)) RegisterStateDriver(self, "assist-help", ("%s[help]nil; [target=targettarget, help]targettarget; nil"):format(pre))
RegisterStateDriver(self, "assist-harm", "[harm]nil; [target=targettarget, harm]targettarget; nil") RegisterStateDriver(self, "assist-harm", "[harm]nil; [target=targettarget, harm]targettarget; nil")
return statedriver
end end
function ActionBar:GetStanceState(stance) function ActionBar:GetStanceState(stance)
@@ -210,3 +221,7 @@ function ActionBar:SetConfigAutoAssist(_, value)
end end
self:ForAll("RefreshAllStateActions") self:ForAll("RefreshAllStateActions")
end end
function ActionBar:SetCopyCustomConditionals()
self.config.states.custom = self:UpdateStates(true)
end
+45
View File
@@ -15,6 +15,9 @@ do
actionbar = "StateOption", actionbar = "StateOption",
possess = "StateOption", possess = "StateOption",
autoassist = "ConfigAutoAssist", autoassist = "ConfigAutoAssist",
customEnabled = "StateOption",
custom = "StateOption",
customCopy = "CopyCustomConditionals",
} }
-- retrieves a valid bar object from the modules actionbars table -- retrieves a valid bar object from the modules actionbars table
function getBar(id) function getBar(id)
@@ -196,6 +199,48 @@ function module:GetStateOptionsTable()
}, },
}, },
}, },
customNl = {
order = 48,
type = "description",
name = "\n",
},
customHeader = {
order = 49,
type = "header",
name = L["Custom Conditionals"],
},
customEnabled = {
order = 50,
type = "toggle",
name = L["Use Custom Condition"],
desc = L["Enable the use of a custom condition, disabling all of the above."],
get = optGetter,
set = optSetter,
disabled = disabledFunc,
--width = "double",
},
customCopy = {
order = 51,
type = "execute",
name = "Copy Conditionals",
desc = "Create a copy of the auto-generated conditionals in the custom configuration as a base template",
func = optSetter,
},
customDesc = {
order = 52,
type = "description",
name = L["Note: Enabling Custom Conditionals will disable all of the above settings!"],
},
custom = {
order = 55,
type = "input",
name = L["Custom Conditionals"],
desc = L["You can use any macro conditionals in the custom string, using the number of the bar as target value.\nExample: [form:1]9;0"],
width = "full",
get = optGetter,
set = optSetter,
disabled = disabledFunc,
},
} }
do do