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

TribesGUI.TribesMPEscapeMenu


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

class TribesMPEscapeMenu extends TribesGUIPage
     ;

import enum EInputKey from Engine.Interactions;
import enum EInputAction from Engine.Interactions;

var(TribesGui) private EditInline Config GUIButton		    ResumeGameButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIButton		    DisconnectButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIButton		    OptionsButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUIButton		    QuitButton "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config GUITabControl		MyTabControl "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config TribesMPPlayersPanel		MPPlayersPanel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config TribesMPAdminPanel			MPAdminPanel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config TribesMPStatsPanel			MPStatsPanel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config TribesMPWeaponStatsPanel	MPWeaponStatsPanel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config TribesMPGameStatsPanel		MPGameStatsPanel "A component of this page which has its behavior defined in the code for this page's class.";
var(TribesGui) private EditInline Config TribesMPHintsPanel			MPHintsPanel "A component of this page which has its behavior defined in the code for this page's class.";
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 EmailLabel "A component of this page which has its behavior defined in the code for this page's class.";


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

    ResumeGameButton.OnClick=InternalOnClick;
    DisconnectButton.OnClick=InternalOnClick;
    OptionsButton.OnClick=InternalOnClick;
    QuitButton.OnClick=InternalOnClick;
	
	OnActivate=InternalOnActivate;
}

event HandleParameters(string Param1, string Param2, optional int param3)
{
	local int i;

	if (Param1 == "")
		return;

	// First param is name of panel to open
	for (i=0; i<MyTabControl.MyTabs.Length; i++)
	{
		if (MyTabControl.MyTabs[i].TabPanel.isA(Name(Param1)))
		{
			MyTabControl.OpenTab(MyTabControl.MyTabs[i].TabPanel);
			return;
		}
	}
}

function InternalOnActivate()
{
	// Hard code the hiding of admin panel, which is #5
	//if (PlayerOwner().PlayerReplicationInfo.bAdmin)
	//	MyTabControl.MyTabs[4].TabHeader.Show();
	//else
	//	MyTabControl.MyTabs[4].TabHeader.Hide();

	ServerNameLabel.Caption = PlayerOwner().GameReplicationInfo.ServerName;
	EmailLabel.Caption = PlayerOwner().GameReplicationinfo.AdminEmail;
}

function InternalOnClick(GUIComponent Sender)
{
	switch (Sender)
	{
		case DisconnectButton:	
            TribesGuiController(Controller).PlayerDisconnect();
			Controller.CloseAll();
			Controller.OpenMenu("TribesGui.TribesMultiplayerMenu", "TribesMultiplayerMenu");
			break;
		case ResumeGameButton:
			Controller.CloseAll();
			break;
		case OptionsButton:
			Controller.OpenMenu("TribesGui.TribesOptionsMenu", "TribesOptionsMenu", "TribesMPEscapeMenu");
			break;
		case QuitButton:
			Quit();
			break;
	}
}

function int getKeyCode(string key)
{
	local int i;

	// If it's a single character, assume we can just fetch the ascii representation
	if (Len(key) == 1)
		return Asc(Key);

	// Otherwise, do some hacky special processing to handle F-keys and TAB, which are the most likely
	// keys that useers will want to bind to the MP escape panels
	if (Left(key, 1) ~= "f")
	{
		i = int(Right(key, 1));
		return EInputKey.IK_F1 + i - 1;
	}

	if (key ~= "TAB")
		return EInputKey.IK_Tab;
}

function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
{
	local PlayerCharacterController pcc;
	local int gameStatsKey, myStatsKey, adminKey;

	pcc = PlayerCharacterController(PlayerOwner());
	gameStatsKey = getKeyCode(pcc.gameStatsKey);
	myStatsKey = getKeyCode(pcc.myStatsKey);
	adminKey = getKeyCode(pcc.adminKey);
    if( bVisible && bActiveInput && State == EInputAction.IST_Press )
    {
		switch(Key)
		{
			case EInputKey.IK_Escape:
					Controller.CloseAll();
					return true;

			// michaelj:  Moved closing to PCC so it's not hard-coded
			case gameStatsKey:
				if (MyTabControl.ActiveTab.TabPanel == MPPlayersPanel)
					Controller.CloseAll();
				else
					MyTabControl.OpenTab(MPPlayersPanel);
				return true;

			case myStatsKey:
				if (MyTabControl.ActiveTab.TabPanel == MPStatsPanel)
					Controller.CloseAll();
				else
					MyTabControl.OpenTab(MPStatsPanel);
				return true;

			case adminKey:
				if (MyTabControl.ActiveTab.TabPanel == MPAdminPanel)
					Controller.CloseAll();
				else
					MyTabControl.OpenTab(MPAdminPanel);
				return true;
		}

		//MyTabControl.OpenTab(MyTabControl.MyTabs[i].TabPanel);
    }

    return Super.InternalOnKeyEvent(Key, State, delta);
}

defaultproperties
{
	OnKeyEvent=InternalOnKeyEvent
}

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