Mercurial > wow > reaction
comparison modules/ReAction_Action/ReAction_Action.lua @ 48:7b7d178dec52
Implemented bar-type selection, extended CreateBar functionality
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Sat, 12 Apr 2008 00:15:09 +0000 |
parents | 0d95ce7a9ec2 |
children | dcf8116560a1 |
comparison
equal
deleted
inserted
replaced
47:e12b736c23c3 | 48:7b7d178dec52 |
---|---|
29 ) | 29 ) |
30 self.buttons = { } | 30 self.buttons = { } |
31 end | 31 end |
32 | 32 |
33 function module:OnEnable() | 33 function module:OnEnable() |
34 ReAction:RegisterDefaultBarConfig(L["Action Bar"], { type = "actionbar" }, true) | |
34 end | 35 end |
35 | 36 |
36 function module:OnDisable() | 37 function module:OnDisable() |
38 ReAction:UnregisterDefaultBarConfig(L["Action Bar"]) | |
37 end | 39 end |
38 | 40 |
39 function module:ApplyToBar(bar) | 41 function module:ApplyToBar(bar) |
40 self:RefreshBar(bar) | 42 if bar.config.type == "actionbar" then |
43 self:RefreshBar(bar) | |
44 end | |
41 end | 45 end |
42 | 46 |
43 function module:RefreshBar(bar) | 47 function module:RefreshBar(bar) |
44 if self.buttons[bar] == nil then | 48 if bar.config.type == "actionbar" then |
45 self.buttons[bar] = { } | 49 if self.buttons[bar] == nil then |
46 end | 50 self.buttons[bar] = { } |
47 local btns = self.buttons[bar] | 51 end |
48 local profile = self.db.profile | 52 local btns = self.buttons[bar] |
49 local barName = bar:GetName() | 53 local profile = self.db.profile |
50 if profile.buttons[barName] == nil then | 54 local barName = bar:GetName() |
51 profile.buttons[barName] = {} | 55 if profile.buttons[barName] == nil then |
52 end | 56 profile.buttons[barName] = {} |
53 local btnCfg = profile.buttons[barName] | 57 end |
54 | 58 local btnCfg = profile.buttons[barName] |
55 local r, c = bar:GetButtonGrid() | 59 |
56 local n = r*c | 60 local r, c = bar:GetButtonGrid() |
57 for i = 1, n do | 61 local n = r*c |
58 if btnCfg[i] == nil then | 62 for i = 1, n do |
59 btnCfg[i] = {} | 63 if btnCfg[i] == nil then |
60 end | 64 btnCfg[i] = {} |
61 if btns[i] == nil then | 65 end |
62 btns[i] = self.BtnClass:new(bar,i,btnCfg[i]) | 66 if btns[i] == nil then |
63 else | 67 btns[i] = self.BtnClass:new(bar,i,btnCfg[i]) |
64 btns[i]:Refresh(bar,i) | 68 else |
65 end | 69 btns[i]:Refresh(bar,i) |
66 end | 70 end |
67 for i = n+1, #btns do | 71 end |
68 btns[i] = btns[i]:Destroy() | 72 for i = n+1, #btns do |
69 if btnCfg[i] then | 73 btns[i] = btns[i]:Destroy() |
70 btnCfg[i] = nil | 74 if btnCfg[i] then |
75 btnCfg[i] = nil | |
76 end | |
71 end | 77 end |
72 end | 78 end |
73 end | 79 end |
74 | 80 |
75 function module:RemoveFromBar(bar) | 81 function module:RemoveFromBar(bar) |
84 end | 90 end |
85 end | 91 end |
86 | 92 |
87 function module:EraseBarConfig(barName) | 93 function module:EraseBarConfig(barName) |
88 self.db.profile.buttons[barName] = nil | 94 self.db.profile.buttons[barName] = nil |
95 end | |
96 | |
97 function module:RenameBarConfig(oldname, newname) | |
98 local b = self.db.profile.buttons | |
99 b[newname], b[oldname] = b[oldname], nil | |
89 end | 100 end |
90 | 101 |
91 function module:ApplyConfigMode(mode,bars) | 102 function module:ApplyConfigMode(mode,bars) |
92 for _, btns in pairs(self.buttons) do | 103 for _, btns in pairs(self.buttons) do |
93 if btn then | 104 if btn then |
111 end | 122 end |
112 end | 123 end |
113 end | 124 end |
114 end | 125 end |
115 | 126 |
116 function module:GetGlobalBarOptions(opts) | |
117 if self.globalBarOpts == nil then | |
118 self.globalBarOpts = { | |
119 newActionBar = { | |
120 type = "execute", | |
121 name = L["New Action Bar"], | |
122 desc = L["Create a new bar of standard action buttons"], | |
123 func = function() | |
124 ReAction:CreateBar() | |
125 end, | |
126 disabled = InCombatLockdown, | |
127 } | |
128 } | |
129 end | |
130 return self.globalBarOpts | |
131 end | |
132 | |
133 function module:GetBarMenuOptions(bar) | |
134 if not bar.modMenuOpts[moduleID] then | |
135 bar.modMenuOpts[moduleID] = { | |
136 } | |
137 end | |
138 return bar.modMenuOpts[moduleID] | |
139 end | |
140 | |
141 function module:GetBarConfigOptions(bar) | |
142 if not bar.modConfigOpts[moduleID] then | |
143 bar.modConfigOpts[moduleID] = { | |
144 } | |
145 end | |
146 return bar.modConfigOpts[moduleID] | |
147 end | |
148 | |
149 | |
150 | |
151 -- use-count of action IDs | 127 -- use-count of action IDs |
152 local ActionIDList = setmetatable( {}, { | 128 local ActionIDList = setmetatable( {}, { |
153 __index = function(self, idx) | 129 __index = function(self, idx) |
154 if idx == nil then | 130 if idx == nil then |
155 for i = 1, 120 do | 131 for i = 1, 120 do |