📄 atlas.lua
字号:
--Atlas, an instance map browser
--Author: Dan Gilbert
--Email: loglow@gmail.com
--AIM: dan5981
ATLAS_VERSION = "1.8.1";
ATLAS_DATE = "August 22, 2006";
--myAddOns data goes here
AtlasDetails = {
name = "Atlas",
version = ATLAS_VERSION,
releaseDate = ATLAS_DATE,
author = "Dan Gilbert",
email = "loglow@gmail.com",
website = "http://www.atlasmod.com/",
optionsframe = "AtlasOptionsFrame",
category = MYADDONS_CATEGORY_MAP
};
local Atlas_Vars_Loaded = nil;
ATLAS_DROPDOWN_LIST = {};
ATLAS_DROPDOWN_LIST_BG = {};
ATLAS_DROPDOWN_LIST_FP = {};
ATLAS_DROPDOWN_LIST_DL = {};
ATLAS_DROPDOWN_LIST_RE = {};
local DefaultAtlasOptions = {
["AtlasVersion"] = ATLAS_VERSION;
["AtlasZone"] = 1;
["AtlasAlpha"] = 1.0;
["AtlasLocked"] = false;
["AtlasMapName"] = true;
["AtlasAutoSelect"] = false;
["AtlasButtonPosition"] = 268;
["AtlasButtonShown"] = true;
["AtlasReplaceWorldMap"] = false;
["AtlasRightClick"] = false;
["AtlasType"] = 1;
["AtlasAcronyms"] = true;
};
function Atlas_FreshOptions()
AtlasOptions = CloneTable(DefaultAtlasOptions);
end
--Code by Grayhoof (SCT)
function CloneTable(t) -- return a copy of the table t
local new = {}; -- create a new table
local i, v = next(t, nil); -- i is an index of t, v = t[i]
while i do
if type(v)=="table" then
v=CloneTable(v);
end
new[i] = v;
i, v = next(t, i); -- get next index
end
return new;
end
--Called when the Atlas frame is first loaded
--We CANNOT assume that data in other files is available yet!
function Atlas_OnLoad()
--Register the Atlas frame for the following events
this:RegisterEvent("ADDON_LOADED");
this:RegisterEvent("VARIABLES_LOADED");
--Allows Atlas to be closed with the Escape key
tinsert(UISpecialFrames, "AtlasFrame");
--Dragging involves some special registration
AtlasFrame:RegisterForDrag("LeftButton");
--Setting up slash commands involves referencing some strage auto-generated variables
SLASH_ATLAS1 = ATLAS_SLASH;
SlashCmdList["ATLAS"] = function(msg)
Atlas_SlashCommand(msg);
end
end
--Removal of articles in map names (for proper alphabetic sorting)
--For example: "The Deadmines" will become "Deadmines"
--Thus it will be sorted under D and not under T
local function Atlas_SanitizeName(text)
text = string.lower(text);
if (AtlasSortIgnore) then
for _,v in AtlasSortIgnore do
local match = string.gfind(text, v)();
if (match) and ((string.len(text) - string.len(match)) <= 4) then
return match;
end
end
end
return text;
end
--Comparator function for alphabetic sorting of maps
local function Atlas_SortZonesAlpha(a, b)
local aa = Atlas_SanitizeName(AtlasText[a].ZoneName);
local bb = Atlas_SanitizeName(AtlasText[b].ZoneName);
return aa < bb;
end
--Comparator function for alphabetic sorting of BG maps
local function Atlas_SortZonesAlphaBG(a, b)
local aa = Atlas_SanitizeName(AtlasBG[a].ZoneName);
local bb = Atlas_SanitizeName(AtlasBG[b].ZoneName);
return aa < bb;
end
--Comparator function for alphabetic sorting of FP maps
local function Atlas_SortZonesAlphaFP(a, b)
local aa = Atlas_SanitizeName(AtlasFP[a].ZoneName);
local bb = Atlas_SanitizeName(AtlasFP[b].ZoneName);
return aa < bb;
end
--Comparator function for alphabetic sorting of DL maps
local function Atlas_SortZonesAlphaDL(a, b)
local aa = Atlas_SanitizeName(AtlasDL[a].ZoneName);
local bb = Atlas_SanitizeName(AtlasDL[b].ZoneName);
return aa < bb;
end
--Comparator function for alphabetic sorting of RE maps
local function Atlas_SortZonesAlphaRE(a, b)
local aa = Atlas_SanitizeName(AtlasRE[a].ZoneName);
local bb = Atlas_SanitizeName(AtlasRE[b].ZoneName);
return aa < bb;
end
--These are the REAL level range values!
--Overrides the values that may be found in the localization files
function Atlas_UpdateLevelRanges()
AtlasText.BlackfathomDeeps.LevelRange = "24-32";
AtlasText.BlackrockSpireLower.LevelRange = "55-60";
AtlasText.BlackrockSpireUpper.LevelRange = "55-60";
AtlasText.BlackrockDepths.LevelRange = "52-60";
AtlasText.ShadowfangKeep.LevelRange = "22-30";
AtlasText.ScarletMonastery.LevelRange = "34-45";
AtlasText.MoltenCore.LevelRange = "60+";
AtlasText.TheSunkenTemple.LevelRange = "50-60";
AtlasText.WailingCaverns.LevelRange = "17-24";
AtlasText.TheStockade.LevelRange = "24-32";
AtlasText.TheDeadmines.LevelRange = "17-26";
AtlasText.DireMaulNorth.LevelRange = "56-60";
AtlasText.DireMaulEast.LevelRange = "56-60";
AtlasText.DireMaulWest.LevelRange = "56-60";
AtlasText.Gnomeregan.LevelRange = "29-38";
AtlasText.RazorfenDowns.LevelRange = "37-46";
AtlasText.RazorfenKraul.LevelRange = "29-38";
AtlasText.Maraudon.LevelRange = "46-55";
AtlasText.OnyxiasLair.LevelRange = "60+";
AtlasText.BlackwingLair.LevelRange = "60+";
AtlasText.RagefireChasm.LevelRange = "13-18";
AtlasText.Scholomance.LevelRange = "58-60";
AtlasText.Stratholme.LevelRange = "58-60";
AtlasText.Uldaman.LevelRange = "41-51";
AtlasText.ZulFarrak.LevelRange = "44-54";
AtlasText.ZulGurub.LevelRange = "60+";
AtlasText.TheTempleofAhnQiraj.LevelRange = "60+";
AtlasText.TheRuinsofAhnQiraj.LevelRange = "60+";
AtlasText.Naxxramas.LevelRange = "60+";
AtlasBG.AlteracValleyNorth.LevelRange = "51-60";
AtlasBG.AlteracValleySouth.LevelRange = "51-60";
AtlasBG.ArathiBasin.LevelRange = "20-60";
AtlasBG.WarsongGulch.LevelRange = "10-60";
AtlasFP.FPAllianceEast.LevelRange = "---";
AtlasFP.FPAllianceWest.LevelRange = "---";
AtlasFP.FPHordeEast.LevelRange = "---";
AtlasFP.FPHordeWest.LevelRange = "---";
AtlasDL.DLEast.LevelRange = "---";
AtlasDL.DLWest.LevelRange = "---";
AtlasRE.Azuregos.LevelRange = "60+";
AtlasRE.FourDragons.LevelRange = "60+";
AtlasRE.Kazzak.LevelRange = "60+";
end
--These are the REAL player limit values!
--Overrides the values that may be found in the localization files
function Atlas_UpdatePlayerLimits()
AtlasText.BlackfathomDeeps.PlayerLimit = "10";
AtlasText.BlackrockSpireLower.PlayerLimit = "10";
AtlasText.BlackrockSpireUpper.PlayerLimit = "10";
AtlasText.BlackrockDepths.PlayerLimit = "5";
AtlasText.ShadowfangKeep.PlayerLimit = "10";
AtlasText.ScarletMonastery.PlayerLimit = "10";
AtlasText.MoltenCore.PlayerLimit = "40";
AtlasText.TheSunkenTemple.PlayerLimit = "10";
AtlasText.WailingCaverns.PlayerLimit = "10";
AtlasText.TheStockade.PlayerLimit = "10";
AtlasText.TheDeadmines.PlayerLimit = "10";
AtlasText.DireMaulNorth.PlayerLimit = "5";
AtlasText.DireMaulEast.PlayerLimit = "5";
AtlasText.DireMaulWest.PlayerLimit = "5";
AtlasText.Gnomeregan.PlayerLimit = "10";
AtlasText.RazorfenDowns.PlayerLimit = "10";
AtlasText.RazorfenKraul.PlayerLimit = "10";
AtlasText.Maraudon.PlayerLimit = "10";
AtlasText.OnyxiasLair.PlayerLimit = "40";
AtlasText.BlackwingLair.PlayerLimit = "40";
AtlasText.RagefireChasm.PlayerLimit = "10";
AtlasText.Scholomance.PlayerLimit = "5";
AtlasText.Stratholme.PlayerLimit = "5";
AtlasText.Uldaman.PlayerLimit = "10";
AtlasText.ZulFarrak.PlayerLimit = "10";
AtlasText.ZulGurub.PlayerLimit = "20";
AtlasText.TheTempleofAhnQiraj.PlayerLimit = "40";
AtlasText.TheRuinsofAhnQiraj.PlayerLimit = "20";
AtlasText.Naxxramas.PlayerLimit = "40";
AtlasBG.AlteracValleyNorth.PlayerLimit = "40";
AtlasBG.AlteracValleySouth.PlayerLimit = "40";
AtlasBG.ArathiBasin.PlayerLimit = "15";
AtlasBG.WarsongGulch.PlayerLimit = "10";
AtlasFP.FPAllianceEast.PlayerLimit = "---";
AtlasFP.FPAllianceWest.PlayerLimit = "---";
AtlasFP.FPHordeEast.PlayerLimit = "---";
AtlasFP.FPHordeWest.PlayerLimit = "---";
AtlasDL.DLEast.PlayerLimit = "---";
AtlasDL.DLWest.PlayerLimit = "---";
AtlasRE.Azuregos.PlayerLimit = "40";
AtlasRE.FourDragons.PlayerLimit = "40";
AtlasRE.Kazzak.PlayerLimit = "40";
end
--Main Atlas event handler
function Atlas_OnEvent()
if (event == "ADDON_LOADED") then
if (strlower(arg1) == "atlas") then
Atlas_Vars_Loaded = 1;
Atlas_Init();
end
elseif (event == "VARIABLES_LOADED") then
if (not Atlas_Vars_Loaded) then
Atlas_Vars_Loaded = 1;
Atlas_Init();
end
end
end
--Initializes everything relating to saved variables and data in other lua files
--This should be called ONLY when we're sure that all other files have been loaded
function Atlas_Init()
if ( AtlasOptions == nil or AtlasOptions["AtlasVersion"] ~= ATLAS_VERSION) then
Atlas_FreshOptions();
end
--Take all the maps listed in the localization files and import them into the dropdown list structure
table.foreach(AtlasText, function(v)
table.insert(ATLAS_DROPDOWN_LIST, v)
end);
table.foreach(AtlasBG, function(v)
table.insert(ATLAS_DROPDOWN_LIST_BG, v)
end);
table.foreach(AtlasFP, function(v)
table.insert(ATLAS_DROPDOWN_LIST_FP, v)
end);
table.foreach(AtlasDL, function(v)
table.insert(ATLAS_DROPDOWN_LIST_DL, v)
end);
table.foreach(AtlasRE, function(v)
table.insert(ATLAS_DROPDOWN_LIST_RE, v)
end);
--Update the level ranges and player limits
--Overrides the values in the localization files because I'm too lazy to change them all
--It's also nice to have all the these figures come from only one place
Atlas_UpdateLevelRanges();
Atlas_UpdatePlayerLimits();
--Sort the lists of maps alphabetically
table.sort(ATLAS_DROPDOWN_LIST, Atlas_SortZonesAlpha);
table.sort(ATLAS_DROPDOWN_LIST_BG, Atlas_SortZonesAlphaBG);
table.sort(ATLAS_DROPDOWN_LIST_FP, Atlas_SortZonesAlphaFP);
table.sort(ATLAS_DROPDOWN_LIST_DL, Atlas_SortZonesAlphaDL);
table.sort(ATLAS_DROPDOWN_LIST_RE, Atlas_SortZonesAlphaRE);
--Now that saved variables have been loaded, update everything accordingly
Atlas_Refresh();
AtlasOptions_Init();
Atlas_UpdateLock();
AtlasButton_UpdatePosition();
Atlas_UpdateAlpha();
--myAddOns support
if(myAddOnsFrame_Register) then
myAddOnsFrame_Register(AtlasDetails);
end
--Cosmos integration
if(EarthFeature_AddButton) then
EarthFeature_AddButton(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -