Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

TribesGUI.TribesMPHostPanel


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
// ====================================================================
//  Class:  TribesGui.TribesMPHostPanel
//
//  Menu to load map from entry screen.
// ====================================================================

class TribesMPHostPanel extends TribesMPPanel
     ;

var(TribesGui) private EditInline Config GUIButton		    StartServerButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIButton		    AdvancedButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUICheckboxButton	DedicatedButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIListBox		    MapListBox "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIListBox		    GameTypeListBox "A component of this page which has its behavior defined in the code for this page's class.";

var(TribesGui) private EditInline Config GUILabel           GameTypeDescriptionLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel           MapDescriptionLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIProgressBar     progressBar "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIImage		    screenshotImage "A component of this page which has its behavior defined in the code for this page's class.";

var(TribesGui) private EditInline Config GUIEditBox         ServerNameBox "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIEditBox         PasswordBox "A component of this page which has its behavior defined in the code for this page's class.";

var(TribesGui) private EditInline Config localized string   BadPassword;

var bool bInitialized;
var array<LevelSummary> summaryList;
var array<String> fileList;
var array<String> gameTypeDescriptions;
var string currentGameType;
var string currentMap;
var Canvas progressCanvas;

function InitComponent(GUIComponent MyOwner)
{
	Super.InitComponent(MyOwner);
	StartServerButton.OnClick=OnStartServerClick;
	AdvancedButton.OnClick=OnAdvancedClick;
	MapListBox.List.OnChange=MapListOnChange;
	GameTypeListBox.List.OnChange=GameTypeListOnChange;
	progressBar.OnDraw=ProgressOnDraw;

	ServerNameBox.SetText(class'GameReplicationInfo'.default.ServerName);
}

function bool ProgressOnDraw(Canvas C)
{
	progressCanvas = C;
	return true;
}

function LoadLevelSummaries(out array<String> levelFileList, out array<LevelSummary> levelSummaryList )
{
	local LevelSummary L;
	local int i, numLevelsToLoad;

	local string FirstMap, NextMap, TestMap, LoadMap;

	FirstMap = PlayerOwner().GetMapName("MP-", "", 0);
	NextMap = FirstMap;

	// Count number of maps first
	while (!(FirstMap ~= TestMap))
	{
		numLevelsToLoad++;

		if(Right(NextMap, 4) ~= ".tvm")
			LoadMap = Left(NextMap, Len(NextMap) - 4);
		else
			LoadMap = NextMap;

		//Log("LOADBOX:  Adding "$LoadMap);
		NextMap = PlayerOwner().GetMapName("MP-", NextMap, 1);
		TestMap = NextMap;

		if (LoadMap != "")
			levelFileList[levelFileList.Length] = LoadMap;
	}

//GUIFIX	progressBar.High = numLevelsToLoad ;

	// Now load the actual LevelSummaries (potentially slow)
	for (i=0; i<levelFileList.Length; i++)
	{
		L = Controller.LoadLevelSummary(levelFileList[i]$".LevelSummary");
		// Old method
		//L = LevelSummary(DynamicLoadObject(levelFileList[i]$".LevelSummary", class'LevelSummary'));

		// Update progress bar
		progressBar.Value = i+1;
		//progressBar.UpdateComponent(progressCanvas);

		if (L == None)
		{
			Log("The map named "$levelFileList[i]$" doesn't have a LevelSummary!");
			continue;
		}

		levelSummaryList[levelSummaryList.Length] = L;
	}
}

function LoadMapList()
{
	local int i,j;
	local LevelSummary L;

	MapListBox.List.Clear();
	
	for (i=0; i<summaryList.Length; i++)
	{
		// See if this map supports the currently selected game type
		L = summaryList[i];

		if (L == None)
		{
			Log("Warning:  while loading maps, levelSummaryList has no levelSummary at index "$i);
			continue;
		}

		for (j=0; j<L.SupportedModes.Length; j++)
		{
			if (L.SupportedModes[j] == None)
				continue;

			if (currentGameType == L.SupportedModes[j].default.acronym)
			{
				//Log(L.Title $ " supports game type "$currentGameType$" -- "$levelFileList[i]);
		        //if (L.Title != "Untitled")
				//	MapListBox.List.Add( L.Title,L, fileList[i] );
				//else
					MapListBox.List.Add( fileList[i],L, fileList[i]);
			}
		}
	}

	MapListBox.List.SetIndex(0);
    MapListBox.List.Sort();
}

