📄 gathererui.lua
字号:
--[[
GUI for Gatherer (by Islorgris, original idea and most of the base UI code came from bcui_TrackingMenu)
Revision: $Id: GathererUI.lua 261 2006-07-26 17:30:09Z islorgris $
]]
-- Counter for fixed item count
fixedItemCount = 0;
gathererFixItems = 0;
-- Number of buttons for the menu defined in the XML file.
GathererUI_NUM_BUTTONS = 7;
-- Constants used in determining menu width/height.
GathererUI_BORDER_WIDTH = 15;
GathererUI_BUTTON_HEIGHT = 12;
GATHERERUI_SUBFRAMES = { "GathererUI_FiltersOptionsBorderFrame",
"GathererUI_GathererOptionsBorderFrame",
"GathererUI_DisplayOptionsBorderFrame" };
-- List of toggles to display.
GathererUI_QuickMenu = {
{name=GATHERER_TEXT_TOGGLE_MINIMAP, option="useMinimap"},
{name=GATHERER_TEXT_TOGGLE_MAINMAP, option="useMainmap"},
{name=GATHERER_TEXT_TOGGLE_HERBS, option="herbs"},
{name=GATHERER_TEXT_TOGGLE_MINERALS, option="mining"},
{name=GATHERER_TEXT_TOGGLE_TREASURE, option="treasure"},
{name=GATHERER_TEXT_TOGGLE_REPORT, option="report" },
{name=GATHERER_TEXT_TOGGLE_SEARCH, option="search" },
};
-- ******************************************************************
function GathererUI_OnLoad()
-- Create the slash commands to show/hide the menu.
SlashCmdList["GathererUI_SHOWMENU"] = GathererUI_ShowMenu;
SLASH_GathererUI_SHOWMENU1 = "/GathererUI_showmenu";
SlashCmdList["GathererUI_HIDEMENU"] = GathererUI_HideMenu;
SLASH_GathererUI_HIDEMENU1 = "/GathererUI_hidemenu";
-- Create the slash commands to show/hide the options window.
SlashCmdList["GathererUI_SHOWOPTIONS"] = GathererUI_ShowOptions;
SLASH_GathererUI_SHOWOPTIONS1 = "/GathererUI_showoptions";
SlashCmdList["GathererUI_HIDEOPTIONS"] = GathererUI_HideOptions;
SLASH_GathererUI_HIDEOPTIONS1 = "/GathererUI_hideoptions";
end
function GathererUI_OnEvent()
if ( event == "VARIABLES_LOADED" ) then
local playerName = UnitName("player");
if ((playerName) and (playerName ~= UNKNOWNOBJECT)) then Gather_Player = playerName; end;
GathererUI_InitializeOptions();
GathererUI_InitializeMenu();
return;
end
if ( event == "UNIT_NAME_UPDATE" ) then
if ((arg1) and (arg1 == "player")) then
local playerName = UnitName("player");
if ((playerName) and (playerName ~= UNKNOWNOBJECT)) then
Gather_Player = playerName;
GathererUI_InitializeMenu();
end
end
end
end
-- ***********************************************************
-- Tab selection code
function ToggleGathererUI_Dialog(tab)
local subFrame = getglobal(tab);
if ( subFrame ) then
PanelTemplates_SetTab(GathererUI_DialogFrame, subFrame:GetID());
if ( GathererUI_DialogFrame:IsVisible() ) then
PlaySound("igCharacterInfoTab");
GathererUI_DialogFrame_ShowSubFrame(tab);
else
GathererUI_DialogFrame:Show();
GathererUI_DialogFrame_ShowSubFrame(tab);
end
end
end
function GathererUI_DialogFrame_ShowSubFrame(frameName)
for index, value in GATHERERUI_SUBFRAMES do
if ( value == frameName ) then
getglobal(value):Show()
else
getglobal(value):Hide();
end
end
end
function GathererUIFrameTab_OnClick()
if ( this:GetName() == "GathererUI_DialogFrameTab1" ) then
ToggleGathererUI_Dialog("GathererUI_FiltersOptionsBorderFrame");
elseif ( this:GetName() == "GathererUI_DialogFrameTab2" ) then
ToggleGathererUI_Dialog("GathererUI_GathererOptionsBorderFrame");
elseif ( this:GetName() == "GathererUI_DialogFrameTab3" ) then
ToggleGathererUI_Dialog("GathererUI_DisplayOptionsBorderFrame");
end
PlaySound("igCharacterInfoTab");
end
-- ******************************************************************
function GathererUI_ShowMenu(x, y, anchor)
if (GathererUI_Popup:IsVisible()) then
GathererUI_Hide();
return;
end
if (not x or not y) then
-- Get the cursor position. Point is relative to the bottom left corner of the screen.
x, y = GetCursorPosition();
end
if (anchor == nil) then
anchor = "center";
end
-- Adjust for the UI scale.
x = x / UIParent:GetEffectiveScale();
y = y / UIParent:GetEffectiveScale();
-- Adjust for the height/width/anchor of the menu.
if (anchor == "topright") then
x = x - GathererUI_Popup:GetWidth();
y = y - GathererUI_Popup:GetHeight();
elseif (anchor == "topleft") then
y = y - GathererUI_Popup:GetHeight();
elseif (anchor == "bottomright") then
x = x - GathererUI_Popup:GetWidth();
elseif (anchor == "bottomleft") then
-- do nothing.
else
-- anchor is either "center" or not a valid value.
x = x - GathererUI_Popup:GetWidth() / 2;
y = y - GathererUI_Popup:GetHeight() / 2;
end
-- Clear the current anchor point, and set it to be centered under the mouse.
GathererUI_Popup:ClearAllPoints();
GathererUI_Popup:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", x, y);
GathererUI_Show();
end
-- ******************************************************************
function GathererUI_HideMenu()
GathererUI_Hide();
end
-- ******************************************************************
function GathererUI_InitializeOptions()
-- flag to determine if we show the menu when the mouse is over the icon.
GatherConfig.ShowOnMouse = GatherConfig.ShowOnMouse or tonumber("1");
-- flag to determine if we show the menu when the icon is clicked.
GatherConfig.ShowOnClick = GatherConfig.ShowOnClick or tonumber("0");
-- flag to determine if we show the menu when the bound key is pressed.
GatherConfig.ShowOnButton = GatherConfig.ShowOnButton or tonumber("0");
-- flag to determine if we hide the menu when the mouse is not over the icon.
GatherConfig.HideOnMouse = GatherConfig.HideOnMouse or tonumber("1");
-- flag to determine if we hide the menu when the icon is clicked.
GatherConfig.HideOnClick = GatherConfig.HideOnClick or tonumber("0");
-- flag to determine if we hide the menu when the bound key is pressed.
GatherConfig.HideOnButton = GatherConfig.HideOnButton or tonumber("0");
-- position of the icon around the border of the minimap.
GatherConfig.Position = GatherConfig.Position or 12;
-- radius from the minimap center
GatherConfig.Radius = GatherConfig.Radius or 80;
GatherConfig.rareOre = GatherConfig.rareOre or tonumber("0");
GatherConfig.NoIconOnMinDist = GatherConfig.NoIconOnMinDist or tonumber("0");
GatherConfig.HideIcon = GatherConfig.HideIcon or tonumber("0");
GatherConfig.HideMiniNotes = GatherConfig.HideMiniNotes or tonumber("0");
GatherConfig.ToggleWorldNotes = GatherConfig.ToggleWorldNotes or tonumber("0");
GatherConfig.IconSize = GatherConfig.IconSize or 12;
if (not GatherConfig.users) then
GatherConfig.users = {};
end
if (not GatherConfig.users[Gather_Player]) then
GatherConfig.users[Gather_Player] = {};
end
if (not GatherConfig.users[Gather_Player].filterRecording ) then
GatherConfig.users[Gather_Player].filterRecording = {};
end
if (not GatherConfig.showWorldMapFilters ) then
GatherConfig.showWorldMapFilters = tonumber("0");
elseif ( GatherConfig.showWorldMapFilters == 1 ) then
GathererWD_DropDownFilters:Show();
else
GathererWD_DropDownFilters:Hide();
end
if ( GatherConfig.disableWMFreezeWorkaround and GatherConfig.disableWMFreezeWorkaround == true )
then
GatherConfig.disableWMFreezeWorkaround = tonumber("1");
end
if ( not GatherConfig.disableWMFreezeWorkaround ) then
GatherConfig.disableWMFreezeWorkaround = tonumber("1");
Gatherer_WorldMapDisplay:Show();
Gatherer_WorldMapDisplay:SetText("Hide Items");
end
if ( GatherConfig.disableWMFreezeWorkaround == 1 ) then
Gatherer_WorldMapDisplay:Show();
else
Gatherer_WorldMapDisplay:Hide();
end
if ( GatherConfig.useMainmap)
then
Gatherer_WorldMapDisplay:SetText("Hide Items");
GathererMapOverlayFrame:Show();
else
Gatherer_WorldMapDisplay:SetText("Show Items");
GathererMapOverlayFrame:Hide();
end
GathererHelp.currentPage = GathererHelp.currentPage or tonumber("1");
-- UI related
GathererUI_CheckShowOnMouse:SetChecked(GatherConfig.ShowOnMouse);
GathererUI_CheckHideOnMouse:SetChecked(GatherConfig.HideOnMouse);
GathererUI_CheckShowOnClick:SetChecked(GatherConfig.ShowOnClick);
GathererUI_CheckHideOnClick:SetChecked(GatherConfig.HideOnClick);
GathererUI_CheckHideIcon:SetChecked(GatherConfig.HideIcon);
GathererUI_CheckHideOnButton:SetChecked(GatherConfig.HideOnButton);
GathererUI_IconFrame:SetPoint("TOPLEFT", "Minimap", "TOPLEFT", 52 - (GatherConfig.Radius * cos(GatherConfig.Position)), (GatherConfig.Radius * sin(GatherConfig.Position)) - 52);
-- Gatherer related
GathererUI_CheckNoMinIcon:SetChecked(GatherConfig.NoIconOnMinDist);
GathererUI_CheckRareOre:SetChecked(GatherConfig.rareOre);
GathererUI_CheckMapMinder:SetChecked(GatherConfig.mapMinder);
GathererUI_CheckHideMiniNotes:SetChecked(GatherConfig.HideMiniNotes);
GathererUI_CheckToggleWorldNotes:SetChecked(GatherConfig.ToggleWorldNotes);
GathererUI_CheckToggleWorldFilters:SetChecked(GatherConfig.showWorldMapFilters);
GathererUI_CheckHerbRecord:SetChecked(GatherConfig.users[Gather_Player].filterRecording[1]);
GathererUI_CheckOreRecord:SetChecked(GatherConfig.users[Gather_Player].filterRecording[2]);
GathererUI_CheckTreasureRecord:SetChecked(GatherConfig.users[Gather_Player].filterRecording[0]);
GathererUI_CheckDisableWMFix:SetChecked(GatherConfig.disableWMFreezeWorkaround);
GathererUI_InitializeMenu();
end
-- ******************************************************************
function GathererUI_InitializeMenu()
GathererUI_IconFrame.haveAbilities = true;
if ( GatherConfig and GatherConfig.HideIcon and GatherConfig.HideIcon == 1 ) then
GathererUI_IconFrame:Hide();
else
GathererUI_IconFrame:Show();
end
-- Set the text for the buttons while keeping track of how many
-- buttons we actually need.
local count = 0;
for quickoptionpos, quickoptiondata in GathererUI_QuickMenu do
quickoptions = quickoptiondata.name;
gathermap_id = quickoptiondata.option;
count = count + 1;
local button = getglobal("GathererUI_PopupButton"..count);
Gatherer_Value="none";
if ( gathermap_id =="useMinimap" ) then
Gatherer_Value = "off";
if (GatherConfig.useMinimap) then Gatherer_Value = "on"; end
button.SpellID = "toggle"
elseif ( gathermap_id == "useMainmap" ) then
Gatherer_Value = "off";
if (GatherConfig.useMainmap) then Gatherer_Value = "on"; end
button.SpellID = "mainmap toggle";
elseif ( gathermap_id == "report" ) then
button.SpellID = "report";
Gatherer_Value = "";
elseif ( gathermap_id == "search" ) then
button.SpellID = "search";
Gatherer_Value = "";
else
Gatherer_Value = Gatherer_GetFilterVal(gathermap_id);
button.SpellID = gathermap_id.." toggle";
end
if ( Gatherer_Value ~= "" ) then
button:SetText(quickoptions.."["..Gatherer_Value.."]");
else
button:SetText(quickoptions);
end
button:Show();
end
-- Set the width for the menu.
local width = GathererUI_TitleButton:GetWidth();
for i = 1, count do
width = math.max(width, getglobal("GathererUI_PopupButton"..i):GetTextWidth());
end
GathererUI_Popup:SetWidth(width + 2 * GathererUI_BORDER_WIDTH);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -