⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gathererui.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 3 页
字号:

	-- By default, the width of the button is set to the width of the text
	-- on the button.  Set the width of each button to the width of the
	-- menu so that you can still click on it without being directly
	-- over the text.
	for i = 1, count do
		getglobal("GathererUI_PopupButton"..i):SetWidth(width);
	end

	-- Hide the buttons we don't need.
	for i = count + 1, GathererUI_NUM_BUTTONS do
		getglobal("GathererUI_PopupButton"..i):Hide();
	end
	
	-- Set the height for the menu.
	GathererUI_Popup:SetHeight(GathererUI_BUTTON_HEIGHT + ((count + 1) * GathererUI_BUTTON_HEIGHT) + (3 * GathererUI_BUTTON_HEIGHT));
end

-- ******************************************************************
function GathererUI_ButtonClick()
	Gatherer_Command(this.SpellID);
	GathererUI_InitializeMenu();	
end

-- ******************************************************************
function GathererUI_Show()
	-- Check to see if the aspect menu is shown.  If so, hide it before
	-- showing the tracking menu.
	if (GathererUI_Popup and GathererUI_Popup:IsVisible()) then
		GathererUI_Hide();
	end

	GathererUI_Popup:Show();
end

-- ******************************************************************
function GathererUI_Hide()
	GathererUI_Popup:Hide();
end

-- ******************************************************************
function GathererUI_ShowOptions()
	GathererUI_DialogFrame:Show();
--	ToggleGathererUI_Dialog(GATHERERUI_SUBFRAMES[PanelTemplates_GetSelectedTab(GathererUI_DialogFrame)]);
end

-- ******************************************************************
function GathererUI_HideOptions()
	GathererUI_DialogFrame:Hide();
end

-- ******************************************************************
function GathererUI_OnUpdate(dummy)
	-- Check to see if the mouse is still over the menu or the icon.
	if (GatherConfig.HideOnMouse == 1 and GathererUI_Popup:IsVisible()) then
		if (not MouseIsOver(GathererUI_Popup) and not MouseIsOver(GathererUI_IconFrame)) then
			-- If not, hide the menu.
			GathererUI_Hide();
		end
	end
end

-- ******************************************************************
function GathererUI_IconFrameOnEnter()
	-- Set the anchor point of the menu so it shows up next to the icon.
	GathererUI_Popup:ClearAllPoints();
	GathererUI_Popup:SetPoint("TOPRIGHT", "GathererUI_IconFrame", "TOPLEFT");

	-- Show the menu.
	if (GatherConfig.ShowOnMouse == 1) then
		GathererUI_Show();
	end
end

-- ******************************************************************
function GathererUI_IconFrameOnClick()
	if (GathererUI_Popup:IsVisible()) then
		if (GatherConfig.HideOnClick == 1) then
			GathererUI_Hide();
		end
	else
		if (GatherConfig.ShowOnClick == 1) then
			GathererUI_Show();
		end
	end
end

-- ******************************************************************
function GathererUIDropDownTheme_Initialize()
	for value in Gather_IconSet do
		local info = {};
		info.text = value;
		info.checked = nil;
		info.func = GathererUIDropDownTheme_OnClick;
		UIDropDownMenu_AddButton(info);
		if (GatherConfig.iconSet == info.text) then
			UIDropDownMenu_SetText(info.text, GathererUI_DropDownTheme);
		end
	end
end

function GathererUIDropDownHerbs_Initialize()
	local filterValue = "herbs";
	local iconIndex = 1;
	local dropDownText = "Herbs";
	GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText);
end

function GathererUIDropDownOre_Initialize()
	local filterValue = "mining";
	local iconIndex = 2;
	local dropDownText = "Ore";
	GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText);
end

function GathererUIDropDownTreasure_Initialize()
	local filterValue = "treasure";
	local iconIndex = 0;
	local dropDownText = "Treasure";
	GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText);
end

function GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText)
	local varMenuVal1, varMenuVal2;
	local value = Gatherer_GetFilterVal(filterValue);
	if ( value == "on" ) then
		varMenuVal1 = NORMAL_FONT_COLOR_CODE.."auto".."|r";
		varMenuVal2 = NORMAL_FONT_COLOR_CODE.."off".."|r";
	elseif ( value == "off" ) then
		varMenuVal1 = NORMAL_FONT_COLOR_CODE.."auto".."|r";
		varMenuVal2 = NORMAL_FONT_COLOR_CODE.."on".."|r";
	else
		varMenuVal1 = NORMAL_FONT_COLOR_CODE.."on".."|r";
		varMenuVal2 = NORMAL_FONT_COLOR_CODE.."off".."|r";
	end
	UIDropDownMenu_SetText(Gatherer_GetMenuName(value), getglobal("GathererUI_DropDown"..dropDownText));

	local itemWithRareMatch = {};
	local rareItem = {};
	for iconName, rareMatch in Gather_RareMatch do
		if (Gather_DB_IconIndex[iconIndex][iconName]) then
			itemWithRareMatch[iconName] = rareMatch;
			rareItem[rareMatch] = iconName;
		end
	end

	if ( itemWithRareMatch[UIDROPDOWNMENU_MENU_VALUE] ) then
		GathererUIDropDownSub_Initialize(UIDROPDOWNMENU_MENU_VALUE, iconIndex, dropDownText);
		return;
	end
		
	local gathererFilters = {varMenuVal1, varMenuVal2};
	for iconName in Gather_DB_IconIndex[iconIndex] do
		if (iconName ~= "default" and not rareItem[iconName]) then
			tinsert(gathererFilters, iconName);
		end
	end

	table.sort(gathererFilters, function (a, b)
		local aSkillLevel = Gather_SkillLevel[a] or 0;
		local bSkillLevel = Gather_SkillLevel[b] or 0;
		if (strfind(a, "on|r") or strfind(a, "off|r") or strfind(a, "auto|r")) then
			aSkillLevel = -1;
		end
		if (strfind(b, "on|r") or strfind(b, "off|r") or strfind(b, "auto|r")) then
			bSkillLevel = -1;
		end
			return string.format("%03d%s", aSkillLevel, a) < string.format("%03d%s", bSkillLevel, b);	
		end);


	for index, value in gathererFilters do
		local info = {};
		info.text = Gatherer_GetMenuName(value);
		info.value = value;
		info.checked = nil;
		if (itemWithRareMatch[value]) then
			info.hasArrow = 1;
			info.func = nil;
		else
			info.hasArrow = nil;
			info.func = getglobal("GathererUIDropDownFilter"..dropDownText.."_OnClick");
		end

		if (string.find(value, "on|r")) then info.value = "on"; end
		if (string.find(value, "off|r")) then info.value = "off"; end
		if (string.find(value, "auto|r")) then info.value = "auto"; end

		if ( index > 2 and GatherConfig) then
			info.keepShownOnClick = 1;

			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].interested ) then GatherConfig.users[Gather_Player].interested = {}; end
			if (not GatherConfig.users[Gather_Player].interested[iconIndex] ) then GatherConfig.users[Gather_Player].interested[iconIndex] = {}; end
			if (GatherConfig.users[Gather_Player].interested[iconIndex][value] == nil ) then GatherConfig.users[Gather_Player].interested[iconIndex][value] = true; end

			if (not GatherConfig.users[Gather_Player]
				or not GatherConfig.users[Gather_Player].interested
				or not GatherConfig.users[Gather_Player].interested[iconIndex]
				or GatherConfig.users[Gather_Player].interested[iconIndex][value] == nil 
				or GatherConfig.users[Gather_Player].interested[iconIndex][value] == true ) then
				info.checked = 1;
			end
			info.textR = 1;
			info.textG = 1;
			info.textB = 1;
		else
			info.textR = 1;
			info.textG = 1;
			info.textB = 255;
			info.checked = nil;
		end

		UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
	end
end

function GathererUIDropDownSub_Initialize(rareItem, iconIndex, dropDownText)
	if (not dropDownText) then
		if (iconIndex == 1) then
			dropDownText = "Herbs";
		elseif (iconIndex == 2) then
			dropDownText = "Ore";
		elseif (iconIndex == 0) then
			dropDownText = "Treasure";
		end
	end	
	
	for index, value in {rareItem, Gather_RareMatch[rareItem]} do
		local info = {};
		info.text = Gatherer_GetMenuName(value);
		info.value = value;
		info.checked = nil;
		info.func = getglobal("GathererUIDropDownFilter"..dropDownText.."_OnClick");

		if ( GatherConfig ) then
			info.keepShownOnClick = 1;
			if (not GatherConfig.users[Gather_Player] 
				or not GatherConfig.users[Gather_Player].interested
				or not GatherConfig.users[Gather_Player].interested[iconIndex]
				or GatherConfig.users[Gather_Player].interested[iconIndex][value] == nil 
				or GatherConfig.users[Gather_Player].interested[iconIndex][value] == true ) then
				info.checked = 1;
			end
			info.textR = 1;
			info.textG = 1;
			info.textB = 1;
		else
			info.textR = 1;
			info.textG = 1;
			info.textB = 255;
			info.checked = nil;
		end
		
		UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
	end	
end

-- World Map functions
-- World Map filters dropdown Load
function Gatherer_WorldMapFilter_Load()
	UIDropDownMenu_SetText(GATHERER_FILTERDM_TEXT, GathererWD_DropDownFilters);

	if ( UIDROPDOWNMENU_MENU_VALUE == "Herb" ) then
		GathererUIDropDownHerbs_Initialize();
		return;
	elseif ( UIDROPDOWNMENU_MENU_VALUE == "Ore" ) then
		GathererUIDropDownOre_Initialize();
		return;
	elseif ( UIDROPDOWNMENU_MENU_VALUE == "Treasure" ) then
		GathererUIDropDownTreasure_Initialize();
		return;
	elseif( Gather_RareMatch[UIDROPDOWNMENU_MENU_VALUE] ) then
		for iconIndex in Gather_DB_IconIndex do
			if (Gather_DB_IconIndex[iconIndex][UIDROPDOWNMENU_MENU_VALUE]) then
				GathererUIDropDownSub_Initialize(UIDROPDOWNMENU_MENU_VALUE, iconIndex);
				break;
			end
		end

		return;
	end
	

	local info = {};
	info.text = GATHERER_TEXT_TOGGLE_HERBS.."["..Gatherer_GetFilterVal("herbs").."]";
	info.value = "Herb"
	info.hasArrow = 1;
	info.func = nil;
	info.notCheckable = 1;
	UIDropDownMenu_AddButton(info);

	local info = {};
	info.text = GATHERER_TEXT_TOGGLE_MINERALS.."["..Gatherer_GetFilterVal("mining").."]";
	info.value = "Ore"
	info.hasArrow = 1;
	info.func = nil;
	info.notCheckable = 1;
	UIDropDownMenu_AddButton(info);

	local info = {};
	info.text = GATHERER_TEXT_TOGGLE_TREASURE.."["..Gatherer_GetFilterVal("treasure").."]";
	info.value = "Treasure"
	info.hasArrow = 1;
	info.func = nil;
	info.notCheckable = 1;
	UIDropDownMenu_AddButton(info);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -