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

📄 earthmenu.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 3 页
字号:
		if ( listFrame:IsVisible() and (EARTH_UIDROPDOWNMENU_OPEN_MENU == tempFrame:GetName()) ) then		listFrame:Hide();	else		-- Hide the listframe anyways since it is redrawn OnShow() 		listFrame:Hide();				-- Frame to anchor the dropdown menu to		local anchorFrame;		-- Display stuff		-- Level specific stuff		if ( level == 1 ) then			if ( not dropDownFrame ) then				dropDownFrame = this:GetParent();			end			EARTH_UIDROPDOWNMENU_OPEN_MENU = dropDownFrame:GetName();			listFrame:ClearAllPoints();			-- If there's no specified anchorName then use left side of the dropdown menu			if ( not anchorName ) then				anchorName = EARTH_UIDROPDOWNMENU_OPEN_MENU.."Left"			end			if ( not xOffset or not yOffset ) then				xOffset = 8;				yOffset = 22;			end			listFrame:SetPoint(customPoint, anchorName, "BOTTOMLEFT", xOffset, yOffset);		else			if ( not dropDownFrame ) then				dropDownFrame = getglobal(EARTH_UIDROPDOWNMENU_OPEN_MENU);			end			listFrame:ClearAllPoints();			-- If this is a dropdown button, not the arrow anchor it to itself			if ( string.sub(this:GetParent():GetName(), 0,17) == "EarthDropDownList" and string.len(this:GetParent():GetName()) == 18 ) then				anchorFrame = this:GetName();			else				anchorFrame = this:GetParent():GetName();			end			listFrame:SetPoint("TOPLEFT", anchorFrame, "TOPRIGHT", 0, 0);		end				-- Auto close after n seconds		if ( Chronos ) then 			local timeout = EARTHMENU_HIDE_TIMEOUT;			if ( EARTHMENU_TEMP_HIDE_TIMEOUT ) then 				timeout = EARTHMENU_TEMP_HIDE_TIMEOUT;			end			if( timeout and timeout > 0 ) then 				Chronos.scheduleByName("EarthMenuAutoHide".."EarthDropDownList"..level, timeout, function() EarthMenu_HideFrame("EarthDropDownList", level);  EARTHMENU_TEMP_HIDE_TIMEOUT = nil; end);			end		end				-- Change list box appearance depending on display mode		if ( dropDownFrame and dropDownFrame.displayMode == "MENU" ) then			getglobal(listFrameName.."Backdrop"):Hide();			getglobal(listFrameName.."MenuBackdrop"):Show();		else			getglobal(listFrameName.."Backdrop"):Show();			getglobal(listFrameName.."MenuBackdrop"):Hide();		end		EarthMenu_Initialize(dropDownFrame, dropDownFrame.initialize, nil, level);		-- If no items in the drop down don't show it		if ( listFrame.numButtons == 0 ) then			return;		end		-- Check to see if the dropdownlist is off the screen, if it is anchor it to the top of the dropdown button		listFrame:Show();		-- Hack will fix this in next revision of dropdowns		if ( not listFrame:GetLeft() ) then			listFrame:Hide();			return;		end		-- Determine whether the menu is off the screen or not		local offscreenY, offscreenX;		if ( listFrame:GetBottom() < 0 ) then			offscreenY = 1;		end		if ( listFrame:GetRight() > WorldFrame:GetRight() ) then			offscreenX = 1;		end				local anchorPoint, relativePoint, offsetX, offsetY;		if ( offscreenY ) then			if ( offscreenX ) then				anchorPoint = string.gsub(customPoint, "TOP(.*)", "BOTTOM%1");				anchorPoint = string.gsub(customPoint, "(.*)LEFT", "%1RIGHT");				relativePoint = "TOPRIGHT";				offsetX = 0;				offsetY = 14;			else				anchorPoint = string.gsub(customPoint, "TOP(.*)", "BOTTOM%1");				relativePoint = "TOPLEFT";				offsetX = 0;				offsetY = 14;			end		else			if ( offscreenX ) then				anchorPoint = string.gsub(customPoint, "(.*)LEFT", "%1RIGHT");				relativePoint = "BOTTOMRIGHT";				offsetX = 0;				offsetY = -14;			else				anchorPoint = customPoint;				relativePoint = "BOTTOMLEFT";				offsetX = 0;				offsetY = -14;			end		end		listFrame:ClearAllPoints();		if ( level == 1 ) then			listFrame:SetPoint(anchorPoint, anchorName, relativePoint, offsetX, offsetY);		else			listFrame:SetPoint(anchorPoint, anchorFrame, relativePoint, offsetX, offsetY);		end	endendfunction EarthMenuButton_OpenColorPicker(button)	EarthMenu_CloseMenus();	if ( not button ) then		button = this;	end	EARTH_UIDROPDOWNMENU_MENU_VALUE = button.index;	ColorPickerFrame.func = button.swatchFunc;	ColorPickerFrame.hasOpacity = button.hasOpacity;	ColorPickerFrame.opacityFunc = button.opacityFunc;	ColorPickerFrame.opacity = button.opacity;	ColorPickerFrame:SetColorRGB(button.r, button.g, button.b);	ColorPickerFrame.previousValues = {r = button.r, g = button.g, b = button.b, opacity = button.opacity};	ColorPickerFrame.cancelFunc = button.cancelFunc;	ShowUIPanel(ColorPickerFrame);endfunction EarthMenu_CloseDropDownMenus(level)	if ( not level ) then		level = 1;	end	for i=level, EARTH_UIDROPDOWNMENU_MAXLEVELS do		getglobal("EarthDropDownList"..i):Hide();	endendfunction EarthMenu_SetWidth(width, frame)	if ( not frame ) then		frame = this;	end	getglobal(frame:GetName().."Middle"):SetWidth(width);	frame:SetWidth(width + 25 + 25);	getglobal(frame:GetName().."Text"):SetWidth(width - 25);	frame.noResize = 1;endfunction EarthMenu_SetButtonWidth(width, frame)	if ( not frame ) then		frame = this;	end		if ( width == "TEXT" ) then		width = getglobal(frame:GetName().."Text"):GetWidth();	end		getglobal(frame:GetName().."Button"):SetWidth(width);	frame.noResize = 1;endfunction EarthMenu_SetText(text, frame)	if ( not frame ) then		frame = this;	end	local filterText = getglobal(frame:GetName().."Text");	if ( filterText ) then 		filterText:SetText(text);	endendfunction EarthMenu_GetText(frame)	if ( not frame ) then		frame = this;	end	local filterText = getglobal(frame:GetName().."Text");	if ( filterText ) then 		return filterText:GetText();	endendfunction EarthMenu_ClearAll(frame)	EarthMenu_SetSelectedID(frame, nil);	EarthMenu_SetSelectedName(frame,nil);	EarthMenu_SetSelectedValue(frame,nil);	EarthMenu_SetText("", frame);	EarthMenu_Refresh(frame, 1)endfunction EarthMenu_JustifyText(justification, frame)	if ( not frame ) then		frame = this;	end	local text = getglobal(frame:GetName().."Text");	text:ClearAllPoints();	if ( justification == "LEFT" ) then		text:SetPoint("LEFT", frame:GetName().."Left", "LEFT", 27, 2);	elseif ( justification == "RIGHT" ) then		text:SetPoint("RIGHT", frame:GetName().."Right", "RIGHT", -43, 2);	elseif ( justification == "CENTER" ) then		text:SetPoint("CENTER", frame:GetName().."Middle", "CENTER", -5, 2);	endendfunction EarthMenu_GetCurrentDropDown()	if ( EARTH_UIDROPDOWNMENU_OPEN_MENU ) then		return getglobal(EARTH_UIDROPDOWNMENU_OPEN_MENU);	end		-- If no dropdown then use this	return this;endfunction EarthMenuButton_GetChecked()	return getglobal(this:GetName().."Check"):IsVisible();endfunction EarthMenuButton_GetName()	return getglobal(this:GetName().."NormalText"):GetText();endfunction EarthMenuButton_OpenColorPicker(button)	EarthMenu_CloseMenus();	if ( not button ) then		button = this;	end	EARTH_UIDROPDOWNMENU_MENU_VALUE = button.index;	ColorPickerFrame.func = button.swatchFunc;	ColorPickerFrame.hasOpacity = button.hasOpacity;	ColorPickerFrame.opacityFunc = button.opacityFunc;	ColorPickerFrame.opacity = button.opacity;	ColorPickerFrame:SetColorRGB(button.r, button.g, button.b);	ColorPickerFrame.previousValues = {r = button.r, g = button.g, b = button.b, opacity = button.opacity};	ColorPickerFrame.cancelFunc = button.cancelFunc;	ShowUIPanel(ColorPickerFrame);endfunction EarthMenu_DisableButton(level, id)	getglobal("EarthDropDownList"..level.."Button"..id):Disable();endfunction EarthMenu_EnableButton(level, id)	getglobal("EarthDropDownList"..level.."Button"..id):Enable();endfunction EarthMenu_SetButtonText(level, id, text, r, g, b)	getglobal("EarthDropDownList"..level.."Button"..id):SetText(text);	if ( r ) then		getglobal("EarthDropDownList"..level.."Button"..id.."NormalText"):SetTextColor(r, g, b);		getglobal("EarthDropDownList"..level.."Button"..id.."HighlightText"):SetTextColor(r, g, b);	endend--[[----	Example Usage Code------]]--[[ List of button attributes======================================================info.text = [STRING]  --  The text of the buttoninfo.value = [ANYTHING] -- The value returned to the info.func when clickedinfo.func = [function()]  --  The function that is called when you click the buttoninfo.checked = [nil, 1]  --  Check the buttoninfo.isTitle = [nil, 1]  --  If it's a title the button is disabled and the font color is set to yellowinfo.disabled = [nil, 1]  --  Disable the button and show an invisible button that still traps the mouseover event so menu doesn't time outinfo.hasArrow = [nil, 1]  --  Show the expand arrow for multilevel menusinfo.hasColorSwatch = [nil, 1]  --  Show color swatch or not, for color selectioninfo.r = [1 - 255]  --  Red color value of the color swatchinfo.g = [1 - 255]  --  Green color value of the color swatchinfo.b = [1 - 255]  --  Blue color value of the color swatchinfo.swatchFunc = [function()]  --  Function called by the color picker on color changeinfo.hasOpacity = [nil, 1]  --  Show the opacity slider on the colorpicker frameinfo.opacity = [0.0 - 1.0]  --  Percentatge of the opacity, 1.0 is fully shown, 0 is transparentinfo.opacityFunc = [function()]  --  Function called by the opacity slider when you change its valueinfo.cancelFunc = [function(previousValues)] -- Function called by the colorpicker when you click the cancel button (it takes the previous values as its argument)info.notClickable = [nil, 1]  --  Disable the button and color the font whiteinfo.notCheckable = [nil, 1]  --  Shrink the size of the buttons and don't display a check boxinfo.owner = [Frame]  --  Dropdown frame that "owns" the current dropdownlistinfo.keepShownOnClick = [nil, 1]  --  Don't hide the dropdownlist after a button is clicked]]--EarthMenu_MenuInfo = { };EarthMenu_MenuLastValue = 0;function EarthMenu_DefaultDropDownMenu_OnLoad()	EarthMenu_Initialize(EarthMenu, EarthMenu_DefaultMenu_Initialize);	EarthMenu_SetButtonWidth(50);	EarthMenu_SetWidth(50);endfunction EarthMenu_DefaultDropDownMenu_OnShow()	EarthMenu_Initialize(this, EarthMenu_DefaultMenu_Initialize);end	function EarthMenu_MenuOpen(menulist, anchor, x, y, mode, autoHideDelay, customPoint)	if ( autoHideDelay ) then EARTHMENU_TEMP_HIDE_TIMEOUT = autoHideDelay; end	if ( menulist ) then EarthMenu_MenuInfo = menulist; end	if ( mode ~= EarthMenu.displayMode ) then 		EarthMenu_Initialize(EarthMenu, EarthMenu_DefaultMenu_Initialize, mode);	end	EarthMenu_ToggleDropDownMenu(1, nil, EarthMenu, anchor, x, y, customPoint);endfunction EarthMenu_DefaultMenu_Initialize()	if ( EARTH_UIDROPDOWNMENU_MENU_LEVEL == 1 ) then		for index, value in EarthMenu_MenuInfo do			if (value.text) then				value.index = index;				EarthMenu_AddButton(value, 1);			end		end	end	if ( EARTH_UIDROPDOWNMENU_MENU_LEVEL == 2 ) then		EarthMenu_MenuLastValue = EARTH_UIDROPDOWNMENU_MENU_VALUE;		for index, value in EarthMenu_MenuInfo[EARTH_UIDROPDOWNMENU_MENU_VALUE] do			if (type(value) == "table") then				if (value.text) then					value.index = index;					EarthMenu_AddButton(value, 2);				end			end		end	end	if ( EARTH_UIDROPDOWNMENU_MENU_LEVEL == 3 ) then		for index, value in EarthMenu_MenuInfo[EarthMenu_MenuLastValue][EARTH_UIDROPDOWNMENU_MENU_VALUE] do			if (type(value) == "table") then				if (value.text) then					EarthMenu_AddButton(value, 3);				end			end		end	endendfunction EarthMenu_HideFrame(frameName, level) 	local frame = getglobal(frameName..level);	if ( not MouseIsOver(frame) and not Chronos.isScheduledByName("EarthMenuAutoHide"..frameName..(level+1)) ) then 		frame:Hide();	else		for i=level,1,-1 do			Chronos.scheduleByName("EarthMenuAutoHide"..frameName..i, EARTHMENU_HIDE_TIMEOUT, function() EarthMenu_HideFrame(frameName, i) end );		end	endend

⌨️ 快捷键说明

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