UTMenu
Class UTMenuStartMatchCW

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

class UTMenuStartMatchCW
extends UMenu.UMenuStartMatchClientWindow


Variables
 UWindowComboControl CategoryCombo
 string CategoryHelp
 string CategoryText
 UWindowCheckbox ChangeLevelsCheck
 string ChangeLevelsHelp
 string ChangeLevelsText
 string GeneralText
 string LastCategory


Function Summary
 void BeforePaint(Canvas C, float X, float Y)
 void CategoryChanged()
 void ChangeLevelsChanged()
 void Created()
 void GameChanged()
 void Notify(UWindowDialogControl C, byte E)
 void SetChangeLevels()



Source Code


00001	class UTMenuStartMatchCW expands UMenuStartMatchClientWindow;
00002	
00003	var UWindowCheckbox ChangeLevelsCheck;
00004	var localized string ChangeLevelsText;
00005	var localized string ChangeLevelsHelp;
00006	
00007	// Category
00008	var UWindowComboControl CategoryCombo;
00009	var localized string CategoryText;
00010	var localized string CategoryHelp;
00011	var localized string GeneralText;
00012	var config string LastCategory;
00013	
00014	function Created()
00015	{
00016		local int i, j, Selection, BestCategory, CategoryCount;
00017		local class<GameInfo> TempClass;
00018		local string TempGame, NextGame;
00019		local string TempGames[256];
00020		local string NextEntry, NextCategory;
00021		local string Categories[256];
00022		local bool bFoundSavedGameClass, bAlreadyHave;
00023	
00024		local int ControlWidth, ControlLeft, ControlRight;
00025		local int CenterWidth, CenterPos;
00026	
00027		Super(UMenuDialogClientWindow).Created();
00028	
00029		DesiredWidth = 270;
00030		DesiredHeight = 100;
00031	
00032		ControlWidth = WinWidth/2.5;
00033		ControlLeft = (WinWidth/2 - ControlWidth)/2;
00034		ControlRight = WinWidth/2 + ControlLeft;
00035	
00036		CenterWidth = (WinWidth/4)*3;
00037		CenterPos = (WinWidth - CenterWidth)/2;
00038	
00039		BotmatchParent = UMenuBotmatchClientWindow(GetParent(class'UMenuBotmatchClientWindow'));
00040		if (BotmatchParent == None)
00041			Log("Error: UMenuStartMatchClientWindow without UMenuBotmatchClientWindow parent.");
00042	
00043		// Category
00044		CategoryCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', CenterPos, 20, CenterWidth, 1));
00045		CategoryCombo.SetButtons(True);
00046		CategoryCombo.SetText(CategoryText);
00047		CategoryCombo.SetHelpText(CategoryHelp);
00048		CategoryCombo.SetFont(F_Normal);
00049		CategoryCombo.SetEditable(False);
00050		CategoryCombo.AddItem(GeneralText);
00051	
00052		// Add all categories.
00053		for(i=0; i<256; i++)
00054		{
00055			bAlreadyHave = false;
00056			GetPlayerOwner().GetNextIntDesc("TournamentGameInfo", i, NextEntry, NextCategory);
00057			for(j =0; j<256; j++)
00058			{
00059				if (Categories[j] ~= NextCategory)
00060					bAlreadyHave = true;
00061			}
00062			if (!bAlreadyHave)
00063				Categories[i] = NextCategory;
00064		}
00065		for(i=0; i<256; i++)
00066		{
00067			if (Len(Categories[i]) > 0)
00068			{
00069				CategoryCombo.AddItem(Categories[i]);
00070				CategoryCount++;
00071				if (Categories[i] ~= LastCategory)
00072					BestCategory = CategoryCount;
00073			}
00074		}
00075		CategoryCombo.SetSelectedIndex(BestCategory);
00076	
00077		// Game Type
00078		GameCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', CenterPos, 45, CenterWidth, 1));
00079		GameCombo.SetButtons(True);
00080		GameCombo.SetText(GameText);
00081		GameCombo.SetHelpText(GameHelp);
00082		GameCombo.SetFont(F_Normal);
00083		GameCombo.SetEditable(False);
00084	
00085		// Compile a list of all gametypes.
00086		i=0;
00087		TempClass = class'TournamentGameInfo';
00088		GetPlayerOwner().GetNextIntDesc("TournamentGameInfo", 0, NextGame, NextCategory);
00089		while (NextGame != "")
00090		{
00091			if ((CategoryCombo.GetValue() ~= GeneralText) && (NextCategory == ""))
00092				TempGames[i] = NextGame;
00093			else if (NextCategory ~= CategoryCombo.GetValue())
00094				TempGames[i] = NextGame;
00095			i++;
00096			if(i == 256)
00097			{
00098				Log("More than 256 gameinfos listed in int files");
00099				break;
00100			}
00101			GetPlayerOwner().GetNextIntDesc("TournamentGameInfo", i, NextGame, NextCategory);
00102		}
00103	
00104		// Fill the control.
00105		for (i=0; i<256; i++)
00106		{
00107			if (TempGames[i] != "")
00108			{
00109				Games[MaxGames] = TempGames[i];
00110				if ( !bFoundSavedGameClass && (Games[MaxGames] ~= BotmatchParent.GameType) )
00111				{
00112					bFoundSavedGameClass = true;
00113					Selection = MaxGames;
00114				}
00115				TempClass = Class<GameInfo>(DynamicLoadObject(Games[MaxGames], class'Class'));
00116				GameCombo.AddItem(TempClass.Default.GameName);
00117				MaxGames++;
00118			}
00119		}
00120	
00121		GameCombo.SetSelectedIndex(Selection);	
00122		BotmatchParent.GameType = Games[Selection];
00123		BotmatchParent.GameClass = Class<GameInfo>(DynamicLoadObject(BotmatchParent.GameType, class'Class'));
00124	
00125		// Map
00126		MapCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', CenterPos, 70, CenterWidth, 1));
00127		MapCombo.SetButtons(True);
00128		MapCombo.SetText(MapText);
00129		MapCombo.SetHelpText(MapHelp);
00130		MapCombo.SetFont(F_Normal);
00131		MapCombo.SetEditable(False);
00132	
00133		IterateMaps(BotmatchParent.Map);
00134	
00135		// Map List Button
00136		MapListButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', CenterPos, 95, 48, 16));
00137		MapListButton.SetText(MapListText);
00138		MapListButton.SetFont(F_Normal);
00139		MapListButton.SetHelpText(MapListHelp);
00140	
00141		// Mutator Button
00142		MutatorButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', CenterPos, 120, 48, 16));
00143		MutatorButton.SetText(MutatorText);
00144		MutatorButton.SetFont(F_Normal);
00145		MutatorButton.SetHelpText(MutatorHelp);
00146	
00147		ControlWidth = WinWidth/2.5;
00148		ControlLeft = (WinWidth/2 - ControlWidth)/2;
00149		ControlRight = WinWidth/2 + ControlLeft;
00150	
00151		CenterWidth = (WinWidth/4)*3;
00152		CenterPos = (WinWidth - CenterWidth)/2;
00153	
00154		ChangeLevelsCheck = UWindowCheckbox(CreateControl(class'UWindowCheckbox', CenterPos, 145, ControlWidth, 1));
00155		ChangeLevelsCheck.SetText(ChangeLevelsText);
00156		ChangeLevelsCheck.SetHelpText(ChangeLevelsHelp);
00157		ChangeLevelsCheck.SetFont(F_Normal);
00158		ChangeLevelsCheck.Align = TA_Right;
00159	
00160		SetChangeLevels();
00161	
00162		Initialized = true;
00163	}
00164	
00165	function BeforePaint(Canvas C, float X, float Y)
00166	{
00167		local int ControlWidth, ControlLeft, ControlRight;
00168		local int CenterWidth, CenterPos;
00169	
00170		Super.BeforePaint(C, X, Y);
00171	
00172		ControlWidth = WinWidth/2.5;
00173		ControlLeft = (WinWidth/2 - ControlWidth)/2;
00174		ControlRight = WinWidth/2 + ControlLeft;
00175	
00176		CenterWidth = (WinWidth/4)*3;
00177		CenterPos = (WinWidth - CenterWidth)/2;
00178	
00179		CategoryCombo.SetSize(CenterWidth, 1);
00180		CategoryCombo.WinLeft = CenterPos;
00181		CategoryCombo.EditBoxWidth = 150;
00182	
00183		ChangeLevelsCheck.SetSize(ControlWidth, 1);		
00184		ChangeLevelsCheck.WinLeft = (WinWidth - ChangeLevelsCheck.WinWidth) / 2;
00185	}
00186	
00187	function CategoryChanged()
00188	{
00189		local string CurCategory;
00190		local int i, Selection;
00191		local string NextGame, NextCategory;
00192		local string TempGames[256];
00193		local class<GameInfo> TempClass;
00194		local bool bFoundSavedGameClass;
00195	
00196		if (!Initialized)
00197			return;
00198	
00199		Initialized = false;
00200	
00201		CurCategory = CategoryCombo.GetValue();
00202		LastCategory = CurCategory;
00203		GameCombo.Clear();
00204	
00205		for (i=0; i<256; i++)
00206			Games[i] = "";
00207		i=0;
00208	
00209		// Compile a list of all gametypes.
00210		TempClass = class'TournamentGameInfo';
00211		GetPlayerOwner().GetNextIntDesc("TournamentGameInfo", 0, NextGame, NextCategory);
00212		while (NextGame != "")
00213		{
00214			if ((CurCategory ~= GeneralText) && (NextCategory == ""))
00215				TempGames[i] = NextGame;
00216			else if (NextCategory ~= CurCategory)
00217				TempGames[i] = NextGame;
00218			i++;
00219			if(i == 256)
00220			{
00221				Log("More than 256 gameinfos listed in int files");
00222				break;
00223			}
00224			GetPlayerOwner().GetNextIntDesc("TournamentGameInfo", i, NextGame, NextCategory);
00225		}
00226	
00227		// Fill the control.
00228		for (i=0; i<256; i++)
00229		{
00230			if (TempGames[i] != "")
00231			{
00232				Games[MaxGames] = TempGames[i];
00233				if ( !bFoundSavedGameClass && (Games[MaxGames] ~= BotmatchParent.GameType) )
00234				{
00235					bFoundSavedGameClass = true;
00236					Selection = MaxGames;
00237				}
00238				TempClass = Class<GameInfo>(DynamicLoadObject(Games[MaxGames], class'Class'));
00239				GameCombo.AddItem(TempClass.Default.GameName);
00240				MaxGames++;
00241			}
00242		}
00243	
00244		GameCombo.SetSelectedIndex(0);
00245	
00246		Initialized = true;
00247	
00248		GameChanged();
00249	
00250		SaveConfig();
00251	}
00252	
00253	function GameChanged()
00254	{
00255		if (!Initialized)
00256			return;
00257	
00258		Super.GameChanged();
00259		SetChangeLevels();
00260	}
00261	
00262	function SetChangeLevels()
00263	{
00264		local class<DeathMatchPlus> DMP;
00265	
00266		DMP = class<DeathMatchPlus>(BotmatchParent.GameClass);
00267		if(DMP == None)
00268		{
00269			ChangeLevelsCheck.HideWindow();
00270		}
00271		else
00272		{
00273			ChangeLevelsCheck.ShowWindow();
00274			ChangeLevelsCheck.bChecked = DMP.default.bChangeLevels;
00275		}
00276	}
00277	
00278	function Notify(UWindowDialogControl C, byte E)
00279	{
00280		Super.Notify(C, E);
00281	
00282		switch(E)
00283		{
00284		case DE_Change:
00285			switch(C)
00286			{
00287			case CategoryCombo:
00288				CategoryChanged();
00289				break;
00290			case ChangeLevelsCheck:
00291				ChangeLevelsChanged();
00292				break;
00293			}
00294			break;
00295		}
00296	}
00297	
00298	function ChangeLevelsChanged()
00299	{
00300		local class<DeathMatchPlus> DMP;
00301	
00302		DMP = class<DeathMatchPlus>(BotmatchParent.GameClass);
00303		if(DMP != None)
00304		{
00305			DMP.default.bChangeLevels = ChangeLevelsCheck.bChecked;
00306			DMP.static.StaticSaveConfig();
00307		}
00308	}
00309	
00310	defaultproperties
00311	{
00312	     ChangeLevelsText="Auto Change Levels"
00313	     ChangeLevelsHelp="If this setting is checked, the server will change levels according to the map list for this game type."
00314	     CategoryText="Category:"
00315	     CategoryHelp="Select a category of gametype!"
00316	     GeneralText="Unreal Tournament"
00317	}

End Source Code