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

TribesGUI.TribesMPServerPropertiesMenu


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
// ====================================================================
//  Class:  TribesGui.TribesMPServerPropertiesMenu
//
//  Menu to load map from entry screen.
// ====================================================================

class TribesMPServerPropertiesMenu extends TribesGUIPage
     ;
var(TribesGui) private EditInline Config GUILabel			ServerNameLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			ServerIPAddressLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			ServerEmailLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			MapNameLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			GameTypeLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			TimeLeftLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			TeamOneNameLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			TeamTwoNameLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			TeamOneScoreLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			TeamTwoScoreLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			VersionLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUILabel			PingLabel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIButton		    CancelButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIButton		    ConnectButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIButton		    RefreshButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIMultiColumnListBox    TeamOneBox "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIMultiColumnListBox    TeamTwoBox "A component of this page which has its behavior defined in the code for this page's class.";

var TribesGameSpyManager gm;
var int currServerId;

var String currIpAddress;
var String currPort;

function InitComponent(GUIComponent MyOwner)
{
	Super.InitComponent(MyOwner);

    CancelButton.OnClick=OnCancelClicked;
    ConnectButton.OnClick=OnConnectClicked;
    RefreshButton.OnClick=OnRefreshClicked;

	TeamOneBox.GetColumn( "Score" ).bSortForward = false;
	TeamTwoBox.GetColumn( "Score" ).bSortForward = false;
}

function HandleParameters(string Param1, string Param2, optional int param3)
{
	currServerId = param3;
	gm.UpdateServer(currServerId, false);
	RefreshData();
}

function InternalOnActivate()
{
	gm = TribesGameSpyManager(PlayerOwner().Level.GetGameSpyManager());

	assert(gm != None);

	gm.CancelUpdate();

	gm.OnServerDataUpdate = ReceiveServerData;
}

function ReceiveServerData(GameSpyServerData gssd)
{
	local int i;
	local int ping;

	assert(gssd.gsServerId == currServerId);

	currIpAddress = gssd.gsIpAddress;
	currPort = gssd.gsHostPort;

	ServerNameLabel.SetCaption(gssd.gsHostName);
	ServerIPAddressLabel.SetCaption(gssd.gsIpAddress$":"$gssd.gsHostPort);
	VersionLabel.SetCaption(gssd.gsGameVer);
	ping = gssd.gsPing;
	if (ping > 999)
		ping = 999;
	PingLabel.SetCaption(String(ping));
	ServerEmailLabel.SetCaption(gssd.gsAdminEmail);
	MapNameLabel.SetCaption(gssd.gsMapName);
	GameTypeLabel.SetCaption(gssd.gsGameType);
	//TimeLeftLabel.SetCaption();
	TeamOneNameLabel.SetCaption(gssd.gsTeamOneName);
	TeamTwoNameLabel.SetCaption(gssd.gsTeamTwoName);
	TeamOneScoreLabel.SetCaption(gssd.gsTeamOneScore);
	TeamTwoScoreLabel.SetCaption(gssd.gsTeamTwoScore);
	PingLabel.SetCaption(string(gssd.gsPing));

	TeamOneBox.Clear();
	TeamTwoBox.Clear();

	for (i = 0; i < gssd.gsPlayerNames.Length; ++i)
	{
		if (gssd.gsPlayerTeams[i] == gssd.gsTeamOneName)
			AddNewRowToList(TeamOneBox, gssd.gsPlayerNames[i], gssd.gsPlayerPings[i], gssd.gsPlayerScores[i]);
		else if (gssd.gsPlayerTeams[i] == gssd.gsTeamTwoName)
			AddNewRowToList(TeamTwoBox, gssd.gsPlayerNames[i], gssd.gsPlayerPings[i], gssd.gsPlayerScores[i]);
		else
			Log("Received player data with an invalid team name");
	}

	TeamOneBox.Sort("Score");
	TeamTwoBox.Sort("Score");
}

function AddNewRowToList(GUIMultiColumnListBox list, String name, String ping, String score)
{
	list.AddNewRowElement("Name",, name);
	list.AddNewRowElement("Ping",, ping, int(ping));
	list.AddNewRowElement("Score",, score, int(score));

	list.PopulateRow();
}

function RefreshData()
{
	gm.UpdateServer(currServerId, true);
}

function OnCancelClicked(GUIComponent Sender)
{
	Controller.CloseMenu();
}

function OnConnectClicked(GUIComponent Sender)
{
	Controller.CloseMenu();
	OnConnect(currIpAddress, currPort);
}

delegate OnConnect(String ipAddress, String Port);

function OnRefreshClicked(GUIComponent Sender)
{
	RefreshData();
}

defaultproperties
{
	OnActivate=InternalOnActivate
	bPersistent=false
}

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.691 - Created with UnCodeX