RMenu
Class RuneMenuStartMatchClientWindow

source: c:\runehov\RMenu\Classes\RuneMenuStartMatchClientWindow.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowClientWindow
            |
            +--UWindow.UWindowDialogClientWindow
               |
               +--UWindow.UWindowPageWindow
                  |
                  +--RMenu.RuneMenuPageWindow
                     |
                     +--RMenu.RuneMenuStartMatchClientWindow
Direct Known Subclasses:None

class RuneMenuStartMatchClientWindow
extends RMenu.RuneMenuPageWindow


Variables
 UWindowComboControl GameCombo
 string GameHelp
 string GameText
 string Games[64]
 bool Initialized
 UWindowComboControl MapCombo
 string MapHelp
 string MapText
 int MaxGames
 RuneMenuScreenshotCW ScreenshotWindow
           ? Move to Map selection page
 RuneMenuServerClientWindow ServerParent


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 RuneMenuStartMatchClientWindow extends RuneMenuPageWindow;
00002	
00003	var RuneMenuServerClientWindow ServerParent;
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[64];
00012	var int MaxGames;
00013	
00014	// Map
00015	var UWindowComboControl MapCombo;
00016	var localized string MapText;
00017	var localized string MapHelp;
00018	
00019	var RuneMenuScreenshotCW ScreenshotWindow;		// ? Move to Map selection page
00020	
00021	function Created()
00022	{
00023		local int i, j, Selection;
00024		local class<GameInfo> TempClass;
00025		local string TempGame;
00026		local string NextGame;
00027		local string TempGames[64];
00028		local bool bFoundSavedGameClass;
00029	
00030		local int ControlWidth, ControlLeft, ControlRight;
00031		local int CenterWidth, CenterPos;
00032	
00033		Super.Created();
00034	
00035		DesiredWidth = 270;
00036		DesiredHeight = 100;
00037	
00038		ControlWidth = WinWidth/2.5;
00039		ControlLeft = (WinWidth/2 - ControlWidth)/2;
00040		ControlRight = WinWidth/2 + ControlLeft;
00041	
00042		CenterWidth = (WinWidth/4)*3;
00043		CenterPos = (WinWidth - CenterWidth)/2;
00044	
00045		ServerParent = RuneMenuServerClientWindow(GetParent(class'RuneMenuServerClientWindow'));
00046		if (ServerParent == None)
00047			Log("Error: RuneMenuStartMatchClientWindow without RuneMenuServerClientWindow parent.");
00048	
00049		// Game Type
00050		GameCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', CenterPos, 20, CenterWidth, 1));
00051		GameCombo.SetButtons(True);
00052		GameCombo.SetText(GameText);
00053		GameCombo.SetHelpText(GameHelp);
00054		GameCombo.SetFont(F_Normal);
00055		GameCombo.SetEditable(False);
00056	
00057		// Compile a list of all gametypes.
00058		NextGame = GetPlayerOwner().GetNextInt("GameInfo", 0); 
00059		while (NextGame != "")
00060		{
00061			TempGames[i] = NextGame;
00062			i++;
00063			NextGame = GetPlayerOwner().GetNextInt("GameInfo", i);
00064		}
00065	
00066		// Fill the control.
00067		for (i=0; i<64; i++)
00068		{
00069			if (TempGames[i] != "")
00070			{
00071				Games[MaxGames] = TempGames[i];
00072				if ( !bFoundSavedGameClass && (Games[MaxGames] ~= ServerParent.GameType) )
00073				{
00074					bFoundSavedGameClass = true;
00075					Selection = MaxGames;
00076				}
00077				//Log("GameClass:"$Games[MaxGames]);
00078				TempClass = Class<GameInfo>(DynamicLoadObject(Games[MaxGames], class'Class'));
00079				GameCombo.AddItem(TempClass.Default.GameName);
00080				MaxGames++;
00081			}
00082		}
00083	
00084		GameCombo.SetSelectedIndex(Selection);	
00085		ServerParent.GameType = Games[Selection];
00086		ServerParent.GameClass = Class<GameInfo>(DynamicLoadObject(ServerParent.GameType, class'Class'));
00087	
00088		// Map
00089		MapCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', CenterPos, 45, CenterWidth, 1));
00090		MapCombo.SetButtons(True);
00091		MapCombo.SetText(MapText);
00092		MapCombo.SetHelpText(MapHelp);
00093		MapCombo.SetFont(F_Normal);
00094		MapCombo.SetEditable(False);
00095		IterateMaps(ServerParent.Map);
00096	
00097		ScreenshotWindow = RuneMenuScreenshotCW(CreateWindow(class'RuneMenuScreenshotCW', (WinWidth-256)/2, 75, 256, 220));
00098	
00099		Initialized = True;
00100	}
00101	
00102	function IterateMaps(string DefaultMap)
00103	{
00104		local string FirstMap, NextMap, TestMap;
00105		local int Selected;
00106	
00107		FirstMap = GetPlayerOwner().GetMapName(ServerParent.GameClass.Default.MapPrefix, "", 0);
00108	
00109		MapCombo.Clear();
00110		NextMap = FirstMap;
00111	
00112		while (!(FirstMap ~= TestMap))
00113		{
00114			// Add the map.
00115			if(!(Left(NextMap, Len(NextMap) - 4) ~= (ServerParent.GameClass.Default.MapPrefix$"-tutorial")))
00116				MapCombo.AddItem(Left(NextMap, Len(NextMap) - 4), NextMap);
00117	
00118			// Get the map.
00119			NextMap = GetPlayerOwner().GetMapName(ServerParent.GameClass.Default.MapPrefix, NextMap, 1);
00120	
00121			// Text to see if this is the last.
00122			TestMap = NextMap;
00123		}
00124		MapCombo.Sort();
00125	
00126		MapCombo.SetSelectedIndex(Max(MapCombo.FindItemIndex2(DefaultMap, True), 0));	
00127	}
00128	
00129	function AfterCreate()
00130	{
00131		ServerParent.Map = MapCombo.GetValue2();
00132		ScreenshotWindow.SetMap(ServerParent.Map);
00133	}
00134	
00135	function BeforePaint(Canvas C, float X, float Y)
00136	{
00137		local int ControlWidth, ControlLeft, ControlRight;
00138		local int CenterWidth, CenterPos;
00139	
00140		ControlWidth = WinWidth/2.5;
00141		ControlLeft = (WinWidth/2 - ControlWidth)/2;
00142		ControlRight = WinWidth/2 + ControlLeft;
00143	
00144		CenterWidth = (WinWidth/4)*3;
00145		CenterPos = (WinWidth - CenterWidth)/2;
00146	
00147		GameCombo.SetSize(CenterWidth, 1);
00148		GameCombo.WinLeft = CenterPos;
00149		GameCombo.EditBoxWidth = 150;
00150	
00151		MapCombo.SetSize(CenterWidth, 1);
00152		MapCombo.WinLeft = CenterPos;
00153		MapCombo.EditBoxWidth = 150;
00154	}
00155	
00156	function Notify(UWindowDialogControl C, byte E)
00157	{
00158		Super.Notify(C, E);
00159	
00160		switch(E)
00161		{
00162		case DE_Change:
00163			switch(C)
00164			{
00165			case GameCombo:
00166				GameChanged();
00167				break;
00168			case MapCombo:
00169				MapChanged();
00170				break;
00171			}
00172			break;
00173		}
00174	}
00175	
00176	function GameChanged()
00177	{
00178		local int CurrentGame, i;
00179	
00180		if (!Initialized)
00181			return;
00182	
00183		if(ServerParent.GameClass != None)
00184			ServerParent.GameClass.static.StaticSaveConfig();
00185	
00186		CurrentGame = GameCombo.GetSelectedIndex();
00187	
00188		ServerParent.GameType = Games[CurrentGame];
00189		ServerParent.GameClass = Class<GameInfo>(DynamicLoadObject(ServerParent.GameType, class'Class'));
00190	
00191		if ( ServerParent.GameClass == None )
00192		{
00193			MaxGames--;
00194			if ( MaxGames > CurrentGame )
00195			{
00196				for ( i=CurrentGame; i<MaxGames; i++ )
00197					Games[i] = Games[i+1];
00198			}
00199			else if ( CurrentGame > 0 )
00200				CurrentGame--;
00201			GameCombo.SetSelectedIndex(CurrentGame);
00202			return;
00203		}
00204		if (MapCombo != None)
00205			IterateMaps(ServerParent.Map);
00206	
00207		ServerParent.GameChanged();
00208	}
00209	
00210	function MapChanged()
00211	{
00212		if (!Initialized)
00213			return;
00214	
00215		ServerParent.Map = MapCombo.GetValue2();
00216		ScreenshotWindow.SetMap(ServerParent.Map);
00217	}
00218	
00219	defaultproperties
00220	{
00221	     GameText="Game Type:"
00222	     GameHelp="Select the type of game to play."
00223	     MapText="Map Name:"
00224	     MapHelp="Select the map to play."
00225	}

End Source Code