UMenu
Class UMenuStartMatchClientWindow

source: e:\games\UnrealTournament\UMenu\Classes\UMenuStartMatchClientWindow.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowClientWindow
            |
            +--UWindow.UWindowDialogClientWindow
               |
               +--UMenu.UMenuDialogClientWindow
                  |
                  +--UMenu.UMenuStartMatchClientWindow
Direct Known Subclasses:UTMenuStartMatchCW

class UMenuStartMatchClientWindow
extends UMenu.UMenuDialogClientWindow


Variables
 UMenuBotmatchClientWindow BotmatchParent
 UWindowComboControl GameCombo
 string GameHelp
 string GameText
 string Games[256]
 bool Initialized
 UWindowComboControl MapCombo
 string MapHelp
 UWindowSmallButton MapListButton
 string MapListHelp
 string MapListText
 string MapText
 int MaxGames
 UWindowSmallButton MutatorButton
 string MutatorHelp
 string MutatorText


Function Summary
 void AfterCreate()
 void BeforePaint(Canvas C, float X, float Y)
 void Created()
 void GameChanged()
 void IterateMaps(string DefaultMap)
 void MapChanged()
 void Notify(UWindowDialogControl C, byte E)



Source Code


00001	class UMenuStartMatchClientWindow extends UMenuDialogClientWindow;
00002	
00003	var UMenuBotmatchClientWindow BotmatchParent;
00004	
00005	var bool Initialized;
00006	
00007	// Game Type
00008	var UWindowComboControl GameCombo;
00009	var localized string GameText;
00010	var localized string GameHelp;
00011	var string Games[256];
00012	var int MaxGames;
00013	
00014	// Map
00015	var UWindowComboControl MapCombo;
00016	var localized string MapText;
00017	var localized string MapHelp;
00018	
00019	// Map List Button
00020	var UWindowSmallButton MapListButton;
00021	var localized string MapListText;
00022	var localized string MapListHelp;
00023	
00024	var UWindowSmallButton MutatorButton;
00025	var localized string MutatorText;
00026	var localized string MutatorHelp;
00027	
00028	function Created()
00029	{
00030		local int i, j, Selection;
00031		local class<GameInfo> TempClass;
00032		local string TempGame;
00033		local string NextGame;
00034		local string TempGames[256];
00035		local bool bFoundSavedGameClass;
00036	
00037		local int ControlWidth, ControlLeft, ControlRight;
00038		local int CenterWidth, CenterPos;
00039	
00040		Super.Created();
00041	
00042		DesiredWidth = 270;
00043		DesiredHeight = 100;
00044	
00045		ControlWidth = WinWidth/2.5;
00046		ControlLeft = (WinWidth/2 - ControlWidth)/2;
00047		ControlRight = WinWidth/2 + ControlLeft;
00048	
00049		CenterWidth = (WinWidth/4)*3;
00050		CenterPos = (WinWidth - CenterWidth)/2;
00051	
00052		BotmatchParent = UMenuBotmatchClientWindow(GetParent(class'UMenuBotmatchClientWindow'));
00053		if (BotmatchParent == None)
00054			Log("Error: UMenuStartMatchClientWindow without UMenuBotmatchClientWindow parent.");
00055	
00056		// Game Type
00057		GameCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', CenterPos, 20, CenterWidth, 1));
00058		GameCombo.SetButtons(True);
00059		GameCombo.SetText(GameText);
00060		GameCombo.SetHelpText(GameHelp);
00061		GameCombo.SetFont(F_Normal);
00062		GameCombo.SetEditable(False);
00063	
00064		// Compile a list of all gametypes.
00065		NextGame = GetPlayerOwner().GetNextInt("GameInfo", 0); 
00066		while (NextGame != "")
00067		{
00068			TempGames[i] = NextGame;
00069			i++;
00070			NextGame = GetPlayerOwner().GetNextInt("GameInfo", i);
00071		}
00072	
00073		// Fill the control.
00074		for (i=0; i<256; i++)
00075		{
00076			if (TempGames[i] != "")
00077			{
00078				Games[MaxGames] = TempGames[i];
00079				if ( !bFoundSavedGameClass && (Games[MaxGames] ~= BotmatchParent.GameType) )
00080				{
00081					bFoundSavedGameClass = true;
00082					Selection = MaxGames;
00083				}
00084				TempClass = Class<GameInfo>(DynamicLoadObject(Games[MaxGames], class'Class'));
00085				if( TempClass != None )
00086				{
00087					GameCombo.AddItem(TempClass.Default.GameName);
00088					MaxGames++;
00089				}
00090			}
00091		}
00092	
00093		GameCombo.SetSelectedIndex(Selection);	
00094		BotmatchParent.GameType = Games[Selection];
00095		BotmatchParent.GameClass = Class<GameInfo>(DynamicLoadObject(BotmatchParent.GameType, class'Class'));
00096	
00097		// Map
00098		MapCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', CenterPos, 45, CenterWidth, 1));
00099		MapCombo.SetButtons(True);
00100		MapCombo.SetText(MapText);
00101		MapCombo.SetHelpText(MapHelp);
00102		MapCombo.SetFont(F_Normal);
00103		MapCombo.SetEditable(False);
00104		IterateMaps(BotmatchParent.Map);
00105	
00106		// Map List Button
00107		MapListButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', CenterPos, 70, 48, 16));
00108		MapListButton.SetText(MapListText);
00109		MapListButton.SetFont(F_Normal);
00110		MapListButton.SetHelpText(MapListHelp);
00111	
00112		// Mutator Button
00113		MutatorButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', CenterPos, 95, 48, 16));
00114		MutatorButton.SetText(MutatorText);
00115		MutatorButton.SetFont(F_Normal);
00116		MutatorButton.SetHelpText(MutatorHelp);
00117	
00118		Initialized = True;
00119	}
00120	
00121	function IterateMaps(string DefaultMap)
00122	{
00123		local string FirstMap, NextMap, TestMap;
00124		local int Selected;
00125	
00126		FirstMap = GetPlayerOwner().GetMapName(BotmatchParent.GameClass.Default.MapPrefix, "", 0);
00127	
00128		MapCombo.Clear();
00129		NextMap = FirstMap;
00130	
00131		while (!(FirstMap ~= TestMap))
00132		{
00133			// Add the map.
00134			if(!(Left(NextMap, Len(NextMap) - 4) ~= (BotmatchParent.GameClass.Default.MapPrefix$"-tutorial")))
00135				MapCombo.AddItem(Left(NextMap, Len(NextMap) - 4), NextMap);
00136	
00137			// Get the map.
00138			NextMap = GetPlayerOwner().GetMapName(BotmatchParent.GameClass.Default.MapPrefix, NextMap, 1);
00139	
00140			// Text to see if this is the last.
00141			TestMap = NextMap;
00142		}
00143		MapCombo.Sort();
00144	
00145		MapCombo.SetSelectedIndex(Max(MapCombo.FindItemIndex2(DefaultMap, True), 0));	
00146	}
00147	
00148	function AfterCreate()
00149	{
00150		BotmatchParent.Map = MapCombo.GetValue2();
00151		BotmatchParent.ScreenshotWindow.SetMap(BotmatchParent.Map);
00152	}
00153	
00154	function BeforePaint(Canvas C, float X, float Y)
00155	{
00156		local int ControlWidth, ControlLeft, ControlRight;
00157		local int CenterWidth, CenterPos;
00158	
00159		ControlWidth = WinWidth/2.5;
00160		ControlLeft = (WinWidth/2 - ControlWidth)/2;
00161		ControlRight = WinWidth/2 + ControlLeft;
00162	
00163		CenterWidth = (WinWidth/4)*3;
00164		CenterPos = (WinWidth - CenterWidth)/2;
00165	
00166		GameCombo.SetSize(CenterWidth, 1);
00167		GameCombo.WinLeft = CenterPos;
00168		GameCombo.EditBoxWidth = 150;
00169	
00170		MapCombo.SetSize(CenterWidth, 1);
00171		MapCombo.WinLeft = CenterPos;
00172		MapCombo.EditBoxWidth = 150;
00173	
00174		MapListButton.AutoWidth(C);
00175		MutatorButton.AutoWidth(C);
00176	
00177		MapListButton.WinWidth = Max(MapListButton.WinWidth, MutatorButton.WinWidth);
00178		MutatorButton.WinWidth = MapListButton.WinWidth;
00179	
00180		MapListButton.WinLeft = (WinWidth - MapListButton.WinWidth)/2;
00181		MutatorButton.WinLeft = (WinWidth - MapListButton.WinWidth)/2;
00182	}
00183	
00184	function Notify(UWindowDialogControl C, byte E)
00185	{
00186		Super.Notify(C, E);
00187	
00188		switch(E)
00189		{
00190		case DE_Change:
00191			switch(C)
00192			{
00193			case GameCombo:
00194				GameChanged();
00195				break;
00196			case MapCombo:
00197				MapChanged();
00198				break;
00199			}
00200			break;
00201		case DE_Click:
00202			switch(C)
00203			{
00204			case MapListButton:
00205				GetParent(class'UWindowFramedWindow').ShowModal(Root.CreateWindow(class'UMenuMapListWindow', 0, 0, 100, 100, BotmatchParent));
00206				break;
00207			case MutatorButton:
00208				GetParent(class'UWindowFramedWindow').ShowModal(Root.CreateWindow(class'UMenuMutatorWindow', 0, 0, 100, 100, BotmatchParent));
00209				break;
00210			}
00211		}
00212	}
00213	
00214	function GameChanged()
00215	{
00216		local int CurrentGame, i;
00217	
00218		if (!Initialized)
00219			return;
00220	
00221		if(BotmatchParent.GameClass != None)
00222			BotmatchParent.GameClass.static.StaticSaveConfig();
00223	
00224		CurrentGame = GameCombo.GetSelectedIndex();
00225	
00226		BotmatchParent.GameType = Games[CurrentGame];
00227		BotmatchParent.GameClass = Class<GameInfo>(DynamicLoadObject(BotmatchParent.GameType, class'Class'));
00228	
00229		if ( BotmatchParent.GameClass == None )
00230		{
00231			MaxGames--;
00232			if ( MaxGames > CurrentGame )
00233			{
00234				for ( i=CurrentGame; i<MaxGames; i++ )
00235					Games[i] = Games[i+1];
00236			}
00237			else if ( CurrentGame > 0 )
00238				CurrentGame--;
00239			GameCombo.SetSelectedIndex(CurrentGame);
00240			return;
00241		}
00242		if (MapCombo != None)
00243			IterateMaps(BotmatchParent.Map);
00244	
00245		BotmatchParent.GameChanged();
00246	}
00247	
00248	function MapChanged()
00249	{
00250		if (!Initialized)
00251			return;
00252	
00253		BotmatchParent.Map = MapCombo.GetValue2();
00254		BotmatchParent.ScreenshotWindow.SetMap(BotmatchParent.Map);
00255	}
00256	
00257	defaultproperties
00258	{
00259	     GameText="Game Type:"
00260	     GameHelp="Select the type of game to play."
00261	     MapText="Map Name:"
00262	     MapHelp="Select the map to play."
00263	     MapListText="Map List"
00264	     MapListHelp="Click this button to change the list of maps which will be cycled."
00265	     MutatorText="Mutators"
00266	     MutatorHelp="Mutators are scripts which modify gameplay.  Press this button to choose which mutators to use."
00267	}

End Source Code