📄 atlas.lua
字号:
{
id = ATLAS_TITLE;
name = ATLAS_TITLE;
subtext = ATLAS_SUBTITLE;
tooltip = ATLAS_DESC;
icon = "Interface\\AddOns\\Atlas\\Images\\AtlasIcon";
callback = Atlas_Toggle;
test = nil;
}
);
elseif(Cosmos_RegisterButton) then
Cosmos_RegisterButton(
ATLAS_TITLE,
ATLAS_SUBTITLE,
ATLAS_DESC,
"Interface\\AddOns\\Atlas\\Images\\AtlasIcon",
Atlas_Toggle
);
end
--CTMod integration
if(CT_RegisterMod) then
CT_RegisterMod(
ATLAS_TITLE,
ATLAS_SUBTITLE,
5,
"Interface\\AddOns\\Atlas\\Images\\AtlasIcon",
ATLAS_DESC,
"switch",
"",
Atlas_Toggle
);
end
end
--Simple function to toggle the Atlas frame's lock status and update it's appearance
function Atlas_ToggleLock()
if(AtlasOptions.AtlasLocked) then
AtlasOptions.AtlasLocked = false;
Atlas_UpdateLock();
else
AtlasOptions.AtlasLocked = true;
Atlas_UpdateLock();
end
end
--Updates the appearance of the lock button based on the status of AtlasLocked
function Atlas_UpdateLock()
if(AtlasOptions.AtlasLocked) then
AtlasLockNorm:SetTexture("Interface\\AddOns\\Atlas\\Images\\LockButton-Locked-Up");
AtlasLockPush:SetTexture("Interface\\AddOns\\Atlas\\Images\\LockButton-Locked-Down");
else
AtlasLockNorm:SetTexture("Interface\\AddOns\\Atlas\\Images\\LockButton-Unlocked-Up");
AtlasLockPush:SetTexture("Interface\\AddOns\\Atlas\\Images\\LockButton-Unlocked-Down");
end
end
--Begin moving the Atlas frame if it's unlocked
function Atlas_StartMoving()
if(not AtlasOptions.AtlasLocked) then
AtlasFrame:StartMoving();
end
end
--Parses slash commands
--If an unrecognized command is given, toggle Atlas
function Atlas_SlashCommand(msg)
if(msg == ATLAS_SLASH_OPTIONS) then
AtlasOptions_Toggle();
else
Atlas_Toggle();
end
end
--Sets the transparency of the Atlas frame based on AtlasAlpha
function Atlas_UpdateAlpha()
AtlasFrame:SetAlpha(AtlasOptions.AtlasAlpha);
end
--Simple function to toggle the visibility of the Atlas frame
function Atlas_Toggle()
if(AtlasFrame:IsVisible()) then
HideUIPanel(AtlasFrame);
else
ShowUIPanel(AtlasFrame);
end
end
--Refreshes the Atlas frame, usually because a new map needs to be displayed
--The zoneID variable represents the internal name used for each map
--Also responsible for updating all the text when a map is changed
function Atlas_Refresh()
local zoneID;
local textSource;
--Just in case AtlasType hasn't been initialized
--Added in response to a possible error
if ( AtlasOptions.AtlasType == nil ) then
AtlasOptions.AtlasType = 1;
end
if ( AtlasOptions.AtlasType == 1 ) then
zoneID = ATLAS_DROPDOWN_LIST[AtlasOptions.AtlasZone];
textSource = AtlasText;
elseif ( AtlasOptions.AtlasType == 2 ) then
zoneID = ATLAS_DROPDOWN_LIST_BG[AtlasOptions.AtlasZone];
textSource = AtlasBG;
elseif ( AtlasOptions.AtlasType == 3 ) then
zoneID = ATLAS_DROPDOWN_LIST_FP[AtlasOptions.AtlasZone];
textSource = AtlasFP;
elseif ( AtlasOptions.AtlasType == 4 ) then
zoneID = ATLAS_DROPDOWN_LIST_DL[AtlasOptions.AtlasZone];
textSource = AtlasDL;
elseif ( AtlasOptions.AtlasType == 5 ) then
zoneID = ATLAS_DROPDOWN_LIST_RE[AtlasOptions.AtlasZone];
textSource = AtlasRE;
end
AtlasMap:ClearAllPoints();
AtlasMap:SetWidth(512);
AtlasMap:SetHeight(512);
AtlasMap:SetPoint("TOPLEFT", "AtlasFrame", "TOPLEFT", 18, -84);
AtlasMap:SetTexture("Interface\\AddOns\\Atlas\\Images\\"..zoneID);
local ZoneNameText = textSource[zoneID]["ZoneName"];
if ( AtlasOptions.AtlasAcronyms and textSource[zoneID]["Acronym"] ~= nil) then
local _RED = "|cffcc6666";
ZoneNameText = ZoneNameText.._RED.." ["..textSource[zoneID]["Acronym"].."]";
end
AtlasText_ZoneName:SetText(ZoneNameText);
AtlasText_Location:SetText(ATLAS_STRING_LOCATION..": "..textSource[zoneID]["Location"]);
AtlasText_LevelRange:SetText(ATLAS_STRING_LEVELRANGE..": "..textSource[zoneID]["LevelRange"]);
AtlasText_PlayerLimit:SetText(ATLAS_STRING_PLAYERLIMIT..": "..textSource[zoneID]["PlayerLimit"]);
for i = 1, 27, 1 do
getglobal("AtlasText_"..i):SetText(textSource[zoneID][i]);
end
end
--Function used to initialize the map type dropdown menu
--Cycle through Atlas_MapTypes to populate the dropdown
function AtlasFrameDropDownType_Initialize()
local info;
for i = 1, getn(Atlas_MapTypes), 1 do
info = {
text = Atlas_MapTypes[i];
func = AtlasFrameDropDownType_OnClick;
};
UIDropDownMenu_AddButton(info);
end
end
--Called whenever the map type dropdown menu is shown
function AtlasFrameDropDownType_OnShow()
UIDropDownMenu_Initialize(AtlasFrameDropDownType, AtlasFrameDropDownType_Initialize);
UIDropDownMenu_SetSelectedID(AtlasFrameDropDownType, AtlasOptions.AtlasType);
UIDropDownMenu_SetWidth(175, AtlasFrameDropDownType);
end
--Called whenever an item in the map type dropdown menu is clicked
--Sets the main dropdown menu contents to reflect the category of map selected
function AtlasFrameDropDownType_OnClick()
i = this:GetID();
UIDropDownMenu_SetSelectedID(AtlasFrameDropDownType, i);
AtlasOptions.AtlasType = i;
AtlasOptions.AtlasZone = 1;
AtlasFrameDropDown_OnShow();
Atlas_Refresh();
end
--Function used to initialize the main dropdown menu
--Looks at the status of AtlasType to determine how to populate the list
function AtlasFrameDropDown_Initialize()
if ( AtlasOptions.AtlasType == 1 ) then
AtlasFrameDropDown_Populate(AtlasText, ATLAS_DROPDOWN_LIST);
elseif ( AtlasOptions.AtlasType == 2 ) then
AtlasFrameDropDown_Populate(AtlasBG, ATLAS_DROPDOWN_LIST_BG);
elseif ( AtlasOptions.AtlasType == 3 ) then
AtlasFrameDropDown_Populate(AtlasFP, ATLAS_DROPDOWN_LIST_FP);
elseif ( AtlasOptions.AtlasType == 4 ) then
AtlasFrameDropDown_Populate(AtlasDL, ATLAS_DROPDOWN_LIST_DL);
elseif ( AtlasOptions.AtlasType == 5 ) then
AtlasFrameDropDown_Populate(AtlasRE, ATLAS_DROPDOWN_LIST_RE);
end
end
--Populates the main dropdown menu based on the arguments given
--mapType is the name used in the localization files for the category of map
--dropList is the (hopefully) sorted list made from one of those categories
function AtlasFrameDropDown_Populate(mapType, dropList)
local info;
for i = 1, getn(dropList), 1 do
info = {
text = mapType[dropList[i]]["ZoneName"];
func = AtlasFrameDropDown_OnClick;
};
UIDropDownMenu_AddButton(info);
end
end
--Called whenever the main dropdown menu is shown
function AtlasFrameDropDown_OnShow()
UIDropDownMenu_Initialize(AtlasFrameDropDown, AtlasFrameDropDown_Initialize);
UIDropDownMenu_SetSelectedID(AtlasFrameDropDown, AtlasOptions.AtlasZone);
UIDropDownMenu_SetWidth(175, AtlasFrameDropDown);
end
--Called whenever an item in the main dropdown menu is clicked
--Sets the newly selected map as current and refreshes the frame
function AtlasFrameDropDown_OnClick()
i = this:GetID();
UIDropDownMenu_SetSelectedID(AtlasFrameDropDown, i);
AtlasOptions.AtlasZone = i;
Atlas_Refresh();
end
--Modifies the value of GetRealZoneText to account for some naming conventions
--Always use this function instead of GetRealZoneText within Atlas
function Atlas_GetFixedZoneText()
local currentZone = GetRealZoneText();
if (AtlasZoneSubstitutions[currentZone]) then
return AtlasZoneSubstitutions[currentZone];
end
return currentZone;
end
--Checks the player's current location against all Atlas maps
--If a match is found display that map right away
function Atlas_AutoSelect()
local currentZone = Atlas_GetFixedZoneText();
local currentMap = AtlasText[ATLAS_DROPDOWN_LIST[AtlasOptions.AtlasZone]]["ZoneName"];
if(currentZone ~= currentMap) then
for i = 1, getn(ATLAS_DROPDOWN_LIST), 1 do
local mapName = AtlasText[ATLAS_DROPDOWN_LIST[i]]["ZoneName"];
if(currentZone == mapName) then
AtlasOptions.AtlasType = 1;
AtlasOptions.AtlasZone = i;
UIDropDownMenu_SetSelectedID(AtlasFrameDropDown, i);
Atlas_Refresh();
end
end
end
end
--Called whenever the Atlas frame is displayed
function Atlas_OnShow()
if(AtlasOptions.AtlasAutoSelect) then
Atlas_AutoSelect();
end
end
--Checks to see if the World Map should be replaced by Atlas or not
--Is the feature turned on? Is the player in an instance?
function Atlas_ReplaceWorldMap()
if(AtlasOptions.AtlasReplaceWorldMap) then
local currentZone = Atlas_GetFixedZoneText();
for i = 1, getn(ATLAS_DROPDOWN_LIST), 1 do
local mapName = AtlasText[ATLAS_DROPDOWN_LIST[i]]["ZoneName"];
if(currentZone == mapName) then
return true;
end
end
end
return false;
end
--Code provided by Morac
--Replaces the default ToggleWorldMap function
function ToggleWorldMap()
if ( WorldMapFrame:IsVisible() ) then
HideUIPanel(WorldMapFrame);
else
if(Atlas_ReplaceWorldMap()) then
Atlas_Toggle();
else
--removed due to error in 1.12 (8/22/06)
--SetupWorldMapScale(WorldMapFrame);
ShowUIPanel(WorldMapFrame);
end
end
end
--Code provided by tyroney
--Bugfix code by Cold
--Runs when the Atlas frame is clicked on
--RightButton closes Atlas and open the World Map if the RightClick option is turned on
function Atlas_OnClick()
if ( arg1 == "RightButton" ) then
if (AtlasOptions.AtlasRightClick) then
local OldAtlasOptReplWMap = AtlasOptions.AtlasReplaceWorldMap;
AtlasOptions.AtlasReplaceWorldMap = false;
Atlas_Toggle();
ToggleWorldMap();
AtlasOptions.AtlasReplaceWorldMap = OldAtlasOptReplWMap;
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -