UnrealShare
Class UnrealChooseGameMenu

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

class UnrealChooseGameMenu
extends UnrealShare.UnrealLongMenu

//============================================================================= // UnrealChooseGameMenu // finds all the single player game types (using the .int files) // then allows the player to choose one (if there is only one, this menu never displays) //=============================================================================
Variables
 string GameNames[20]
 string StartMaps[20]


Function Summary
 void DrawMenu(Canvas Canvas)
 void PostBeginPlay()
 bool ProcessSelection()



Source Code


00001	//=============================================================================
00002	// UnrealChooseGameMenu
00003	// finds all the single player game types (using the .int files)
00004	// then allows the player to choose one (if there is only one, this menu never displays)
00005	//=============================================================================
00006	class UnrealChooseGameMenu extends UnrealLongMenu;
00007	
00008	var() config string StartMaps[20];
00009	var() config string GameNames[20];
00010	
00011	function PostBeginPlay()
00012	{
00013		local string NextGame;
00014		local class<SinglePlayer> GameClass;
00015	
00016		Super.PostBeginPlay();
00017		MenuLength = 0;
00018		NextGame = GetNextInt("SinglePlayer", 0); 
00019		while ( (NextGame != "") && (MenuLength < 20) )
00020		{
00021			GameClass = class<SinglePlayer>(DynamicLoadObject(NextGame, class'Class'));
00022			if ( GameClass != None )
00023			{
00024				MenuLength++;
00025				StartMaps[MenuLength] = GameClass.Default.StartMap;
00026				GameNames[MenuLength] = GameClass.Default.GameName;
00027			}
00028			NextGame = GetNextInt("SinglePlayer", MenuLength); 
00029		}
00030	}
00031	
00032	function bool ProcessSelection()
00033	{
00034		local Menu ChildMenu;
00035	
00036		ChildMenu = spawn(class'UnrealNewGameMenu', owner);
00037		HUD(Owner).MainMenu = ChildMenu;
00038		ChildMenu.PlayerOwner = PlayerOwner;
00039		PlayerOwner.UpdateURL("Game","", false);
00040		UnrealNewGameMenu(ChildMenu).StartMap = StartMaps[Selection];
00041	
00042		if ( MenuLength == 1 )
00043		{
00044			ChildMenu.ParentMenu = ParentMenu;
00045			Destroy();
00046		}
00047		else
00048			ChildMenu.ParentMenu = self;
00049	}
00050	
00051	function DrawMenu(canvas Canvas)
00052	{
00053		local int i, StartX, StartY, Spacing;
00054	
00055		if ( MenuLength == 1 )
00056		{
00057			DrawBackGround(Canvas, false);
00058			Selection = 1;
00059			ProcessSelection();
00060			return;
00061		}
00062	
00063		DrawBackGround(Canvas, false);
00064		DrawTitle(Canvas);
00065	
00066		Canvas.Style = 3;
00067		Spacing = Clamp(0.04 * Canvas.ClipY, 11, 32);
00068		StartX = Max(40, 0.5 * Canvas.ClipX - 120);
00069		StartY = Max(36, 0.5 * (Canvas.ClipY - MenuLength * Spacing - 128));
00070	
00071		// draw text
00072		for ( i=0; i<20; i++ )
00073			MenuList[i] = GameNames[i];
00074		DrawList(Canvas, false, Spacing, StartX, StartY); 
00075	
00076		// Draw help panel
00077		DrawHelpPanel(Canvas, StartY + MenuLength * Spacing + 8, 228);
00078	}
00079	
00080	defaultproperties
00081	{
00082	     HelpMessage(1)="Choose which game to play."
00083	     HelpMessage(2)="Choose which game to play."
00084	     HelpMessage(3)="Choose which game to play."
00085	     HelpMessage(4)="Choose which game to play."
00086	     HelpMessage(5)="Choose which game to play."
00087	     HelpMessage(6)="Choose which game to play."
00088	     HelpMessage(7)="Choose which game to play."
00089	     HelpMessage(8)="Choose which game to play."
00090	     HelpMessage(9)="Choose which game to play."
00091	     HelpMessage(10)="Choose which game to play."
00092	     HelpMessage(11)="Choose which game to play."
00093	     HelpMessage(12)="Choose which game to play."
00094	     HelpMessage(13)="Choose which game to play."
00095	     HelpMessage(14)="Choose which game to play."
00096	     HelpMessage(15)="Choose which game to play."
00097	     HelpMessage(16)="Choose which game to play."
00098	     HelpMessage(17)="Choose which game to play."
00099	     HelpMessage(18)="Choose which game to play."
00100	     HelpMessage(19)="Choose which game to play."
00101	     MenuTitle="CHOOSE GAME"
00102	}

End Source Code