vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- Font Colors
2 TRZ_WHITE = HIGHLIGHT_FONT_COLOR_CODE;
3 TRZ_RED = RED_FONT_COLOR_CODE;
4 TRZ_ORANGE = "|cffff8020";
5 TRZ_YELLOW = "|cffffff20";
6 TRZ_GREEN = GREEN_FONT_COLOR_CODE;
7 TRZ_GRAY = GRAY_FONT_COLOR_CODE;
8 TRZ_NORMAL = NORMAL_FONT_COLOR_CODE;
9 TRZ_FONT_OFF = FONT_COLOR_CODE_CLOSE;
10  
11 TRZ_INSTANCE_TEXT = "%s%s%s (%d+ " .. TRZ_TOOLTIP_TO .. " %d+)" .. TRZ_FONT_OFF; -- Instance (35+ to 45+)
12 TRZ_INSTANCE_TEXT2 = "%s%s%s (%d+)" .. TRZ_FONT_OFF; -- Instance (35+)
13 TRZ_WORLDMAP_TEXT = "(%d-%d)" .. "\n\n" .. TRZ_FONT_OFF;
14  
15 TRZ_MAX_ROWS = 29;
16  
17 TRZ_ID = "TRZ";
18  
19 trz_tooltip_text = "";
20 trz_button_text = "";
21 trz_current_continent = 0;
22 trz_current_zone = 0;
23  
24 function TRZ_Init()
25 local zonearray = {};
26 local i;
27  
28 if (myAddOnsFrame_Register) then
29 myAddOnsFrame_Register( {name="TitanRecZone",version=TRZ_VERSION,category=MYADDONS_CATEGORY_PLUGINS} );
30 end
31  
32 TRZ_ToggleWorldMapText();
33  
34 -- Populate zonenames (Hopefully should work for all locales)
35 zonearray[1]={GetMapZones(1)};
36 zonearray[2]={GetMapZones(2)};
37 for i = 0, table.getn(TRZ_ZONES), 1 do
38 TRZ_ZONES[i].zone = zonearray[TRZ_ZONES[i].continent][TRZ_ZONES[i].nr];
39 end
40 end
41  
42 function TRZ_OnLoad()
43 this.registry = {
44 id = TRZ_ID,
45 menuText = TRZ_MENU_TEXT,
46 buttonTextFunction = "TRZ_GetButtonText",
47 tooltipTitle = TRZ_TOOLTIP_TITEL,
48 tooltipTextFunction = "TRZ_GetTooltipText",
49 category="Information",
50 version=TRZ_VERSION,
51 savedVariables = {
52 ShowCurInstance = 1,
53 ShowInstance = 1,
54 ShowBattleground = 1,
55 ShowRaid = TITAN_NIL,
56 ShowFaction = TITAN_NIL,
57 ShowContinent = TITAN_NIL,
58 ShowLoc = 1,
59 ShowMap = 1,
60 ShowLower = TITAN_NIL,
61 ShowHigher = TITAN_NIL,
62 ShowColoredText = 1,
63 ShowLabelText = 1, -- Default to 1
64 }
65 };
66 this:RegisterEvent("VARIABLES_LOADED");
67 this:RegisterEvent("PLAYER_ENTERING_WORLD");
68 end
69  
70 function TRZ_OnEvent()
71 if (event == "VARIABLES_LOADED") then
72 TRZ_Init();
73 elseif (event == "PLAYER_ENTERING_WORLD") then
74 this:UnregisterEvent("PLAYER_ENTERING_WORLD");
75 this:RegisterEvent("PLAYER_LEAVING_WORLD");
76 this:RegisterEvent("MINIMAP_ZONE_CHANGED");
77 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
78 this:RegisterEvent("PLAYER_LEVEL_UP");
79 --TRZ_UpdateButtonText();
80 TitanPanelButton_UpdateButton(TRZ_ID);
81 elseif (event == "PLAYER_LEAVING_WORLD") then
82 this:UnregisterEvent("PLAYER_LEAVING_WORLD");
83 this:UnregisterEvent("MINIMAP_ZONE_CHANGED");
84 this:UnregisterEvent("ZONE_CHANGED_NEW_AREA");
85 this:UnregisterEvent("PLAYER_LEVEL_UP");
86 this:RegisterEvent("PLAYER_ENTERING_WORLD");
87 else
88 --TRZ_UpdateButtonText();
89 TitanPanelButton_UpdateButton(TRZ_ID);
90 end
91 end
92  
93 function TRZ_GetButtonText(id)
94 TRZ_UpdateButtonText();
95 TRZ_ToggleWorldMapText();
96 return TRZ_BUTTON_LABEL, trz_button_text;
97 end
98  
99 function TRZ_GetTooltipText()
100 TRZ_UpdateTooltipText();
101 return trz_tooltip_text;
102 end
103  
104 function TitanPanelRightClickMenu_PrepareTRZMenu()
105 TitanPanelRightClickMenu_AddTitle(TitanPlugins[TRZ_ID].menuText);
106  
107 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_CUR_INSTANCE, TRZ_ID, "ShowCurInstance");
108 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_FACTION, TRZ_ID, "ShowFaction");
109 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_CONTINENT, TRZ_ID, "ShowContinent");
110 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_INSTANCE, TRZ_ID, "ShowInstance");
111 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_BG, TRZ_ID, "ShowBattleground");
112 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_RAID, TRZ_ID, "ShowRaid");
113 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_LOC, TRZ_ID, "ShowLoc");
114 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_LOWER, TRZ_ID, "ShowLower");
115 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_HIGHER, TRZ_ID, "ShowHigher");
116 TitanPanelRightClickMenu_AddToggleVar(TRZ_TOGGLE_MAP_TEXT, TRZ_ID, "ShowMap");
117  
118 TitanPanelRightClickMenu_AddSpacer();
119 TitanPanelRightClickMenu_AddToggleColoredText(TRZ_ID)
120 TitanPanelRightClickMenu_AddToggleLabelText(TRZ_ID);
121  
122 TitanPanelRightClickMenu_AddSpacer();
123 TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TRZ_ID, TITAN_PANEL_MENU_FUNC_HIDE);
124 end
125  
126 -- end titan panel setup
127  
128 function TRZ_GetColor(low,high)
129 -- PlayerLevel <= low for zone - 4 == RED
130 -- PlayerLevel < low for zone == ORANGE
131 -- PlayerLevel <= high == YELLOW
132 -- PlayerLevel < high + 5 == GREEN
133 -- Otherwise == GRAY
134 local playerLevel = UnitLevel("player");
135 if (playerLevel <= (low-4)) then
136 return TRZ_RED;
137 elseif (playerLevel < low) then
138 return TRZ_ORANGE;
139 elseif (playerLevel <= high) then
140 return TRZ_YELLOW;
141 elseif (playerLevel < (high+5)) then
142 return TRZ_GREEN;
143 else
144 return TRZ_GRAY;
145 end
146 end
147  
148 function TRZ_GetInstanceText(index,colors)
149 local instanceColor = TRZ_WHITE;
150 local instanceType = "";
151 if ( TRZ_INSTANCES[index] == nil ) then
152 return "";
153 end
154 if (colors) then
155 instanceColor = TRZ_GetColor(TRZ_INSTANCES[index].low,TRZ_INSTANCES[index].high);
156 end
157 if (TRZ_INSTANCES[index].type ~= TRZ_INSTANCE) then
158 return instanceColor .. TRZ_INSTANCES[index].zone .. TRZ_INSTANCE_TYPE[TRZ_INSTANCES[index].type];
159 end
160 if (TRZ_INSTANCES[index].low == TRZ_INSTANCES[index].high) then
161 return format(TRZ_INSTANCE_TEXT2, instanceColor, TRZ_INSTANCES[index].zone,
162 TRZ_INSTANCE_TYPE[TRZ_INSTANCES[index].type],
163 TRZ_INSTANCES[index].low );
164 end
165 return format(TRZ_INSTANCE_TEXT, instanceColor, TRZ_INSTANCES[index].zone,
166 TRZ_INSTANCE_TYPE[TRZ_INSTANCES[index].type],
167 TRZ_INSTANCES[index].low, TRZ_INSTANCES[index].high );
168 end
169  
170 function TRZ_GetZoneText(index,colors)
171 local zoneColor = TRZ_WHITE;
172 if ( TRZ_ZONES[index] == nil ) then
173 return "";
174 end
175 -- No level range for city zones
176 if ( TRZ_ZONES[index].faction == TRZ_CITY ) then
177 return TRZ_WHITE .. TRZ_ZONES[index].zone .. TRZ_FONT_OFF;
178 end
179 if (colors) then
180 zoneColor = TRZ_GetColor(TRZ_ZONES[index].low,TRZ_ZONES[index].high);
181 end
182 -- Add zone name and level range.
183 return zoneColor .. TRZ_ZONES[index].zone ..
184 " (" .. TRZ_ZONES[index].low .. "-" .. TRZ_ZONES[index].high .. ")" .. TRZ_FONT_OFF;
185 end
186  
187 function TRZ_GetFactionText(index,colors)
188 local factionColor = TRZ_WHITE;
189 if ( TRZ_ZONES[index] == nil ) then
190 return "";
191 end
192 if (colors) then
193 if ( TRZ_ZONES[index].faction == TRZ_CONTESTED ) then
194 factionColor = TRZ_YELLOW;
195 else
196 factionColor = TRZ_GREEN;
197 end
198 end
199 return factionColor .. " [" .. TRZ_FACTION[TRZ_ZONES[index].faction] .. "]" .. TRZ_FONT_OFF;
200 end
201  
202 function TRZ_GetContinentText(index,colors)
203 local continentColor = TRZ_WHITE;
204 if ( TRZ_ZONES[index] == nil ) then
205 return "";
206 end
207 if (colors) then
208 if ( TRZ_ZONES[index].continent == trz_current_continent ) then
209 continentColor = TRZ_GREEN;
210 else
211 continentColor = TRZ_YELLOW;
212 end
213 end
214 return continentColor .. " (" .. TRZ_CONTINENT[TRZ_ZONES[index].continent] .. ")";
215 end
216  
217 function TRZ_GetLevelText(low,high,colors)
218 local levelColor = TRZ_WHITE;
219 if ( colors ) then
220 levelColor = TRZ_GetColor(low,high);
221 end
222 return levelColor .. format("%d-%d", low, high) .. TRZ_FONT_OFF;
223 end
224  
225 function TRZ_UpdateButtonText()
226 local i;
227 local zoneColor;
228 local playerLevel = UnitLevel("player");
229 local zoneName = GetRealZoneText();
230 local colorTooltip = TitanGetVar(TRZ_ID, "ShowColoredText");
231  
232 trz_button_text = "";
233 for i = 0, table.getn(TRZ_ZONES), 1 do
234 if (string.find(zoneName, TRZ_ZONES[i].zone)) then
235 trz_current_continent = TRZ_ZONES[i].continent;
236 trz_current_zone = i;
237 if (TRZ_ZONES[i].faction == TRZ_CITY) then
238 trz_button_text = TRZ_WHITE .. TRZ_FACTION[TRZ_ZONES[i].faction] .. TRZ_FONT_OFF;
239 else
240 trz_button_text = TRZ_GetLevelText(TRZ_ZONES[i].low, TRZ_ZONES[i].high, colorTooltip);
241 end
242 return
243 end
244 end
245 -- Check if we are in an instance
246 for i = 0, table.getn(TRZ_INSTANCES), 1 do
247 if (string.find(zoneName, TRZ_INSTANCES[i].zone)) then
248 trz_current_zone = i+100;
249 trz_button_text = TRZ_GetLevelText(TRZ_INSTANCES[i].low, TRZ_INSTANCES[i].high, colorTooltip);
250 return;
251 end
252 end
253 return
254 end
255  
256 function TRZ_UpdateTooltipText()
257 local player_level = UnitLevel("player");
258 local c,i;
259 local tempText;
260 local firstShown;
261 local showLower = 0;
262 local showHigher = 0;
263 local colorTooltip = TitanGetVar(TRZ_ID, "ShowColoredText");
264 local showInstance = TitanGetVar(TRZ_ID, "ShowInstance");
265 local showCurInstance = TitanGetVar(TRZ_ID, "ShowCurInstance");
266 local showBattleground = TitanGetVar(TRZ_ID, "ShowBattleground");
267 local showRaid = TitanGetVar(TRZ_ID, "ShowRaid");
268 local showFaction = TitanGetVar(TRZ_ID, "ShowFaction");
269 local showContinent = TitanGetVar(TRZ_ID, "ShowContinent");
270 local showLoc = TitanGetVar(TRZ_ID, "ShowLoc");
271 local rows = 4;
272  
273 trz_tooltip_text = "";
274 if ( TitanGetVar(TRZ_ID, "ShowLower" ) ) then
275 showLower = 5;
276 end
277 if ( TitanGetVar(TRZ_ID, "ShowHigher" ) ) then
278 showHigher = 5;
279 end
280 if (trz_current_zone >= 100 ) then
281 tempText = TRZ_TOOLTIP_CZONE .. TRZ_GetInstanceText(trz_current_zone-100,colorTooltip);
282 else
283 tempText = TRZ_TOOLTIP_CZONE .. TRZ_GetZoneText(trz_current_zone,colorTooltip) .. "\t";
284 -- Show faction
285 if ( showFaction ) then
286 tempText = tempText .. TRZ_GetFactionText(trz_current_zone,colorTooltip);
287 end
288 -- show continent
289 if ( showContinent ) then
290 tempText = tempText .. TRZ_GetContinentText(trz_current_zone,colorTooltip);
291 end
292  
293 -- Show instances for current zone.
294 if ( showCurInstance ) then
295 if ( TRZ_ZONES[trz_current_zone].instances[0] ~= nil ) then
296 for c = 0, table.getn(TRZ_ZONES[trz_current_zone].instances), 1 do
297 local f = TRZ_INSTANCES[TRZ_ZONES[trz_current_zone].instances[c]].faction;
298 if ( (f == TRZ_CONTESTED) or (TRZ_FACTION[f] == UnitFactionGroup("player")) ) then
299 tempText = tempText .. "\n" .. TRZ_TOOLTIP_CINSTANCES ..
300 TRZ_GetInstanceText(TRZ_ZONES[trz_current_zone].instances[c], colorTooltip);
301 rows = rows + 1;
302 end
303 end
304 end
305 end
306 end
307  
308 -- Show recommended zones.
309 tempText = tempText .. "\n\n" .. TRZ_WHITE .. TRZ_TOOLTIP_RECOMMEND .. TRZ_FONT_OFF;
310 for i = 0, table.getn(TRZ_ZONES), 1 do
311 if ( (TRZ_ZONES[i].low - showHigher) <= player_level and
312 (TRZ_ZONES[i].high + showLower) >= player_level ) then
313 if ( (TRZ_ZONES[i].faction == TRZ_CONTESTED) or (UnitFactionGroup("player") == TRZ_FACTION[TRZ_ZONES[i].faction]) ) then
314  
315 if ( rows >= TRZ_MAX_ROWS ) then
316 tempText = tempText .. "\n" .. TRZ_TOOLTIP_MORE;
317 trz_tooltip_text = tempText;
318 return
319 end
320  
321 -- Add zone name and level range.
322 tempText = tempText .. "\n" .. TRZ_GetZoneText(i,colorTooltip) .. "\t";
323 rows = rows + 1;
324  
325 -- Show faction
326 if ( showFaction ) then
327 tempText = tempText .. TRZ_GetFactionText(i,colorTooltip);
328 end
329  
330 -- show continent
331 if ( showContinent ) then
332 tempText = tempText .. TRZ_GetContinentText(i,colorTooltip);
333 end
334 end
335 end
336 end
337  
338 -- Show recommended instances/battlegrounds/raids
339 if( showInstance or showRaid or showBattleground ) then
340 firstShown = nil;
341 for i = 0, table.getn(TRZ_INSTANCES), 1 do
342 if ( (TRZ_INSTANCES[i].low - showHigher) <= player_level and
343 (TRZ_INSTANCES[i].high + showLower) >= player_level ) then
344 local f = TRZ_INSTANCES[i].faction;
345 if ( (f == TRZ_CONTESTED) or (TRZ_FACTION[f] == UnitFactionGroup("player")) ) then
346 local t = TRZ_INSTANCES[i].type
347 if ( (t == TRZ_INSTANCE and showInstance) or
348 ((t == TRZ_RAID20 or t == TRZ_RAID40) and showRaid) or
349 (t == TRZ_BATTLEGROUND and showBattleground)) then
350 if ( rows >= TRZ_MAX_ROWS ) then
351 tempText = tempText .. "\n" .. TRZ_TOOLTIP_MORE;
352 trz_tooltip_text = tempText;
353 return
354 end
355 if ( not firstShown ) then
356 tempText = tempText .. "\n\n" .. TRZ_WHITE .. TRZ_TOOLTIP_RECOMMEND_INSTANCES .. TRZ_FONT_OFF;
357 firstShown = 1;
358 rows = rows + 1;
359 end
360 if ( rows >= TRZ_MAX_ROWS ) then
361 tempText = tempText .. "\n" .. TRZ_TOOLTIP_MORE;
362 trz_tooltip_text = tempText;
363 return
364 end
365 tempText = tempText .. "\n" .. TRZ_GetInstanceText(i,colorTooltip);
366 rows = rows + 1;
367 if ( showLoc ) then
368 if ( TRZ_INSTANCES[i].iloc ) then
369 tempText = tempText .. "\t" .. TRZ_WHITE .. "<" .. TRZ_INSTANCES[TRZ_INSTANCES[i].iloc].zone .. ">" .. TRZ_FONT_OFF
370 else
371 tempText = tempText .. "\t" .. TRZ_WHITE .. "<" .. TRZ_ZONES[TRZ_INSTANCES[i].loc].zone .. ">" .. TRZ_FONT_OFF
372 end
373 end
374 end
375 end
376 end
377 end
378 end
379  
380 trz_tooltip_text = tempText;
381 return
382 end
383  
384  
385 -- Worldmap function --
386  
387 function TRZ_ToggleWorldMapText()
388 if (TitanGetVar(TRZ_ID, "ShowMap")) then
389 TRZ_WorldMap_Frame:Show();
390 else
391 TRZ_WorldMap_Frame:Hide();
392 end
393 end
394  
395 function TRZ_WorldMapButton_OnUpdate()
396 local player_level = UnitLevel("player");
397 local zoneColor;
398 if (WorldMapFrame.areaName ~= nil) then
399 for i = 0, table.getn(TRZ_ZONES), 1 do
400 if (string.find(WorldMapFrame.areaName, TRZ_ZONES[i].zone)) then
401 zoneColor = TRZ_GetColor(TRZ_ZONES[i].low, TRZ_ZONES[i].high);
402 zoneText = zoneColor .. format(TRZ_WORLDMAP_TEXT, TRZ_ZONES[i].low, TRZ_ZONES[i].high);
403 if ( TRZ_ZONES[i].instances[0] ~= nil ) then
404 zoneText = zoneText .. TRZ_NORMAL .. TRZ_TOOLTIP_CINSTANCES .. "\n" .. TRZ_FONT_OFF;
405 for c = 0, table.getn(TRZ_ZONES[i].instances), 1 do
406 zoneText = zoneText .. TRZ_GetInstanceText(TRZ_ZONES[i].instances[c], true) .. "\n";
407 end
408 end
409 TRZ_WorldMap_Text:SetText(zoneText);
410 end
411 end
412 else
413 TRZ_WorldMap_Text:SetText("");
414 end
415  
416 if (WorldMapFrame.poiHighlight == 1) then
417 for i = 0, table.getn(TRZ_ZONES), 1 do
418 if (string.find(WorldMapFrameAreaLabel:GetText(), TRZ_ZONES[i].zone)) then
419 zoneText = TRZ_WHITE .. TRZ_FACTION[TRZ_ZONES[i].faction] .. "\n\n" .. TRZ_FONT_OFF;
420 if (TRZ_ZONES[i].instances ~= nil) then
421 zoneText = zoneText .. TRZ_NORMAL .. TRZ_TOOLTIP_RINSTANCES .. "\n" .. TRZ_FONT_OFF;
422 for c = 0, table.getn(TRZ_ZONES[i].instances), 1 do
423 zoneText = zoneText .. TRZ_GetInstanceText(TRZ_ZONES[i].instances[c], true) .. "\n";
424 end
425 end
426 TRZ_WorldMap_Text:SetText(zoneText);
427 end
428 end
429 end
430 end
431