vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --Atlas, an instance map browser |
2 | --Author: Dan Gilbert |
||
3 | --Email: loglow@gmail.com |
||
4 | --AIM: dan5981 |
||
5 | ATLAS_VERSION = "1.8.1"; |
||
6 | ATLAS_DATE = "August 22, 2006"; |
||
7 | |||
8 | --myAddOns data goes here |
||
9 | AtlasDetails = { |
||
10 | name = "Atlas", |
||
11 | version = ATLAS_VERSION, |
||
12 | releaseDate = ATLAS_DATE, |
||
13 | author = "Dan Gilbert", |
||
14 | email = "loglow@gmail.com", |
||
15 | website = "http://www.atlasmod.com/", |
||
16 | optionsframe = "AtlasOptionsFrame", |
||
17 | category = MYADDONS_CATEGORY_MAP |
||
18 | }; |
||
19 | |||
20 | local Atlas_Vars_Loaded = nil; |
||
21 | ATLAS_DROPDOWN_LIST = {}; |
||
22 | ATLAS_DROPDOWN_LIST_BG = {}; |
||
23 | ATLAS_DROPDOWN_LIST_FP = {}; |
||
24 | ATLAS_DROPDOWN_LIST_DL = {}; |
||
25 | ATLAS_DROPDOWN_LIST_RE = {}; |
||
26 | |||
27 | local DefaultAtlasOptions = { |
||
28 | ["AtlasVersion"] = ATLAS_VERSION; |
||
29 | ["AtlasZone"] = 1; |
||
30 | ["AtlasAlpha"] = 1.0; |
||
31 | ["AtlasLocked"] = false; |
||
32 | ["AtlasMapName"] = true; |
||
33 | ["AtlasAutoSelect"] = false; |
||
34 | ["AtlasButtonPosition"] = 268; |
||
35 | ["AtlasButtonShown"] = true; |
||
36 | ["AtlasReplaceWorldMap"] = false; |
||
37 | ["AtlasRightClick"] = false; |
||
38 | ["AtlasType"] = 1; |
||
39 | ["AtlasAcronyms"] = true; |
||
40 | }; |
||
41 | |||
42 | function Atlas_FreshOptions() |
||
43 | AtlasOptions = CloneTable(DefaultAtlasOptions); |
||
44 | end |
||
45 | |||
46 | --Code by Grayhoof (SCT) |
||
47 | function CloneTable(t) -- return a copy of the table t |
||
48 | local new = {}; -- create a new table |
||
49 | local i, v = next(t, nil); -- i is an index of t, v = t[i] |
||
50 | while i do |
||
51 | if type(v)=="table" then |
||
52 | v=CloneTable(v); |
||
53 | end |
||
54 | new[i] = v; |
||
55 | i, v = next(t, i); -- get next index |
||
56 | end |
||
57 | return new; |
||
58 | end |
||
59 | |||
60 | --Called when the Atlas frame is first loaded |
||
61 | --We CANNOT assume that data in other files is available yet! |
||
62 | function Atlas_OnLoad() |
||
63 | |||
64 | --Register the Atlas frame for the following events |
||
65 | this:RegisterEvent("ADDON_LOADED"); |
||
66 | this:RegisterEvent("VARIABLES_LOADED"); |
||
67 | |||
68 | --Allows Atlas to be closed with the Escape key |
||
69 | tinsert(UISpecialFrames, "AtlasFrame"); |
||
70 | |||
71 | --Dragging involves some special registration |
||
72 | AtlasFrame:RegisterForDrag("LeftButton"); |
||
73 | |||
74 | --Setting up slash commands involves referencing some strage auto-generated variables |
||
75 | SLASH_ATLAS1 = ATLAS_SLASH; |
||
76 | SlashCmdList["ATLAS"] = function(msg) |
||
77 | Atlas_SlashCommand(msg); |
||
78 | end |
||
79 | end |
||
80 | |||
81 | --Removal of articles in map names (for proper alphabetic sorting) |
||
82 | --For example: "The Deadmines" will become "Deadmines" |
||
83 | --Thus it will be sorted under D and not under T |
||
84 | local function Atlas_SanitizeName(text) |
||
85 | text = string.lower(text); |
||
86 | if (AtlasSortIgnore) then |
||
87 | for _,v in AtlasSortIgnore do |
||
88 | local match = string.gfind(text, v)(); |
||
89 | if (match) and ((string.len(text) - string.len(match)) <= 4) then |
||
90 | return match; |
||
91 | end |
||
92 | end |
||
93 | end |
||
94 | return text; |
||
95 | end |
||
96 | |||
97 | --Comparator function for alphabetic sorting of maps |
||
98 | local function Atlas_SortZonesAlpha(a, b) |
||
99 | local aa = Atlas_SanitizeName(AtlasText[a].ZoneName); |
||
100 | local bb = Atlas_SanitizeName(AtlasText[b].ZoneName); |
||
101 | return aa < bb; |
||
102 | end |
||
103 | |||
104 | --Comparator function for alphabetic sorting of BG maps |
||
105 | local function Atlas_SortZonesAlphaBG(a, b) |
||
106 | local aa = Atlas_SanitizeName(AtlasBG[a].ZoneName); |
||
107 | local bb = Atlas_SanitizeName(AtlasBG[b].ZoneName); |
||
108 | return aa < bb; |
||
109 | end |
||
110 | |||
111 | --Comparator function for alphabetic sorting of FP maps |
||
112 | local function Atlas_SortZonesAlphaFP(a, b) |
||
113 | local aa = Atlas_SanitizeName(AtlasFP[a].ZoneName); |
||
114 | local bb = Atlas_SanitizeName(AtlasFP[b].ZoneName); |
||
115 | return aa < bb; |
||
116 | end |
||
117 | |||
118 | --Comparator function for alphabetic sorting of DL maps |
||
119 | local function Atlas_SortZonesAlphaDL(a, b) |
||
120 | local aa = Atlas_SanitizeName(AtlasDL[a].ZoneName); |
||
121 | local bb = Atlas_SanitizeName(AtlasDL[b].ZoneName); |
||
122 | return aa < bb; |
||
123 | end |
||
124 | |||
125 | --Comparator function for alphabetic sorting of RE maps |
||
126 | local function Atlas_SortZonesAlphaRE(a, b) |
||
127 | local aa = Atlas_SanitizeName(AtlasRE[a].ZoneName); |
||
128 | local bb = Atlas_SanitizeName(AtlasRE[b].ZoneName); |
||
129 | return aa < bb; |
||
130 | end |
||
131 | |||
132 | --These are the REAL level range values! |
||
133 | --Overrides the values that may be found in the localization files |
||
134 | function Atlas_UpdateLevelRanges() |
||
135 | AtlasText.BlackfathomDeeps.LevelRange = "24-32"; |
||
136 | AtlasText.BlackrockSpireLower.LevelRange = "55-60"; |
||
137 | AtlasText.BlackrockSpireUpper.LevelRange = "55-60"; |
||
138 | AtlasText.BlackrockDepths.LevelRange = "52-60"; |
||
139 | AtlasText.ShadowfangKeep.LevelRange = "22-30"; |
||
140 | AtlasText.ScarletMonastery.LevelRange = "34-45"; |
||
141 | AtlasText.MoltenCore.LevelRange = "60+"; |
||
142 | AtlasText.TheSunkenTemple.LevelRange = "50-60"; |
||
143 | AtlasText.WailingCaverns.LevelRange = "17-24"; |
||
144 | AtlasText.TheStockade.LevelRange = "24-32"; |
||
145 | AtlasText.TheDeadmines.LevelRange = "17-26"; |
||
146 | AtlasText.DireMaulNorth.LevelRange = "56-60"; |
||
147 | AtlasText.DireMaulEast.LevelRange = "56-60"; |
||
148 | AtlasText.DireMaulWest.LevelRange = "56-60"; |
||
149 | AtlasText.Gnomeregan.LevelRange = "29-38"; |
||
150 | AtlasText.RazorfenDowns.LevelRange = "37-46"; |
||
151 | AtlasText.RazorfenKraul.LevelRange = "29-38"; |
||
152 | AtlasText.Maraudon.LevelRange = "46-55"; |
||
153 | AtlasText.OnyxiasLair.LevelRange = "60+"; |
||
154 | AtlasText.BlackwingLair.LevelRange = "60+"; |
||
155 | AtlasText.RagefireChasm.LevelRange = "13-18"; |
||
156 | AtlasText.Scholomance.LevelRange = "58-60"; |
||
157 | AtlasText.Stratholme.LevelRange = "58-60"; |
||
158 | AtlasText.Uldaman.LevelRange = "41-51"; |
||
159 | AtlasText.ZulFarrak.LevelRange = "44-54"; |
||
160 | AtlasText.ZulGurub.LevelRange = "60+"; |
||
161 | AtlasText.TheTempleofAhnQiraj.LevelRange = "60+"; |
||
162 | AtlasText.TheRuinsofAhnQiraj.LevelRange = "60+"; |
||
163 | AtlasText.Naxxramas.LevelRange = "60+"; |
||
164 | AtlasBG.AlteracValleyNorth.LevelRange = "51-60"; |
||
165 | AtlasBG.AlteracValleySouth.LevelRange = "51-60"; |
||
166 | AtlasBG.ArathiBasin.LevelRange = "20-60"; |
||
167 | AtlasBG.WarsongGulch.LevelRange = "10-60"; |
||
168 | AtlasFP.FPAllianceEast.LevelRange = "---"; |
||
169 | AtlasFP.FPAllianceWest.LevelRange = "---"; |
||
170 | AtlasFP.FPHordeEast.LevelRange = "---"; |
||
171 | AtlasFP.FPHordeWest.LevelRange = "---"; |
||
172 | AtlasDL.DLEast.LevelRange = "---"; |
||
173 | AtlasDL.DLWest.LevelRange = "---"; |
||
174 | AtlasRE.Azuregos.LevelRange = "60+"; |
||
175 | AtlasRE.FourDragons.LevelRange = "60+"; |
||
176 | AtlasRE.Kazzak.LevelRange = "60+"; |
||
177 | end |
||
178 | |||
179 | --These are the REAL player limit values! |
||
180 | --Overrides the values that may be found in the localization files |
||
181 | function Atlas_UpdatePlayerLimits() |
||
182 | AtlasText.BlackfathomDeeps.PlayerLimit = "10"; |
||
183 | AtlasText.BlackrockSpireLower.PlayerLimit = "10"; |
||
184 | AtlasText.BlackrockSpireUpper.PlayerLimit = "10"; |
||
185 | AtlasText.BlackrockDepths.PlayerLimit = "5"; |
||
186 | AtlasText.ShadowfangKeep.PlayerLimit = "10"; |
||
187 | AtlasText.ScarletMonastery.PlayerLimit = "10"; |
||
188 | AtlasText.MoltenCore.PlayerLimit = "40"; |
||
189 | AtlasText.TheSunkenTemple.PlayerLimit = "10"; |
||
190 | AtlasText.WailingCaverns.PlayerLimit = "10"; |
||
191 | AtlasText.TheStockade.PlayerLimit = "10"; |
||
192 | AtlasText.TheDeadmines.PlayerLimit = "10"; |
||
193 | AtlasText.DireMaulNorth.PlayerLimit = "5"; |
||
194 | AtlasText.DireMaulEast.PlayerLimit = "5"; |
||
195 | AtlasText.DireMaulWest.PlayerLimit = "5"; |
||
196 | AtlasText.Gnomeregan.PlayerLimit = "10"; |
||
197 | AtlasText.RazorfenDowns.PlayerLimit = "10"; |
||
198 | AtlasText.RazorfenKraul.PlayerLimit = "10"; |
||
199 | AtlasText.Maraudon.PlayerLimit = "10"; |
||
200 | AtlasText.OnyxiasLair.PlayerLimit = "40"; |
||
201 | AtlasText.BlackwingLair.PlayerLimit = "40"; |
||
202 | AtlasText.RagefireChasm.PlayerLimit = "10"; |
||
203 | AtlasText.Scholomance.PlayerLimit = "5"; |
||
204 | AtlasText.Stratholme.PlayerLimit = "5"; |
||
205 | AtlasText.Uldaman.PlayerLimit = "10"; |
||
206 | AtlasText.ZulFarrak.PlayerLimit = "10"; |
||
207 | AtlasText.ZulGurub.PlayerLimit = "20"; |
||
208 | AtlasText.TheTempleofAhnQiraj.PlayerLimit = "40"; |
||
209 | AtlasText.TheRuinsofAhnQiraj.PlayerLimit = "20"; |
||
210 | AtlasText.Naxxramas.PlayerLimit = "40"; |
||
211 | AtlasBG.AlteracValleyNorth.PlayerLimit = "40"; |
||
212 | AtlasBG.AlteracValleySouth.PlayerLimit = "40"; |
||
213 | AtlasBG.ArathiBasin.PlayerLimit = "15"; |
||
214 | AtlasBG.WarsongGulch.PlayerLimit = "10"; |
||
215 | AtlasFP.FPAllianceEast.PlayerLimit = "---"; |
||
216 | AtlasFP.FPAllianceWest.PlayerLimit = "---"; |
||
217 | AtlasFP.FPHordeEast.PlayerLimit = "---"; |
||
218 | AtlasFP.FPHordeWest.PlayerLimit = "---"; |
||
219 | AtlasDL.DLEast.PlayerLimit = "---"; |
||
220 | AtlasDL.DLWest.PlayerLimit = "---"; |
||
221 | AtlasRE.Azuregos.PlayerLimit = "40"; |
||
222 | AtlasRE.FourDragons.PlayerLimit = "40"; |
||
223 | AtlasRE.Kazzak.PlayerLimit = "40"; |
||
224 | end |
||
225 | |||
226 | --Main Atlas event handler |
||
227 | function Atlas_OnEvent() |
||
228 | |||
229 | if (event == "ADDON_LOADED") then |
||
230 | if (strlower(arg1) == "atlas") then |
||
231 | Atlas_Vars_Loaded = 1; |
||
232 | Atlas_Init(); |
||
233 | end |
||
234 | elseif (event == "VARIABLES_LOADED") then |
||
235 | if (not Atlas_Vars_Loaded) then |
||
236 | Atlas_Vars_Loaded = 1; |
||
237 | Atlas_Init(); |
||
238 | end |
||
239 | end |
||
240 | |||
241 | end |
||
242 | |||
243 | --Initializes everything relating to saved variables and data in other lua files |
||
244 | --This should be called ONLY when we're sure that all other files have been loaded |
||
245 | function Atlas_Init() |
||
246 | |||
247 | if ( AtlasOptions == nil or AtlasOptions["AtlasVersion"] ~= ATLAS_VERSION) then |
||
248 | Atlas_FreshOptions(); |
||
249 | end |
||
250 | |||
251 | --Take all the maps listed in the localization files and import them into the dropdown list structure |
||
252 | table.foreach(AtlasText, function(v) |
||
253 | table.insert(ATLAS_DROPDOWN_LIST, v) |
||
254 | end); |
||
255 | table.foreach(AtlasBG, function(v) |
||
256 | table.insert(ATLAS_DROPDOWN_LIST_BG, v) |
||
257 | end); |
||
258 | table.foreach(AtlasFP, function(v) |
||
259 | table.insert(ATLAS_DROPDOWN_LIST_FP, v) |
||
260 | end); |
||
261 | table.foreach(AtlasDL, function(v) |
||
262 | table.insert(ATLAS_DROPDOWN_LIST_DL, v) |
||
263 | end); |
||
264 | table.foreach(AtlasRE, function(v) |
||
265 | table.insert(ATLAS_DROPDOWN_LIST_RE, v) |
||
266 | end); |
||
267 | |||
268 | --Update the level ranges and player limits |
||
269 | --Overrides the values in the localization files because I'm too lazy to change them all |
||
270 | --It's also nice to have all the these figures come from only one place |
||
271 | Atlas_UpdateLevelRanges(); |
||
272 | Atlas_UpdatePlayerLimits(); |
||
273 | |||
274 | --Sort the lists of maps alphabetically |
||
275 | table.sort(ATLAS_DROPDOWN_LIST, Atlas_SortZonesAlpha); |
||
276 | table.sort(ATLAS_DROPDOWN_LIST_BG, Atlas_SortZonesAlphaBG); |
||
277 | table.sort(ATLAS_DROPDOWN_LIST_FP, Atlas_SortZonesAlphaFP); |
||
278 | table.sort(ATLAS_DROPDOWN_LIST_DL, Atlas_SortZonesAlphaDL); |
||
279 | table.sort(ATLAS_DROPDOWN_LIST_RE, Atlas_SortZonesAlphaRE); |
||
280 | |||
281 | --Now that saved variables have been loaded, update everything accordingly |
||
282 | Atlas_Refresh(); |
||
283 | AtlasOptions_Init(); |
||
284 | Atlas_UpdateLock(); |
||
285 | AtlasButton_UpdatePosition(); |
||
286 | Atlas_UpdateAlpha(); |
||
287 | |||
288 | --myAddOns support |
||
289 | if(myAddOnsFrame_Register) then |
||
290 | myAddOnsFrame_Register(AtlasDetails); |
||
291 | end |
||
292 | |||
293 | --Cosmos integration |
||
294 | if(EarthFeature_AddButton) then |
||
295 | EarthFeature_AddButton( |
||
296 | { |
||
297 | id = ATLAS_TITLE; |
||
298 | name = ATLAS_TITLE; |
||
299 | subtext = ATLAS_SUBTITLE; |
||
300 | tooltip = ATLAS_DESC; |
||
301 | icon = "Interface\\AddOns\\Atlas\\Images\\AtlasIcon"; |
||
302 | callback = Atlas_Toggle; |
||
303 | test = nil; |
||
304 | } |
||
305 | ); |
||
306 | elseif(Cosmos_RegisterButton) then |
||
307 | Cosmos_RegisterButton( |
||
308 | ATLAS_TITLE, |
||
309 | ATLAS_SUBTITLE, |
||
310 | ATLAS_DESC, |
||
311 | "Interface\\AddOns\\Atlas\\Images\\AtlasIcon", |
||
312 | Atlas_Toggle |
||
313 | ); |
||
314 | end |
||
315 | |||
316 | --CTMod integration |
||
317 | if(CT_RegisterMod) then |
||
318 | CT_RegisterMod( |
||
319 | ATLAS_TITLE, |
||
320 | ATLAS_SUBTITLE, |
||
321 | 5, |
||
322 | "Interface\\AddOns\\Atlas\\Images\\AtlasIcon", |
||
323 | ATLAS_DESC, |
||
324 | "switch", |
||
325 | "", |
||
326 | Atlas_Toggle |
||
327 | ); |
||
328 | end |
||
329 | end |
||
330 | |||
331 | --Simple function to toggle the Atlas frame's lock status and update it's appearance |
||
332 | function Atlas_ToggleLock() |
||
333 | if(AtlasOptions.AtlasLocked) then |
||
334 | AtlasOptions.AtlasLocked = false; |
||
335 | Atlas_UpdateLock(); |
||
336 | else |
||
337 | AtlasOptions.AtlasLocked = true; |
||
338 | Atlas_UpdateLock(); |
||
339 | end |
||
340 | end |
||
341 | |||
342 | --Updates the appearance of the lock button based on the status of AtlasLocked |
||
343 | function Atlas_UpdateLock() |
||
344 | if(AtlasOptions.AtlasLocked) then |
||
345 | AtlasLockNorm:SetTexture("Interface\\AddOns\\Atlas\\Images\\LockButton-Locked-Up"); |
||
346 | AtlasLockPush:SetTexture("Interface\\AddOns\\Atlas\\Images\\LockButton-Locked-Down"); |
||
347 | else |
||
348 | AtlasLockNorm:SetTexture("Interface\\AddOns\\Atlas\\Images\\LockButton-Unlocked-Up"); |
||
349 | AtlasLockPush:SetTexture("Interface\\AddOns\\Atlas\\Images\\LockButton-Unlocked-Down"); |
||
350 | end |
||
351 | end |
||
352 | |||
353 | --Begin moving the Atlas frame if it's unlocked |
||
354 | function Atlas_StartMoving() |
||
355 | if(not AtlasOptions.AtlasLocked) then |
||
356 | AtlasFrame:StartMoving(); |
||
357 | end |
||
358 | end |
||
359 | |||
360 | --Parses slash commands |
||
361 | --If an unrecognized command is given, toggle Atlas |
||
362 | function Atlas_SlashCommand(msg) |
||
363 | if(msg == ATLAS_SLASH_OPTIONS) then |
||
364 | AtlasOptions_Toggle(); |
||
365 | else |
||
366 | Atlas_Toggle(); |
||
367 | end |
||
368 | end |
||
369 | |||
370 | --Sets the transparency of the Atlas frame based on AtlasAlpha |
||
371 | function Atlas_UpdateAlpha() |
||
372 | AtlasFrame:SetAlpha(AtlasOptions.AtlasAlpha); |
||
373 | end |
||
374 | |||
375 | --Simple function to toggle the visibility of the Atlas frame |
||
376 | function Atlas_Toggle() |
||
377 | if(AtlasFrame:IsVisible()) then |
||
378 | HideUIPanel(AtlasFrame); |
||
379 | else |
||
380 | ShowUIPanel(AtlasFrame); |
||
381 | end |
||
382 | end |
||
383 | |||
384 | --Refreshes the Atlas frame, usually because a new map needs to be displayed |
||
385 | --The zoneID variable represents the internal name used for each map |
||
386 | --Also responsible for updating all the text when a map is changed |
||
387 | function Atlas_Refresh() |
||
388 | local zoneID; |
||
389 | local textSource; |
||
390 | |||
391 | --Just in case AtlasType hasn't been initialized |
||
392 | --Added in response to a possible error |
||
393 | if ( AtlasOptions.AtlasType == nil ) then |
||
394 | AtlasOptions.AtlasType = 1; |
||
395 | end |
||
396 | |||
397 | if ( AtlasOptions.AtlasType == 1 ) then |
||
398 | zoneID = ATLAS_DROPDOWN_LIST[AtlasOptions.AtlasZone]; |
||
399 | textSource = AtlasText; |
||
400 | elseif ( AtlasOptions.AtlasType == 2 ) then |
||
401 | zoneID = ATLAS_DROPDOWN_LIST_BG[AtlasOptions.AtlasZone]; |
||
402 | textSource = AtlasBG; |
||
403 | elseif ( AtlasOptions.AtlasType == 3 ) then |
||
404 | zoneID = ATLAS_DROPDOWN_LIST_FP[AtlasOptions.AtlasZone]; |
||
405 | textSource = AtlasFP; |
||
406 | elseif ( AtlasOptions.AtlasType == 4 ) then |
||
407 | zoneID = ATLAS_DROPDOWN_LIST_DL[AtlasOptions.AtlasZone]; |
||
408 | textSource = AtlasDL; |
||
409 | elseif ( AtlasOptions.AtlasType == 5 ) then |
||
410 | zoneID = ATLAS_DROPDOWN_LIST_RE[AtlasOptions.AtlasZone]; |
||
411 | textSource = AtlasRE; |
||
412 | end |
||
413 | AtlasMap:ClearAllPoints(); |
||
414 | AtlasMap:SetWidth(512); |
||
415 | AtlasMap:SetHeight(512); |
||
416 | AtlasMap:SetPoint("TOPLEFT", "AtlasFrame", "TOPLEFT", 18, -84); |
||
417 | AtlasMap:SetTexture("Interface\\AddOns\\Atlas\\Images\\"..zoneID); |
||
418 | local ZoneNameText = textSource[zoneID]["ZoneName"]; |
||
419 | if ( AtlasOptions.AtlasAcronyms and textSource[zoneID]["Acronym"] ~= nil) then |
||
420 | local _RED = "|cffcc6666"; |
||
421 | ZoneNameText = ZoneNameText.._RED.." ["..textSource[zoneID]["Acronym"].."]"; |
||
422 | end |
||
423 | AtlasText_ZoneName:SetText(ZoneNameText); |
||
424 | AtlasText_Location:SetText(ATLAS_STRING_LOCATION..": "..textSource[zoneID]["Location"]); |
||
425 | AtlasText_LevelRange:SetText(ATLAS_STRING_LEVELRANGE..": "..textSource[zoneID]["LevelRange"]); |
||
426 | AtlasText_PlayerLimit:SetText(ATLAS_STRING_PLAYERLIMIT..": "..textSource[zoneID]["PlayerLimit"]); |
||
427 | for i = 1, 27, 1 do |
||
428 | getglobal("AtlasText_"..i):SetText(textSource[zoneID][i]); |
||
429 | end |
||
430 | end |
||
431 | |||
432 | --Function used to initialize the map type dropdown menu |
||
433 | --Cycle through Atlas_MapTypes to populate the dropdown |
||
434 | function AtlasFrameDropDownType_Initialize() |
||
435 | local info; |
||
436 | for i = 1, getn(Atlas_MapTypes), 1 do |
||
437 | info = { |
||
438 | text = Atlas_MapTypes[i]; |
||
439 | func = AtlasFrameDropDownType_OnClick; |
||
440 | }; |
||
441 | UIDropDownMenu_AddButton(info); |
||
442 | end |
||
443 | end |
||
444 | |||
445 | --Called whenever the map type dropdown menu is shown |
||
446 | function AtlasFrameDropDownType_OnShow() |
||
447 | UIDropDownMenu_Initialize(AtlasFrameDropDownType, AtlasFrameDropDownType_Initialize); |
||
448 | UIDropDownMenu_SetSelectedID(AtlasFrameDropDownType, AtlasOptions.AtlasType); |
||
449 | UIDropDownMenu_SetWidth(175, AtlasFrameDropDownType); |
||
450 | end |
||
451 | |||
452 | --Called whenever an item in the map type dropdown menu is clicked |
||
453 | --Sets the main dropdown menu contents to reflect the category of map selected |
||
454 | function AtlasFrameDropDownType_OnClick() |
||
455 | i = this:GetID(); |
||
456 | UIDropDownMenu_SetSelectedID(AtlasFrameDropDownType, i); |
||
457 | AtlasOptions.AtlasType = i; |
||
458 | AtlasOptions.AtlasZone = 1; |
||
459 | AtlasFrameDropDown_OnShow(); |
||
460 | Atlas_Refresh(); |
||
461 | end |
||
462 | |||
463 | --Function used to initialize the main dropdown menu |
||
464 | --Looks at the status of AtlasType to determine how to populate the list |
||
465 | function AtlasFrameDropDown_Initialize() |
||
466 | if ( AtlasOptions.AtlasType == 1 ) then |
||
467 | AtlasFrameDropDown_Populate(AtlasText, ATLAS_DROPDOWN_LIST); |
||
468 | elseif ( AtlasOptions.AtlasType == 2 ) then |
||
469 | AtlasFrameDropDown_Populate(AtlasBG, ATLAS_DROPDOWN_LIST_BG); |
||
470 | elseif ( AtlasOptions.AtlasType == 3 ) then |
||
471 | AtlasFrameDropDown_Populate(AtlasFP, ATLAS_DROPDOWN_LIST_FP); |
||
472 | elseif ( AtlasOptions.AtlasType == 4 ) then |
||
473 | AtlasFrameDropDown_Populate(AtlasDL, ATLAS_DROPDOWN_LIST_DL); |
||
474 | elseif ( AtlasOptions.AtlasType == 5 ) then |
||
475 | AtlasFrameDropDown_Populate(AtlasRE, ATLAS_DROPDOWN_LIST_RE); |
||
476 | end |
||
477 | end |
||
478 | |||
479 | --Populates the main dropdown menu based on the arguments given |
||
480 | --mapType is the name used in the localization files for the category of map |
||
481 | --dropList is the (hopefully) sorted list made from one of those categories |
||
482 | function AtlasFrameDropDown_Populate(mapType, dropList) |
||
483 | local info; |
||
484 | for i = 1, getn(dropList), 1 do |
||
485 | info = { |
||
486 | text = mapType[dropList[i]]["ZoneName"]; |
||
487 | func = AtlasFrameDropDown_OnClick; |
||
488 | }; |
||
489 | UIDropDownMenu_AddButton(info); |
||
490 | end |
||
491 | end |
||
492 | |||
493 | --Called whenever the main dropdown menu is shown |
||
494 | function AtlasFrameDropDown_OnShow() |
||
495 | UIDropDownMenu_Initialize(AtlasFrameDropDown, AtlasFrameDropDown_Initialize); |
||
496 | UIDropDownMenu_SetSelectedID(AtlasFrameDropDown, AtlasOptions.AtlasZone); |
||
497 | UIDropDownMenu_SetWidth(175, AtlasFrameDropDown); |
||
498 | end |
||
499 | |||
500 | --Called whenever an item in the main dropdown menu is clicked |
||
501 | --Sets the newly selected map as current and refreshes the frame |
||
502 | function AtlasFrameDropDown_OnClick() |
||
503 | i = this:GetID(); |
||
504 | UIDropDownMenu_SetSelectedID(AtlasFrameDropDown, i); |
||
505 | AtlasOptions.AtlasZone = i; |
||
506 | Atlas_Refresh(); |
||
507 | end |
||
508 | |||
509 | --Modifies the value of GetRealZoneText to account for some naming conventions |
||
510 | --Always use this function instead of GetRealZoneText within Atlas |
||
511 | function Atlas_GetFixedZoneText() |
||
512 | local currentZone = GetRealZoneText(); |
||
513 | if (AtlasZoneSubstitutions[currentZone]) then |
||
514 | return AtlasZoneSubstitutions[currentZone]; |
||
515 | end |
||
516 | return currentZone; |
||
517 | end |
||
518 | |||
519 | --Checks the player's current location against all Atlas maps |
||
520 | --If a match is found display that map right away |
||
521 | function Atlas_AutoSelect() |
||
522 | local currentZone = Atlas_GetFixedZoneText(); |
||
523 | local currentMap = AtlasText[ATLAS_DROPDOWN_LIST[AtlasOptions.AtlasZone]]["ZoneName"]; |
||
524 | if(currentZone ~= currentMap) then |
||
525 | for i = 1, getn(ATLAS_DROPDOWN_LIST), 1 do |
||
526 | local mapName = AtlasText[ATLAS_DROPDOWN_LIST[i]]["ZoneName"]; |
||
527 | if(currentZone == mapName) then |
||
528 | AtlasOptions.AtlasType = 1; |
||
529 | AtlasOptions.AtlasZone = i; |
||
530 | UIDropDownMenu_SetSelectedID(AtlasFrameDropDown, i); |
||
531 | Atlas_Refresh(); |
||
532 | end |
||
533 | end |
||
534 | end |
||
535 | end |
||
536 | |||
537 | --Called whenever the Atlas frame is displayed |
||
538 | function Atlas_OnShow() |
||
539 | if(AtlasOptions.AtlasAutoSelect) then |
||
540 | Atlas_AutoSelect(); |
||
541 | end |
||
542 | end |
||
543 | |||
544 | --Checks to see if the World Map should be replaced by Atlas or not |
||
545 | --Is the feature turned on? Is the player in an instance? |
||
546 | function Atlas_ReplaceWorldMap() |
||
547 | if(AtlasOptions.AtlasReplaceWorldMap) then |
||
548 | local currentZone = Atlas_GetFixedZoneText(); |
||
549 | for i = 1, getn(ATLAS_DROPDOWN_LIST), 1 do |
||
550 | local mapName = AtlasText[ATLAS_DROPDOWN_LIST[i]]["ZoneName"]; |
||
551 | if(currentZone == mapName) then |
||
552 | return true; |
||
553 | end |
||
554 | end |
||
555 | end |
||
556 | return false; |
||
557 | end |
||
558 | |||
559 | --Code provided by Morac |
||
560 | --Replaces the default ToggleWorldMap function |
||
561 | function ToggleWorldMap() |
||
562 | if ( WorldMapFrame:IsVisible() ) then |
||
563 | HideUIPanel(WorldMapFrame); |
||
564 | else |
||
565 | if(Atlas_ReplaceWorldMap()) then |
||
566 | Atlas_Toggle(); |
||
567 | else |
||
568 | --removed due to error in 1.12 (8/22/06) |
||
569 | --SetupWorldMapScale(WorldMapFrame); |
||
570 | ShowUIPanel(WorldMapFrame); |
||
571 | end |
||
572 | end |
||
573 | end |
||
574 | |||
575 | --Code provided by tyroney |
||
576 | --Bugfix code by Cold |
||
577 | --Runs when the Atlas frame is clicked on |
||
578 | --RightButton closes Atlas and open the World Map if the RightClick option is turned on |
||
579 | function Atlas_OnClick() |
||
580 | if ( arg1 == "RightButton" ) then |
||
581 | if (AtlasOptions.AtlasRightClick) then |
||
582 | local OldAtlasOptReplWMap = AtlasOptions.AtlasReplaceWorldMap; |
||
583 | AtlasOptions.AtlasReplaceWorldMap = false; |
||
584 | Atlas_Toggle(); |
||
585 | ToggleWorldMap(); |
||
586 | AtlasOptions.AtlasReplaceWorldMap = OldAtlasOptReplWMap; |
||
587 | end |
||
588 | end |
||
589 | end |