vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- registers the mod with Cosmos |
2 | function CooldownCount_Register_Cosmos() |
||
3 | if ( ( Cosmos_UpdateValue ) and ( Cosmos_RegisterConfiguration ) and ( CooldownCount_Cosmos_Registered == 0 ) ) then |
||
4 | Cosmos_RegisterConfiguration( |
||
5 | "COS_COOLDOWNCOUNT", |
||
6 | "SECTION", |
||
7 | TEXT(COOLDOWNCOUNT_CONFIG_HEADER), |
||
8 | TEXT(COOLDOWNCOUNT_CONFIG_HEADER_INFO) |
||
9 | ); |
||
10 | Cosmos_RegisterConfiguration( |
||
11 | "COS_COOLDOWNCOUNT_HEADER", |
||
12 | "SEPARATOR", |
||
13 | TEXT(COOLDOWNCOUNT_CONFIG_HEADER), |
||
14 | TEXT(COOLDOWNCOUNT_CONFIG_HEADER_INFO) |
||
15 | ); |
||
16 | Cosmos_RegisterConfiguration( |
||
17 | "COS_COOLDOWNCOUNT_ENABLED", |
||
18 | "CHECKBOX", |
||
19 | TEXT(COOLDOWNCOUNT_ENABLED), |
||
20 | TEXT(COOLDOWNCOUNT_ENABLED_INFO), |
||
21 | CooldownCount_Toggle_Enabled, |
||
22 | CooldownCount_Enabled |
||
23 | ); |
||
24 | Cosmos_RegisterConfiguration( |
||
25 | "COS_COOLDOWNCOUNT_ROGUE_STEALTH", |
||
26 | "CHECKBOX", |
||
27 | TEXT(COOLDOWNCOUNT_ROGUE_STEALTH), |
||
28 | TEXT(COOLDOWNCOUNT_ROGUE_STEALTH_INFO), |
||
29 | CooldownCount_Toggle_RogueStealth, |
||
30 | CooldownCount_RogueStealth |
||
31 | ); |
||
32 | |||
33 | Cosmos_RegisterConfiguration( |
||
34 | "COS_COOLDOWNCOUNT_NOSPACES", |
||
35 | "CHECKBOX", |
||
36 | TEXT(COOLDOWNCOUNT_NOSPACES), |
||
37 | TEXT(COOLDOWNCOUNT_NOSPACES_INFO), |
||
38 | CooldownCount_Toggle_NoSpaces, |
||
39 | CooldownCount_NoSpaces |
||
40 | ); |
||
41 | CooldownCount_UseLongTimerDescriptions = 0; |
||
42 | --[[ |
||
43 | Cosmos_RegisterConfiguration( |
||
44 | "COS_COOLDOWNCOUNT_USELONGTIMERS", |
||
45 | "CHECKBOX", |
||
46 | TEXT(COOLDOWNCOUNT_USELONGTIMERS), |
||
47 | TEXT(COOLDOWNCOUNT_USELONGTIMERS_INFO), |
||
48 | CooldownCount_Toggle_UseLongTimers, |
||
49 | CooldownCount_UseLongTimerDescriptions |
||
50 | ); |
||
51 | ]]-- |
||
52 | Cosmos_RegisterConfiguration( |
||
53 | "COS_COOLDOWNCOUNT_FLASHSPEED", |
||
54 | "SLIDER", |
||
55 | TEXT(COOLDOWNCOUNT_FLASHSPEED), |
||
56 | TEXT(COOLDOWNCOUNT_FLASHSPEED_INFO), |
||
57 | function (checked, value) CooldownCount_SetFlashSpeed(value, true); end, |
||
58 | 1, |
||
59 | CooldownCount_TimeBetweenFlashes, |
||
60 | 0.1, |
||
61 | 1, |
||
62 | COOLDOWNCOUNT_FLASHSPEED_SLIDER_DESCRIPTION, |
||
63 | 0.1, |
||
64 | 1, |
||
65 | COOLDOWNCOUNT_FLASHSPEED_SLIDER_APPEND, |
||
66 | 1 |
||
67 | ); |
||
68 | Cosmos_RegisterConfiguration( |
||
69 | "COS_COOLDOWNCOUNT_USERSCALE", |
||
70 | "SLIDER", |
||
71 | TEXT(COOLDOWNCOUNT_USERSCALE), |
||
72 | TEXT(COOLDOWNCOUNT_USERSCALE_INFO), |
||
73 | function (checked, value) CooldownCount_SetUserScale(value, true); end, |
||
74 | 1, |
||
75 | CooldownCount_UserScale, |
||
76 | 0.1, |
||
77 | 5, |
||
78 | COOLDOWNCOUNT_USERSCALE_SLIDER_DESCRIPTION, |
||
79 | 0.1, |
||
80 | 1, |
||
81 | COOLDOWNCOUNT_USERSCALE_SLIDER_APPEND, |
||
82 | 100 |
||
83 | ); |
||
84 | Cosmos_RegisterConfiguration( |
||
85 | "COS_COOLDOWNCOUNT_ALPHA", |
||
86 | "SLIDER", |
||
87 | TEXT(COOLDOWNCOUNT_ALPHA), |
||
88 | TEXT(COOLDOWNCOUNT_ALPHA_INFO), |
||
89 | function (checked, value) CooldownCount_Set_Alpha(value, true); end, |
||
90 | 1, |
||
91 | CooldownCountOptions.alpha, |
||
92 | 0.01, |
||
93 | 1, |
||
94 | COOLDOWNCOUNT_ALPHA_SLIDER_DESCRIPTION, |
||
95 | 0.01, |
||
96 | 1, |
||
97 | COOLDOWNCOUNT_ALPHA_SLIDER_APPEND, |
||
98 | 100 |
||
99 | ); |
||
100 | Cosmos_RegisterConfiguration( |
||
101 | "COS_COOLDOWNCOUNT_HIDEUNTILTIMELEFT", |
||
102 | "SLIDER", |
||
103 | TEXT(COOLDOWNCOUNT_HIDEUNTILTIMELEFT), |
||
104 | TEXT(COOLDOWNCOUNT_HIDEUNTILTIMELEFT_INFO), |
||
105 | function (checked, value) CooldownCount_SetHideUntilTimeLeft(value, true); end, |
||
106 | 1, |
||
107 | CooldownCount_HideUntilTimeLeft, |
||
108 | 0, |
||
109 | 60, |
||
110 | COOLDOWNCOUNT_FLASHSPEED_SLIDER_DESCRIPTION, |
||
111 | 1, |
||
112 | 1, |
||
113 | COOLDOWNCOUNT_FLASHSPEED_SLIDER_APPEND, |
||
114 | 1 |
||
115 | ); |
||
116 | Cosmos_RegisterConfiguration( |
||
117 | "COS_COOLDOWNCOUNT_NORMALCOLORSET", |
||
118 | "BUTTON", |
||
119 | COOLDOWNCOUNT_NORMALCOLOR_SET, |
||
120 | COOLDOWNCOUNT_NORMALCOLOR_SET_INFO, |
||
121 | CooldownCount_NormalColorSetButton, |
||
122 | 0, |
||
123 | 0, |
||
124 | 0, |
||
125 | 0, |
||
126 | COOLDOWNCOUNT_SETTEXT |
||
127 | ); |
||
128 | Cosmos_RegisterConfiguration( |
||
129 | "COS_COOLDOWNCOUNT_FLASHCOLORSET", |
||
130 | "BUTTON", |
||
131 | COOLDOWNCOUNT_FLASHCOLOR_SET, |
||
132 | COOLDOWNCOUNT_FLASHCOLOR_SET_INFO, |
||
133 | CooldownCount_FlashColorSetButton, |
||
134 | 0, |
||
135 | 0, |
||
136 | 0, |
||
137 | 0, |
||
138 | COOLDOWNCOUNT_SETTEXT |
||
139 | ); |
||
140 | CooldownCount_Cosmos_Registered = 1; |
||
141 | end |
||
142 | end |
||
143 | |||
144 | |||
145 | function CooldownCount_Extract_NextParameter(msg) |
||
146 | local params = msg; |
||
147 | local command = params; |
||
148 | local index = strfind(command, " "); |
||
149 | if ( index ) then |
||
150 | command = strsub(command, 1, index-1); |
||
151 | params = strsub(params, index+1); |
||
152 | else |
||
153 | params = ""; |
||
154 | end |
||
155 | return command, params; |
||
156 | end |
||
157 | |||
158 | |||
159 | -- registers the mod with the system, integrating it with slash commands and "master" AddOns |
||
160 | function CooldownCount_Register() |
||
161 | if ( Cosmos_RegisterConfiguration ) then |
||
162 | CooldownCount_Register_Cosmos(); |
||
163 | else |
||
164 | SlashCmdList["COOLDOWNCOUNTSLASHMAIN"] = CooldownCount_Main_ChatCommandHandler; |
||
165 | SLASH_COOLDOWNCOUNTSLASHMAIN1 = "/cooldowncount"; |
||
166 | SLASH_COOLDOWNCOUNTSLASHMAIN2 = "/cc"; |
||
167 | --[[ |
||
168 | SlashCmdList["COOLDOWNCOUNTSLASHENABLE"] = CooldownCount_Enable_ChatCommandHandler; |
||
169 | SLASH_COOLDOWNCOUNTSLASHENABLE1 = "/cooldowncountenable"; |
||
170 | SLASH_COOLDOWNCOUNTSLASHENABLE2 = "/ccenable"; |
||
171 | SLASH_COOLDOWNCOUNTSLASHENABLE3 = "/cce"; |
||
172 | SLASH_COOLDOWNCOUNTSLASHENABLE4 = "/cooldowncountdisable"; |
||
173 | SLASH_COOLDOWNCOUNTSLASHENABLE5 = "/ccdisable"; |
||
174 | SLASH_COOLDOWNCOUNTSLASHENABLE6 = "/ccd"; |
||
175 | SLASH_COOLDOWNCOUNTSLASHENABLE7 = "/cooldowncounttoggle"; |
||
176 | SLASH_COOLDOWNCOUNTSLASHENABLE8 = "/cctoggle"; |
||
177 | SLASH_COOLDOWNCOUNTSLASHENABLE9 = "/cct"; |
||
178 | SlashCmdList["COOLDOWNCOUNTSLASHFLASHSPEED"] = CooldownCount_FlashSpeed_ChatCommandHandler; |
||
179 | SLASH_COOLDOWNCOUNTSLASHFLASHSPEED1 = "/cooldowncountflashspeed"; |
||
180 | SLASH_COOLDOWNCOUNTSLASHFLASHSPEED2 = "/ccflashspeed"; |
||
181 | SLASH_COOLDOWNCOUNTSLASHFLASHSPEED3 = "/ccfs"; |
||
182 | SlashCmdList["COOLDOWNCOUNTSLASHSCALE"] = CooldownCount_Scale_ChatCommandHandler; |
||
183 | SLASH_COOLDOWNCOUNTSLASHSCALE1 = "/cooldowncountscale"; |
||
184 | SLASH_COOLDOWNCOUNTSLASHSCALE2 = "/ccscale"; |
||
185 | SLASH_COOLDOWNCOUNTSLASHSCALE3 = "/ccs"; |
||
186 | ]]-- |
||
187 | end |
||
188 | this:RegisterEvent("ACTIONBAR_PAGE_CHANGED"); |
||
189 | |||
190 | if ( Cosmos_RegisterChatCommand ) then |
||
191 | local CooldownCountMainCommands = {"/cooldowncount", "/cc", "/cooldowncountenable", "/ccenable", "/cce", "/cooldowncountdisable", "/ccdisable", "/ccd","/cooldowncounttoggle","/cctoggle","/cct"}; |
||
192 | Cosmos_RegisterChatCommand ( |
||
193 | "COOLDOWNCOUNT_MAIN_COMMANDS", -- Some Unique Group ID |
||
194 | CooldownCountMainCommands, -- The Commands |
||
195 | CooldownCount_Main_ChatCommandHandler, |
||
196 | COOLDOWNCOUNT_CHAT_COMMAND_MAIN_INFO -- Description String |
||
197 | ); |
||
198 | --[[ |
||
199 | local CooldownCountEnableCommands = {"/cooldowncountenable", "/ccenable", "/cce", "/cooldowncountdisable", "/ccdisable", "/ccd","/cooldowncounttoggle","/cctoggle","/cct"}; |
||
200 | Cosmos_RegisterChatCommand ( |
||
201 | "COOLDOWNCOUNT_ENABLE_COMMANDS", -- Some Unique Group ID |
||
202 | CooldownCountEnableCommands, -- The Commands |
||
203 | CooldownCount_Enable_ChatCommandHandler, |
||
204 | COOLDOWNCOUNT_CHAT_COMMAND_ENABLE_INFO -- Description String |
||
205 | ); |
||
206 | local CooldownCountFlashSpeedCommands = {"/cooldowncountflashspeed", "/ccflashspeed", "/ccfs"}; |
||
207 | Cosmos_RegisterChatCommand ( |
||
208 | "COOLDOWNCOUNT_FLASHSPEED_COMMANDS", -- Some Unique Group ID |
||
209 | CooldownCountFlashSpeedCommands, -- The Commands |
||
210 | CooldownCount_FlashSpeed_ChatCommandHandler, |
||
211 | COOLDOWNCOUNT_CHAT_COMMAND_FLASHSPEED_INFO -- Description String |
||
212 | ); |
||
213 | local CooldownCountScaleCommands = {"/cooldowncountscale", "/ccscale", "/ccs"}; |
||
214 | Cosmos_RegisterChatCommand ( |
||
215 | "COOLDOWNCOUNT_SCALE_COMMANDS", -- Some Unique Group ID |
||
216 | CooldownCountScaleCommands, -- The Commands |
||
217 | CooldownCount_Scale_ChatCommandHandler, |
||
218 | COOLDOWNCOUNT_CHAT_COMMAND_SCALE_INFO -- Description String |
||
219 | ); |
||
220 | ]]-- |
||
221 | end |
||
222 | end |
||
223 | |||
224 | function CooldownCount_GetChatValue(msg) |
||
225 | msg = string.lower(msg); |
||
226 | -- Toggle appropriately |
||
227 | if ( (string.find(msg, COOLDOWNCOUNT_PARAM_ON)) or ((string.find(msg, '1')) and (not string.find(msg, '-1')) ) ) then |
||
228 | return 1; |
||
229 | else |
||
230 | if ( (string.find(msg, COOLDOWNCOUNT_PARAM_OFF)) or (string.find(msg, '0')) ) then |
||
231 | return 0; |
||
232 | else |
||
233 | return -1; |
||
234 | end |
||
235 | end |
||
236 | end |
||
237 | |||
238 | |||
239 | function CooldownCount_Enable_ChatCommandHandler(msg) |
||
240 | CooldownCount_Toggle_Enabled(1); |
||
241 | end |
||
242 | |||
243 | function CooldownCount_Disable_ChatCommandHandler(msg) |
||
244 | CooldownCount_Toggle_Enabled(0); |
||
245 | end |
||
246 | |||
247 | function CooldownCount_Set_ChatCommandHandler(msg) |
||
248 | local value = CooldownCount_GetChatValue(msg); |
||
249 | CooldownCount_Toggle_Enabled(value); |
||
250 | end |
||
251 | |||
252 | function CooldownCount_NoSpaces_ChatCommandHandler(msg) |
||
253 | local value = CooldownCount_GetChatValue(msg); |
||
254 | CooldownCount_Toggle_NoSpaces(value); |
||
255 | end |
||
256 | |||
257 | function CooldownCount_UseLongTimers_ChatCommandHandler(msg) |
||
258 | local value = CooldownCount_GetChatValue(msg); |
||
259 | CooldownCount_Toggle_UseLongTimers(value); |
||
260 | end |
||
261 | |||
262 | function CooldownCount_Scale_ChatCommandHandler(msg) |
||
263 | local scale = nil; |
||
264 | if ( msg ) and ( strlen(msg) > 0 ) then |
||
265 | scale = tonumber(msg); |
||
266 | end |
||
267 | if ( scale ) then |
||
268 | CooldownCount_SetUserScale(scale); |
||
269 | else |
||
270 | CooldownCount_Print(COOLDOWNCOUNT_CHAT_USERSCALE_NOT_SPECIFIED); |
||
271 | end |
||
272 | end |
||
273 | |||
274 | function CooldownCount_Alpha_ChatCommandHandler(msg) |
||
275 | local alpha = nil; |
||
276 | if ( msg ) and ( strlen(msg) > 0 ) then |
||
277 | alpha = tonumber(msg); |
||
278 | end |
||
279 | if ( alpha ) then |
||
280 | CooldownCount_Set_Alpha(alpha); |
||
281 | else |
||
282 | CooldownCount_Print(COOLDOWNCOUNT_CHAT_ALPHA_NOT_SPECIFIED); |
||
283 | end |
||
284 | end |
||
285 | |||
286 | function CooldownCount_HideUntilTimeLeft_ChatCommandHandler(msg) |
||
287 | local timeLeft = nil; |
||
288 | if ( msg ) and ( strlen(msg) > 0 ) then |
||
289 | timeLeft = tonumber(msg); |
||
290 | end |
||
291 | if ( timeLeft ) then |
||
292 | CooldownCount_SetHideUntilTimeLeft(timeLeft); |
||
293 | else |
||
294 | CooldownCount_Print(COOLDOWNCOUNT_CHAT_HIDEUNTILTIMELEFT_NOT_SPECIFIED); |
||
295 | end |
||
296 | end |
||
297 | |||
298 | -- Handles chat - e.g. slashcommands - enabling/disabling the CooldownCount |
||
299 | function CooldownCount_FlashSpeed_ChatCommandHandler(msg) |
||
300 | msg = string.lower(msg); |
||
301 | |||
302 | -- Toggle appropriately |
||
303 | local num = tonumber(msg); |
||
304 | if ( num ) then |
||
305 | CooldownCount_SetFlashSpeed(num); |
||
306 | end |
||
307 | end |
||
308 | |||
309 | function CooldownCount_PrintUsage() |
||
310 | for k, v in COOLDOWNCOUNT_SLASH_USAGE do |
||
311 | CooldownCount_Print(v); |
||
312 | end |
||
313 | end |
||
314 | |||
315 | function CooldownCount_Main_ChatCommandHandler(msg) |
||
316 | local cmd, params = CooldownCount_Extract_NextParameter(msg); |
||
317 | cmd = string.lower(cmd); |
||
318 | if ( string.find(cmd, COOLDOWNCOUNT_SLASH_ENABLE ) ) then |
||
319 | return CooldownCount_Enable_ChatCommandHandler(params); |
||
320 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_DISABLE ) ) then |
||
321 | return CooldownCount_Disable_ChatCommandHandler(params); |
||
322 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_SET ) ) then |
||
323 | return CooldownCount_Set_ChatCommandHandler(params); |
||
324 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_FLASHSPEED ) ) then |
||
325 | return CooldownCount_FlashSpeed_ChatCommandHandler(params); |
||
326 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_SCALE ) ) then |
||
327 | return CooldownCount_Scale_ChatCommandHandler(params); |
||
328 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_ALPHA ) ) then |
||
329 | return CooldownCount_Alpha_ChatCommandHandler(params); |
||
330 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_NOSPACES ) ) then |
||
331 | return CooldownCount_NoSpaces_ChatCommandHandler(params); |
||
332 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_NORMALCOLOR ) ) then |
||
333 | return CooldownCount_NormalColorSetButton(true); |
||
334 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_FLASHCOLOR ) ) then |
||
335 | return CooldownCount_FlashColorSetButton(true); |
||
336 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_USELONGTIMERS ) ) then |
||
337 | return CooldownCount_UseLongTimers_ChatCommandHandler(params); |
||
338 | elseif ( string.find(cmd, COOLDOWNCOUNT_SLASH_HIDEUNTILTIMELEFT ) ) then |
||
339 | return CooldownCount_HideUntilTimeLeft_ChatCommandHandler(params); |
||
340 | else |
||
341 | CooldownCount_PrintUsage(); |
||
342 | return; |
||
343 | end |
||
344 | end |
||
345 | |||
346 | |||
347 | function CooldownCount_LoadOptions() |
||
348 | if ( CooldownCount_Cosmos_Registered == 0 ) then |
||
349 | local value = CooldownCount_Enabled; |
||
350 | if (value == nil ) then |
||
351 | -- defaults to off |
||
352 | value = 0; |
||
353 | end |
||
354 | CooldownCount_Toggle_Enabled(value); |
||
355 | |||
356 | local value = CooldownCount_TimeBetweenFlashes; |
||
357 | if (value == nil ) then |
||
358 | value = 0.25; |
||
359 | end |
||
360 | CooldownCount_SetFlashSpeed(value); |
||
361 | |||
362 | local value = CooldownCount_UserScale; |
||
363 | if (value == nil ) then |
||
364 | value = 2; |
||
365 | end |
||
366 | CooldownCount_SetUserScale(value); |
||
367 | |||
368 | local value = CooldownCount_UseLongTimerDescriptions; |
||
369 | if (value == nil ) then |
||
370 | value = 1; |
||
371 | end |
||
372 | CooldownCount_Toggle_UseLongTimers(value); |
||
373 | if ( CooldownCountOptions ) then |
||
374 | CooldownCount_Set_Alpha(CooldownCountOptions.alpha); |
||
375 | CooldownCount_Set_NormalColor(CooldownCountOptions.color.normal); |
||
376 | CooldownCount_Set_FlashColor(CooldownCountOptions.color.flash); |
||
377 | end |
||
378 | local value = CooldownCount_NoSpaces; |
||
379 | if ( value == nil ) then |
||
380 | value = 0; |
||
381 | end |
||
382 | CooldownCount_Toggle_NoSpaces(value); |
||
383 | local value = CooldownCount_HideUntilTimeLeft; |
||
384 | if ( value == nil ) then |
||
385 | value = 0; |
||
386 | end |
||
387 | CooldownCount_SetHideUntilTimeLeft(value); |
||
388 | end |
||
389 | end |