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

📄 earthmenu.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 3 页
字号:
--[[----	Earth Menu----		By Alexander Brazie----	Unfortunately, OnEvent handlers require code. --	Hopefully, this will make it easier to use than --	the stock Blizzard code. ----	This will hopefully avoid collisions with --	Blizzard menus as well. I've tried to avoid--	duplicating code by reusing Blizzards functions--	where they are sufficiently generic.----	Eventually, this will need to be redone to resolve--	those Lua issues that popup, but the basic --	structure should be the same: ----	Edit a widget's .onEvent to change that function. --	Leave it nil for default functionality.--	--]]--[[----	Earth Menu Instructions--	--	To overwrite a widget event handler, simply ----	menu = getglobal("WidgetSubMenu1");--	menu.onClick = function() MyCommands() end;--	menu.onEnter = function() bar(); end----	and so on...--	--]]EARTH_UIDROPDOWNMENU_MAXBUTTONS = 32;EARTH_UIDROPDOWNMENU_MAXLEVELS = 3;EARTH_UIDROPDOWNMENU_BUTTON_HEIGHT = 16;EARTH_UIDROPDOWNMENU_BORDER_HEIGHT = 15;-- The current open menuEARTH_UIDROPDOWNMENU_OPEN_MENU = nil;-- The current menu being initializedEARTH_UIDROPDOWNMENU_INIT_MENU = nil;-- Current level shown of the open menuEARTH_UIDROPDOWNMENU_MENU_LEVEL = 1;-- Current value of the open menuEARTH_UIDROPDOWNMENU_MENU_VALUE = nil;-- Time to wait to hide the menuEARTH_UIDROPDOWNMENU_SHOW_TIME = 2;EARTHMENU_HIDE_TIMEOUT = 2;EARTHMENU_TEMP_HIDE_TIMEOUT = nil;---- Event Handlers:--function EarthMenu_ColorSwatchScriptedTemplate_OnClick() 	if(not this.onClick ) then 		EarthMenu_CloseMenus();		EarthMenuButton_OpenColorPicker(this:GetParent());	else		this.onClick();	endendfunction EarthMenu_ColorSwatchScriptedTemplate_OnEnter()	if(not this.onEnter) then 		EarthMenu_CloseDropDownMenus(this:GetParent():GetParent():GetID()+1);		getglobal(this:GetName().."SwatchBg"):SetVertexColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);		EarthMenu_StopCounting(this:GetParent():GetParent());	else		this.onEnter();	endendfunction EarthMenu_ColorSwatchScriptedTemplate_OnLeave()	if ( not this.onLeave ) then 		getglobal(this:GetName().."SwatchBg"):SetVertexColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);		EarthMenu_StartCounting(this:GetParent():GetParent());	else		this.onLeave();	endendfunction EarthMenu_ExpandArrowScriptedTemplate_OnClick ()	if ( not this.onClick ) then 		EarthMenu_ToggleDropDownMenu(this:GetParent():GetParent():GetID()+1, this:GetParent().index);			EarthMenu_SetSelectedValue(this:GetParent():GetParent(), this:GetParent().value);	else		this.onClick();	endendfunction EarthMenu_ExpandArrowScriptedTemplate_OnEnter()	if ( not this.onEnter) then 		EarthMenu_ToggleDropDownMenu(this:GetParent():GetParent():GetID()+1, this:GetParent().index);			EarthMenu_SetSelectedValue(this:GetParent():GetParent(), this:GetParent().value);		EarthMenu_StopCounting(this:GetParent():GetParent());	else 		this.onEnter();	endendfunction EarthMenu_ExpandArrowScriptedTemplate_OnLeave()	if ( not this.onLeave ) then 		EarthMenu_StartCounting(this:GetParent():GetParent());		else		this.onLeave();	endendfunction EarthMenu_InvisibleButtonScriptedTemplate_OnEnter()	if ( not this.onEnter ) then		EarthMenu_StopCounting(this:GetParent():GetParent());		else		this.onEnter();	endendfunction EarthMenu_InvisibleButtonScriptedTemplate_OnLeave()	if ( not this.onLeave ) then		EarthMenu_StartCounting(this:GetParent():GetParent());	else 		this.onLeave();	endendfunction EarthMenu_ButtonScriptedTemplate_OnClick()	if ( not this.onClick ) then		EarthMenuButton_OnClick();		else		this.onClick();	endendfunction EarthMenu_ButtonScriptedTemplate_OnEnter()	if ( not this.onEnter ) then		if ( this.hasArrow ) then			EarthMenu_ToggleDropDownMenu(this:GetParent():GetID() + 1, this.index);		end		getglobal(this:GetName().."Highlight"):Show();		EarthMenu_StopCounting(this:GetParent());		if ( this.tooltipTitle ) then			GameTooltip_AddNewbieTip(this.tooltipTitle, 1.0, 1.0, 1.0, this.tooltipText, 1);		end	else		this.onEnter();	endendfunction EarthMenu_ButtonScriptedTemplate_OnLeave()	if ( not this.onLeave ) then		getglobal(this:GetName().."Highlight"):Hide();		EarthMenu_StartCounting(this:GetParent());		GameTooltip:Hide();		else		this.onLeave();	endendfunction EarthMenu_ListGraphicTemplateMenuBackdrop_OnLoad()	if ( not this.onLoad ) then 		this:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b);		this:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b);		else		this.onLoad();	endendfunction EarthMenu_ListScriptedTemplate_OnClick()	if ( not this.onClick ) then 		this:Hide();	else		this.onClick();	endendfunction EarthMenu_ListScriptedTemplate_OnEnter()	if ( not this.onEnter ) then 		EarthMenu_StopCounting(this);	else		this.onEnter();	endendfunction EarthMenu_ListScriptedTemplate_OnLeave()	if ( not this.onLeave ) then 		EarthMenu_StartCounting(this);	else		this.onLeave();	endendfunction EarthMenu_ListScriptedTemplate_OnHide()	if ( not this.onHide ) then 		EarthMenu_CloseDropDownMenus (this:GetID()+1);	else		this.onHide();	endendfunction EarthMenu_ListScriptedTemplate_OnUpdate(elapsed)	if ( not this.onUpdate ) then		EarthMenu_OnUpdate(elapsed);	else		this.onUpdate();	endendfunction EarthMenu_ListScriptedTemplate_OnShow()	if ( not this.onShow ) then 		for i=1, EARTH_UIDROPDOWNMENU_MAXBUTTONS do			if (not this.noResize) then				getglobal(this:GetName().."Button"..i):SetWidth(this.maxWidth);			end		end		if (not this.noResize) then			this:SetWidth(this.maxWidth+15);		end		this.showTime = nil;		if ( this:GetID() > 1 ) then			this.parent = getglobal("EarthDropDownList"..(this:GetID() - 1));		end	else		this.onShow();	endendfunction EarthMenu_TemplateScriptedButtonTemplate_OnClick()	if( not this.onClick ) then 		EarthMenu_ToggleDropDownMenu();		PlaySound("igMainMenuOptionCheckBoxOn");	else		this.onClick();	endendfunction EarthMenu_ScriptedTemplate_OnHide()	if ( not this.onHide ) then 		EarthMenu_CloseDropDownMenus();	else		this.onHide();	endend--[[---- Real code----]]function EarthMenu_Initialize(frame, initFunction, displayMode, level)	if ( not frame ) then		frame = this;	end	if ( frame:GetName() ~= EARTH_UIDROPDOWNMENU_OPEN_MENU ) then		EARTH_UIDROPDOWNMENU_MENU_LEVEL = 1;	end	-- Set the frame that's being intialized	EARTH_UIDROPDOWNMENU_INIT_MENU = frame:GetName();	-- Hide all the buttons	local button, dropDownList;	for i = 1, EARTH_UIDROPDOWNMENU_MAXLEVELS, 1 do		dropDownList = getglobal("EarthDropDownList"..i);		if ( i >= EARTH_UIDROPDOWNMENU_MENU_LEVEL or frame:GetName() ~= EARTH_UIDROPDOWNMENU_OPEN_MENU ) then			dropDownList.numButtons = 0;			dropDownList.maxWidth = 0;			for j=1, EARTH_UIDROPDOWNMENU_MAXBUTTONS, 1 do				button = getglobal("EarthDropDownList"..i.."Button"..j);				button:Hide();			end		end	end	frame:SetHeight(EARTH_UIDROPDOWNMENU_BUTTON_HEIGHT * 2);		-- Set the initialize function and call it.  The initFunction populates the dropdown list.	if ( initFunction ) then		frame.initialize = initFunction;		initFunction(level);	end	-- Change appearance based on the displayMode	if ( displayMode == "MENU" ) then		getglobal(frame:GetName().."Left"):Hide();		getglobal(frame:GetName().."Middle"):Hide();		getglobal(frame:GetName().."Right"):Hide();		--[[		getglobal(frame:GetName().."ButtonNormalTexture"):SetTexture("");		getglobal(frame:GetName().."ButtonDisabledTexture"):SetTexture("");		getglobal(frame:GetName().."ButtonPushedTexture"):SetTexture("");		getglobal(frame:GetName().."ButtonHighlightTexture"):SetTexture("");		getglobal(frame:GetName().."Button"):ClearAllPoints();		]]		getglobal(frame:GetName().."Button"):SetPoint("LEFT", frame:GetName().."Text", "LEFT", -9, 0);		getglobal(frame:GetName().."Button"):SetPoint("RIGHT", frame:GetName().."Text", "RIGHT", 6, 0);	else 		getglobal(frame:GetName().."Left"):Show();		getglobal(frame:GetName().."Middle"):Show();		getglobal(frame:GetName().."Right"):Show();		--[[		getglobal(frame:GetName().."ButtonNormalTexture"):SetTexture("");		getglobal(frame:GetName().."ButtonDisabledTexture"):SetTexture("");		getglobal(frame:GetName().."ButtonPushedTexture"):SetTexture("");		getglobal(frame:GetName().."ButtonHighlightTexture"):SetTexture("");		getglobal(frame:GetName().."Button"):ClearAllPoints();		]]		getglobal(frame:GetName().."Button"):SetPoint("LEFT", frame:GetName().."Text", "LEFT", -9, 0);		getglobal(frame:GetName().."Button"):SetPoint("RIGHT", frame:GetName().."Text", "RIGHT", 6, 0);			end	frame.displayMode = displayMode;end-- If dropdown is visible then see if its timer has expired, if so hide the framefunction EarthMenu_OnUpdate(elapsed)	if ( this:IsVisible() ) then		if ( not this.showTimer or not this.isCounting ) then			return;		elseif ( this.showTimer < 0 ) then			this:Hide();			this.showTimer = nil;			this.isCounting = nil;		else			if ( type(elapsed) == "number") then 				this.showTimer = this.showTimer - elapsed;			end		end	endend-- Start the countdown on a framefunction EarthMenu_StartCounting(frame)	if ( frame.parent ) then		EarthMenu_StartCounting(frame.parent);	else		frame.showTimer = EARTH_UIDROPDOWNMENU_SHOW_TIME;		frame.isCounting = 1;	endend-- Stop the countdown on a framefunction EarthMenu_StopCounting(frame)	if ( frame.parent ) then		EarthMenu_StopCounting(frame.parent);	else		frame.isCounting = nil;	endend--[[List of button attributes======================================================info.text = [STRING]  --  The text of the buttoninfo.value = [ANYTHING]  --  The value that EARTH_UIDROPDOWNMENU_MENU_VALUE is set to when the button is clickedinfo.func = [function()]  --  The function that is called when you click the buttoninfo.checked = [nil, 1]  --  Check the button

⌨️ 快捷键说明

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