function LoadGameTypes()
{
	local LevelSummary L;
	local int i,j;

	for (i=0; i<summaryList.Length; i++)
	{
		// See if this map supports the currently selected game type
		L = summaryList[i];

		if (L == None)
		{
			Log("Warning:  while loading game types, levelSummaryList has no levelSummary at index "$i);
			continue;
		}

		for (j=0; j<L.SupportedModes.Length; j++)
		{
			if (L.SupportedModes[j] == None || L.SupportedModes[j].default.acronym == "")
				continue;

			if (GameTypeListBox.List.Find(L.SupportedModes[j].default.acronym) == "")
			{
				//Log("GAMETYPE:  A gametype was detected!  "$L.SupportedModes[j].default.acronym$", classname = "$L.SupportedModes[j]);
				// Store GameTypeDescriptions since I couldn't get it to properly store the GameInfo class
				GameTypeListBox.List.Add(L.SupportedModes[j].default.acronym,L.SupportedModes[j],string(L.SupportedModes[j]), GameTypeDescriptions.Length);
				GameTypeDescriptions[GameTypeDescriptions.Length] = L.SupportedModes[j].default.GameDescription;
			}
		}
	}
	GameTypeListBox.List.Sort();
}


function string getSelectedGameInfoName()
{
	return GameTypeListBox.List.GetExtra();
}

function OnStartServerClick(GUIComponent Sender)
{
	local string mapName;
	local string serverName, password;

	mapName = MapListBox.List.GetExtra();

	// Remember server name save it out
	serverName = ServerNameBox.GetText();
	class'GameReplicationInfo'.default.ServerName = ServerName;
	class'GameReplicationInfo'.static.StaticSaveConfig();

	// Setup join password
	password = PasswordBox.GetText();
	if (password != "")
	{
		if (!IsValidForURL(password))
		{
			GUIPage(MenuOwner.MenuOwner).OpenDlg(BadPassword, QBTN_Ok);
			return;
		}
		else
			GC.MPHostURL = GC.MPHostURL$"?GamePassword="$password;
	}

	// Setup gameinfo subclass
	GC.MPHostURL = GC.MPHostURL$"?game="$getSelectedGameInfoName();

	// Setup stat tracking (configured in advanced screen)
	GC.MPHostURL = GC.MPHostURL$"?GameStats="$ class'GameReplicationInfo'.default.bCollectStats;

	// Setup internet or LAN only (configured in advanced screen)
	if (!class'GameReplicationInfo'.default.bAdvertise)
		GC.MPHostURL = GC.MPHostURL$"?LAN";

	// Setup max players (configured in advanced screen)
	GC.MPHostURL = GC.MPHostURL $ "?MaxPlayers="$class'MultiplayerGameInfo'.default.MaxPlayers;

	// Setup session admin name and password, if applicable (configured in advanced screen)
	if ( class'GameReplicationInfo'.default.AdminName!="")
		GC.MPHostURL = GC.MPHostURL$"?AdminName="$class'GameReplicationInfo'.default.AdminName;
	if ( class'GameReplicationInfo'.default.AdminPass != "")
		GC.MPHostURL = GC.MPHostURL$"?AdminPassword="$class'GameReplicationInfo'.default.AdminPass;

	GC.CurrentMission = mapName;	
	GC.bDedicated = DedicatedButton.bChecked;
	GC.bTravelMission = false;

	// If it's a listen server then also fetch profile options
	if (!GC.bDedicated)
		GC.MPHostURL = GC.MPHostURL$"?listen?"$TribesGUIController(Controller).profileManager.GetURLOptions();

	TribesGUIController(Controller).GameStart();
}

function OnAdvancedClick(GUIComponent Sender)
{
	Controller.OpenMenu("TribesGui.TribesMPServerConfigMenu", "TribesMPServerConfigMenu");
}

function MapListOnChange(GUIComponent Sender)
{
	local LevelSummary L;

	currentMap = MapListBox.List.Get();
	L = LevelSummary(MapListBox.List.GetObject());

	if (L != None)
	{
		screenshotImage.Image = L.screenshot;
	}
	else
	{
		screenshotImage.Image = screenshotImage.default.Image;
	}
}

function GameTypeListOnChange(GUIComponent Sender)
{
	if (!bInitialized)
		return;

	currentGameType = GameTypeListBox.List.Get();

	GameTypeDescriptionLabel.Caption = GameTypeDescriptions[GameTypeListBox.List.GetExtraIntData()];

	if (currentGameType != "")
		LoadMapList();
}

function InternalOnActivate()
{
	// If coming back from the advanced server config menu, change the selection
	if (GC.advancedGameType != "")
	{
		GameTypeListBox.List.Find(GC.advancedGameType);
		GC.advancedGameType = "";
	}

	if (GC.advancedMap != "")
	{
		MapListBox.List.Find(GC.advancedMap);
		GC.advancedMap = "";
	}

	SetTimer(0.2, false);
}

function Timer()
{
	if (!bInitialized)
	{
		LoadLevelSummaries(fileList, summaryList);
		LoadGameTypes();
		bInitialized = true;
		GameTypeListBox.List.SetIndex(0);
		LoadMapList();
	}
}

defaultproperties
{
	OnActivate=InternalOnActivate
	bInitialized=false
	BadPassword="The password contains invalid characters. You cannot use spaces or puncuation in the server password."
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: st 16.4.2014 10:20:44.000 - Creation time: st 23.5.2018 00:10:48.627 - Created with UnCodeX