Mercurial > wow > reaction
comparison ReAction.lua @ 33:c54c481ad0ed
- Moved bar control frame from ConfigUI to Bar
- Added LICENSE.txt
- added profile management options
- other minor cleanup
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Thu, 03 Apr 2008 20:25:40 +0000 |
parents | 0d95ce7a9ec2 |
children | 52ac6db0c8ca |
comparison
equal
deleted
inserted
replaced
32:821b2b7edff1 | 33:c54c481ad0ed |
---|---|
1 -- ReAction.lua | 1 -- ReAction.lua |
2 -- See modules/ReAction_ModuleTemplate for Module API listing | 2 -- See modules/ReAction_ModuleTemplate for Module API listing |
3 -- See Bar.lua for Bar object listing | 3 -- See Bar.lua for Bar object listing |
4 local MAJOR_VERSION = GetAddOnMetadata("ReAction","Version") | |
5 | |
6 ------ LIBRARIES ------ | |
7 local L = LibStub("AceLocale-3.0"):GetLocale("ReAction") | |
8 | 4 |
9 ------ CORE ------ | 5 ------ CORE ------ |
10 local ReAction = LibStub("AceAddon-3.0"):NewAddon( "ReAction", | 6 local ReAction = LibStub("AceAddon-3.0"):NewAddon( "ReAction", |
11 "AceConsole-3.0" | 7 "AceConsole-3.0", |
8 "AceEvent-3.0" | |
12 ) | 9 ) |
13 ReAction.revision = tonumber(("$Revision: 1 $"):match("%d+")) | 10 ReAction.version = GetAddOnMetadata("ReAction","Version") |
14 ReAction.version = MAJOR_VERSION | 11 ReAction.revision = tonumber(("$Revision$"):match("%d+")) |
15 ReAction.L = L | |
16 | 12 |
17 ------ GLOBALS ------ | 13 ------ GLOBALS ------ |
18 _G["ReAction"] = ReAction | 14 _G["ReAction"] = ReAction |
19 | 15 |
20 ------ DEBUGGING ------ | 16 ------ DEBUGGING ------ |
25 end | 21 end |
26 --seterrorhandler(ReAction.print) | 22 --seterrorhandler(ReAction.print) |
27 else | 23 else |
28 ReAction.print = function() end | 24 ReAction.print = function() end |
29 end | 25 end |
26 | |
27 ------ LIBRARIES ------ | |
28 local L = LibStub("AceLocale-3.0"):GetLocale("ReAction") | |
29 ReAction.L = L | |
30 | 30 |
31 ------ PRIVATE ------ | 31 ------ PRIVATE ------ |
32 local SelectBar, DestroyBar, InitializeBars, TearDownBars, DeepCopy, SafeCall, CheckMethod, SlashHandler | 32 local SelectBar, DestroyBar, InitializeBars, TearDownBars, DeepCopy, SafeCall, CheckMethod, SlashHandler |
33 do | 33 do |
34 local pcall = pcall | 34 local pcall = pcall |
110 error("Invalid method") | 110 error("Invalid method") |
111 end | 111 end |
112 end | 112 end |
113 | 113 |
114 local function CallOptsModule(method,...) | 114 local function CallOptsModule(method,...) |
115 local m = ReAction:GetModule("ConfigUI",true) | 115 local m = ReAction:GetModule("ConfigUI",true) |
116 if not m then | 116 if not m then |
117 LoadAddOn("ReAction_ConfigUI") | 117 LoadAddOn("ReAction_ConfigUI") |
118 m = ReAction:GetModule("ConfigUI") | 118 m = ReAction:GetModule("ConfigUI") |
119 end | 119 end |
120 if m and type(m) == "table" and type(m[method]) == "function" then | 120 if m and type(m) == "table" and type(m[method]) == "function" then |
121 m[method](m,...) | 121 m[method](m,...) |
122 else | 122 else |
123 ReAction:Print("Options module not found") | 123 ReAction:Print("Options module not found") |
124 end | 124 end |
125 end | 125 end |
126 | 126 |
127 SlashHandler = function(option) | 127 SlashHandler = function(option) |
128 if option == "config" then | 128 if option == "config" then |
129 CallOptsModule("OpenConfig",true) | 129 CallOptsModule("OpenConfig",true) |
130 elseif option == "unlock" then | 130 elseif option == "unlock" then |
131 CallOptsModule("SetConfigMode",true) | 131 ReAction:SetConfigMode(true) |
132 elseif option == "lock" then | 132 elseif option == "lock" then |
133 CallOptsModule("SetConfigMode",false) | 133 ReAction:SetConfigMode(false) |
134 else | 134 else |
135 ReAction:Print(ReAction.version) | 135 ReAction:Print(ReAction.version) |
136 ReAction:Print("/reaction config") | 136 ReAction:Print("/reaction config") |
137 ReAction:Print("/reaction unlock") | 137 ReAction:Print("/reaction unlock") |
138 ReAction:Print("/reaction lock") | 138 ReAction:Print("/reaction lock") |
154 ) | 154 ) |
155 self.db.RegisterCallback(self,"OnProfileChanged") | 155 self.db.RegisterCallback(self,"OnProfileChanged") |
156 self.callbacks = LibStub("CallbackHandler-1.0"):New(self) | 156 self.callbacks = LibStub("CallbackHandler-1.0"):New(self) |
157 self:RegisterChatCommand("reaction", SlashHandler) | 157 self:RegisterChatCommand("reaction", SlashHandler) |
158 self:RegisterChatCommand("rxn", SlashHandler) | 158 self:RegisterChatCommand("rxn", SlashHandler) |
159 self:RegisterEvent("PLAYER_REGEN_DISABLED") | |
159 | 160 |
160 self.bars = {} | 161 self.bars = {} |
161 end | 162 end |
162 | 163 |
163 function ReAction:OnEnable() | 164 function ReAction:OnEnable() |
167 function ReAction:OnDisable() | 168 function ReAction:OnDisable() |
168 TearDownBars() | 169 TearDownBars() |
169 end | 170 end |
170 | 171 |
171 function ReAction:OnProfileChanged() | 172 function ReAction:OnProfileChanged() |
172 self.TearDownBars() | 173 TearDownBars() |
173 self.InitializeBars() | 174 InitializeBars() |
174 end | 175 end |
175 | 176 |
176 function ReAction:OnModuleEnable(module) | 177 function ReAction:OnModuleEnable(module) |
177 if module.ApplyToBar then | 178 if module.ApplyToBar then |
178 for _, b in pairs(bars) do | 179 for _, b in pairs(bars) do |
190 module:RemoveFromBar(b) | 191 module:RemoveFromBar(b) |
191 end | 192 end |
192 end | 193 end |
193 end | 194 end |
194 end | 195 end |
196 | |
197 function ReAction:PLAYER_REGEN_DISABLED() | |
198 if self.configMode == true then | |
199 UIErrorsFrame:AddMessage(L["ReAction config mode disabled during combat."]) | |
200 self:SetConfigMode(false) | |
201 end | |
202 end | |
203 | |
195 | 204 |
196 | 205 |
197 ------ API ------ | 206 ------ API ------ |
198 function ReAction:CallMethodOnAllModules(method, ...) | 207 function ReAction:CallMethodOnAllModules(method, ...) |
199 local m = CheckMethod(method) | 208 local m = CheckMethod(method) |
227 profile.bars[name] = profile.bars[name] or DeepCopy(defaultConfig) | 236 profile.bars[name] = profile.bars[name] or DeepCopy(defaultConfig) |
228 local bar = self.Bar:new( name, profile.bars[name] ) -- ReAction.Bar defined in Bar.lua | 237 local bar = self.Bar:new( name, profile.bars[name] ) -- ReAction.Bar defined in Bar.lua |
229 self:CallMethodOnAllModules("ApplyToBar", bar) | 238 self:CallMethodOnAllModules("ApplyToBar", bar) |
230 self.bars[name] = bar | 239 self.bars[name] = bar |
231 self.callbacks:Fire("OnCreateBar", bar) | 240 self.callbacks:Fire("OnCreateBar", bar) |
241 if self.configMode then | |
242 bar:ShowControls(true) | |
243 end | |
244 | |
232 return bar | 245 return bar |
233 end | 246 end |
234 | 247 |
235 function ReAction:EraseBar(x) | 248 function ReAction:EraseBar(x) |
236 local bar, name = SelectBar(x) | 249 local bar, name = SelectBar(x) |
293 end | 306 end |
294 | 307 |
295 function ReAction:RefreshOptions() | 308 function ReAction:RefreshOptions() |
296 self.callbacks:Fire("OnOptionsRefreshed") | 309 self.callbacks:Fire("OnOptionsRefreshed") |
297 end | 310 end |
311 | |
312 function ReAction:SetConfigMode( mode ) | |
313 self:CallMethodOnAllBars("ShowControls",mode) | |
314 self:CallMethodOnAllModules("ApplyConfigMode",mode,self.bars) | |
315 self.configMode = mode | |
316 end |