📄 gathererui.lua
字号:
end
-- ******************************************************************
function GathererUIDropDownTheme_OnClick()
UIDropDownMenu_SetSelectedID(GathererUI_DropDownTheme, this:GetID());
local cmd = UIDropDownMenu_GetText(GathererUI_DropDownTheme);
Gatherer_Command("theme "..cmd);
end
function GathererUIDropDownFilterHerbs_OnClick()
local filterValue = "herbs";
local iconIndex = 1;
local dropDownText = "Herbs";
GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText);
end
function GathererUIDropDownFilterOre_OnClick()
local filterValue = "mining";
local iconIndex = 2;
local dropDownText = "Ore";
GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText);
end
function GathererUIDropDownFilterTreasure_OnClick()
local filterValue = "treasure";
local iconIndex = 0;
local dropDownText = "Treasure";
GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText);
end
function GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText)
if ( this:GetID() < 3 and (this.value == "on" or this.value == "off" or this.value == "auto")) then
UIDropDownMenu_SetText(Gatherer_GetMenuName(this.value), getglobal("GathererUI_DropDown"..dropDownText));
Gatherer_Command(filterValue.." "..this.value);
GathererUI_InitializeMenu();
else
if ( not GatherConfig.users[Gather_Player].interested ) then
GatherConfig.users[Gather_Player].interested = {};
end
if ( not GatherConfig.users[Gather_Player].interested[iconIndex] ) then
GatherConfig.users[Gather_Player].interested[iconIndex] = {};
end
GatherConfig.users[Gather_Player].interested[iconIndex][this.value] = not this.checked;
end
GatherMain_Draw();
end
function GathererUI_OnEnterPressed_HerbSkillEditBox()
if ( GathererUI_HerbSkillEditBox:GetNumber() > 300 ) then
GathererUI_HerbSkillEditBox:SetNumber(300);
end
if ( GathererUI_HerbSkillEditBox:GetNumber() < 0 ) then
GathererUI_HerbSkillEditBox:SetNumber(0);
end
GatherConfig.users[Gather_Player].minSetHerbSkill = GathererUI_HerbSkillEditBox:GetNumber();
end
function GathererUI_OnEnterPressed_OreSkillEditBox()
if ( GathererUI_OreSkillEditBox:GetNumber() > 300 ) then
GathererUI_OreSkillEditBox:SetNumber(300);
end
if ( GathererUI_OreSkillEditBox:GetNumber() < 0 ) then
GathererUI_OreSkillEditBox:SetNumber(0);
end
GatherConfig.users[Gather_Player].minSetOreSkill = GathererUI_OreSkillEditBox:GetNumber();
end
function GathererUI_OnEnterPressed_IconSizeEditBox()
if (GatherConfig) then
if ( GathererUI_WorldMapIconSize:GetNumber() < 8 or GathererUI_WorldMapIconSize:GetNumber() > 16 ) then
if ( GatherConfig.IconSize ) then
GathererUI_WorldMapIconSize:SetNumber(GatherConfig.IconSize)
else
GathererUI_WorldMapIconSize:SetNumber(12);
end
end
GatherConfig.IconSize = GathererUI_WorldMapIconSize:GetNumber();
end
end
function GathererUI_OnEnterPressed_IconAlphaEditBox()
if (GatherConfig) then
if ( GathererUI_WorldMapIconAlpha:GetNumber() < 20 or GathererUI_WorldMapIconAlpha:GetNumber() > 100 ) then
if ( GatherConfig.IconAlpha ) then
GathererUI_WorldMapIconAlpha:SetNumber(GatherConfig.IconAlpha/100)
else
GathererUI_WorldMapIconAlpha:SetNumber(80);
end
end
GatherConfig.IconAlpha = GathererUI_WorldMapIconAlpha:GetNumber();
end
end
-- *******************************************************************
-- Zone Rematch Section: Handle with care
function GathererUI_ZoneRematch(sourceZoneMapping, destZoneMapping)
local zone_swap=0;
local new_idx_z, gatherType;
NewGatherItems = {}
fixedItemCount = 0;
Gatherer_ChatPrint(GATHERER_TEXT_APPLY_REMATCH.." "..sourceZoneMapping.." -> "..destZoneMapping);
for idx_c, rec_continent in GatherItems do
if (idx_c ~= 0) then NewGatherItems[idx_c]= {}; end
for idx_z, rec_zone in rec_continent do
if ( idx_c ~= 0 and idx_z ~= 0) then
new_idx_z= GathererUI_ZoneMatchTable[sourceZoneMapping][destZoneMapping][idx_c][idx_z];
if ( idx_z ~= new_idx_z ) then zone_swap = zone_swap + 1; end;
NewGatherItems[idx_c][new_idx_z] = {};
for myItems, rec_gatheritem in rec_zone do
local fixedItemName;
if (gathererFixItems == 1) then
fixedItemName = GathererUI_FixItemName(myItems);
else
fixedItemName= myItems;
end
NewGatherItems[idx_c][new_idx_z][fixedItemName] = {};
for idx_item, myGather in rec_gatheritem do
local myGatherType, myIcon;
if ( type(myGather.gtype) == "number" ) then
myGatherType = myGather.gtype;
else
myGatherType = Gather_DB_TypeIndex[myGather.gtype];
end
if ( type(myGather.icon) == "number" ) then
myIcon= myGather.icon;
else
myIcon= Gatherer_GetDB_IconIndex(myGather.icon, myGatherType);
end
-- convertion of rich thorium veins to new format
if ( myGatherType == 2 and myIcon == 8 ) then
myIcon = Gatherer_GetDB_IconIndex(Gatherer_FindOreType(fixedItemName), myGatherType);
end
NewGatherItems[idx_c][new_idx_z][fixedItemName][idx_item] = { x=myGather.x, y=myGather.y, gtype=myGatherType, icon=myIcon, count=myGather.count };
fixedItemCount = fixedItemCount + 1;
end
end
end
end
end
Gatherer_ChatPrint("Zone swapping completed ("..zone_swap.." done, "..fixedItemCount.." items accounted for).")
end
-- *******************************************************************
-- Zone Match UI functions
function GathererUI_ShowRematchDialog()
if ( GathererUI_ZoneRematchDialog:IsVisible() ) then
GathererUI_ZoneRematchDialog:Hide()
GathererUI_DestinationZoneDropDown:Hide();
else
GathererUI_ZoneRematchDialog:Show()
end
end
-- *******************************************************************
-- DropDown Menu functions
function GathererUIDropDownSourceZone_Initialize()
for index in GathererUI_ZoneMatchTable do
local info = {};
info.text = index;
info.checked = nil;
info.func = GathererUIDropDownFilterSourceZone_OnClick;
UIDropDownMenu_AddButton(info);
if ( GatherConfig.DataBuild and GatherConfig.DataBuild == info.text ) then
UIDropDownMenu_SetText(info.text, GathererUI_SourceZoneDropDown);
end
end
end
function GathererUIDropDownDestionationZone_Initialize()
local cmd = UIDropDownMenu_GetText(GathererUI_SourceZoneDropDown);
if ( cmd and cmd ~= "" ) then
for index in GathererUI_ZoneMatchTable[cmd] do
local info = {};
info.text = index;
info.checked = nil;
info.func = GathererUIDropDownFilterDestinationZone_OnClick;
UIDropDownMenu_AddButton(info);
end
end
end
-- *******************************************************************
-- OnClick in DropDown Menu functions
function GathererUIDropDownFilterSourceZone_OnClick()
UIDropDownMenu_SetSelectedID(GathererUI_SourceZoneDropDown, this:GetID());
GathererUI_DestinationZoneDropDown:Show();
end
function GathererUIDropDownFilterDestinationZone_OnClick()
UIDropDownMenu_SetSelectedID(GathererUI_DestinationZoneDropDown, this:GetID());
end
-- *******************************************************************
-- Apply Button
function GathererUI_ShowRematchDialogApply()
local source, dest
source = UIDropDownMenu_GetText(GathererUI_SourceZoneDropDown);
dest = UIDropDownMenu_GetText(GathererUI_DestinationZoneDropDown);
if( source and dest ) then
-- hide Option dialog (since the position of the confirmation dialog can cause miss-click on stuff in there)
GathererUI_HideOptions()
-- add extra confirmation dialog
StaticPopup_Show("CONFIRM_REMATCH");
elseif ( not source ) then
Gatherer_ChatPrint(GATHERER_TEXT_SRCZONE_MISSING);
else
Gatherer_ChatPrint(GATHERER_TEXT_DESTZONE_MISSING);
end
end
StaticPopupDialogs["CONFIRM_REMATCH"] = {
text = TEXT(GATHERER_TEXT_CONFIRM_REMATCH),
button1 = TEXT(ACCEPT),
button2 = TEXT(DECLINE),
OnAccept = function()
Gatherer_ConfirmZoneRematch();
end,
timeout = 60,
showAlert = 1,
};
function Gatherer_ConfirmZoneRematch()
local source = UIDropDownMenu_GetText(GathererUI_SourceZoneDropDown);
local dest = UIDropDownMenu_GetText(GathererUI_DestinationZoneDropDown);
-- Swap tables and Recompute notes
GathererUI_ZoneRematch(source, dest);
GatherItems = NewGatherItems;
GatherConfig.DataBuild = dest;
GathererUI_ShowRematchDialog();
end
-- **************************************************************************
-- Help Page functions.
-- Update the help
function GathererUI_HelpFrame_Update()
-- Check if an addon is selected
GathererUI_HelpFrameName:SetText("Gatherer Help");
local help = GathererHelp;
local currentPage = help.currentPage;
local totalPages = 9;
GathererUI_HelpFrameHelp:SetText(help[currentPage]);
GathererUI_HelpFramePage:SetText("Page "..currentPage.."/"..totalPages);
GathererUI_HelpFrame_UpdateButtons()
end
-- Enable/Disable the help buttons
function GathererUI_HelpFrame_UpdateButtons()
-- Get the help
local help = GathererHelp;
-- Check if there is an help
local currentPage = help.currentPage;
local totalPages = 9;
-- Check if the current help page is the first one
if (currentPage == 1) then
GathererUI_HelpFramePrevPageButton:Disable();
else
GathererUI_HelpFramePrevPageButton:Enable();
end
-- Check if the current help page is the last one
if (currentPage == totalPages) then
GathererUI_HelpFrameNextPageButton:Disable();
else
GathererUI_HelpFrameNextPageButton:Enable();
end
end
-- Help previous page OnClick event
function GathererUI_HelpFramePrevPageButton_OnClick()
-- Set the current page to previous page
local help = GathererHelp;
help.currentPage = help.currentPage - 1;
-- Update the help
GathererUI_HelpFrame_Update()
end
-- Help next page OnClick event
function GathererUI_HelpFrameNextPageButton_OnClick()
-- Set the current page to next page
local help = GathererHelp;
help.currentPage = help.currentPage + 1;
-- Update the help
GathererUI_HelpFrame_Update();
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -