vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 CountDoomLayouts = {};
2  
3 local CDL = {};
4 ---------------------------------------
5 --
6 -- CountDoom's default text only layout
7 --
8 ---------------------------------------
9 -- Common button attributes
10 CDL.button = {};
11 CDL.button.visible = true;
12 CDL.button.width = 30;
13 CDL.button.height = 15;
14 CDL.button.point = "TOPLEFT";
15 CDL.button.relativeObject = "previous";
16 CDL.button.relativePoint = "BOTTOMLEFT";
17 CDL.button.xoffset = 0;
18 CDL.button.yoffset = 0;
19  
20 -- Overrides for specific buttons
21 CDL.button0 = {};
22 CDL.button0.relativeObject = "frame";
23 CDL.button0.relativePoint = "TOPLEFT";
24 CDL.button0.xoffset = 5;
25 CDL.button0.yoffset = -5;
26  
27 -- Texture/Icon settings
28 CDL.texture = {};
29 CDL.texture.visible = false;
30 CDL.texture.width = 30;
31 CDL.texture.height = 15;
32  
33 -- Text settings
34 CDL.text = {};
35 CDL.text.visible = true;
36 CDL.text.point = "LEFT";
37 CDL.text.relativeObject = "button";
38 CDL.text.relativePoint = "LEFT";
39 CDL.text.xoffset = 0;
40 CDL.text.yoffset = 0;
41 CDL.text.formatString = "$ti";
42  
43 -- Frame settings
44 CDL.frame = {};
45 CDL.frame.visible = false;
46 CDL.frame.point = "TOP";
47 CDL.frame.relativeObject = "UIParent";
48 CDL.frame.relativePoint = nil;
49 CDL.frame.xoffset = 150;
50 CDL.frame.yoffset = -50;
51 CDL.frame.widthPerTimer = 0;
52 CDL.frame.widthBase = 5 + 5 + 250;
53 CDL.frame.heightPerTimer = 15;
54 CDL.frame.heightBase = 5 + 5;
55  
56 -- Store this in our table
57 CountDoomLayouts.textonly = CDL;
58 CDL = {};
59  
60  
61 ---------------------------------------
62 --
63 -- CountDoom's default horizontal layout
64 --
65 ---------------------------------------
66 -- Common button attributes
67 CDL.button = {};
68 CDL.button.visible = true;
69 CDL.button.width = 30;
70 CDL.button.height = 30;
71 CDL.button.point = "TOPLEFT";
72 CDL.button.relativeObject = "previous";
73 CDL.button.relativePoint = "TOPRIGHT";
74 CDL.button.xoffset = 0;
75 CDL.button.yoffset = 0;
76  
77 -- Overrides for specific buttons
78 CDL.button0 = {};
79 CDL.button0.relativeObject = "frame";
80 CDL.button0.relativePoint = "TOPLEFT";
81 CDL.button0.xoffset = 5;
82 CDL.button0.yoffset = -5;
83  
84 -- Texture/Icon settings
85 CDL.texture = {};
86 CDL.texture.visible = true;
87 CDL.texture.width = 30;
88 CDL.texture.height = 30;
89  
90 -- Text settings
91 CDL.text = {};
92 CDL.text.visible = true;
93 CDL.text.point = "LEFT";
94 CDL.text.relativeObject = "button";
95 CDL.text.relativePoint = "LEFT";
96 CDL.text.xoffset = 0;
97 CDL.text.yoffset = -(5 + (CDL.button.height/2));
98 CDL.text.formatString = "$ti";
99  
100 -- Frame settings
101 CDL.frame = {};
102 CDL.frame.visible = false;
103 CDL.frame.point = "TOP";
104 CDL.frame.relativeObject = "UIParent";
105 CDL.frame.relativePoint = nil;
106 CDL.frame.xoffset = 150;
107 CDL.frame.yoffset = -50;
108 CDL.frame.widthPerTimer = CDL.button.width;
109 CDL.frame.widthBase = 5 + 5;
110 CDL.frame.heightPerTimer = 0;
111 CDL.frame.heightBase = 5 + 5 + CDL.button.height + 12;
112  
113 -- Store this in our table
114 CountDoomLayouts.horizontal = CDL;
115 CDL = {};
116  
117  
118 ---------------------------------------
119 --
120 -- CountDoom's default vertical layout
121 --
122 ---------------------------------------
123 -- Common button attributes
124 CDL.button = {};
125 CDL.button.visible = true;
126 CDL.button.width = 30;
127 CDL.button.height = 30;
128 CDL.button.point = "TOPLEFT";
129 CDL.button.relativeObject = "previous";
130 CDL.button.relativePoint = "BOTTOMLEFT";
131 CDL.button.xoffset = 0;
132 CDL.button.yoffset = 0;
133  
134 -- Overrides for specific buttons
135 CDL.button0 = {};
136 CDL.button0.relativeObject = "frame";
137 CDL.button0.relativePoint = "TOPLEFT";
138 CDL.button0.xoffset = 5;
139 CDL.button0.yoffset = -5;
140  
141 -- Texture/Icon settingsCDL.
142 CDL.texture = {};
143 CDL.texture.visible = true;
144 CDL.texture.width = 30;
145 CDL.texture.height = 30;
146  
147 -- Text settings
148 CDL.text = {};
149 CDL.text.visible = true;
150 CDL.text.point = "LEFT";
151 CDL.text.relativeObject = "button";
152 CDL.text.relativePoint = "LEFT";
153 CDL.text.xoffset = CDL.button.width + 10;
154 CDL.text.yoffset = -7;
155 CDL.text.formatString = "$ti";
156  
157 -- Frame settings
158 CDL.frame = {};
159 CDL.frame.visible = false;
160 CDL.frame.point = "TOP";
161 CDL.frame.relativeObject = "UIParent";
162 CDL.frame.relativePoint = nil;
163 CDL.frame.xoffset = 150;
164 CDL.frame.yoffset = -50;
165 CDL.frame.widthPerTimer = 0;
166 CDL.frame.widthBase = 5 + 5 + CDL.button.width + 40;
167 CDL.frame.heightPerTimer = CDL.button.height;
168 CDL.frame.heightBase = 5 + 5;
169  
170 -- Store this in our table
171 CountDoomLayouts.vertical = CDL;
172 CDL = {};
173  
174 CountDoomLayout = {};
175  
176 -- Function to set the parameters on a frame
177 CountDoomLayout.LoadFrameSettings = function( CDL )
178 local numTimers = CDTimer_maxButtons;
179 if numTimers == 0 then
180 numTimers = 1;
181 end
182  
183 -- Set the frame parameters
184 local frame = CDL.frame;
185 if frame ~= nil then
186  
187 local obj = CountDoomFrame;
188  
189 --[[
190 -- The frame is enabled/disabled when timers are active or unlocked.
191 if frame.visible then
192 obj:Show();
193 else
194 obj:Hide();
195 end
196 --]]
197  
198 ---
199 --- Set width
200 ---
201 local width = 0;
202 if frame.widthPerTimer ~= nil then
203 width = frame.widthPerTimer * numTimers;
204 end
205  
206 if frame.widthBase ~= nil then
207 width = width + frame.widthBase;
208 end
209  
210 if width ~= 0 then
211 obj:SetWidth( width );
212 end
213  
214 ---
215 --- Set height
216 ---
217 local height = 0;
218 if frame.heightPerTimer ~= nil then
219 height = frame.heightPerTimer * numTimers;
220 end
221  
222 if frame.heightBase ~= nil then
223 height = height + frame.heightBase;
224 end
225  
226 if height ~= 0 then
227 obj:SetHeight( height );
228 end
229  
230 --[[
231 CDL.frame = {};
232 CDL.frame.point = "TOP";
233 CDL.frame.relativeObject = "UIParent";
234 CDL.frame.relativePoint = nil;
235 CDL.frame.xoffset = 150;
236 CDL.frame.yoffset = -50;
237 --]]
238 end;
239 end;
240  
241  
242 CountDoomLayout.LoadButtonSettings = function( CDL )
243 local buttonID = 0;
244 local prevObj = nil;
245  
246 if CDL.button == nil then
247 CountDoom.prt( "No button settings found." );
248 return;
249 end;
250  
251 for buttonID = 0, CDTimer_maxButtons - 1 do
252 local obj = getglobal( "CDTimerButton" .. buttonID);
253  
254 if obj ~= nil then
255  
256 local overrideString = "button" .. buttonID;
257  
258 local point = CDL.button.point;
259 if CDL[overrideString] ~= nil and
260 CDL[overrideString].point ~= nil then
261 point = CDL[overrideString].point;
262 end;
263  
264 local relativeObjectString = CDL.button.relativeObject;
265 if CDL[overrideString] ~= nil and
266 CDL[overrideString].relativeObject ~= nil then
267 relativeObjectString = CDL[overrideString].relativeObject;
268 end;
269  
270 local relativePoint = CDL.button.relativePoint;
271 if CDL[overrideString] ~= nil and
272 CDL[overrideString].relativePoint ~= nil then
273 relativePoint = CDL[overrideString].relativePoint;
274 end;
275  
276 local xoffset = CDL.button.xoffset;
277 if CDL[overrideString] ~= nil and
278 CDL[overrideString].xoffset ~= nil then
279 xoffset = CDL[overrideString].xoffset;
280 end;
281  
282 local yoffset = CDL.button.yoffset;
283 if CDL[overrideString] ~= nil and
284 CDL[overrideString].yoffset ~= nil then
285 yoffset = CDL[overrideString].yoffset;
286 end;
287  
288 if relativeObjectString == "previous" then
289 relativeObject = prevObj;
290 elseif relativeObjectString == "frame" then
291 relativeObject = CountDoomFrame;
292 else
293 relativeObject = getglobal( relativeObjectString );
294 end;
295  
296 if point ~= nil and
297 relativeObject ~= nil and
298 relativePoint ~= nil and
299 xoffset ~= nil and
300 yoffset ~= nil then
301 --
302 -- Set this button's anchor information
303 obj:ClearAllPoints();
304 obj:SetPoint(point, relativeObject, relativePoint, xoffset, yoffset);
305 end;
306  
307 --
308 -- Set button width
309 --
310 local width = CDL.button.width;
311 if CDL[overrideString] ~= nil and
312 CDL[overrideString].width ~= nil then
313 width = CDL[overrideString].width;
314 end;
315  
316 if width ~= nil then
317 obj:SetWidth(width);
318 end;
319  
320 --
321 -- Set button height
322 --
323 local height = CDL.button.height;
324 if CDL[overrideString] ~= nil and
325 CDL[overrideString].height ~= nil then
326 height = CDL[overrideString].height;
327 end;
328  
329 if height ~= nil then
330 obj:SetHeight(height);
331 end;
332  
333 --
334 -- Button visibility is determined by an active timer.
335 -- Not sure we should be setting here.
336 --
337 end;
338  
339 prevObj = obj;
340 end;
341 end;
342  
343  
344 CountDoomLayout.LoadTextSettings = function( CDL )
345 local buttonID = 0;
346 local prevObj = nil;
347  
348 if CDL.button == nil then
349 CountDoom.prt( "No button settings found." );
350 return;
351 end;
352  
353 for buttonID = 0, CDTimer_maxButtons - 1 do
354 local obj = getglobal( "CDTimerButton" .. buttonID .. "_DurationText" );
355  
356 if obj ~= nil then
357  
358 local point = CDL.text.point;
359 local relativeObjectString = CDL.text.relativeObject;
360 local relativePoint = CDL.text.relativePoint;
361 local xoffset = CDL.text.xoffset;
362 local yoffset = CDL.text.yoffset;
363  
364 if relativeObjectString == "previous" then
365 relativeObject = prevObj;
366 elseif relativeObjectString == "frame" then
367 relativeObject = CountDoomFrame;
368 elseif relativeObjectString == "button" then
369 relativeObject = getglobal( "CDTimerButton" .. buttonID );
370 else
371 relativeObject = getglobal( relativeObjectString );
372 end;
373  
374 if point ~= nil and
375 relativeObject ~= nil and
376 relativePoint ~= nil and
377 xoffset ~= nil and
378 yoffset ~= nil then
379 --
380 -- Set this button's anchor information
381 obj:ClearAllPoints();
382 obj:SetPoint(point, relativeObject, relativePoint, xoffset, yoffset);
383 end;
384  
385 --
386 -- Set width
387 --
388 local width = CDL.text.width;
389 if width ~= nil then
390 obj:SetWidth(width);
391 end;
392  
393 --
394 -- Set height
395 --
396 local height = CDL.text.height;
397 if height ~= nil then
398 obj:SetHeight(height);
399 end;
400  
401 --
402 -- Set visibility
403 --
404 local visible = CDL.text.visible;
405 if visible then
406 obj:Show();
407 else
408 obj:Hide();
409 end;
410 end;
411  
412 prevObj = obj;
413 end;
414  
415 end;
416  
417  
418 CountDoomLayout.LoadIconSettings = function( CDL )
419 local buttonID = 0;
420 local prevObj = nil;
421  
422 if CDL.button == nil then
423 CountDoom.prt( "No button settings found." );
424 return;
425 end;
426  
427 for buttonID = 0, CDTimer_maxButtons - 1 do
428 local obj = getglobal( "CDTimerButton" .. buttonID .. "_Icon" );
429  
430 if obj ~= nil then
431 local width = CDL.texture.width;
432 if width ~= nil then
433 obj:SetWidth(width);
434 end;
435  
436 local height = CDL.texture.height;
437 if height ~= nil then
438 obj:SetHeight(height);
439 end;
440  
441 local visible = CDL.texture.visible;
442 if visible then
443 obj:Show();
444 else
445 obj:Hide();
446 end;
447 end;
448  
449 prevObj = obj;
450 end;
451 end;
452  
453  
454 -- Function to load a layout
455 CountDoomLayout.Load = function ( layout )
456 if layout == nil then
457 CountDoom.prt( "nil passed to CountDoomLayout.Load" );
458 return;
459 end;
460  
461 local CDL = CountDoomLayouts[ layout ];
462 if CDL == nil then
463 CountDoom.prt( "Layout " .. layout .. " not found." );
464 return;
465 end;
466  
467 CountDoomLayout.LoadFrameSettings( CDL );
468 CountDoomLayout.LoadButtonSettings( CDL );
469 CountDoomLayout.LoadTextSettings( CDL );
470 CountDoomLayout.LoadIconSettings( CDL );
471  
472 CountDoom.prt( "Layout " .. layout .. " loaded." );
473 end;
474  
475  
476 CountDoomLayout.Delete = function ( layout )
477 if layout == nil then
478 CountDoom.prt( "nil passed to CountDoomLayout.Delete" );
479 return;
480 end;
481  
482 if CountDoomLayouts[ layout ] == nil then
483 CountDoom.prt( "Layout " .. layout .. " not found." );
484 return;
485 end;
486  
487 CountDoomLayouts[ layout ] = nil;
488  
489 CountDoom.prt( "Layout " .. layout .. " deleted." );
490 end;
491  
492  
493 function CDIcon_Update(arg1)
494 end;
495  
496  
497 CountDoomLayout.textTable = {};
498  
499  
500 CountDoomLayout.GetRemainingTime = function( timerIndex, countDown )
501 local minutes = 0;
502 local seconds = 0;
503 local hseconds = 0;
504  
505 if( CDTimers[ timerIndex ] == nil ) then
506 CountDoom.dpf( "Invalid timerIndex in CountDoomLayout.textTable: " .. timerIndex );
507 return minutes, seconds, hseconds;
508 end
509  
510 local currentTime = GetTime();
511 local rawDelta = currentTime - CDTimers[ timerIndex ].startTime;
512 local duration = CDTimers[ timerIndex ].duration;
513 local warningTime = CDTimers[ timerIndex ].warningTime;
514  
515 local delta = floor(rawDelta);
516 if( delta > duration ) then
517 delta = duration;
518 end
519  
520 -- Invert for count down situations
521 local timeDelta = rawDelta;
522 if( countDown ) then
523 timeDelta = duration - rawDelta;
524 end
525  
526 local signScalar = 1;
527 if timeDelta < 0 then
528 signScalar = -1;
529 timeDelta = -timeDelta;
530 end
531  
532 local minutes = signScalar * floor(timeDelta/60);
533 local seconds = floor(math.mod(timeDelta, 60));
534 local hseconds = floor(math.mod(floor(rawDelta*100), 100));
535  
536 return minutes, seconds, hseconds;
537 end;
538  
539  
540 CountDoomLayout.textTable[ "$t1" ] = function( textStr, timerIndex )
541 local countDown = CDTimers[ timerIndex ].countDown;
542 local minutes, seconds, hseconds = CountDoomLayout.GetRemainingTime( timerIndex, countDown );
543  
544 local timeText = "" .. minutes;
545 textStr = string.gsub(textStr, '$t1', timeText);
546 return textStr;
547 end;
548  
549  
550 CountDoomLayout.textTable[ "$t2" ] = function( textStr, timerIndex )
551 local countDown = CDTimers[ timerIndex ].countDown;
552 local minutes, seconds, hseconds = CountDoomLayout.GetRemainingTime( timerIndex, countDown );
553  
554 local timeText = "";
555 if (seconds >= 10) then
556 timeText = minutes .. ":" .. seconds;
557 else
558 timeText = minutes .. ":0" .. seconds;
559 end
560  
561 textStr = string.gsub(textStr, '$t2', timeText);
562 return textStr;
563 end;
564  
565  
566 CountDoomLayout.textTable[ "$t3" ] = function( textStr, timerIndex )
567 local countDown = CDTimers[ timerIndex ].countDown;
568 local minutes, seconds, hseconds = CountDoomLayout.GetRemainingTime( timerIndex, countDown );
569  
570 local timeText = "";
571 if (seconds >= 10) then
572 timeText = minutes .. ":" .. seconds;
573 else
574 timeText = minutes .. ":0" .. seconds;
575 end
576  
577 local htimeText = "";
578 if (hseconds >= 10) then
579 htimeText = "." .. hseconds;
580 else
581 htimeText = ".0" .. hseconds;
582 end
583  
584 textStr = string.gsub(textStr, '$t3', timeText .. htimeText);
585 return textStr;
586 end;
587  
588  
589 function CDText_Update(arg1)
590 --[[
591 if( CDTimers[ timerIndex ] == nil ) then
592 CountDoom.dpf( "Invalid timerIndex in CountDoomLayout.textTable: " .. timerIndex );
593 return;
594 end
595 --]]
596 end;
597  
598  
599 CDLTest = function()
600 CountDoomLayout.Load( "NotFoundLayout" );
601 CountDoomLayout.Load( "horizontal" );
602 CountDoomLayout.Load( "vertical" );
603 CountDoomLayout.Load( "textonly" );
604  
605 --CountDoomLayout.Delete( "textonly" );
606  
607 CountDoomLayout.Load( "horizontal" );
608 CountDoomLayout.Load( "vertical" );
609 CountDoomLayout.Load( "textonly" );
610 end;