Mercurial > wow > reaction
view modules/Action.lua @ 237:704f4a05a1d7
Demodulificate all bar options (except state options)
author | Flick |
---|---|
date | Thu, 24 Mar 2011 13:11:30 -0700 |
parents | 0e20f65375d5 |
children |
line wrap: on
line source
local addonName, addonTable = ... local ReAction = addonTable.ReAction local L = ReAction.L local _G = _G local format = string.format local wipe = wipe local weak = { __mode="k" } -- module declaration local moduleID = "Action" local module = ReAction:NewModule( moduleID ) -- Class declarations local PropHandler = { } -- Event handlers function module:OnInitialize() self.handles = setmetatable({ }, weak) end function module:OnEnable() ReAction:GetModule("State"):RegisterStateProperty("page", nil, PropHandler.GetOptions(), PropHandler) end function module:OnDisable() ReAction:GetModule("State"):UnregisterStateProperty("page") end ------ State property options ------ do local pageOptions = { page = { name = L["Show Page #"], order = 11, type = "select", width = "half", disabled = "IsPageDisabled", hidden = "IsPageHidden", values = "GetPageValues", set = "SetProp", get = "GetPage", }, } function PropHandler.GetOptions() return pageOptions end function PropHandler:IsPageDisabled() local c = self.bar:GetConfig() local n = c and c.nPages or 1 return not (n > 1) end function PropHandler:IsPageHidden() return not self.bar:GetConfig() end function PropHandler:GetPageValues() if not self._pagevalues then self._pagevalues = { } end local c = self.bar:GetConfig() if c then local n = c.nPages -- cache the results if self._npages ~= n then self._npages = n wipe(self._pagevalues) for i = 1, n do self._pagevalues["page"..i] = i end end end return self._pagevalues end function PropHandler:GetPage(info) return self:GetProp(info) or 1 end end