Engine
Class Menu

source: e:\games\UnrealTournament\Engine\Classes\Menu.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Menu
Direct Known Subclasses:UnrealMenu

class Menu
extends Engine.Actor

//============================================================================= // Menu: An in-game menu. // This is a built-in Unreal class and it shouldn't be modified. // // Serves as a generic menu master class. Can be used with any style // of menu implementation. Offers menu services such as reading input. // Not dependent on any visual style. //=============================================================================
Variables
 string CenterString
 string DisabledString
 string EnabledString
 string HelpMessage[24]
 string LeftString
 int MenuLength
 string MenuList[24]
 string MenuTitle
 string NoString
 Menu ParentMenu
 PlayerPawn PlayerOwner
 string RightString
 int Selection
 string YesString
 bool bConfigChanged
 bool bExitAllMenus


Function Summary
 void DrawMenu(Canvas Canvas)
 void ExitAllMenus()
 Menu ExitMenu()
 void MenuInit()
 void MenuProcessInput(byte KeyNum, byte ActionNum)
 void MenuTick(float DeltaTime)
 void PlayEnterSound()
 void PlayModifySound()
 void PlaySelectSound()
 bool ProcessLeft()
 void ProcessMenuEscape()
 void ProcessMenuInput(string InputString)
 void ProcessMenuKey(int KeyNo, string KeyName)
 void ProcessMenuUpdate(string InputString)
 bool ProcessNo()
 bool ProcessRight()
 bool ProcessSelection()
 bool ProcessYes()
 void SaveConfigs()
 void SetFontBrightness(Canvas Canvas, bool bBright)



Source Code


00001	//=============================================================================
00002	// Menu: An in-game menu.
00003	// This is a built-in Unreal class and it shouldn't be modified.
00004	//
00005	// Serves as a generic menu master class.  Can be used with any style
00006	// of menu implementation.  Offers menu services such as reading input.
00007	// Not dependent on any visual style.
00008	//=============================================================================
00009	class Menu extends Actor
00010		native;
00011	
00012	var Menu	ParentMenu;
00013	var int		Selection;
00014	var() int	MenuLength;
00015	var bool	bConfigChanged;
00016	var bool    bExitAllMenus;
00017	var PlayerPawn PlayerOwner;
00018	
00019	var() localized string HelpMessage[24];
00020	var() localized string MenuList[24];
00021	var() localized string LeftString;
00022	var() localized string RightString;
00023	var() localized string CenterString;
00024	var() localized string EnabledString;
00025	var() localized string DisabledString;
00026	var() localized string MenuTitle;
00027	var() localized string YesString;
00028	var() localized string NoString;
00029	
00030	function bool ProcessSelection();
00031	function bool ProcessLeft();
00032	function bool ProcessRight();
00033	function bool ProcessYes();
00034	function bool ProcessNo();
00035	function SaveConfigs();
00036	function PlaySelectSound();
00037	function PlayModifySound();
00038	function PlayEnterSound();
00039	function ProcessMenuInput( coerce string InputString );
00040	function ProcessMenuUpdate( coerce string InputString );
00041	function ProcessMenuEscape();
00042	function ProcessMenuKey( int KeyNo, string KeyName );
00043	function MenuTick( float DeltaTime );
00044	function MenuInit();
00045	
00046	function DrawMenu(canvas Canvas);
00047	
00048	function ExitAllMenus()
00049	{
00050		while ( Hud(Owner).MainMenu != None )
00051			Hud(Owner).MainMenu.ExitMenu();
00052	}
00053	
00054	function Menu ExitMenu()
00055	{
00056		Hud(Owner).MainMenu = ParentMenu;
00057		if ( bConfigChanged )
00058			SaveConfigs();
00059		if ( ParentMenu == None )
00060		{
00061			PlayerOwner.bShowMenu = false;
00062			PlayerOwner.Player.Console.GotoState('');
00063			if( Level.Netmode == NM_Standalone )
00064				PlayerOwner.SetPause(False);
00065		}
00066	
00067		Destroy();
00068	}
00069	
00070	function SetFontBrightness(canvas Canvas, bool bBright)
00071	{
00072		if ( bBright )
00073		{
00074			Canvas.DrawColor.R = 255;
00075			Canvas.DrawColor.G = 255;
00076			Canvas.DrawColor.B = 255;
00077		}
00078		else 
00079			Canvas.DrawColor = Canvas.Default.DrawColor;
00080	}
00081	
00082	function MenuProcessInput( byte KeyNum, byte ActionNum )
00083	{
00084		if ( KeyNum == EInputKey.IK_Escape )
00085		{
00086			PlayEnterSound();
00087			ExitMenu();
00088			return;
00089		}	
00090		else if ( KeyNum == EInputKey.IK_Up )
00091		{
00092			PlaySelectSound();
00093			Selection--;
00094			if ( Selection < 1 )
00095				Selection = MenuLength;
00096		}
00097		else if ( KeyNum == EInputKey.IK_Down )
00098		{
00099			PlaySelectSound();
00100			Selection++;
00101			if ( Selection > MenuLength )
00102				Selection = 1;
00103		}
00104		else if ( KeyNum == EInputKey.IK_Enter )
00105		{
00106			bConfigChanged=true;
00107			if ( ProcessSelection() )
00108				PlayEnterSound();
00109		}
00110		else if ( KeyNum == EInputKey.IK_Left )
00111		{
00112			bConfigChanged=true;
00113			if ( ProcessLeft() )
00114				PlayModifySound();
00115		}
00116		else if ( KeyNum == EInputKey.IK_Right )
00117		{
00118			bConfigChanged=true;
00119			if ( ProcessRight() )
00120				PlayModifySound();
00121		}
00122		else if ( Chr(KeyNum) ~= left(YesString, 1) ) 
00123		{
00124			bConfigChanged=true;
00125			if ( ProcessYes() )
00126				PlayModifySound();
00127		}
00128		else if ( Chr(KeyNum) ~= left(NoString, 1) )
00129		{
00130			bConfigChanged=true;
00131			if ( ProcessNo() )
00132				PlayModifySound();
00133		}
00134	
00135		if ( bExitAllMenus )
00136			ExitAllMenus(); 
00137		
00138	}
00139	
00140	defaultproperties
00141	{
00142	     Selection=1
00143	     HelpMessage(1)="This menu has not yet been implemented."
00144	     LeftString="Left"
00145	     RightString="Right"
00146	     CenterString="Center"
00147	     EnabledString="Enabled"
00148	     DisabledString="Disabled"
00149	     YesString="yes"
00150	     NoString="no"
00151	     bHidden=True
00152	}

End Source Code