vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- Constants
2 TITAN_PANEL_UPDATE_BUTTON = 1;
3 TITAN_PANEL_UDPATE_TOOLTIP = 2;
4 TITAN_PANEL_UPDATE_ALL = 3;
5 TITAN_PANEL_LABEL_SEPARATOR = " "
6  
7 TITAN_PANEL_BUTTON_TYPE_TEXT = 1;
8 TITAN_PANEL_BUTTON_TYPE_ICON = 2;
9 TITAN_PANEL_BUTTON_TYPE_COMBO = 3;
10 TITAN_PANEL_BUTTON_TYPE_CUSTOM = 4;
11  
12 TITAN_ATLAS_ID = "Atlas";
13 TITAN_ATLAS_FREQUENCY = 1;
14  
15 ATLAS_INDEX = 0;
16  
17 local Atlas_Initialized = false;
18  
19 AtlasOptions = {};
20  
21 ATLAS_DROPDOWN_LIST = {
22 "BlackfathomDeeps",
23 "BlackrockDepths",
24 "BlackrockSpireLower",
25 "BlackrockSpireUpper",
26 "TheDeadmines",
27 "DireMaulEast",
28 "DireMaulNorth",
29 "DireMaulWest",
30 "Gnomeregan",
31 "Maraudon",
32 "MoltenCore",
33 "OnyxiasLair",
34 "RagefireChasm",
35 "RazorfenDowns",
36 "RazorfenKraul",
37 "ScarletMonastery",
38 "Scholomance",
39 "ShadowfangKeep",
40 "TheStockades",
41 "Stratholme",
42 "TheSunkenTemple",
43 "Uldaman",
44 "WailingCaverns",
45 "ZulFarrak",
46 "ZulGurub"
47 };
48  
49 function TitanOptionSlider_TooltipText(text, value)
50 return text .. GREEN_FONT_COLOR_CODE .. value .. FONT_COLOR_CODE_CLOSE;
51 end
52  
53 function TitanPanelAtlasButton_OnLoad()
54 -- register plugin
55 this.registry = {
56 id = TITAN_ATLAS_ID,
57 menuText = ATLAS_LOCALE["menu"],
58 buttonTextFunction = "TitanPanelAtlasButton_GetButtonText",
59 tooltipTitle = ATLAS_LOCALE["tooltip"],
60 tooltipTextFunction = "TitanPanelAtlasButton_GetTooltipText",
61 frequency = TITAN_ATLAS_FREQUENCY,
62 icon = "Interface\\AddOns\\TitanAtlas\\Images\\TitanAtlas",
63 iconWidth = 16,
64 savedVariables = {
65 ShowIcon = 1,
66 ShowLabelText = 1,
67 ShowColoredText = TITAN_NIL
68 }
69 };
70 this:RegisterEvent("VARIABLES_LOADED");
71 this:RegisterEvent("ZONE_CHANGED");
72 this:RegisterEvent("ZONE_CHANGED_INDOORS");
73 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
74 this:RegisterEvent("MINIMAP_ZONE_CHANGED");
75 this:RegisterEvent("PLAYER_ENTERING_WORLD");
76 end
77  
78 function TitanPanelAtlasButton_OnEvent()
79 if(event == "VARIABLES_LOADED") then
80 if (AtlasOptions.AtlasZone == nil) then
81 AtlasOptions.AtlasZone = 1;
82 end
83 if (AtlasOptions.AtlasAlpha == nil) then
84 AtlasOptions.AtlasAlpha = 1.0;
85 end
86 if (AtlasOptions.AtlasLocked == nil) then
87 AtlasOptions.AtlasLocked = false;
88 end
89 if (AtlasOptions.AtlasMapName == nil) then
90 AtlasOptions.AtlasMapName = true;
91 end
92 if (AtlasOptions.AtlasAutoSelect == nil) then
93 AtlasOptions.AtlasAutoSelect = true;
94 end
95 Atlas_Initialized = true;
96 end
97 if(event == "ZONE_CHANGED") then
98 Atlas_OnShow();
99 end
100 this.zoneText = GetZoneText();
101 this.subZoneText = GetSubZoneText();
102 end
103  
104 function TitanPanelAtlasButton_GetButtonText(id)
105 local retstr = "";
106 if (AtlasOptions.AtlasMapName) then
107 if (TitanGetVar(TITAN_ATLAS_ID, "ShowColoredText")) then
108 retstr = TitanUtils_GetGreenText(ATLAS_DROPDOWN_LIST[AtlasOptions.AtlasZone]);
109 else
110 retstr = TitanUtils_GetNormalText(ATLAS_DROPDOWN_LIST[AtlasOptions.AtlasZone]);
111 end
112 else
113 retstr = " ";
114 end
115  
116 -- supports turning off labels
117 if (TitanGetVar(TITAN_ATLAS_ID, "ShowLabelText")) then
118 retstr = ATLAS_LOCALE["button"] .. retstr
119 end
120  
121 return retstr;
122 end
123  
124 function TitanPanelAtlasButton_GetTooltipText()
125 local retstr = "You are currently in " .. this.zoneText .. " (" .. this.subZoneText .. ")\n";
126 retstr = retstr .. TitanUtils_GetGreenText(ATLAS_HINT);
127 return retstr;
128 end
129  
130 function TitanPanelRightClickMenu_PrepareAtlasMenu()
131 TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_ATLAS_ID].menuText);
132  
133 TitanPanelRightClickMenu_AddSpacer();
134  
135 info = {};
136 info.text = ATLAS_OPTIONS_AUTOSEL;
137 info.func = AtlasOptions_AutoSelectToggle;
138 info.value = ATLAS_OPTIONS_AUTOSEL;
139 info.checked = AtlasOptions.AtlasAutoSelect;
140 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
141  
142 info = {};
143 info.text = ATLAS_OPTIONS_SHOWMAPNAME;
144 info.func = AtlasOptions_MapNameToggle;
145 info.value = ATLAS_OPTIONS_SHOWMAPNAME;
146 info.checked = AtlasOptions.AtlasMapName;
147 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
148 info = {};
149  
150 TitanPanelRightClickMenu_AddSpacer();
151  
152 TitanPanelRightClickMenu_AddToggleIcon(TITAN_ATLAS_ID);
153 TitanPanelRightClickMenu_AddToggleLabelText(TITAN_ATLAS_ID);
154 TitanPanelRightClickMenu_AddToggleColoredText(TITAN_ATLAS_ID);
155  
156 TitanPanelRightClickMenu_AddSpacer();
157 TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TITAN_ATLAS_ID, TITAN_PANEL_MENU_FUNC_HIDE);
158 end
159  
160 function TitalPanelAtlasButton_OnClick(button)
161 if ( button == "LeftButton" ) then
162 Atlas_Toggle();
163 end
164 end
165  
166 function Atlas_OnLoad()
167 this:RegisterEvent("VARIABLES_LOADED");
168 tinsert(UISpecialFrames, "AtlasFrame");
169 UIPanelWindows["AtlasFrame"] = nil;
170 AtlasFrame:RegisterForDrag("LeftButton");
171 SLASH_ATLAS1 = ATLAS_SLASH;
172 SlashCmdList["ATLAS"] = function(msg)
173 Atlas_SlashCommand(msg);
174 end
175 end
176  
177 function Atlas_OnShow()
178 if(AtlasOptions.AtlasAutoSelect) then
179 local currentZone = GetRealZoneText();
180 local currentMap = AtlasText[ATLAS_DROPDOWN_LIST[UIDropDownMenu_GetSelectedID(AtlasFrameDropDown)]]["ZoneName"];
181 if(currentZone ~= currentMap) then
182 for i = 1, getn(ATLAS_DROPDOWN_LIST), 1 do
183 local mapName = AtlasText[ATLAS_DROPDOWN_LIST[i]]["ZoneName"];
184 if(currentZone == mapName) then
185 UIDropDownMenu_Initialize(AtlasFrameDropDown, AtlasFrameDropDown_Initialize);
186 UIDropDownMenu_SetSelectedID(AtlasFrameDropDown, i);
187 Atlas_Refresh();
188 end
189 end
190 end
191 end
192 end
193  
194 function Atlas_OnEvent()
195 if(event == "VARIABLES_LOADED") then
196 Atlas_Refresh();
197 AtlasOptions_Init();
198 Atlas_UpdateLock();
199 Atlas_UpdateAlpha();
200 end
201 end
202  
203 function Atlas_StartMoving()
204 if(not AtlasOptions.AtlasLocked) then
205 AtlasFrame:StartMoving();
206 end
207 end
208  
209 function Atlas_SlashCommand(msg)
210 if(msg == ATLAS_SLASH_OPTIONS) then
211 AtlasOptions_Toggle();
212 else
213 Atlas_Toggle();
214 end
215 end
216  
217 function Atlas_UpdateAlpha()
218 AtlasFrame:SetAlpha(AtlasOptions.AtlasAlpha);
219 end
220  
221 function Atlas_Toggle()
222 if(AtlasFrame:IsVisible()) then
223 HideUIPanel(AtlasFrame);
224 else
225 ShowUIPanel(AtlasFrame);
226 end
227 end
228  
229 function Atlas_ToggleLock()
230 if(AtlasOptions.AtlasLocked) then
231 AtlasOptions.AtlasLocked = false;
232 Atlas_UpdateLock();
233 else
234 AtlasOptions.AtlasLocked = true;
235 Atlas_UpdateLock();
236 end
237 end
238  
239 function Atlas_UpdateLock()
240 if(AtlasOptions.AtlasLocked) then
241 AtlasLockNorm:SetTexture("Interface\\AddOns\\TitanAtlas\\Images\\LockButton-Locked-Up");
242 AtlasLockPush:SetTexture("Interface\\AddOns\\TitanAtlas\\Images\\LockButton-Locked-Down");
243 else
244 AtlasLockNorm:SetTexture("Interface\\AddOns\\TitanAtlas\\Images\\LockButton-Unlocked-Up");
245 AtlasLockPush:SetTexture("Interface\\AddOns\\TitanAtlas\\Images\\LockButton-Unlocked-Down");
246 end
247 end
248  
249 function Atlas_Refresh()
250 AtlasOptions.AtlasZone = UIDropDownMenu_GetSelectedID(AtlasFrameDropDown);
251 local zoneID = ATLAS_DROPDOWN_LIST[AtlasOptions.AtlasZone];
252  
253 AtlasMap:ClearAllPoints();
254 AtlasMap:SetWidth(512);
255 AtlasMap:SetHeight(512);
256 AtlasMap:SetPoint("TOPLEFT", "AtlasFrame", "TOPLEFT", 14, -71);
257 AtlasMap:SetTexture("Interface\\AddOns\\TitanAtlas\\Images\\"..zoneID);
258 AtlasText_ZoneName:SetText(AtlasText[zoneID]["ZoneName"]);
259 AtlasText_Location:SetText(ATLAS_STRING_LOCATION..": "..AtlasText[zoneID]["Location"]);
260 AtlasText_LevelRange:SetText(ATLAS_STRING_LEVELRANGE..": "..AtlasText[zoneID]["LevelRange"]);
261 AtlasText_PlayerLimit:SetText(ATLAS_STRING_PLAYERLIMIT..": "..AtlasText[zoneID]["PlayerLimit"]);
262 for i = 1, 28, 1 do
263 getglobal("AtlasText_"..i):SetText(AtlasText[zoneID][i]);
264 end
265 end
266  
267 function Atlas_SlashCommand(msg)
268 if(msg == ATLAS_SLASH_OPTIONS) then
269 AtlasOptions_Toggle();
270 else
271 Atlas_Toggle();
272 end
273 end
274  
275 function AtlasFrameDropDown_Initialize()
276 local info;
277 for i = 1, getn(ATLAS_DROPDOWN_LIST), 1 do
278 info = {
279 text = AtlasText[ATLAS_DROPDOWN_LIST[i]]["ZoneName"];
280 func = AtlasFrameDropDownButton_OnClick;
281 };
282 UIDropDownMenu_AddButton(info);
283 end
284 end
285  
286 function AtlasFrameDropDown_OnLoad()
287 this:RegisterEvent("VARIABLES_LOADED");
288 end
289  
290 function AtlasFrameDropDown_OnEvent()
291 if(event == "VARIABLES_LOADED") then
292 UIDropDownMenu_Initialize(AtlasFrameDropDown, AtlasFrameDropDown_Initialize);
293 UIDropDownMenu_SetSelectedID(AtlasFrameDropDown, AtlasOptions.AtlasZone);
294 UIDropDownMenu_SetWidth(175);
295 end
296 end
297  
298 function AtlasFrameDropDownButton_OnClick()
299 local oldID = UIDropDownMenu_GetSelectedID(AtlasFrameDropDown);
300 UIDropDownMenu_SetSelectedID(AtlasFrameDropDown, this:GetID());
301 if(oldID ~= this:GetID()) then
302 Atlas_Refresh();
303 end
304 end
305  
306 function AtlasOptions_Toggle()
307 if(AtlasOptionsFrame:IsVisible()) then
308 AtlasOptionsFrame:Hide();
309 else
310 AtlasOptionsFrame:Show();
311 end
312 end
313  
314 function AtlasOptions_AutoSelectToggle()
315 if(AtlasOptions.AtlasAutoSelect) then
316 AtlasOptions.AtlasAutoSelect = false;
317 else
318 AtlasOptions.AtlasAutoSelect = true;
319 end
320 end
321  
322 function AtlasOptions_MapNameToggle()
323 if(AtlasOptions.AtlasMapName) then
324 AtlasOptions.AtlasMapName = false;
325 else
326 AtlasOptions.AtlasMapName = true;
327 end
328 end
329  
330 function AtlasOptions_Init()
331 SliderAlpha:SetValue(AtlasOptions.AtlasAlpha);
332 end
333  
334 function AtlasOptions_OnLoad()
335 UIPanelWindows['AtlasOptionsFrame'] = {area = 'center', pushable = 0};
336 end
337  
338 function AtlasOptions_OnHide()
339 if(MYADDONS_ACTIVE_OPTIONSFRAME == this) then
340 ShowUIPanel(myAddOnsFrame);
341 end
342 end
343  
344 function DebugReport(msg, color, bSecondChatWindow)
345 local r = 0.50;
346 local g = 0.50;
347 local b = 1.00;
348  
349 if (color) then
350 r = color.r;
351 g = color.g;
352 b = color.b;
353 end
354  
355 local frame = DEFAULT_CHAT_FRAME;
356 if (bSecondChatWindow) then
357 frame = ChatFrame2;
358 end
359  
360 if (frame) then
361 frame:AddMessage(msg,r,g,b);
362 end
363 end