flickerstreak@25: --[[ flickerstreak@62: ReAction bar state driver interface flickerstreak@25: flickerstreak@25: --]] flickerstreak@25: flickerstreak@25: -- local imports flickerstreak@25: local ReAction = ReAction flickerstreak@25: local L = ReAction.L flickerstreak@25: local _G = _G flickerstreak@25: local InCombatLockdown = InCombatLockdown flickerstreak@25: flickerstreak@25: -- module declaration flickerstreak@25: local moduleID = "State" flickerstreak@25: local module = ReAction:NewModule( moduleID ) flickerstreak@25: flickerstreak@62: flickerstreak@62: -- module event handlers flickerstreak@25: function module:OnInitialize() flickerstreak@62: self.db = ReAction.db:RegisterNamespace( moduleID, flickerstreak@25: { flickerstreak@62: profile = { flickerstreak@62: bars = { }, flickerstreak@62: presets = { } flickerstreak@62: } flickerstreak@25: } flickerstreak@25: ) flickerstreak@62: self.states = { } flickerstreak@62: self.options = setmetatable({},{__mode="k"}) flickerstreak@25: end flickerstreak@25: flickerstreak@62: flickerstreak@62: flickerstreak@62: -- ReAction module interface flickerstreak@62: function module:ApplyToBar(bar) flickerstreak@62: self:RefreshBar(bar) flickerstreak@62: end flickerstreak@62: flickerstreak@62: function module:RefreshBar(bar) flickerstreak@62: local c = self.db.profile.bars[bar:GetName()] flickerstreak@62: if c then flickerstreak@62: --self:BuildStates(bar) flickerstreak@62: --self:BuildRules(bar) flickerstreak@62: end flickerstreak@62: end flickerstreak@62: flickerstreak@62: function module:RemoveFromBar(bar) flickerstreak@62: end flickerstreak@62: flickerstreak@62: function module:EraseBarConfig(barName) flickerstreak@62: self.db.profile.bars[barName] = nil flickerstreak@62: end flickerstreak@62: flickerstreak@62: function module:RenameBarConfig(oldname, newname) flickerstreak@62: local b = self.db.profile.bars flickerstreak@62: bars[newname], bars[oldname] = bars[oldname], nil flickerstreak@62: end flickerstreak@62: flickerstreak@62: function module:ApplyConfigMode(mode,bars) flickerstreak@62: -- swap out hidestates flickerstreak@62: end flickerstreak@62: flickerstreak@62: flickerstreak@62: flickerstreak@62: flickerstreak@62: -- Private -- flickerstreak@62: flickerstreak@62: -- traverse a table tree by key list and fetch the result or first nil flickerstreak@62: local function tfetch(t, ...) flickerstreak@62: for i = 1, select('#', ...) do flickerstreak@62: t = t and t[select(i, ...)] flickerstreak@62: end flickerstreak@62: return t flickerstreak@62: end flickerstreak@62: flickerstreak@62: -- traverse a table tree by key list and build tree as necessary flickerstreak@62: local function tbuild(t, ...) flickerstreak@62: for i = 1, select('#', ...) do flickerstreak@62: local key = select(i, ...) flickerstreak@62: if not t[key] then t[key] = { } end flickerstreak@62: t = t[key] flickerstreak@62: end flickerstreak@62: return t flickerstreak@62: end flickerstreak@62: flickerstreak@62: flickerstreak@62: local rules flickerstreak@62: local BuildRuleString flickerstreak@62: do flickerstreak@62: local function ClassCheck(...) flickerstreak@62: for i = 1, select('#',...) do flickerstreak@62: local _, c = UnitClass("player") flickerstreak@62: if c == select(i,...) then flickerstreak@62: return false flickerstreak@62: end flickerstreak@62: end flickerstreak@62: return true flickerstreak@62: end flickerstreak@62: flickerstreak@62: -- The structure of this table is important: each row is designed to be unpack()ed flickerstreak@62: -- into variables as defined in the header comment row. flickerstreak@62: -- The 'fields' subtable (index 4) structure is also important: its subtables flickerstreak@62: -- are ordered to match appearances of '%s' (string-substitutions) in the corresponding flickerstreak@62: -- rules[] format-string entry. Each subtable's single element's key is the storage key used flickerstreak@62: -- in the user db, and the name of the group-element table in the config tree, so it too flickerstreak@62: -- is important. flickerstreak@62: -- flickerstreak@62: -- While this allows for very compact code and data storage, the scheme is admittedly obtuse, flickerstreak@62: -- so I document it here for my own sanity. flickerstreak@62: -- flickerstreak@62: rules = { flickerstreak@62: -- rule name hidden fields flickerstreak@62: { "stance", L["Warrior Stance"], ClassCheck("WARRIOR"), { {battle = L["Battle Stance"]}, {defensive = L["Defensive Stance"]}, {berserker = L["Berserker Stance"]} } }, flickerstreak@62: { "form", L["Druid Form"], ClassCheck("DRUID"), { {bear = L["Bear"]}, {cat = L["Cat"]}, {treeOrMoonkin = L["Tree/Moonkin"]}, {caster = L["Normal"]}, } }, flickerstreak@62: { "stealth", L["Stealth"], ClassCheck("ROGUE","DRUID"), { {stealth = L["Stealth"]}, {normal = L["Normal"]} } }, flickerstreak@62: { "shadow", L["Shadowform"], ClassCheck("PRIEST"), { {shadowform = L["Shadowform"]}, {normal = L["Normal"]} } }, flickerstreak@62: { "pet", L["Pet"], ClassCheck("HUNTER","WARLOCK"), { {pet = L["With Pet"]}, {nopet = L["Without Pet"]} } }, flickerstreak@62: { "target", L["Target"], false, { {hostile = L["Hostile Target"]}, {friendly = L["Friendly Target"]}, {none = L["No Target"]} } }, flickerstreak@62: { "focus", L["Focus"], false, { {hostile = L["Hostile Focus"]}, {friendly = L["Friendly Focus"]}, {none = L["No Focus"]} } }, flickerstreak@62: { "group", L["In Group"], false, { {raid = L["Raid"]}, {party = L["Party"]}, {solo = L["Solo"]} } }, flickerstreak@62: { "key", L["Key Press"], false, { {state = L["On Key Press"]}, {keybinding = false} } }, -- keybinding has no state-selector, it's implemented elsewhere flickerstreak@62: { "combat", L["Combat"], false, { {combat = L["In Combat"]}, {nocombat = L["Out of Combat"]} } }, flickerstreak@62: { "custom", L["Custom"], false, { {rule = false} } }, -- custom has no state-selector, it's implemented elsewhere flickerstreak@62: } flickerstreak@62: flickerstreak@62: do flickerstreak@62: local forms = { } flickerstreak@62: for i = 1, GetNumShapeshiftForms() do flickerstreak@62: local icon, name = GetShapeshiftFormInfo(i) flickerstreak@62: -- TODO: need to find out if name is localized, it probably is flickerstreak@62: forms[name] = i; flickerstreak@62: end flickerstreak@62: local dStance = forms["Defensive Stance"] or 2 flickerstreak@62: local zStance = forms["Berserker Stance"] or 3 flickerstreak@62: local bForm = forms["Dire Bear Form"] or forms["Bear Form"] or 1 flickerstreak@62: local cForm = forms["Cat Form"] or 3 flickerstreak@62: local tForm = forms["Tree of Life"] or forms["Moonkin Form"] or 5 flickerstreak@62: flickerstreak@62: -- TODO: do the macro conditional strings need to be localized? flickerstreak@62: local ruleformats = { flickerstreak@62: stance = ("[stance:1] %%s; [stance:%d] %%s; [stance:%d] %%s"):format(dStance,zStance), flickerstreak@62: form = ("[form:%d] %%s; [form:%d] %%s; [form:%d] %%s; %%s"):format(bForm,cForm,tForm), flickerstreak@62: stealth = "[stealth] %s; %s", flickerstreak@62: shadow = "[stance:1] %s; %s", flickerstreak@62: pet = "[pet] %s; %s", flickerstreak@62: target = "[harm] %s; [help] %s; %s", flickerstreak@62: focus = "[target=focus,harm] %s; [target=focus,help] %s; %s", flickerstreak@62: group = "[group:raid] %s; [group] %s; %s", flickerstreak@62: combat = "[combat] %s; %s", flickerstreak@62: custom = "%s", flickerstreak@62: } flickerstreak@62: flickerstreak@62: local fieldmap = { } flickerstreak@62: for i = 1, #rules do flickerstreak@62: fieldmap[rules[i][1]] = rules[i][4] flickerstreak@62: end flickerstreak@62: flickerstreak@62: local _scratch = { } flickerstreak@62: function BuildRuleString(bar, name) flickerstreak@62: local rule, data = module:GetRule(bar,name) flickerstreak@62: if not rule then return "" end flickerstreak@62: local fields = fieldmap[rule] flickerstreak@62: for i = 1, #fields do flickerstreak@62: _scratch[i] = data[next(fields[i])] -- TODO: insert default state here flickerstreak@62: end flickerstreak@62: for i = #fields+1, #_scratch do flickerstreak@62: _scratch[i] = nil flickerstreak@62: end flickerstreak@62: local success, value = pcall(string.format, ruleformats[rule], unpack(_scratch)) flickerstreak@62: return success and value or "" flickerstreak@62: end flickerstreak@62: end flickerstreak@62: flickerstreak@25: flickerstreak@25: end flickerstreak@25: flickerstreak@25: flickerstreak@62: flickerstreak@62: -- API -- flickerstreak@62: flickerstreak@62: function module:BuildStates( bar ) flickerstreak@62: local c = tfetch(self.db.profile.bars, bar:GetName(), "states") flickerstreak@62: if c then flickerstreak@62: for name, s in pairs(c) do flickerstreak@62: -- TODO: new state here flickerstreak@62: end flickerstreak@62: end flickerstreak@25: end flickerstreak@25: flickerstreak@62: function module:CreateState( bar, name ) flickerstreak@62: local c = tbuild(self.db.profile.bars, bar:GetName(), "states") flickerstreak@62: if c[name] then flickerstreak@62: ReAction:UserError(L["State named '%s' already exists"]:format(name)) flickerstreak@62: else flickerstreak@62: c[name] = { } flickerstreak@62: -- TODO: new state here flickerstreak@62: end flickerstreak@62: end flickerstreak@25: flickerstreak@62: function module:DeleteState( bar, name ) flickerstreak@62: local c = tfetch(self.db.profile.bars, bar:GetName(), "states") flickerstreak@62: if c[name] then flickerstreak@62: -- TODO: delete state flickerstreak@62: c[name] = nil flickerstreak@62: end flickerstreak@62: end flickerstreak@25: flickerstreak@62: function module:BuildRules( bar ) flickerstreak@62: for bar, c in pairs(self.db.profile.bars) do flickerstreak@62: if c.rules then flickerstreak@62: for name, t in pairs(c.rules) do flickerstreak@62: local rule, config = next(t) flickerstreak@62: self:SetRule(bar, name, rule, config) flickerstreak@62: end flickerstreak@62: end flickerstreak@62: end flickerstreak@62: end flickerstreak@25: flickerstreak@62: function module:CreateRule( bar, name, rule, config ) flickerstreak@62: local c = tbuild(self.db.profile.bars, bar:GetName(), "rules") flickerstreak@62: if c[name] then flickerstreak@62: ReAction:UserError(L["Rule named '%s' already exists"]:format(name)) flickerstreak@62: else flickerstreak@62: tbuild(self.db.profile.bars, bar:GetName(), "rules", name) flickerstreak@62: if rule then flickerstreak@62: self:SetRule(bar,name,rule,config) flickerstreak@62: end flickerstreak@62: end flickerstreak@62: end flickerstreak@62: flickerstreak@62: function module:DeleteRule( bar, name ) flickerstreak@62: local c = tfetch(self.db.profile.bars, bar:GetName(), "rules") flickerstreak@62: if c[name] then flickerstreak@62: local f = bar:GetFrame() flickerstreak@62: -- TODO: delete rule flickerstreak@62: c[name] = nil flickerstreak@62: end flickerstreak@62: end flickerstreak@62: flickerstreak@62: function module:UpdateRule( bar, name ) flickerstreak@62: local rule, c = self:GetRule(bar,name) flickerstreak@62: -- TODO: remove all relevant outdated attributes flickerstreak@62: -- TODO: set new attributes flickerstreak@62: end flickerstreak@62: flickerstreak@62: function module:GetRule(bar, name) flickerstreak@62: local c = tfetch(self.db.profile.bars, bar:GetName(), "rules", name) flickerstreak@62: if c then flickerstreak@62: return next(c) -- returns key, value (= rulename, configtable) flickerstreak@62: end flickerstreak@62: end flickerstreak@62: flickerstreak@62: function module:SetRule(bar, name, rule, config) flickerstreak@62: tbuild(self.db.profile.bars, bar:GetName(), "rules")[name] = { [rule] = (config or {}) } flickerstreak@62: self:UpdateRule(bar,name) flickerstreak@62: end flickerstreak@62: flickerstreak@62: flickerstreak@62: -- options -- flickerstreak@62: local CreateBarOptions flickerstreak@62: do flickerstreak@62: local function GetRuleConfig(bar, name, rule, field) flickerstreak@62: return tfetch(module.db.profile.bars, bar:GetName(), "rules", name, rule, field) flickerstreak@62: end flickerstreak@62: flickerstreak@62: local function SetRuleConfig( bar, name, rule, field, value ) flickerstreak@62: tbuild(module.db.profile.bars, bar:GetName(), "rules", name, rule)[field] = value flickerstreak@62: end flickerstreak@62: flickerstreak@62: local function CreateStateOptions(bar, name) flickerstreak@62: return { flickerstreak@62: type = "group", flickerstreak@62: name = name, flickerstreak@62: args = { flickerstreak@62: -- show/hide would go here flickerstreak@62: -- page # would go here flickerstreak@62: -- anchoring would go here flickerstreak@62: __delete__ = { flickerstreak@62: type = "execute", flickerstreak@62: name = L["Delete this State"], flickerstreak@62: func = function(info) flickerstreak@62: module:DeleteState(bar,name) flickerstreak@62: module.options[bar].args.states.args[name] = nil flickerstreak@62: end, flickerstreak@62: order = -1 flickerstreak@62: }, flickerstreak@62: } flickerstreak@62: } flickerstreak@62: end flickerstreak@62: flickerstreak@62: flickerstreak@62: -- display rule string setting is shared between all rule opts and is transient flickerstreak@62: -- (mostly used for debugging) flickerstreak@62: local display = { show = false } flickerstreak@62: flickerstreak@62: local function CreateRuleOptions(bar, name) flickerstreak@62: local function get(info) flickerstreak@62: local rule = info[#info-1] flickerstreak@62: local field = info[#info] flickerstreak@62: return GetRuleConfig(bar,name,rule,field) or "" flickerstreak@25: end flickerstreak@25: flickerstreak@62: local function set(info, value) flickerstreak@62: local rule = info[#info-1] flickerstreak@62: local field = info[#info] flickerstreak@62: SetRuleConfig(bar,name,rule,field,value) flickerstreak@62: module:UpdateRule(bar,name) flickerstreak@62: end flickerstreak@25: flickerstreak@62: local opts = { flickerstreak@62: type = "group", flickerstreak@62: name = name, flickerstreak@62: childGroups = "inline", flickerstreak@62: args = { flickerstreak@62: __select__ = { flickerstreak@62: type = "select", flickerstreak@62: name = L["Select Rule Type"], flickerstreak@62: get = function(info) return module:GetRule(bar,name) or "" end, flickerstreak@62: set = function(info,value) module:SetRule(bar,name,value) end, -- TODO: get default rule config and pass as final value flickerstreak@62: values = function() flickerstreak@62: local v = { } flickerstreak@62: for i = 1, #rules do flickerstreak@62: local rule, name, hidden = unpack(rules[i]) flickerstreak@62: if not hidden then flickerstreak@62: v[rule] = name flickerstreak@62: end flickerstreak@62: end flickerstreak@62: return v flickerstreak@62: end, flickerstreak@62: order = 1, flickerstreak@62: }, flickerstreak@62: __delete__ = { flickerstreak@62: type = "execute", flickerstreak@62: name = L["Delete this Rule"], flickerstreak@62: func = function(info) flickerstreak@62: module:DeleteRule(bar,name) flickerstreak@62: module.options[bar].args.rules.args[name] = nil flickerstreak@62: end, flickerstreak@62: order = -3 flickerstreak@62: }, flickerstreak@62: -- flickerstreak@62: -- rule selection groups will be inserted here flickerstreak@62: -- flickerstreak@62: __show__ = { flickerstreak@62: type = "toggle", flickerstreak@62: name = L["Show Rule String"], flickerstreak@62: desc = L["Toggles display of the raw rule string"], flickerstreak@62: get = function() return display.show end, flickerstreak@62: set = function(info,value) display.show = value end, flickerstreak@62: order = -2 flickerstreak@62: }, flickerstreak@62: __rule__ = { flickerstreak@62: type = "input", flickerstreak@62: name = L["Rule String"], flickerstreak@62: disabled = true, flickerstreak@62: multiline = true, flickerstreak@62: width = "double", flickerstreak@62: hidden = function() return not display.show end, flickerstreak@62: get = function() return BuildRuleString(bar,name) end, flickerstreak@62: set = function() end, flickerstreak@62: order = -1 flickerstreak@25: } flickerstreak@25: } flickerstreak@25: } flickerstreak@62: flickerstreak@62: -- unpack rules table flickerstreak@62: for i = 1, #rules do flickerstreak@62: local rule, label, _, fields = unpack(rules[i]) flickerstreak@62: local hidden = function() flickerstreak@62: return module:GetRule(bar,name) ~= rule flickerstreak@62: end flickerstreak@62: opts.args[rule] = { flickerstreak@62: type = "group", flickerstreak@62: name = label, flickerstreak@62: hidden = hidden, flickerstreak@62: disabled = hidden, flickerstreak@62: inline = true, flickerstreak@62: args = { } flickerstreak@62: } flickerstreak@62: for j = 1, #fields do flickerstreak@62: local field, label = next(fields[j]) -- extract from table of single key-value pair flickerstreak@62: if field and label then flickerstreak@62: opts.args[rule].args[field] = { flickerstreak@62: type = "select", flickerstreak@62: name = L["Select State (%s):"]:format(label), flickerstreak@62: values = function () flickerstreak@62: local states = tfetch(module.db.profile.bars,bar:GetName(),"states") flickerstreak@62: local v = { } flickerstreak@62: if states then flickerstreak@62: for k in pairs(states) do flickerstreak@62: v[k] = k flickerstreak@62: end flickerstreak@62: end flickerstreak@62: return v flickerstreak@62: end, flickerstreak@62: set = set, flickerstreak@62: get = get, flickerstreak@62: order = 100 + j flickerstreak@62: } flickerstreak@62: end flickerstreak@62: end flickerstreak@62: end flickerstreak@62: flickerstreak@62: -- set up special entry for keybinding flickerstreak@62: opts.args.key.args.binding = { flickerstreak@62: type = "keybinding", flickerstreak@62: name = L["Key Binding"], flickerstreak@62: get = get, flickerstreak@62: set = set, flickerstreak@62: order = -1 flickerstreak@62: } flickerstreak@62: flickerstreak@62: -- set up special entry for custom flickerstreak@62: opts.args.custom.args.rule = { flickerstreak@62: type = "input", flickerstreak@62: name = L["Rule"], flickerstreak@62: desc = L["Syntax like macro conditions: see preset rules for examples"], flickerstreak@62: get = get, flickerstreak@62: set = set, flickerstreak@62: validate = function (info, rule) flickerstreak@62: local s = rule:gsub("%s","") -- remove all spaces flickerstreak@62: if s:match(";$") then -- can't end with semicolon flickerstreak@62: return L["Invalid custom rule '%s': Rule cannot end with ';'"]:format(rule) flickerstreak@62: end flickerstreak@62: if s == "" then flickerstreak@62: return true flickerstreak@62: end flickerstreak@62: -- unfortunately %b and captures don't support the '+' notation, or this would be considerably simpler flickerstreak@62: repeat flickerstreak@62: repeat flickerstreak@62: local c, r = s:match("(%b[])(.*)") flickerstreak@62: if r then s = r end flickerstreak@62: until c == nil flickerstreak@62: local state, s = s:match("(%w+)(.*)") flickerstreak@62: if not state then flickerstreak@62: return L["Invalid custom rule '%s': Each expression must have a state"]:format(rule) flickerstreak@62: end flickerstreak@62: if not tfetch(module.db.profile.bars,bar:GetName(),"states",state) then flickerstreak@62: return L["Invalid custom rule '%s': '%s' is not a state"]:format(rule,state) flickerstreak@62: end flickerstreak@62: if s:match("^[^;]") then flickerstreak@62: return L["Invalid custom rule '%s': Expressions must be separated by ';'"]:format(rule) flickerstreak@62: end flickerstreak@62: until #s == 0 flickerstreak@62: return true flickerstreak@62: end, flickerstreak@62: multiline = true, flickerstreak@62: order = 1, flickerstreak@62: } flickerstreak@62: flickerstreak@62: return opts flickerstreak@25: end flickerstreak@62: flickerstreak@62: CreateBarOptions = function(bar) flickerstreak@62: local private = { } flickerstreak@62: local options = { flickerstreak@62: type = "group", flickerstreak@62: name = L["Dynamic State"], flickerstreak@62: childGroups = "tab", flickerstreak@62: disabled = InCombatLockdown, flickerstreak@62: args = { flickerstreak@62: states = { flickerstreak@62: type = "group", flickerstreak@62: name = L["States"], flickerstreak@62: childGroups = "tree", flickerstreak@62: order = 1, flickerstreak@62: args = { flickerstreak@62: __new__ = { flickerstreak@62: type = "group", flickerstreak@62: name = L["New State..."], flickerstreak@62: order = 1, flickerstreak@62: args = { flickerstreak@62: name = { flickerstreak@62: type = "input", flickerstreak@62: name = L["State Name"], flickerstreak@62: desc = L["Set a name for the new state"], flickerstreak@62: get = function() return private.newstatename or "" end, flickerstreak@62: set = function(info,value) private.newstatename = value end, flickerstreak@62: pattern = "^%w*$", flickerstreak@62: usage = L["State names must be alphanumeric without spaces"], flickerstreak@62: order = 1 flickerstreak@62: }, flickerstreak@62: create = { flickerstreak@62: type = "execute", flickerstreak@62: name = L["Create State"], flickerstreak@62: func = function () flickerstreak@62: local name = private.newstatename flickerstreak@62: module:CreateState(bar,name) -- TODO: select default state options and pass as final argument flickerstreak@62: module.options[bar].args.states.args[name] = CreateStateOptions(bar,name) flickerstreak@62: private.newstatename = "" flickerstreak@62: end, flickerstreak@62: disabled = function() flickerstreak@62: local name = private.newstatename or "" flickerstreak@62: return #name == 0 or name:find("%W") flickerstreak@62: end, flickerstreak@62: order = 2, flickerstreak@62: } flickerstreak@62: } flickerstreak@62: } flickerstreak@62: } flickerstreak@62: }, flickerstreak@62: rules = { flickerstreak@62: type = "group", flickerstreak@62: name = L["Transition Rules"], flickerstreak@62: childGroups = "tree", flickerstreak@62: order = 2, flickerstreak@62: args = { flickerstreak@62: __new__ = { flickerstreak@62: type = "group", flickerstreak@62: name = L["New Rule..."], flickerstreak@62: order = 1, flickerstreak@62: args = { flickerstreak@62: name = { flickerstreak@62: type = "input", flickerstreak@62: name = L["Rule Name"], flickerstreak@62: desc = L["Set a name for the new transition rule"], flickerstreak@62: get = function() return private.newtransname or "" end, flickerstreak@62: set = function(info,value) private.newtransname = value end, flickerstreak@62: pattern = "^%w*$", flickerstreak@62: usage = L["Rule names must be alphanumeric without spaces"], flickerstreak@62: order = 1 flickerstreak@62: }, flickerstreak@62: create = { flickerstreak@62: type = "execute", flickerstreak@62: name = L["Create Rule"], flickerstreak@62: func = function () flickerstreak@62: local name = private.newtransname flickerstreak@62: module:CreateRule(bar,name) -- TODO: select default rule and add as final argument flickerstreak@62: module.options[bar].args.rules.args[name] = CreateRuleOptions(bar,name) flickerstreak@62: private.newtransname = "" flickerstreak@62: end, flickerstreak@62: disabled = function () flickerstreak@62: local name = private.newtransname or "" flickerstreak@62: return #name == 0 or name:find("%W") flickerstreak@62: end, flickerstreak@62: order = 2, flickerstreak@62: }, flickerstreak@62: } flickerstreak@62: } flickerstreak@62: } flickerstreak@62: }, flickerstreak@62: presets = { flickerstreak@62: type = "group", flickerstreak@62: name = L["Presets"], flickerstreak@62: order = 3, flickerstreak@62: args = { flickerstreak@62: desc = { flickerstreak@62: type = "description", flickerstreak@62: name = L["Presets are canned sets of states and transitions. You can create your own presets to add to ReAction's built in defaults."], flickerstreak@62: order = 1, flickerstreak@62: }, flickerstreak@62: select = { flickerstreak@62: type = "select", flickerstreak@62: name = L["Select Preset"], flickerstreak@62: set = function(info,value) end, flickerstreak@62: get = function() return "" end, flickerstreak@62: values = function() return { } end, flickerstreak@62: order = 2, flickerstreak@62: }, flickerstreak@62: load = { flickerstreak@62: type = "execute", flickerstreak@62: name = L["Load"], flickerstreak@62: func = function() end, flickerstreak@62: width = "half", flickerstreak@62: order = 3, flickerstreak@62: }, flickerstreak@62: delete = { flickerstreak@62: type = "execute", flickerstreak@62: name = L["Delete"], flickerstreak@62: disabled = function() return false end, flickerstreak@62: func = function() end, flickerstreak@62: width = "half", flickerstreak@62: order = 4, flickerstreak@62: }, flickerstreak@62: hdr = { flickerstreak@62: type = "header", flickerstreak@62: name = " ", flickerstreak@62: order = 5, flickerstreak@62: }, flickerstreak@62: save = { flickerstreak@62: type = "input", flickerstreak@62: name = L["Save As..."], flickerstreak@62: get = function() return "" end, flickerstreak@62: set = function(info,name) end, flickerstreak@62: order = 6, flickerstreak@62: }, flickerstreak@62: }, flickerstreak@62: }, flickerstreak@62: } flickerstreak@62: } flickerstreak@62: local states = tfetch(module.db.profile.bars, bar:GetName(), "states") flickerstreak@62: if states then flickerstreak@62: for name, config in pairs(states) do flickerstreak@62: options.args.states.args[name] = CreateStateOptions(bar,name) flickerstreak@62: end flickerstreak@62: end flickerstreak@62: local rules = tfetch(module.db.profile.bars, bar:GetName(), "rules") flickerstreak@62: if rules then flickerstreak@62: for name, config in pairs(rules) do flickerstreak@62: options.args.rules.args[name] = CreateRuleOptions(bar,name) flickerstreak@62: end flickerstreak@62: end flickerstreak@62: return options flickerstreak@62: end flickerstreak@25: end flickerstreak@25: flickerstreak@62: function module:GetBarOptions(bar) flickerstreak@62: if not self.options[bar] then flickerstreak@62: self.options[bar] = CreateBarOptions(bar) flickerstreak@62: end flickerstreak@62: return self.options[bar] flickerstreak@25: end