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

TribesGUI.TribesAdminLoginPopup


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
// ====================================================================
//  Class:  TribesGui.TribesAdminLoginPopup
//  Parent: TribesGUIPage
//
// ====================================================================

class TribesAdminLoginPopup extends TribesGuiPage;

var(TribesGui) private EditInline Config GUIButton	LoginButton "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 GUIEditBox			UsernameBox "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 GUICheckBoxButton	AutologinButton "A component of this page which has its behavior defined in the code for this page's class.";

var PlayerProfile p;

var() editconst noexport string CurrentIP, CurrentPort;

function InitComponent(GUIComponent MyOwner)
{
	Super.InitComponent(MyOwner);
    CancelButton.OnClick=InternalOnClick;
	LoginButton.OnClick=InternalOnClick;

	p = TribesGUIController(Controller).profileManager.GetActiveProfile();
}

function InternalOnShow()
{
	local string str, S, port;
	local int i;

	// Find port
	S = PlayerOwner().Level.GetAddressURL();
	i = InStr( S, ":" );
	port = Mid(S,i+1);

	str = PlayerOwner().GetServerNetworkAddress();

	if ( str != "" )
	{
		if ( !Div(str, ":", CurrentIP, CurrentPort) )
		{
			CurrentIP = str;
			CurrentPort = port;
		}
	}

	i = p.FindCredentials(CurrentIP, CurrentPort);
	if ( i != -1 && p.LoginHistory[i].bAutoLogin )
	{
		UsernameBox.SetText(p.LoginHistory[i].Username);
		PasswordBox.SetText(p.LoginHistory[i].Password);
	}
}

function InternalOnClick(GUIComponent Sender)
{
	switch (Sender)
	{
		case CancelButton:
            Controller.CloseMenu();
            break;

		case LoginButton:
			DoLogin();
			Controller.CloseMenu();
			break;
	}
}

function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
{
    if( bVisible && bActiveInput &&
        Key == EInputKey.IK_Tab && State == EInputAction.IST_Press )
    {
		// Manually toggle between edit boxes
		if (UsernameBox.MenuState==MSAT_Focused)
			PasswordBox.Focus();
		else
			Usernamebox.Focus();
		return true;
	}

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

function DoLogin()
{
	PlayerOwner().ConsoleCommand("adminlogin "$UsernameBox.GetText()@PasswordBox.GetText());
	if (AutologinButton.bChecked)
	{
		p.bStoreLogins = true;
		p.SaveCredentials(UsernameBox.GetText(), PasswordBox.GetText(), CurrentIP, CurrentPort, true);
	}
}


defaultproperties
{
	OnShow=InternalOnShow
    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.012 - Created with UnCodeX