vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 TITAN_PANEL_FRAME_SPACEING = 20;
2 TITAN_PANEL_ICON_SPACEING = 4;
3 TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE = 10;
4 TITAN_AUTOHIDE_WAIT_TIME = 0.5;
5 TITAN_PANEL_INITIAL_PLUGINS = {"Coords", "XP", "LootType", "Clock", "Volume", "UIScale", "Trans", "AutoHide", "HonorPlus", "Bag", "Money", "AuxAutoHide", "Repair", "ItemBonuses"};
6 TITAN_PANEL_INITIAL_PLUGIN_LOCATION = {"Bar", "Bar", "Bar", "Bar", "Bar", "Bar", "Bar", "Bar", "AuxBar", "AuxBar", "AuxBar", "AuxBar", "AuxBar", "AuxBar"};
7  
8 TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY = {"General","Combat","Information","Interface","Profession"}
9 TITAN_PANEL_BUTTONS_ALIGN_LEFT = 1;
10 TITAN_PANEL_BUTTONS_ALIGN_CENTER = 2;
11 TITAN_PANEL_BUTTONS_ALIGN_RIGHT = 3;
12  
13 TITAN_PANEL_BARS_SINGLE = 1;
14 TITAN_PANEL_BARS_DOUBLE = 2;
15  
16 TITAN_PANEL_BUTTONS_INIT_FLAG = nil;
17 TITAN_PANEL_SELECTED = "Bar";
18  
19 TITAN_PANEL_FROM_TOP = -25;
20 TITAN_PANEL_FROM_BOTTOM = 25;
21 TITAN_PANEL_FROM_BOTTOM_MAIN = 1;
22 TITAN_PANEL_FROM_TOP_MAIN = 1;
23  
24 TITAN_PANEL_MOVE_ADDON = nil;
25 TITAN_PANEL_DROPOFF_ADDON = nil;
26 TITAN_PANEL_NEXT_ADDON = nil;
27 TITAN_PANEL_MOVING = 0;
28  
29 TITAN_PANEL_SAVED_VARIABLES = {
30 Buttons = TITAN_PANEL_INITIAL_PLUGINS,
31 Location = TITAN_PANEL_INITIAL_PLUGIN_LOCATION,
32 Transparency = 0.7,
33 Scale = 1,
34 FontScale = 1,
35 ScreenAdjust = TITAN_NIL,
36 AutoHide = TITAN_NIL,
37 Position = TITAN_PANEL_PLACE_TOP,
38 DoubleBar = TITAN_PANEL_BARS_SINGLE,
39 ButtonAlign = TITAN_PANEL_BUTTONS_ALIGN_LEFT,
40 BothBars = 1,
41 AuxScreenAdjust = TITAN_NIL,
42 AuxAutoHide = TITAN_NIL,
43 AuxDoubleBar = TITAN_PANEL_BARS_SINGLE,
44 AuxButtonAlign = TITAN_PANEL_BUTTONS_ALIGN_LEFT,
45 VersionShown = 1,
46 ToolTipsShown = 1,
47 DisableFont = TITAN_NIL,
48 CastingBar = 1
49 };
50  
51 function TitanPanelBarButton_OnLoad()
52 this:RegisterEvent("ADDON_LOADED");
53 this:RegisterEvent("VARIABLES_LOADED");
54 this:RegisterEvent("PLAYER_ENTERING_WORLD");
55 this:RegisterEvent("UNIT_NAME_UPDATE");
56 this:RegisterEvent("TIME_PLAYED_MSG");
57 this:RegisterEvent("PLAYER_LEVEL_UP");
58 this:RegisterEvent("CVAR_UPDATE");
59 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
60 this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
61 end
62  
63 function TitanPanelBarButton_OnEvent(frame)
64 if frame == "TitanPanelBarButton" then
65 if (event == "VARIABLES_LOADED") then
66 TitanVariables_InitTitanSettings();
67  
68 elseif (event == "ADDON_LOADED") then
69 TitanPanel_AddonLoaded(arg1);
70  
71 elseif (event == "UNIT_NAME_UPDATE") then
72 TitanVariables_InitDetailedSettings();
73  
74 elseif (event == "PLAYER_ENTERING_WORLD") then
75 TitanVariables_InitDetailedSettings();
76  
77 -- Initial session time
78 if (not this.sessionTime) then
79 this.sessionTime = 0;
80 RequestTimePlayed();
81 end
82  
83 if ( not ServerTimeOffsets ) then
84 ServerTimeOffsets = {};
85 end
86  
87 local realmName = GetCVar("realmName");
88  
89 if ( ServerTimeOffsets[realmName] ) then
90 TitanSetVar(TITAN_CLOCK_ID, "OffsetHour", ServerTimeOffsets[realmName]);
91 end
92  
93 elseif ( event == "PLAYER_LEAVING_WORLD" ) then
94 local realmName = GetCVar("realmName");
95 ServerTimeOffsets[realmName] = TitanGetVar(TITAN_CLOCK_ID, "OffsetHour");
96  
97 elseif (event == "TIME_PLAYED_MSG") then
98 -- Remember play time
99 this.totalTime = arg1;
100 this.levelTime = arg2;
101  
102 -- Move frames
103 TitanPanelFrame_ScreenAdjust();
104  
105 -- Init panel buttons
106 TitanPanel_InitPanelBarButton();
107 TitanPanel_InitPanelButtons();
108  
109 -- Set initial Panel AutoHide
110 if (TitanPanelGetVar("AutoHide")) then
111 TitanPanelBarButton_Hide("TitanPanelBarButton", TitanPanelGetVar("Position"));
112 end
113 if (TitanPanelGetVar("AuxAutoHide")) then
114 TitanPanelBarButton_Hide("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
115 end
116  
117 TitanPanel_SetTransparent("TitanPanelBarButtonHider", TitanPanelGetVar("Position"));
118  
119 elseif (event == "PLAYER_LEVEL_UP") then
120 -- Reset level time
121 this.levelTime = 0;
122  
123 elseif (event == "CVAR_UPDATE") then
124 if (arg1 == "USE_UISCALE" or arg1 == "WINDOWED_MODE") then
125 if (TitanPlayerSettings and TitanPanelGetVar("Scale")) then
126 TitanPanel_SetScale();
127 TitanPanel_RefreshPanelButtons();
128 -- Adjust frame positions
129 TitanPanelFrame_ScreenAdjust();
130 end
131 end
132 elseif (event == "ZONE_CHANGED_NEW_AREA") then
133 -- Move frames
134 TitanPanel_InitPanelButtons();
135 end
136 end
137 end
138  
139 function TitanPanelFrame_ScreenAdjust()
140 TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
141 TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"), TitanPanelGetVar("ScreenAdjust"));
142 TitanMovableFrame_AdjustBlizzardFrames();
143  
144 TitanMovableFrame_CheckFrames(TITAN_PANEL_PLACE_BOTTOM);
145 TitanMovableFrame_MoveFrames(TITAN_PANEL_PLACE_BOTTOM, TitanPanelGetVar("AuxScreenAdjust"));
146 TitanMovableFrame_AdjustBlizzardFrames();
147 end
148  
149 function TitanPanelBarButtonHider_OnUpdate(elapsed)
150 local x, y = GetCursorPosition(UIParent);
151 local scale = UIParent:GetEffectiveScale();
152  
153 if scale ~= 1.0 then
154 y = y / (scale);
155 end
156 if (TitanPanelGetVar("AutoHide") or TitanPanelGetVar("AuxAutoHide")) then
157  
158 if not (TitanPanelRightClickMenu_IsVisible()) then
159 TITAN_PANEL_SELECTED = TitanUtils_GetButtonID(this:GetName())
160 TitanUtils_CheckAutoHideCounting(elapsed);
161 if TITAN_PANEL_SELECTED == "Bar" and TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_TOP then
162 if y < TitanPanelBarButtonHider:GetBottom() and TitanPanelBarButtonHider.isCounting == nil then
163 TitanUtils_StartAutoHideCounting("TitanPanelBarButtonHider");
164 end
165 elseif TITAN_PANEL_SELECTED == "Bar" and TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_BOTTOM then
166 if y > TitanPanelBarButtonHider:GetTop() and TitanPanelBarButtonHider.isCounting == nil then
167 TitanUtils_StartAutoHideCounting("TitanPanelBarButtonHider");
168 end
169 elseif TITAN_PANEL_SELECTED == "AuxBar" then
170 if y > TitanPanelAuxBarButtonHider:GetTop() and TitanPanelAuxBarButtonHider.isCounting == nil then
171 TitanUtils_StartAutoHideCounting("TitanPanelAuxBarButtonHider");
172 end
173 end
174 end
175 end
176  
177 end
178  
179 function TitanPanelBarButton_OnUpdate(elapsed)
180 if TITAN_PANEL_MOVING == 2 and TITAN_PANEL_DROPOFF_ADDON ~= nil then
181 TITAN_PANEL_MOVING = 3;
182 end
183 -- Update play time
184 if (this.totalTime) then
185 this.totalTime = this.totalTime + elapsed;
186 this.sessionTime = this.sessionTime + elapsed;
187 this.levelTime = this.levelTime + elapsed;
188 end
189 TitanPanelFrame_ScreenAdjust();
190 end
191  
192 function TitanPanelBarButton_OnClick(button)
193 if (button == "LeftButton") then
194  
195 TitanUtils_CloseAllControlFrames();
196 TitanUtils_CloseRightClickMenu();
197 elseif (button == "RightButton") then
198 TitanUtils_CloseAllControlFrames();
199 -- Show RightClickMenu anyway
200 if (TitanPanelRightClickMenu_IsVisible()) then
201 TitanPanelRightClickMenu_Close();
202 end
203 TitanPanelRightClickMenu_Toggle();
204 end
205 end
206  
207 function TitanPanelBarButtonHider_OnEnter(frame)
208 if (TitanPanelGetVar("AutoHide") or TitanPanelGetVar("AuxAutoHide")) then
209 local frname = getglobal(frame)
210  
211 if frname.isCounting ~= nil then
212 TitanUtils_StopAutoHideCounting(frame);
213 end
214  
215 if (frame == "TitanPanelBarButtonHider" and TitanPanelBarButton.hide == 1) then
216 if (TitanPanelBarButton.hide) then
217 TitanPanelBarButton_Show("TitanPanelBarButton", TitanPanelGetVar("Position"));
218 end
219 else
220 if (TitanPanelAuxBarButton.hide and TitanPanelAuxBarButton.hide == 1) then
221 if TitanPanelGetVar("BothBars") then
222 TitanPanelBarButton_Show("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
223 end
224 end
225 end
226 end
227 end
228  
229 function TitanPanelBarButtonHider_OnLeave(frame)
230 --Removed
231 end
232  
233 function TitanPanelRightClickMenu_BarOnClick()
234 if (UIDropDownMenuButton_GetChecked()) then
235 TitanPanel_RemoveButton(this.value);
236 else
237 TitanPanel_AddButton(this.value);
238 end
239 end
240  
241 function TitanPanelBarButton_ToggleAlign()
242 if ( TitanPanelGetVar("ButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then
243 TitanPanelSetVar("ButtonAlign", TITAN_PANEL_BUTTONS_ALIGN_LEFT);
244 else
245 TitanPanelSetVar("ButtonAlign", TITAN_PANEL_BUTTONS_ALIGN_CENTER);
246 end
247  
248 -- Justify button position
249 TitanPanelButton_Justify();
250 end
251  
252 function TitanPanelBarButton_ToggleAuxAlign()
253 if ( TitanPanelGetVar("AuxButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then
254 TitanPanelSetVar("AuxButtonAlign", TITAN_PANEL_BUTTONS_ALIGN_LEFT);
255 else
256 TitanPanelSetVar("AuxButtonAlign", TITAN_PANEL_BUTTONS_ALIGN_CENTER);
257 end
258  
259 -- Justify button position
260 TitanPanelButton_Justify();
261 end
262  
263 function TitanPanelBarButton_ToggleDoubleBar()
264 if ( TitanPanelGetVar("DoubleBar") == TITAN_PANEL_BARS_SINGLE ) then
265 TitanPanelSetVar("DoubleBar", TITAN_PANEL_BARS_DOUBLE);
266 TitanPanelBarButtonHider:SetHeight(48);
267 else
268 TitanPanelSetVar("DoubleBar", TITAN_PANEL_BARS_SINGLE);
269 TitanPanelBarButtonHider:SetHeight(24);
270 end
271  
272 TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
273 TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"), TitanPanelGetVar("DoubleBar"));
274 TitanMovableFrame_AdjustBlizzardFrames();
275 TitanPanel_InitPanelBarButton();
276 TitanPanel_InitPanelButtons();
277 TitanPanel_SetTransparent("TitanPanelBarButtonHider", TitanPanelGetVar("Position"));
278  
279 if (TitanPanelGetVar("AutoHide")) then
280 TitanPanelBarButton_Hide("TitanPanelBarButton", TitanPanelGetVar("Position"));
281 end
282 if (TitanPanelGetVar("AuxAutoHide")) then
283 TitanPanelBarButton_Hide("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
284 end
285  
286 end
287  
288 function TitanPanelBarButton_ToggleAuxDoubleBar()
289 if ( TitanPanelGetVar("AuxDoubleBar") == TITAN_PANEL_BARS_SINGLE ) then
290 TitanPanelSetVar("AuxDoubleBar", TITAN_PANEL_BARS_DOUBLE);
291 TitanPanelAuxBarButtonHider:SetHeight(48);
292 else
293 TitanPanelSetVar("AuxDoubleBar", TITAN_PANEL_BARS_SINGLE);
294 TitanPanelAuxBarButtonHider:SetHeight(24);
295 end
296 TitanMovableFrame_CheckFrames(TITAN_PANEL_PLACE_BOTTOM);
297 TitanMovableFrame_MoveFrames(TITAN_PANEL_PLACE_BOTTOM, 1);
298 TitanMovableFrame_AdjustBlizzardFrames();
299 TitanPanel_InitPanelBarButton();
300 TitanPanel_InitPanelButtons();
301 TitanPanel_SetTransparent("TitanPanelAuxBarButtonHider", TITAN_PANEL_PLACE_BOTTOM);
302  
303 if (TitanPanelGetVar("AutoHide")) then
304 TitanPanelBarButton_Hide("TitanPanelBarButton", TitanPanelGetVar("Position"));
305 end
306 if (TitanPanelGetVar("AuxAutoHide")) then
307 TitanPanelBarButton_Hide("TitanPanelAuxBarButton", TitanPanelGetVar("Position"));
308 end
309  
310 end
311  
312 function TitanPanelBarButton_ToggleAutoHide()
313 TitanPanelToggleVar("AutoHide");
314 if (TitanPanelGetVar("AutoHide")) then
315 TitanPanelBarButton_Hide("TitanPanelBarButton", TitanPanelGetVar("Position"));
316 else
317 TitanPanelBarButton_Show("TitanPanelBarButton", TitanPanelGetVar("Position"));
318 end
319 TitanPanelAutoHideButton_SetIcon();
320 end
321  
322 function TitanPanelBarButton_ToggleAuxAutoHide()
323 TitanPanelToggleVar("AuxAutoHide");
324 if (TitanPanelGetVar("AuxAutoHide")) then
325 if TitanPanelGetVar("BothBars") then
326 TitanPanelBarButton_Hide("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
327 end
328 else
329 if TitanPanelGetVar("BothBars") then
330 TitanPanelBarButton_Show("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
331 end
332 end
333 --Needs changing!
334 TitanPanelAuxAutoHideButton_SetIcon();
335 end
336  
337 function TitanPanelBarButton_ToggleScreenAdjust()
338 TitanPanelToggleVar("ScreenAdjust");
339 TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
340 TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"), TitanPanelGetVar("ScreenAdjust"));
341 TitanMovableFrame_AdjustBlizzardFrames();
342 end
343  
344 function TitanPanelBarButton_ToggleAuxScreenAdjust()
345 TitanPanelToggleVar("AuxScreenAdjust");
346 TitanMovableFrame_CheckFrames(TITAN_PANEL_PLACE_BOTTOM);
347 TitanMovableFrame_MoveFrames(TITAN_PANEL_PLACE_BOTTOM, TitanPanelGetVar("AuxScreenAdjust"));
348 TitanMovableFrame_AdjustBlizzardFrames();
349 end
350  
351 function TitanPanelBarButton_TogglePosition()
352 if (TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_TOP) then
353 TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
354 TitanPanelSetVar("Position", TITAN_PANEL_PLACE_BOTTOM);
355 TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"), TitanPanelGetVar("ScreenAdjust"));
356 else
357 TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
358 TitanPanelSetVar("Position", TITAN_PANEL_PLACE_TOP);
359 TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"), TitanPanelGetVar("ScreenAdjust"));
360 end
361  
362 -- Set panel position and texture
363 TitanPanel_SetPosition("TitanPanelBarButton", TitanPanelGetVar("Position"));
364 TitanPanel_SetTexture("TitanPanelBarButton", TitanPanelGetVar("Position"));
365 TitanPanel_SetTransparent("TitanPanelBarButtonHider", TitanPanelGetVar("Position"));
366  
367 -- Adjust frame positions
368 TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
369 TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"), TitanPanelGetVar("ScreenAdjust"));
370 TitanMovableFrame_AdjustBlizzardFrames();
371 TitanPanelButton_Justify();
372  
373 end
374  
375 function TitanPanelBarButton_ToggleBarsShown()
376 TitanPanelToggleVar("BothBars");
377 TitanPanelBarButton_DisplayBarsWanted();
378 TitanPanelRightClickMenu_Close();
379 end
380  
381 function TitanPanelBarButton_ToggleVersionShown()
382 TitanPanelToggleVar("VersionShown");
383 end
384  
385 function TitanPanelBarButton_ToggleToolTipsShown()
386 TitanPanelToggleVar("ToolTipsShown");
387 end
388  
389 function TitanPanelBarButton_ToggleCastingBar()
390 TitanPanelToggleVar("CastingBar");
391 end
392  
393 function TitanPanelBarButton_ToggleDisableFont()
394 TitanPanelToggleVar("DisableFont");
395 if TitanPanelGetVar("DisableFont") then
396 TitanPanelSetVar("FontScale", 1.0);
397 GameTooltip:SetScale(1);
398 end
399 end
400  
401 function TitanPanelBarButton_DisplayBarsWanted()
402 --Need to handle top & bottom
403 if (TitanPanelGetVar("BothBars")) then
404 if (TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_BOTTOM) then
405 TitanPanelBarButton_TogglePosition();
406 end
407  
408 TitanMovableFrame_CheckFrames(TITAN_PANEL_PLACE_TOP);
409 TitanMovableFrame_MoveFrames(TITAN_PANEL_PLACE_TOP, TitanPanelGetVar("ScreenAdjust"));
410  
411 -- Set panel position and texture
412 TitanPanel_SetPosition("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
413 TitanPanel_SetTexture("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
414  
415 -- Adjust frame positions
416 TitanMovableFrame_CheckFrames(TITAN_PANEL_PLACE_BOTTOM);
417 TitanMovableFrame_MoveFrames(TITAN_PANEL_PLACE_BOTTOM, TitanPanelGetVar("AuxScreenAdjust"));
418 TitanMovableFrame_AdjustBlizzardFrames();
419  
420 else
421 TitanPanelBarButton_TogglePosition();
422 TitanPanelBarButton_Hide("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM)
423 TitanPanelBarButton_TogglePosition();
424 end
425 end
426  
427 function TitanPanelBarButton_Show(frame, position)
428 local frName = getglobal(frame);
429 local barnumber = TitanUtils_GetDoubleBar(TitanPanelGetVar("BothBars"), position);
430  
431 if (position == TITAN_PANEL_PLACE_TOP) then
432 frName:ClearAllPoints();
433 frName:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, 0);
434 frName:SetPoint("BOTTOMRIGHT", "UIParent", "TOPRIGHT", 0, -24);
435 else
436 frName:ClearAllPoints();
437 frName:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0);
438 frName:SetPoint("TOPRIGHT", "UIParent", "BOTTOMRIGHT", 0, 24);
439 end
440  
441 frName.hide = nil;
442 end
443  
444 function TitanPanelBarButton_Hide(frame, position)
445 local frName = getglobal(frame);
446 local barnumber = TitanUtils_GetDoubleBar(TitanPanelGetVar("BothBars"), position);
447  
448 if frName ~= nil then
449  
450 if (position == TITAN_PANEL_PLACE_TOP) then
451 frName:ClearAllPoints();
452 frName:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, (35*barnumber));
453 frName:SetPoint("BOTTOMRIGHT", "UIParent", "TOPRIGHT", 0, -3);
454  
455 elseif (position == TITAN_PANEL_PLACE_BOTTOM) and frame == "TitanPanelBarButton" then
456 frName:ClearAllPoints();
457 frName:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, -35);
458 frName:SetPoint("TOPRIGHT", "UIParent", "BOTTOMRIGHT", 0, 3);
459  
460 else
461 if TitanPanelGetVar("BothBars") == nil and frame == "TitanPanelAuxBarButton" then
462 frName:ClearAllPoints();
463 frName:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, (-35*barnumber));
464 frName:SetPoint("TOPRIGHT", "UIParent", "BOTTOMRIGHT", 0, -35);
465 else
466 frName:ClearAllPoints();
467 frName:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, (-35*barnumber));
468 frName:SetPoint("TOPRIGHT", "UIParent", "BOTTOMRIGHT", 0, -35);
469 end
470 end
471  
472 frName.hide = 1;
473 end
474 end
475  
476 function TitanPanel_InitPanelBarButton()
477 -- Set Titan Panel position/textures
478 TitanPanel_SetPosition("TitanPanelBarButton", TitanPanelGetVar("Position"));
479 TitanPanel_SetTexture("TitanPanelBarButton", TitanPanelGetVar("Position"));
480  
481 -- Set initial Panel Scale
482 TitanPanel_SetScale();
483  
484 -- Set initial Panel Transparency
485 TitanPanelBarButton:SetAlpha(TitanPanelGetVar("Transparency"));
486 TitanPanelAuxBarButton:SetAlpha(TitanPanelGetVar("Transparency"));
487 end
488  
489 function TitanPanel_SetPosition(frame, position)
490 local frName = getglobal(frame);
491 if (position == TITAN_PANEL_PLACE_TOP) then
492 if frame == "TitanPanelBarButton" then
493 TitanPanelBackground12:ClearAllPoints();
494 TitanPanelBackground12:SetPoint("BOTTOMLEFT", "TitanPanelBackground0", "BOTTOMLEFT", 0, -25);
495 end
496 frName:ClearAllPoints();
497 frName:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, 0);
498 frName:SetPoint("BOTTOMRIGHT", "UIParent", "TOPRIGHT", 0, -24);
499 else
500 if frame == "TitanPanelBarButton" then
501 TitanPanelBackground12:ClearAllPoints();
502 TitanPanelBackground12:SetPoint("BOTTOMLEFT", "TitanPanelBackground0", "BOTTOMLEFT", 0, 25);
503 end
504 frName:ClearAllPoints();
505 frName:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0);
506 frName:SetPoint("TOPRIGHT", "UIParent", "BOTTOMRIGHT", 0, 24);
507 end
508 end
509  
510 function TitanPanel_SetTransparent(frame, position)
511 local frName = getglobal(frame);
512 local topBars = TitanUtils_GetDoubleBar(TitanPanelGetVar("BothBars"), TITAN_PANEL_PLACE_TOP);
513 local bottomBars = TitanUtils_GetDoubleBar(TitanPanelGetVar("BothBars"), TITAN_PANEL_PLACE_BOTTOM);
514  
515 if (position == TITAN_PANEL_PLACE_TOP) then
516 frName:ClearAllPoints();
517 frName:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, 0);
518 frName:SetPoint("BOTTOMRIGHT", "UIParent", "TOPRIGHT", 0, -24 * topBars);
519 TitanPanelAuxBarButtonHider:ClearAllPoints();
520 TitanPanelAuxBarButtonHider:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0);
521 TitanPanelAuxBarButtonHider:SetPoint("TOPRIGHT", "UIParent", "BOTTOMRIGHT", 0, 24 * bottomBars);
522 elseif position == TITAN_PANEL_PLACE_BOTTOM and frame == "TitanPanelBarButtonHider" then
523 frName:ClearAllPoints();
524 frName:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0);
525 frName:SetPoint("TOPRIGHT", "UIParent", "BOTTOMRIGHT", 0, 24 * bottomBars);
526 TitanPanelAuxBarButtonHider:ClearAllPoints();
527 TitanPanelAuxBarButtonHider:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0);
528 TitanPanelAuxBarButtonHider:SetPoint("TOPRIGHT", "UIParent", "BOTTOMRIGHT", 0, 0);
529 else
530 frName:ClearAllPoints();
531 frName:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0);
532 frName:SetPoint("TOPRIGHT", "UIParent", "BOTTOMRIGHT", 0, 24 * bottomBars);
533 end
534 end
535  
536 function TitanPanel_SetTexture(frame, position)
537 local frName = getglobal(frame);
538 local barnumber = TitanUtils_GetDoubleBar(TitanPanelGetVar("BothBars"), position);
539  
540 if frame == "TitanPanelBarButton" then
541 local pos = TitanUtils_Ternary(position == TITAN_PANEL_PLACE_TOP, "Top", "Bottom");
542 for i = 0, 11 do
543 getglobal("TitanPanelBackground"..i):SetTexture(TITAN_ARTWORK_PATH.."TitanPanelBackground"..pos..math.mod(i, 2));
544 end
545 for i = 12, 22 do
546 if barnumber == 2 then
547 TitanPanelBarButtonHider:SetHeight(48);
548 getglobal("TitanPanelBackground"..i):SetTexture(TITAN_ARTWORK_PATH.."TitanPanelBackground"..pos..math.mod(i, 2));
549 else
550 TitanPanelBarButtonHider:SetHeight(24);
551 getglobal("TitanPanelBackground"..i):SetTexture();
552 end
553 end
554 else
555 local pos = TitanUtils_Ternary(position == TITAN_PANEL_PLACE_BOTTOM, "Top", "Bottom");
556 for i = 0, 11 do
557 getglobal("TitanPanelBackgroundAux"..i):SetTexture(TITAN_ARTWORK_PATH.."TitanPanelBackground".."Bottom"..math.mod(i, 2));
558 end
559 for i = 12, 22 do
560 if barnumber == 2 then
561 TitanPanelAuxBarButtonHider:SetHeight(48);
562 getglobal("TitanPanelBackgroundAux"..i):SetTexture(TITAN_ARTWORK_PATH.."TitanPanelBackground".."Bottom"..math.mod(i, 2));
563 else
564 TitanPanelAuxBarButtonHider:SetHeight(24);
565 getglobal("TitanPanelBackgroundAux"..i):SetTexture();
566 end
567 end
568 end
569 end
570  
571 function TitanPanel_InitPanelButtons()
572 local button, leftButton, rightButton, leftAuxButton, rightAuxButton, leftDoubleButton, rightDoubleButton, leftAuxDoubleButton, rightAuxDoubleButton;
573 local nextLeft, nextAuxLeft
574 local newButtons = {};
575 local scale = TitanPanelGetVar("Scale");
576 local isClockOnRightSide;
577  
578 TitanPanelBarButton_DisplayBarsWanted();
579 -- Position Clock first if it's displayed on the far right side
580 if ( TitanUtils_TableContainsValue(TitanPanelSettings.Buttons, TITAN_CLOCK_ID) and TitanGetVar(TITAN_CLOCK_ID, "DisplayOnRightSide") ) then
581 isClockOnRightSide = 1;
582 button = TitanUtils_GetButton(TITAN_CLOCK_ID);
583 local i = TitanPanel_GetButtonNumber(TITAN_CLOCK_ID)
584  
585 if TitanPanelSettings.Location[i] == nil then
586 TitanPanelSettings.Location[i] = "Bar";
587 end
588 if TitanPanelSettings.Location[i] == "AuxBar" then
589 button:ClearAllPoints();
590 button:SetPoint("RIGHT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "RIGHT", -TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_BOTTOM_MAIN);
591 rightAuxButton = button;
592 else
593 button:ClearAllPoints();
594 button:SetPoint("RIGHT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "RIGHT", -TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_TOP_MAIN);
595 rightButton = button;
596 end
597 end
598  
599 -- Position all the buttons
600 for index, id in TitanPanelSettings.Buttons do
601 if ( TitanUtils_IsPluginRegistered(id) ) then
602 local i = TitanPanel_GetButtonNumber(id);
603 if(TitanPanelSettings.Location[i] == nil) then
604 if id ~= "AuxAutoHide" then
605 TitanPanelSettings.Location[i] = "Bar";
606 else
607 TitanPanelSettings.Location[i] = "AuxBar";
608 end
609 end
610  
611 button = TitanUtils_GetButton(id);
612  
613 if ( id == TITAN_CLOCK_ID and isClockOnRightSide ) then
614 -- Do nothing, since it's already positioned
615 elseif ( TitanPanelButton_IsIcon(id) ) then
616  
617 if ( rightAuxButton and TitanPanelSettings.Location[i] == "AuxBar" ) then
618 button:ClearAllPoints();
619 button:SetPoint("RIGHT", rightAuxButton:GetName(), "LEFT", -TITAN_PANEL_ICON_SPACEING * scale, 0);
620 elseif ( not rightButton ) then
621 button:ClearAllPoints();
622 button:SetPoint("RIGHT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "RIGHT", -TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_TOP_MAIN);
623 else
624 if ( not rightAuxButton and TitanPanelSettings.Location[i] == "AuxBar") then
625 button:ClearAllPoints();
626 button:SetPoint("RIGHT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "RIGHT", -TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_BOTTOM_MAIN);
627 elseif TitanPanelSettings.Location[i] == "AuxBar" then
628 button:ClearAllPoints();
629 button:SetPoint("RIGHT", rightAuxButton:GetName(), "LEFT", -TITAN_PANEL_ICON_SPACEING * scale, 0);
630 else
631 button:ClearAllPoints();
632 button:SetPoint("RIGHT", rightButton:GetName(), "LEFT", -TITAN_PANEL_ICON_SPACEING * scale, 0);
633 end
634 end
635  
636 if TitanPanelSettings.Location[i] == "AuxBar" then
637 rightAuxButton = button;
638 else
639 rightButton = button;
640 end
641 else
642 if ( TitanPanelSettings.Location[i] == "AuxBar" ) then
643 if (nextAuxLeft == "Double") then
644 button:ClearAllPoints();
645 button:SetPoint("LEFT", leftAuxDoubleButton:GetName(), "RIGHT", TITAN_PANEL_FRAME_SPACEING * scale, 0);
646 nextAuxLeft = "Main"
647 leftAuxDoubleButton = button;
648 elseif (nextAuxLeft == "DoubleFirst") then
649 button:ClearAllPoints();
650 button:SetPoint("LEFT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_BOTTOM);
651 nextAuxLeft = "Main"
652 leftAuxDoubleButton = button;
653 elseif (nextAuxLeft == "Main") then
654 button:ClearAllPoints();
655 button:SetPoint("LEFT", leftAuxButton:GetName(), "RIGHT", TITAN_PANEL_FRAME_SPACEING * scale, 0);
656 nextAuxLeft = TitanPanel_Nextbar("AuxDoubleBar");
657 leftAuxButton = button;
658 else
659 button:ClearAllPoints();
660 button:SetPoint("LEFT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_BOTTOM_MAIN);
661 nextAuxLeft = TitanPanel_Nextbar("AuxDoubleBar");
662 if nextAuxLeft == "Double" then
663 nextAuxLeft = "DoubleFirst";
664 end
665 leftAuxButton = button;
666 end
667 else
668 if (nextLeft == "Double") then
669 button:ClearAllPoints();
670 button:SetPoint("LEFT", leftDoubleButton:GetName(), "RIGHT", TITAN_PANEL_FRAME_SPACEING * scale, 0);
671 nextLeft = "Main"
672 leftDoubleButton = button;
673 elseif (nextLeft == "DoubleFirst") then
674 button:ClearAllPoints();
675 if TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_TOP then
676 button:SetPoint("LEFT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_TOP);
677 else
678 button:SetPoint("LEFT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_BOTTOM);
679 end
680 nextLeft = "Main"
681 leftDoubleButton = button;
682 elseif (nextLeft == "Main") then
683 button:ClearAllPoints();
684 button:SetPoint("LEFT", leftButton:GetName(), "RIGHT", TITAN_PANEL_FRAME_SPACEING * scale, 0);
685 nextLeft = TitanPanel_Nextbar("DoubleBar");
686 leftButton = button;
687 else
688 button:ClearAllPoints();
689 button:SetPoint("LEFT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_TOP_MAIN);
690 nextLeft = TitanPanel_Nextbar("DoubleBar");
691 if nextLeft == "Double" then
692 nextLeft = "DoubleFirst";
693 end
694 leftButton = button;
695 end
696 end
697 end
698  
699 table.insert(newButtons, id);
700 button:Show();
701  
702 end
703 end
704  
705 -- Set TitanPanelSettings.Buttons
706 TitanPanelSettings.Buttons = newButtons;
707  
708 -- Set panel button init flag
709 TITAN_PANEL_BUTTONS_INIT_FLAG = 1;
710 TitanPanelButton_Justify();
711 end
712  
713 function TitanPanel_Nextbar(var)
714 if TitanPanelGetVar(var) == TITAN_PANEL_BARS_DOUBLE then
715 return "Double";
716 else
717 return "Main";
718 end
719 end
720  
721 function TitanPanel_RemoveButton(id)
722 if ( not TitanPanelSettings ) then
723 return;
724 end
725  
726 local i = TitanPanel_GetButtonNumber(id)
727 local currentButton = TitanUtils_GetButton(id);
728 currentButton:Hide();
729  
730 TitanPanel_ReOrder(i);
731 table.remove(TitanPanelSettings.Buttons, TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons, id));
732 TitanPanel_InitPanelButtons();
733 end
734  
735 function TitanPanel_AddButton(id)
736 if (not TitanPanelSettings) then
737 return;
738 end
739  
740 local i = TitanPanel_GetButtonNumber(id)
741 TitanPanelSettings.Location[i] = TITAN_PANEL_SELECTED;
742  
743 table.insert(TitanPanelSettings.Buttons, id);
744  
745 TitanPanel_InitPanelButtons();
746 end
747  
748 function TitanPanel_ReOrder(index)
749 for i = index, table.getn(TitanPanelSettings.Buttons) do
750 TitanPanelSettings.Location[i] = TitanPanelSettings.Location[i+1]
751 end
752 end
753  
754 function TitanPanel_GetButtonNumber(id)
755 if (TitanPanelSettings) then
756 for i = 1, table.getn(TitanPanelSettings.Buttons) do
757 if(TitanPanelSettings.Buttons[i] == id) then
758 return i;
759 end
760 end
761 return table.getn(TitanPanelSettings.Buttons)+1;
762 else
763 return 0;
764 end
765 end
766  
767 function TitanPanel_RefreshPanelButtons()
768 if (TitanPanelSettings) then
769 for i = 1, table.getn(TitanPanelSettings.Buttons) do
770 TitanPanelButton_UpdateButton(TitanPanelSettings.Buttons[i], 1);
771 end
772 end
773 end
774  
775 function TitanPanelButton_Justify()
776 if ( not TITAN_PANEL_BUTTONS_INIT_FLAG or not TitanPanelSettings ) then
777 return;
778 end
779  
780 -- Check if clock displayed on the far right side
781 local isClockOnRightSide;
782 if ( TitanUtils_TableContainsValue(TitanPanelSettings.Buttons, TITAN_CLOCK_ID) and TitanGetVar(TITAN_CLOCK_ID, "DisplayOnRightSide") ) then
783 isClockOnRightSide = 1;
784 end
785  
786 local firstLeftButton = TitanUtils_GetFirstButton(TitanPanelSettings.Buttons, 1, nil, isClockOnRightSide);
787 local secondLeftButton;
788 local scale = TitanPanelGetVar("Scale");
789 local leftWidth = 0;
790 local rightWidth = 0;
791 local leftDoubleWidth = 0;
792 local rightDoubleWidth = 0;
793 local counter = 0;
794 local triggered = 0;
795 if ( firstLeftButton ) then
796 if ( TitanPanelGetVar("ButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_LEFT ) then
797 counter = 0;
798 triggered = 0;
799 for index, id in TitanPanelSettings.Buttons do
800 local button = TitanUtils_GetButton(id);
801  
802 if ( not button:GetWidth() ) then
803 return;
804 end
805 if TitanUtils_GetWhichBar(id) == "Bar" then
806 if TitanPanelGetVar("DoubleBar") == 2 and mod(counter,2) == 1 and not TitanPanelButton_IsIcon(id) then
807 if triggered == 0 then
808 secondLeftButton = button;
809 triggered = 1;
810 end
811 end
812 if ( TitanPanelButton_IsIcon(id) or (id == TITAN_CLOCK_ID and isClockOnRightSide) ) then
813 -- Do nothing
814 else
815 counter = counter + 1;
816 end
817 end
818 end
819  
820 firstLeftButton:ClearAllPoints();
821 firstLeftButton:SetPoint("LEFT", "TitanPanelBarButton", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_TOP_MAIN);
822 if triggered == 1 then
823 secondLeftButton:ClearAllPoints();
824 if TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_TOP then
825 secondLeftButton:SetPoint("LEFT", "TitanPanelBarButton", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_TOP);
826 else
827 secondLeftButton:SetPoint("LEFT", "TitanPanelBarButton", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_BOTTOM);
828 end
829 end
830  
831 elseif ( TitanPanelGetVar("ButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then
832 leftWidth = 0;
833 rightWidth = 0;
834 leftDoubleWidth = 0;
835 rightDoubleWidth = 0;
836 counter = 0;
837 triggered = 0;
838 for index, id in TitanPanelSettings.Buttons do
839 local button = TitanUtils_GetButton(id);
840  
841 if ( not button:GetWidth() ) then
842 return;
843 end
844 if TitanUtils_GetWhichBar(id) == "Bar" then
845 if TitanPanelGetVar("DoubleBar") == 2 and mod(counter,2) == 1 and not TitanPanelButton_IsIcon(id) then
846 if triggered == 0 then
847 secondLeftButton = button;
848 triggered = 1;
849 end
850 if ( TitanPanelButton_IsIcon(id) or (id == TITAN_CLOCK_ID and isClockOnRightSide) ) then
851 rightDoubleWidth = rightDoubleWidth + TITAN_PANEL_ICON_SPACEING + button:GetWidth();
852 else
853 counter = counter + 1;
854 leftDoubleWidth = leftDoubleWidth + TITAN_PANEL_FRAME_SPACEING + button:GetWidth();
855 end
856 else
857 if ( TitanPanelButton_IsIcon(id) or (id == TITAN_CLOCK_ID and isClockOnRightSide) ) then
858 rightWidth = rightWidth + TITAN_PANEL_ICON_SPACEING + button:GetWidth();
859 else
860 counter = counter + 1;
861 leftWidth = leftWidth + TITAN_PANEL_FRAME_SPACEING + button:GetWidth();
862 end
863 end
864 end
865 end
866  
867 firstLeftButton:ClearAllPoints();
868 firstLeftButton:SetPoint("LEFT", "TitanPanelBarButton", "CENTER", 0 - leftWidth / 2, TITAN_PANEL_FROM_TOP_MAIN);
869 if triggered == 1 then
870 secondLeftButton:ClearAllPoints();
871 if TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_TOP then
872 secondLeftButton:SetPoint("LEFT", "TitanPanelBarButton", "CENTER", 0 - leftDoubleWidth / 2, TITAN_PANEL_FROM_TOP);
873 else
874 secondLeftButton:SetPoint("LEFT", "TitanPanelBarButton", "CENTER", 0 - leftDoubleWidth / 2, TITAN_PANEL_FROM_BOTTOM);
875 end
876 end
877 end
878 end
879  
880 local firstLeftButton = TitanUtils_GetFirstAuxButton(TitanPanelSettings.Buttons, 1, nil, isClockOnRightSide);
881 secondLeftButton = nil;
882 if ( firstLeftButton ) then
883 if ( TitanPanelGetVar("AuxButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_LEFT ) then
884 triggered = 0;
885 counter = 0;
886 for index, id in TitanPanelSettings.Buttons do
887 local button = TitanUtils_GetButton(id);
888  
889 if ( not button:GetWidth() ) then
890 return;
891 end
892 if TitanUtils_GetWhichBar(id) == "AuxBar" then
893 if TitanPanelGetVar("AuxDoubleBar") == 2 and mod(counter,2) == 1 and not TitanPanelButton_IsIcon(id) then
894 if triggered == 0 then
895 secondLeftButton = button;
896 triggered = 1;
897 end
898 end
899 if ( TitanPanelButton_IsIcon(id) or (id == TITAN_CLOCK_ID and isClockOnRightSide) ) then
900 -- Do nothing
901 else
902 counter = counter + 1;
903 end
904 end
905 end
906  
907 firstLeftButton:ClearAllPoints();
908 firstLeftButton:SetPoint("LEFT", "TitanPanelAuxBarButton", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_BOTTOM_MAIN);
909 if triggered == 1 then
910 secondLeftButton:ClearAllPoints();
911 secondLeftButton:SetPoint("LEFT", "TitanPanelAuxBarButton", "LEFT", TITAN_PANEL_FRAME_SPACEING / 2 * scale, TITAN_PANEL_FROM_BOTTOM);
912 end
913 elseif ( TitanPanelGetVar("AuxButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then
914 leftWidth = 0;
915 rightWidth = 0;
916 leftDoubleWidth = 0;
917 rightDoubleWidth = 0;
918 counter = 0;
919 triggered = 0;
920 for index, id in TitanPanelSettings.Buttons do
921 local button = TitanUtils_GetButton(id);
922  
923 if ( not button:GetWidth() ) then
924 return;
925 end
926 if TitanUtils_GetWhichBar(id) == "AuxBar" then
927 if TitanPanelGetVar("AuxDoubleBar") == 2 and mod(counter,2) == 1 and not TitanPanelButton_IsIcon(id) then
928 if triggered == 0 then
929 secondLeftButton = button;
930 triggered = 1;
931 end
932 if ( TitanPanelButton_IsIcon(id) or (id == TITAN_CLOCK_ID and isClockOnRightSide) ) then
933 rightDoubleWidth = rightDoubleWidth + TITAN_PANEL_ICON_SPACEING + button:GetWidth();
934 else
935 counter = counter + 1;
936 leftDoubleWidth = leftDoubleWidth + TITAN_PANEL_FRAME_SPACEING + button:GetWidth();
937 end
938 else
939 if ( TitanPanelButton_IsIcon(id) or (id == TITAN_CLOCK_ID and isClockOnRightSide) ) then
940 rightWidth = rightWidth + TITAN_PANEL_ICON_SPACEING + button:GetWidth();
941 else
942 counter = counter + 1;
943 leftWidth = leftWidth + TITAN_PANEL_FRAME_SPACEING + button:GetWidth();
944 end
945 end
946 end
947 end
948  
949 firstLeftButton:ClearAllPoints();
950 firstLeftButton:SetPoint("LEFT", "TitanPanelAuxBarButton", "CENTER", 0 - leftWidth / 2, TITAN_PANEL_FROM_BOTTOM_MAIN);
951 if triggered == 1 then
952 secondLeftButton:ClearAllPoints();
953 secondLeftButton:SetPoint("LEFT", "TitanPanelAuxBarButton", "CENTER", 0 - leftDoubleWidth / 2, TITAN_PANEL_FROM_BOTTOM);
954 end
955 end
956 end
957  
958 end
959  
960 function TitanPanel_SetScale()
961 local scale = TitanPanelGetVar("Scale");
962 local fontscale = TitanPanelGetVar("FontScale");
963 TitanPanelBarButton:SetScale(scale);
964 if not TitanPanelGetVar("DisableFont") then
965 GameTooltip:SetScale(fontscale);
966 end
967  
968 for index, value in TitanPlugins do
969 if index ~= nil then
970 TitanUtils_GetButton(index):SetScale(scale);
971 end
972 end
973 end
974  
975 function TitanPanelRightClickMenu_Customize()
976 StaticPopupDialogs["CUSTOMIZATION_FEATURE_COMING_SOON"] = {
977 text = TEXT(CUSTOMIZATION_FEATURE_COMING_SOON),
978 button1 = TEXT(OKAY),
979 showAlert = 1,
980 timeout = 0,
981 };
982 StaticPopup_Show("CUSTOMIZATION_FEATURE_COMING_SOON");
983 end
984  
985 function TitanPanel_LoadError(ErrorMsg)
986 StaticPopupDialogs["LOADING_ERROR"] = {
987 text = ErrorMsg,
988 button1 = TEXT(OKAY),
989 showAlert = 1,
990 timeout = 0,
991 };
992 StaticPopup_Show("LOADING_ERROR");
993 end
994  
995 function TitanPanelRightClickMenu_PrepareBarMenu()
996 -- Level 2
997 if ( UIDROPDOWNMENU_MENU_LEVEL == 2 ) then
998 TitanPanel_BuildPluginsMenu();
999 TitanPanel_BuildOtherPluginsMenu();
1000 TitanPanel_OptionsMenu();
1001 TitanPanel_LoadServerSettingsMenu();
1002 return;
1003 end
1004  
1005 -- Level 3
1006 if ( UIDROPDOWNMENU_MENU_LEVEL == 3 ) then
1007 TitanPanel_LoadPlayerSettingsMenu();
1008 return;
1009 end
1010  
1011 -- Level 1
1012 TitanPanel_MainMenu()
1013 end
1014  
1015 function TitanPanel_MainMenu()
1016 local info = {};
1017 local checked;
1018 local plugin;
1019 local frame = this:GetName();
1020 local frname = getglobal(frame);
1021  
1022 TitanPanelRightClickMenu_AddTitle(TITAN_PANEL_MENU_TITLE);
1023  
1024 if frame == "TitanPanelBarButton" then
1025 info = {};
1026 info.text = TITAN_PANEL_MENU_BUILTINS;
1027 info.value = "Builtins";
1028 info.hasArrow = 1;
1029 UIDropDownMenu_AddButton(info);
1030 else
1031 info = {};
1032 info.text = TITAN_PANEL_MENU_BUILTINS;
1033 info.value = "BuiltinsAux";
1034 info.hasArrow = 1;
1035 UIDropDownMenu_AddButton(info);
1036 end
1037  
1038 TitanPanelRightClickMenu_AddSpacer(UIDROPDOWNMENU_MENU_LEVEL);
1039 TitanPanelRightClickMenu_AddTitle(TITAN_PANEL_MENU_PLUGINS);
1040  
1041  
1042 for index, id in TITAN_PANEL_MENU_CATEGORIES do
1043 info = {};
1044 info.text = TITAN_PANEL_MENU_CATEGORIES[index];
1045 info.value = "Addons_" .. TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY[index];
1046 info.hasArrow = 1;
1047 UIDropDownMenu_AddButton(info);
1048 end
1049  
1050 TitanPanelRightClickMenu_AddSpacer();
1051  
1052 if frame == "TitanPanelBarButton" then
1053 info = {};
1054 info.text = TITAN_PANEL_MENU_OPTIONS;
1055 info.value = "Options";
1056 info.hasArrow = 1;
1057 UIDropDownMenu_AddButton(info);
1058 else
1059 info = {};
1060 info.text = TITAN_PANEL_MENU_OPTIONS;
1061 info.value = "OptionsAux";
1062 info.hasArrow = 1;
1063 UIDropDownMenu_AddButton(info);
1064 end
1065  
1066 info = {};
1067 info.text = TITAN_PANEL_MENU_LOAD_SETTINGS;
1068 info.value = "Settings";
1069 info.hasArrow = 1;
1070 UIDropDownMenu_AddButton(info);
1071 end
1072  
1073 function TitanPanel_OptionsMenu()
1074 local info = {};
1075  
1076 if ( UIDROPDOWNMENU_MENU_VALUE == "OptionsAux" ) then
1077 info = {};
1078 info.text = TITAN_PANEL_MENU_AUTOHIDE;
1079 info.func = TitanPanelBarButton_ToggleAuxAutoHide;
1080 info.checked = TitanPanelGetVar("AuxAutoHide");
1081 info.keepShownOnClick = 1;
1082 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1083  
1084 info = {};
1085 info.text = TITAN_PANEL_MENU_CENTER_TEXT;
1086 info.func = TitanPanelBarButton_ToggleAuxAlign;
1087 info.checked = (TitanPanelGetVar("AuxButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_CENTER);
1088 info.keepShownOnClick = 1;
1089 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1090  
1091 info = {};
1092 info.text = TITAN_PANEL_MENU_DISABLE_PUSH;
1093 info.func = TitanPanelBarButton_ToggleAuxScreenAdjust;
1094 info.checked = TitanPanelGetVar("AuxScreenAdjust");
1095 info.keepShownOnClick = 1;
1096 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1097  
1098 info = {};
1099 info.text = TITAN_PANEL_MENU_DOUBLE_BAR;
1100 info.func = TitanPanelBarButton_ToggleAuxDoubleBar;
1101 info.checked = TitanPanelGetVar("AuxDoubleBar") == TITAN_PANEL_BARS_DOUBLE;
1102 info.keepShownOnClick = 1;
1103 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1104 end
1105  
1106 if ( UIDROPDOWNMENU_MENU_VALUE == "Options" ) then
1107 info = {};
1108 info.text = TITAN_PANEL_MENU_AUTOHIDE;
1109 info.func = TitanPanelBarButton_ToggleAutoHide;
1110 info.checked = TitanPanelGetVar("AutoHide");
1111 info.keepShownOnClick = 1;
1112 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1113  
1114 info = {};
1115 info.text = TITAN_PANEL_MENU_CENTER_TEXT;
1116 info.func = TitanPanelBarButton_ToggleAlign;
1117 info.checked = (TitanPanelGetVar("ButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_CENTER);
1118 info.keepShownOnClick = 1;
1119 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1120  
1121 info = {};
1122 info.text = TITAN_PANEL_MENU_DISABLE_PUSH;
1123 info.func = TitanPanelBarButton_ToggleScreenAdjust;
1124 info.checked = TitanPanelGetVar("ScreenAdjust");
1125 info.keepShownOnClick = 1;
1126 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1127  
1128 info = {};
1129 info.text = TITAN_PANEL_MENU_DOUBLE_BAR;
1130 info.func = TitanPanelBarButton_ToggleDoubleBar;
1131 info.checked = TitanPanelGetVar("DoubleBar") == TITAN_PANEL_BARS_DOUBLE;
1132 info.keepShownOnClick = 1;
1133 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1134 end
1135  
1136 if ( UIDROPDOWNMENU_MENU_VALUE == "Options" or UIDROPDOWNMENU_MENU_VALUE == "OptionsAux" ) then
1137 TitanPanelRightClickMenu_AddSpacer(UIDROPDOWNMENU_MENU_LEVEL);
1138  
1139 info = {};
1140 info.text = TITAN_PANEL_MENU_DISPLAY_ONTOP;
1141 info.func = TitanPanelBarButton_TogglePosition;
1142 info.checked = (TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_TOP);
1143 info.disabled = TitanPanelGetVar("BothBars")
1144 info.keepShownOnClick = 1;
1145 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1146  
1147 info = {};
1148 info.text = TITAN_PANEL_MENU_DISPLAY_BOTH;
1149 info.func = TitanPanelBarButton_ToggleBarsShown;
1150 info.checked = TitanPanelGetVar("BothBars");
1151 info.keepShownOnClick = 1;
1152 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1153  
1154 TitanPanelRightClickMenu_AddSpacer(UIDROPDOWNMENU_MENU_LEVEL);
1155 info = {};
1156 info.text = TITAN_PANEL_MENU_TOOLTIPS_SHOWN;
1157 info.func = TitanPanelBarButton_ToggleToolTipsShown;
1158 info.checked = TitanPanelGetVar("ToolTipsShown");
1159 info.keepShownOnClick = 1;
1160 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1161  
1162 info = {};
1163 info.text = TITAN_PANEL_MENU_VERSION_SHOWN;
1164 info.func = TitanPanelBarButton_ToggleVersionShown;
1165 info.checked = TitanPanelGetVar("VersionShown");
1166 info.keepShownOnClick = 1;
1167 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1168  
1169 info = {};
1170 info.text = TITAN_PANEL_MENU_DISBALE_FONT;
1171 info.func = TitanPanelBarButton_ToggleDisableFont;
1172 info.checked = TitanPanelGetVar("DisableFont");
1173 info.keepShownOnClick = 1;
1174 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1175  
1176 info = {};
1177 info.text = TITAN_PANEL_MENU_CASTINGBAR;
1178 info.func = TitanPanelBarButton_ToggleCastingBar;
1179 info.checked = TitanPanelGetVar("CastingBar");
1180 info.keepShownOnClick = 1;
1181 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1182  
1183 info = {};
1184 info.text = TITAN_PANEL_MENU_RESET;
1185 info.func = TitanPanel_ResetBar;
1186 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1187 end
1188 end
1189  
1190 function TitanPanel_LoadServerSettingsMenu()
1191 local info = {};
1192 local servers = {};
1193 local server = nil;
1194 local s, e, ident;
1195  
1196  
1197 if ( UIDROPDOWNMENU_MENU_VALUE == "Settings" ) then
1198 for index, id in TitanSettings.Players do
1199 s, e, ident = string.find(index, "@");
1200 if s ~= nil then
1201 server = string.sub(index, s+1);
1202 else
1203 server = "Unknown";
1204 end
1205  
1206 if TitanUtils_GetCurrentIndex(servers, server) == nil then
1207 table.insert(servers, server);
1208 info = {};
1209 info.text = server;
1210 info.value = server;
1211 info.hasArrow = 1;
1212 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1213 end
1214 end
1215 end
1216 end
1217  
1218 function TitanPanel_LoadPlayerSettingsMenu()
1219 local info = {};
1220 local player = nil;
1221 local server = nil;
1222 local s, e, ident;
1223  
1224  
1225 for index, id in TitanSettings.Players do
1226 s, e, ident = string.find(index, "@");
1227 if s ~= nil then
1228 server = string.sub(index, s+1);
1229 player = string.sub(index, 1, s-1);
1230 else
1231 server = "Unknown";
1232 player = "Unknown";
1233 end
1234  
1235 if server == UIDROPDOWNMENU_MENU_VALUE then
1236 info = {};
1237 info.text = player;
1238 info.value = index;
1239 info.func = TitanVariables_UseSettings;
1240 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1241 end
1242 end
1243 end
1244  
1245 function TitanPanel_BuildOtherPluginsMenu()
1246 local info = {};
1247 local checked;
1248 local plugin;
1249 local frame = this:GetName();
1250 local frname = getglobal(frame);
1251  
1252 for index, id in TitanPluginsIndex do
1253 plugin = TitanUtils_GetPlugin(id);
1254 if not plugin.category then
1255 plugin.category = "General";
1256 end
1257  
1258 if ( UIDROPDOWNMENU_MENU_VALUE == "Addons_" .. plugin.category ) then
1259 if (not plugin.builtIn) then
1260 checked = nil;
1261 if ( TitanPanel_IsPluginShown(id) ) then
1262 checked = 1;
1263 end
1264  
1265 info = {};
1266 if plugin.version ~= nil and TitanPanelGetVar("VersionShown") then
1267 info.text = plugin.menuText .. TitanUtils_GetGreenText(" (v" .. plugin.version .. ")");
1268 else
1269 info.text = plugin.menuText;
1270 end
1271 info.value = id;
1272 info.func = TitanPanelRightClickMenu_BarOnClick;
1273 info.checked = checked;
1274 info.keepShownOnClick = 1;
1275 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1276 end
1277 end
1278 end
1279 end
1280  
1281 function TitanPanel_BuildPluginsMenu()
1282 local info = {};
1283 local checked;
1284 local plugin;
1285  
1286 if ( UIDROPDOWNMENU_MENU_VALUE == "Builtins" ) then
1287 TitanPanelRightClickMenu_AddTitle(TITAN_PANEL_MENU_LEFT_SIDE, UIDROPDOWNMENU_MENU_LEVEL);
1288  
1289 for index, id in TitanPluginsIndex do
1290 plugin = TitanUtils_GetPlugin(id);
1291 if ( plugin.builtIn and ( TitanPanel_GetPluginSide(id) == "Left") ) then
1292 checked = nil;
1293 if ( TitanPanel_IsPluginShown(id) ) then
1294 checked = 1;
1295 end
1296  
1297 info = {};
1298 if plugin.version ~= nil and TitanPanelGetVar("VersionShown") then
1299 info.text = plugin.menuText .. TitanUtils_GetGreenText(" (v" .. plugin.version .. ")");
1300 else
1301 info.text = plugin.menuText;
1302 end
1303 info.value = id;
1304 info.func = TitanPanelRightClickMenu_BarOnClick;
1305 info.checked = checked;
1306 info.keepShownOnClick = 1;
1307 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1308 end
1309 end
1310  
1311 TitanPanelRightClickMenu_AddSpacer(UIDROPDOWNMENU_MENU_LEVEL);
1312 TitanPanelRightClickMenu_AddTitle(TITAN_PANEL_MENU_RIGHT_SIDE, UIDROPDOWNMENU_MENU_LEVEL);
1313  
1314 for index, id in TitanPluginsIndex do
1315 plugin = TitanUtils_GetPlugin(id);
1316 if ( plugin.builtIn and ( TitanPanel_GetPluginSide(id) == "Right") ) then
1317 checked = nil;
1318 if ( TitanPanel_IsPluginShown(id) ) then
1319 checked = 1;
1320 end
1321  
1322 if id ~= "AuxAutoHide" then
1323 info = {};
1324 if plugin.version ~= nil and TitanPanelGetVar("VersionShown") then
1325 info.text = plugin.menuText .. TitanUtils_GetGreenText(" (v" .. plugin.version .. ")");
1326 else
1327 info.text = plugin.menuText;
1328 end
1329 info.value = id;
1330 info.func = TitanPanelRightClickMenu_BarOnClick;
1331 info.checked = checked;
1332 info.keepShownOnClick = 1;
1333 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1334 end
1335 end
1336 end
1337 end
1338 if ( UIDROPDOWNMENU_MENU_VALUE == "BuiltinsAux" ) then
1339 TitanPanelRightClickMenu_AddTitle(TITAN_PANEL_MENU_LEFT_SIDE, UIDROPDOWNMENU_MENU_LEVEL);
1340  
1341 for index, id in TitanPluginsIndex do
1342 plugin = TitanUtils_GetPlugin(id);
1343 if ( plugin.builtIn and ( TitanPanel_GetPluginSide(id) == "Left") ) then
1344 checked = nil;
1345 if ( TitanPanel_IsPluginShown(id) ) then
1346 checked = 1;
1347 end
1348  
1349 info = {};
1350 if plugin.version ~= nil and TitanPanelGetVar("VersionShown") then
1351 info.text = plugin.menuText .. TitanUtils_GetGreenText(" (v" .. plugin.version .. ")");
1352 else
1353 info.text = plugin.menuText;
1354 end
1355 info.value = id;
1356 info.func = TitanPanelRightClickMenu_BarOnClick;
1357 info.checked = checked;
1358 info.keepShownOnClick = 1;
1359 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1360 end
1361 end
1362  
1363 TitanPanelRightClickMenu_AddSpacer(UIDROPDOWNMENU_MENU_LEVEL);
1364 TitanPanelRightClickMenu_AddTitle(TITAN_PANEL_MENU_RIGHT_SIDE, UIDROPDOWNMENU_MENU_LEVEL);
1365  
1366 for index, id in TitanPluginsIndex do
1367 plugin = TitanUtils_GetPlugin(id);
1368 if ( plugin.builtIn and ( TitanPanel_GetPluginSide(id) == "Right") ) then
1369 checked = nil;
1370 if ( TitanPanel_IsPluginShown(id) ) then
1371 checked = 1;
1372 end
1373  
1374 if id ~= "AutoHide" then
1375 info = {};
1376 if plugin.version ~= nil and TitanPanelGetVar("VersionShown") then
1377 info.text = plugin.menuText .. TitanUtils_GetGreenText(" (v" .. plugin.version .. ")");
1378 else
1379 info.text = plugin.menuText;
1380 end
1381 info.value = id;
1382 info.func = TitanPanelRightClickMenu_BarOnClick;
1383 info.checked = checked;
1384 info.keepShownOnClick = 1;
1385 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
1386 end
1387 end
1388 end
1389 end
1390 end
1391  
1392 function TitanPanel_IsPluginShown(id)
1393 if ( id and TitanPanelSettings ) then
1394 return TitanUtils_TableContainsValue(TitanPanelSettings.Buttons, id);
1395 end
1396 end
1397  
1398 function TitanPanel_GetPluginSide(id)
1399 if ( id == TITAN_CLOCK_ID and TitanGetVar(TITAN_CLOCK_ID, "DisplayOnRightSide") ) then
1400 return "Right";
1401 elseif ( TitanPanelButton_IsIcon(id) ) then
1402 return "Right";
1403 else
1404 return "Left";
1405 end
1406 end
1407  
1408 function TitanPanel_ResetBar()
1409 local playerName = UnitName("player");
1410 local serverName = GetCVar("realmName");
1411  
1412 TitanCopyPlayerSettings = TitanSettings.Players[playerName.."@"..serverName];
1413 TitanCopyPluginSettings = TitanCopyPlayerSettings["Plugins"];
1414  
1415 for index, id in TitanPanelSettings["Buttons"] do
1416 local currentButton = TitanUtils_GetButton(TitanPanelSettings["Buttons"][index]);
1417 currentButton:Hide();
1418 end
1419  
1420 TitanSettings.Players[playerName.."@"..serverName] = {};
1421 TitanSettings.Players[playerName.."@"..serverName].Plugins = {};
1422 TitanSettings.Players[playerName.."@"..serverName].Panel = {}
1423 TitanSettings.Players[playerName.."@"..serverName].Panel.Buttons = TITAN_PANEL_INITIAL_PLUGINS;
1424 TitanSettings.Players[playerName.."@"..serverName].Panel.Locations = TITAN_PANEL_INITIAL_PLUGIN_LOCATION;
1425  
1426 TITAN_FIRST_LOAD = 1;
1427  
1428 -- Set global variables
1429 TitanPlayerSettings = TitanSettings.Players[playerName.."@"..serverName];
1430 TitanPluginSettings = TitanPlayerSettings["Plugins"];
1431 TitanPanelSettings = TitanPlayerSettings["Panel"];
1432  
1433 ReloadUI()
1434 end
1435  
1436 TitanPanelDetails = {
1437 name = "Titan Panel (Multibar)",
1438 description = "Adds a control panel/info box at the top and bottom of the screen.",
1439 version = TITAN_VERSION,
1440 releaseDate = TITAN_LAST_UPDATED,
1441 author = "TitanMod/Adsertor",
1442 email = "",
1443 website = "http://ui.worldofwar.net/ui.php?id=1442",
1444 category = MYADDONS_CATEGORY_BARS,
1445 frame = "TitanPanel",
1446 optionsframe = "",
1447 };
1448  
1449 TitanPanelHelp = {};
1450 TitanPanelHelp[1] = "Titan Panel adds a control panel/info box at the top and bottom of the screen.\n\nFeatures include:\n1. Ammo/Thrown counter\n2. Bag\n3. Experience (XP)\n4. FPS\n5. Latency\n6. Location\n7. Loot Type\n8. Memory\n9. Money\n10. PvP Honor\n11. Clock\n\nAlso build-in controls allow you to:\n1. Adjust master sound volume\n2. Adjust UI Scale\n3. Adjust panel transparency\n4. Toggle auto-hide on/off\n\nFully support plug-ins system. All modules on the panel are plug-n-play. Allows other developers to create plugins to import the new features.\n\n\nThanks go to\n- Sotakone, for providing a bug fix for German clients\n- Kilan, for submitting code which makes Titan Panel save per-realm-per-character";
1451  
1452 function TitanPanelFrame_OnLoad()
1453 -- Register the events that need to be watched
1454 this:RegisterEvent("VARIABLES_LOADED");
1455 end
1456  
1457 function TitanPanelFrame_OnEvent()
1458 if(event == "VARIABLES_LOADED") then
1459 -- Check if myAddOns is loaded
1460 if(myAddOnsFrame_Register) then
1461 -- Register the addon in myAddOns
1462 myAddOnsFrame_Register(TitanPanelDetails, TitanPanelHelp);
1463 end
1464 end
1465 end
1466  
1467 function TitanPanel_AddonLoaded(addonname)
1468 if addonname == "Blizzard_BattlefieldMinimap" then
1469 if ( not BattlefieldMinimapOptions ) then
1470 BattlefieldMinimapOptions = BattlefieldMinimapDefaults;
1471 end
1472  
1473 if not ( BattlefieldMinimapOptions.position ) then
1474 BattlefieldMinimapTab:SetPoint("CENTER", "UIParent", "BOTTOMLEFT", 845, 443);
1475 BattlefieldMinimapTab:SetUserPlaced(true);
1476 BattlefieldMinimapTab:Show();
1477 BattlefieldMinimapOptions["locked"] = false
1478 BattlefieldMinimapOptions.position = {};
1479 BattlefieldMinimapOptions.position.x, BattlefieldMinimapOptions.position.y = BattlefieldMinimapTab:GetCenter();
1480 local loaded, reason = LoadAddOn("Blizzard_BattlefieldMinimap");
1481 end
1482 end
1483 end