flickerstreak@175: local addonName, addonTable = ... flickerstreak@175: local ReAction = addonTable.ReAction flickerstreak@24: local L = ReAction.L flickerstreak@24: local _G = _G flickerstreak@24: local CreateFrame = CreateFrame flickerstreak@88: local format = string.format flickerstreak@92: local wipe = wipe flickerstreak@24: flickerstreak@116: local weak = { __mode="k" } flickerstreak@116: flickerstreak@24: -- module declaration flickerstreak@24: local moduleID = "Action" flickerstreak@28: local module = ReAction:NewModule( moduleID ) flickerstreak@24: flickerstreak@90: -- Class declarations flickerstreak@128: local Button = ReAction.Button.Action -- see /classes/ActionButton.lua flickerstreak@90: local Handle = { } flickerstreak@90: local PropHandler = { } flickerstreak@87: flickerstreak@77: -- Event handlers flickerstreak@24: function module:OnInitialize() flickerstreak@28: self.db = ReAction.db:RegisterNamespace( moduleID, flickerstreak@24: { flickerstreak@28: profile = { flickerstreak@75: bars = { }, flickerstreak@28: } flickerstreak@24: } flickerstreak@24: ) flickerstreak@90: self.handles = setmetatable({ }, weak) flickerstreak@49: flickerstreak@63: ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") flickerstreak@63: flickerstreak@90: ReAction.RegisterCallback(self, "OnCreateBar") flickerstreak@90: ReAction.RegisterCallback(self, "OnRefreshBar") flickerstreak@63: ReAction.RegisterCallback(self, "OnDestroyBar") flickerstreak@63: ReAction.RegisterCallback(self, "OnEraseBar") flickerstreak@63: ReAction.RegisterCallback(self, "OnRenameBar") flickerstreak@24: end flickerstreak@24: flickerstreak@24: function module:OnEnable() flickerstreak@53: ReAction:RegisterBarType(L["Action Bar"], flickerstreak@53: { flickerstreak@53: type = moduleID, flickerstreak@91: defaultButtonSize = 36, flickerstreak@53: defaultBarRows = 1, flickerstreak@53: defaultBarCols = 12, flickerstreak@53: defaultBarSpacing = 3 flickerstreak@53: }, true) flickerstreak@90: ReAction:GetModule("State"):RegisterStateProperty("page", nil, PropHandler.GetOptions(), PropHandler) flickerstreak@24: end flickerstreak@24: flickerstreak@24: function module:OnDisable() flickerstreak@53: ReAction:UnregisterBarType(L["Action Bar"]) flickerstreak@90: ReAction:GetModule("State"):UnregisterStateProperty("page") flickerstreak@90: end flickerstreak@90: flickerstreak@90: function module:OnCreateBar(event, bar, name) flickerstreak@90: if bar.config.type == moduleID then flickerstreak@90: local profile = self.db.profile flickerstreak@90: if profile.bars[name] == nil then flickerstreak@90: profile.bars[name] = { flickerstreak@90: buttons = { } flickerstreak@90: } flickerstreak@90: end flickerstreak@90: if self.handles[bar] == nil then flickerstreak@90: self.handles[bar] = Handle:New(bar, profile.bars[name]) flickerstreak@90: end flickerstreak@90: end flickerstreak@24: end flickerstreak@24: flickerstreak@63: function module:OnRefreshBar(event, bar, name) flickerstreak@90: if self.handles[bar] then flickerstreak@90: self.handles[bar]:Refresh() flickerstreak@24: end flickerstreak@24: end flickerstreak@24: flickerstreak@63: function module:OnDestroyBar(event, bar, name) flickerstreak@90: if self.handles[bar] then flickerstreak@90: self.handles[bar]:Destroy() flickerstreak@90: self.handles[bar] = nil flickerstreak@24: end flickerstreak@24: end flickerstreak@24: flickerstreak@63: function module:OnEraseBar(event, bar, name) flickerstreak@75: self.db.profile.bars[name] = nil flickerstreak@24: end flickerstreak@24: flickerstreak@63: function module:OnRenameBar(event, bar, oldname, newname) flickerstreak@75: b = self.db.profile.bars flickerstreak@75: b[newname], b[oldname] = b[oldname], nil flickerstreak@48: end flickerstreak@48: flickerstreak@90: ---- Interface ---- flickerstreak@90: function module:GetBarOptions(bar) flickerstreak@90: local h = self.handles[bar] flickerstreak@90: if h then flickerstreak@90: return h:GetOptions() flickerstreak@90: end flickerstreak@90: end flickerstreak@90: flickerstreak@90: flickerstreak@90: ---- Bar Handle ---- flickerstreak@90: flickerstreak@87: do flickerstreak@87: local options = { flickerstreak@87: hideEmpty = { flickerstreak@87: name = L["Hide Empty Buttons"], flickerstreak@87: order = 1, flickerstreak@87: type = "toggle", flickerstreak@87: width = "double", flickerstreak@87: get = "GetHideEmpty", flickerstreak@87: set = "SetHideEmpty", flickerstreak@87: }, flickerstreak@102: lockButtons = { flickerstreak@102: name = L["Lock Buttons"], flickerstreak@147: desc = L["Prevents picking up/dragging actions (use SHIFT to override this behavior)"], flickerstreak@102: order = 2, flickerstreak@102: type = "toggle", flickerstreak@102: get = "GetLockButtons", flickerstreak@102: set = "SetLockButtons", flickerstreak@102: }, flickerstreak@102: lockOnlyCombat = { flickerstreak@102: name = L["Only in Combat"], flickerstreak@102: desc = L["Only lock the buttons when in combat"], flickerstreak@102: order = 3, flickerstreak@102: type = "toggle", flickerstreak@102: disabled = "LockButtonsCombatDisabled", flickerstreak@102: get = "GetLockButtonsCombat", flickerstreak@102: set = "SetLockButtonsCombat", flickerstreak@102: }, flickerstreak@87: pages = { flickerstreak@87: name = L["# Pages"], flickerstreak@87: desc = L["Use the Dynamic State tab to specify page transitions"], flickerstreak@102: order = 4, flickerstreak@87: type = "range", flickerstreak@87: min = 1, flickerstreak@87: max = 10, flickerstreak@87: step = 1, flickerstreak@87: get = "GetNumPages", flickerstreak@87: set = "SetNumPages", flickerstreak@87: }, flickerstreak@90: mindcontrol = { flickerstreak@90: name = L["Mind Control Support"], flickerstreak@90: desc = L["When possessing a target (e.g. via Mind Control), map the first 12 buttons of this bar to the possessed target's actions."], flickerstreak@102: order = 5, flickerstreak@90: type = "toggle", flickerstreak@90: width = "double", flickerstreak@90: set = "SetMindControl", flickerstreak@90: get = "GetMindControl", flickerstreak@90: }, flickerstreak@121: vehicle = { flickerstreak@121: name = L["Vehicle Support"], flickerstreak@121: desc = L["When on a vehicle, map the first 6 buttons of this bar to the vehicle actions. The vehicle-exit button is mapped to the 7th button. Pitch controls are not supported."], flickerstreak@121: order = 6, flickerstreak@121: type = "toggle", flickerstreak@121: width = "double", flickerstreak@121: get = "GetVehicle", flickerstreak@121: set = "SetVehicle", flickerstreak@121: }, flickerstreak@87: actions = { flickerstreak@87: name = L["Edit Action IDs"], flickerstreak@121: order = 7, flickerstreak@87: type = "group", flickerstreak@87: inline = true, flickerstreak@87: args = { flickerstreak@87: method = { flickerstreak@87: name = L["Assign"], flickerstreak@87: order = 1, flickerstreak@87: type = "select", flickerstreak@87: width = "double", flickerstreak@87: values = { [0] = L["Choose Method..."], flickerstreak@87: [1] = L["Individually"], flickerstreak@87: [2] = L["All at Once"], }, flickerstreak@87: get = "GetActionEditMethod", flickerstreak@87: set = "SetActionEditMethod", flickerstreak@87: }, flickerstreak@87: rowSelect = { flickerstreak@87: name = L["Row"], flickerstreak@87: desc = L["Rows are numbered top to bottom"], flickerstreak@87: order = 2, flickerstreak@87: type = "select", flickerstreak@87: width = "half", flickerstreak@87: hidden = "IsButtonSelectHidden", flickerstreak@87: values = "GetRowList", flickerstreak@87: get = "GetSelectedRow", flickerstreak@87: set = "SetSelectedRow", flickerstreak@87: }, flickerstreak@87: colSelect = { flickerstreak@87: name = L["Col"], flickerstreak@87: desc = L["Columns are numbered left to right"], flickerstreak@87: order = 3, flickerstreak@87: type = "select", flickerstreak@87: width = "half", flickerstreak@87: hidden = "IsButtonSelectHidden", flickerstreak@87: values = "GetColumnList", flickerstreak@87: get = "GetSelectedColumn", flickerstreak@87: set = "SetSelectedColumn", flickerstreak@87: }, flickerstreak@87: pageSelect = { flickerstreak@87: name = L["Page"], flickerstreak@87: order = 4, flickerstreak@87: type = "select", flickerstreak@87: width = "half", flickerstreak@87: hidden = "IsPageSelectHidden", flickerstreak@87: values = "GetPageList", flickerstreak@87: get = "GetSelectedPage", flickerstreak@87: set = "SetSelectedPage", flickerstreak@87: }, flickerstreak@87: single = { flickerstreak@87: name = L["Action ID"], flickerstreak@87: usage = L["Specify ID 1-120"], flickerstreak@87: order = 5, flickerstreak@87: type = "input", flickerstreak@87: width = "half", flickerstreak@87: hidden = "IsButtonSelectHidden", flickerstreak@87: get = "GetActionID", flickerstreak@87: set = "SetActionID", flickerstreak@87: validate = "ValidateActionID", flickerstreak@87: }, flickerstreak@87: multi = { flickerstreak@87: name = L["ID List"], flickerstreak@87: usage = L["Specify a comma-separated list of IDs for each button in the bar (in order). Separate multiple pages with semicolons (;)"], flickerstreak@87: order = 6, flickerstreak@87: type = "input", flickerstreak@87: multiline = true, flickerstreak@87: width = "double", flickerstreak@87: hidden = "IsMultiIDHidden", flickerstreak@87: get = "GetMultiID", flickerstreak@87: set = "SetMultiID", flickerstreak@87: validate = "ValidateMultiID", flickerstreak@90: }, flickerstreak@90: }, flickerstreak@87: }, flickerstreak@87: } flickerstreak@77: flickerstreak@90: local meta = { __index = Handle } flickerstreak@90: flickerstreak@90: function Handle:New( bar, config ) flickerstreak@90: local self = setmetatable( flickerstreak@90: { flickerstreak@90: bar = bar, flickerstreak@90: config = config, flickerstreak@90: btns = { } flickerstreak@90: }, flickerstreak@90: meta) flickerstreak@90: flickerstreak@90: if self.config.buttons == nil then flickerstreak@90: self.config.buttons = { } flickerstreak@90: end flickerstreak@90: self:Refresh() flickerstreak@90: return self flickerstreak@90: end flickerstreak@90: flickerstreak@90: function Handle:Refresh() flickerstreak@90: local r, c = self.bar:GetButtonGrid() flickerstreak@90: local n = r*c flickerstreak@90: local btnCfg = self.config.buttons flickerstreak@90: if n ~= #self.btns then flickerstreak@90: for i = 1, n do flickerstreak@90: if btnCfg[i] == nil then flickerstreak@90: btnCfg[i] = {} flickerstreak@90: end flickerstreak@90: if self.btns[i] == nil then flickerstreak@128: local lastButton = self:GetLastButton() flickerstreak@128: local hint = lastButton and lastButton.config.actionID flickerstreak@128: local b = Button:New(i, self.config, self.bar, hint) flickerstreak@90: self.btns[i] = b flickerstreak@90: self.bar:AddButton(i,b) flickerstreak@90: end flickerstreak@90: end flickerstreak@90: for i = n+1, #self.btns do flickerstreak@90: if self.btns[i] then flickerstreak@90: self.bar:RemoveButton(self.btns[i]) flickerstreak@90: self.btns[i]:Destroy() flickerstreak@90: self.btns[i] = nil flickerstreak@90: btnCfg[i] = nil flickerstreak@90: end flickerstreak@90: end flickerstreak@90: end flickerstreak@90: for _, b in ipairs(self.btns) do flickerstreak@90: b:Refresh() flickerstreak@90: end flickerstreak@128: Button.SetupBarHeader(self.bar,self.config) flickerstreak@102: self:UpdateButtonLock() flickerstreak@90: end flickerstreak@90: flickerstreak@90: function Handle:Destroy() flickerstreak@90: for _,b in pairs(self.btns) do flickerstreak@90: if b then flickerstreak@90: b:Destroy() flickerstreak@90: end flickerstreak@90: end flickerstreak@90: end flickerstreak@90: flickerstreak@102: function Handle:UpdateButtonLock() flickerstreak@128: Button.SetButtonLock(self.bar, self.config.lockButtons, self.config.lockButtonsCombat) flickerstreak@102: end flickerstreak@102: flickerstreak@90: function Handle:GetLastButton() flickerstreak@90: return self.btns[#self.btns] flickerstreak@90: end flickerstreak@90: flickerstreak@90: -- options handlers flickerstreak@90: function Handle:GetOptions() flickerstreak@87: return { flickerstreak@87: type = "group", flickerstreak@87: name = L["Action Buttons"], flickerstreak@90: handler = self, flickerstreak@87: args = options flickerstreak@87: } flickerstreak@77: end flickerstreak@77: flickerstreak@90: function Handle:SetHideEmpty(info, value) flickerstreak@90: if value ~= self.config.hideEmpty then flickerstreak@90: self.config.hideEmpty = value flickerstreak@128: for _, b in pairs(self.btns) do flickerstreak@128: b:ShowGrid(not value) flickerstreak@128: end flickerstreak@77: end flickerstreak@77: end flickerstreak@77: flickerstreak@90: function Handle:GetHideEmpty() flickerstreak@90: return self.config.hideEmpty flickerstreak@77: end flickerstreak@87: flickerstreak@102: function Handle:GetLockButtons() flickerstreak@128: return self.config.lockButtons flickerstreak@102: end flickerstreak@102: flickerstreak@102: function Handle:SetLockButtons(info, value) flickerstreak@102: self.config.lockButtons = value flickerstreak@102: self:UpdateButtonLock() flickerstreak@102: end flickerstreak@102: flickerstreak@102: function Handle:GetLockButtonsCombat() flickerstreak@102: return self.config.lockButtonsCombat flickerstreak@102: end flickerstreak@102: flickerstreak@102: function Handle:SetLockButtonsCombat(info, value) flickerstreak@102: self.config.lockButtonsCombat = value flickerstreak@102: self:UpdateButtonLock() flickerstreak@102: end flickerstreak@102: flickerstreak@102: function Handle:LockButtonsCombatDisabled() flickerstreak@128: return not self.config.lockButtons flickerstreak@102: end flickerstreak@102: flickerstreak@90: function Handle:GetNumPages() flickerstreak@90: return self.config.nPages flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:SetNumPages(info, value) flickerstreak@90: self.config.nPages = value flickerstreak@90: self:Refresh() flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:GetMindControl() flickerstreak@90: return self.config.mindcontrol flickerstreak@90: end flickerstreak@90: flickerstreak@90: function Handle:SetMindControl(info, value) flickerstreak@90: self.config.mindcontrol = value flickerstreak@90: self:Refresh() flickerstreak@90: end flickerstreak@90: flickerstreak@121: function Handle:GetVehicle() flickerstreak@121: return self.config.vehicle flickerstreak@121: end flickerstreak@121: flickerstreak@121: function Handle:SetVehicle(info, value) flickerstreak@121: self.config.vehicle = value flickerstreak@121: self:Refresh() flickerstreak@121: end flickerstreak@121: flickerstreak@90: function Handle:GetActionEditMethod() flickerstreak@87: return self.editMethod or 0 flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:SetActionEditMethod(info, value) flickerstreak@87: self.editMethod = value flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:IsButtonSelectHidden() flickerstreak@87: return self.editMethod ~= 1 flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:GetRowList() flickerstreak@87: local r,c = self.bar:GetButtonGrid() flickerstreak@87: if self.rowList == nil or #self.rowList ~= r then flickerstreak@87: local list = { } flickerstreak@87: for i = 1, r do flickerstreak@87: table.insert(list,i) flickerstreak@87: end flickerstreak@87: self.rowList = list flickerstreak@87: end flickerstreak@87: return self.rowList flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:GetSelectedRow() flickerstreak@87: local r, c = self.bar:GetButtonGrid() flickerstreak@87: local row = self.selectedRow or 1 flickerstreak@87: if row > r then flickerstreak@87: row = 1 flickerstreak@87: end flickerstreak@87: self.selectedRow = row flickerstreak@87: return row flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:SetSelectedRow(info, value) flickerstreak@87: self.selectedRow = value flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:GetColumnList() flickerstreak@87: local r,c = self.bar:GetButtonGrid() flickerstreak@87: if self.columnList == nil or #self.columnList ~= c then flickerstreak@87: local list = { } flickerstreak@87: for i = 1, c do flickerstreak@87: table.insert(list,i) flickerstreak@87: end flickerstreak@87: self.columnList = list flickerstreak@87: end flickerstreak@87: return self.columnList flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:GetSelectedColumn() flickerstreak@87: local r, c = self.bar:GetButtonGrid() flickerstreak@87: local col = self.selectedColumn or 1 flickerstreak@87: if col > c then flickerstreak@87: col = 1 flickerstreak@87: end flickerstreak@87: self.selectedColumn = col flickerstreak@87: return col flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:SetSelectedColumn(info, value) flickerstreak@87: self.selectedColumn = value flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:IsPageSelectHidden() flickerstreak@90: return self.editMethod ~= 1 or (self.config.nPages or 1) < 2 flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:GetPageList() flickerstreak@90: local n = self.config.nPages or 1 flickerstreak@87: if self.pageList == nil or #self.pageList ~= n then flickerstreak@87: local p = { } flickerstreak@87: for i = 1, n do flickerstreak@87: table.insert(p,i) flickerstreak@87: end flickerstreak@87: self.pageList = p flickerstreak@87: end flickerstreak@87: return self.pageList flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:GetSelectedPage() flickerstreak@87: local p = self.selectedPage or 1 flickerstreak@90: if p > (self.config.nPages or 1) then flickerstreak@87: p = 1 flickerstreak@87: end flickerstreak@87: self.selectedPage = p flickerstreak@87: return p flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:SetSelectedPage(info, value) flickerstreak@87: self.selectedPage = value flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:GetActionID() flickerstreak@87: local row = self.selectedRow or 1 flickerstreak@87: local col = self.selectedColumn or 1 flickerstreak@87: local r, c = self.bar:GetButtonGrid() flickerstreak@87: local n = (row-1) * c + col flickerstreak@90: local btn = self.btns[n] flickerstreak@87: if btn then flickerstreak@87: return tostring(btn:GetActionID(self.selectedPage or 1)) flickerstreak@87: end flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:SetActionID(info, value) flickerstreak@87: local row = self.selectedRow or 1 flickerstreak@87: local col = self.selectedColumn or 1 flickerstreak@87: local r, c = self.bar:GetButtonGrid() flickerstreak@87: local n = (row-1) * c + col flickerstreak@90: local btn = self.btns[n] flickerstreak@87: if btn then flickerstreak@87: btn:SetActionID(tonumber(value), self.selectedPage or 1) flickerstreak@87: end flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:ValidateActionID(info, value) flickerstreak@87: value = tonumber(value) flickerstreak@87: if value == nil or value < 1 or value > 120 then flickerstreak@87: return L["Specify ID 1-120"] flickerstreak@87: end flickerstreak@87: return true flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:IsMultiIDHidden() flickerstreak@87: return self.editMethod ~= 2 flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:GetMultiID() flickerstreak@87: local p = { } flickerstreak@90: for i = 1, self.config.nPages or 1 do flickerstreak@87: local b = { } flickerstreak@90: for _, btn in ipairs(self.btns) do flickerstreak@87: table.insert(b, btn:GetActionID(i)) flickerstreak@87: end flickerstreak@87: table.insert(p, table.concat(b,",")) flickerstreak@87: end flickerstreak@87: return table.concat(p,";\n") flickerstreak@87: end flickerstreak@87: flickerstreak@87: flickerstreak@87: local function ParseMultiID(nBtns, nPages, s) flickerstreak@87: if s:match("[^%d%s,;]") then flickerstreak@87: return nil flickerstreak@87: end flickerstreak@87: local p = { } flickerstreak@87: for list in s:gmatch("[^;]+") do flickerstreak@87: local pattern = ("^%s?$"):format(("%s*(%d+)%s*,"):rep(nBtns)) flickerstreak@87: local ids = { list:match(pattern) } flickerstreak@87: if #ids ~= nBtns then flickerstreak@87: return nil flickerstreak@87: end flickerstreak@87: table.insert(p,ids) flickerstreak@87: end flickerstreak@87: if #p ~= nPages then flickerstreak@87: return nil flickerstreak@87: end flickerstreak@87: return p flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:SetMultiID(info, value) flickerstreak@91: local p = ParseMultiID(#self.btns, self.config.nPages or 1, value) flickerstreak@87: for page, b in ipairs(p) do flickerstreak@87: for button, id in ipairs(b) do flickerstreak@90: self.btns[button]:SetActionID(id, page) flickerstreak@87: end flickerstreak@87: end flickerstreak@87: end flickerstreak@87: flickerstreak@90: function Handle:ValidateMultiID(info, value) flickerstreak@87: local bad = L["Invalid action ID list string"] flickerstreak@90: if value == nil or ParseMultiID(#self.btns, self.config.nPages or 1, value) == nil then flickerstreak@87: return bad flickerstreak@87: end flickerstreak@87: return true flickerstreak@87: end flickerstreak@77: end flickerstreak@77: flickerstreak@77: flickerstreak@87: ------ State property options ------ flickerstreak@87: do flickerstreak@87: local pageOptions = { flickerstreak@87: page = { flickerstreak@92: name = L["Show Page #"], flickerstreak@92: order = 11, flickerstreak@92: type = "select", flickerstreak@92: width = "half", flickerstreak@87: disabled = "IsPageDisabled", flickerstreak@87: hidden = "IsPageHidden", flickerstreak@87: values = "GetPageValues", flickerstreak@87: set = "SetProp", flickerstreak@87: get = "GetPage", flickerstreak@87: }, flickerstreak@87: } flickerstreak@50: flickerstreak@90: local function GetBarConfig(bar) flickerstreak@90: return module.db.profile.bars[bar:GetName()] flickerstreak@87: end flickerstreak@87: flickerstreak@90: function PropHandler.GetOptions() flickerstreak@90: return pageOptions flickerstreak@87: end flickerstreak@87: flickerstreak@90: function PropHandler:IsPageDisabled() flickerstreak@90: local c = GetBarConfig(self.bar) flickerstreak@90: local n = c and c.nPages or 1 flickerstreak@90: return not (n > 1) flickerstreak@87: end flickerstreak@87: flickerstreak@90: function PropHandler:IsPageHidden() flickerstreak@87: return not GetBarConfig(self.bar) flickerstreak@87: end flickerstreak@87: flickerstreak@90: function PropHandler:GetPageValues() flickerstreak@92: if not self._pagevalues then flickerstreak@92: self._pagevalues = { } flickerstreak@92: end flickerstreak@87: local c = GetBarConfig(self.bar) flickerstreak@87: if c then flickerstreak@87: local n = c.nPages flickerstreak@92: -- cache the results flickerstreak@87: if self._npages ~= n then flickerstreak@87: self._npages = n flickerstreak@92: wipe(self._pagevalues) flickerstreak@87: for i = 1, n do flickerstreak@90: self._pagevalues["page"..i] = i flickerstreak@87: end flickerstreak@87: end flickerstreak@87: end flickerstreak@92: return self._pagevalues flickerstreak@87: end flickerstreak@87: flickerstreak@90: function PropHandler:GetPage(info) flickerstreak@87: return self:GetProp(info) or 1 flickerstreak@87: end flickerstreak@90: flickerstreak@87: end flickerstreak@87: