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

GUI2K4.AdminPanelLogin


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
//==============================================================================
//  Created on: 11/12/2003
//  Default screen that appears until successfully logged in
//
//  Written by Ron Prestenback
//  © 2003, Epic Games, Inc. All Rights Reserved
//==============================================================================

class AdminPanelLogin extends AdminPanelBase
    config(LoginCache);

var() config bool bStoreLogins;
var() config array<AutoLoginInfo> LoginHistory;
var() localized string WaitingForLoginText, LoggedText;

var automated moEditBox  ed_LoginName, ed_LoginPassword;
var automated GUIButton  b_Login, b_Logout;
var automated GUILabel   l_Status;

var() editconst noexport string CurrentIP, CurrentPort;

function InitComponent( GUIController C, GUIComponent O )
{
    local PlayerController PC;
    local string str;
    local int i;

    Super.InitComponent(C, O);

    PC = PlayerOwner();
    str = PC.GetServerNetworkAddress();

    if ( str != "" )
    {
        if ( !Divide(str, ":", CurrentIP, CurrentPort) )
        {
            CurrentIP = str;
            CurrentPort = "7777";
        }
    }

    i = FindCredentials(CurrentIP, CurrentPort);
    if ( i != -1 )
    {
        ed_Loginname.SetText(LoginHistory[i].Username);
        ed_LoginPassword.SetText(LoginHistory[i].Password);

        if ( LoginHistory[i].bAutoLogin )
            InternalOnClick(b_Login);
    }
}

protected function UpdateStatus(string NewStatusMsg )
{
    l_Status.Caption = NewStatusMsg;
}

function bool InternalOnClick(GUIComponent Sender)
{
    local PlayerController PC;
    local string cmd, uname, upass;

    PC = PlayerOwner();
    if ( PC == None )
        return true;

    if ( Sender == b_Login )
    {
        cmd = "AdminLogin";
        uname = ed_LoginName.GetText();
        upass = ed_LoginPassword.GetText();

        UpdateStatus(WaitingForLoginText);
    }

    else if ( Sender == b_Logout )
        cmd = "AdminLogout";

    if ( uname != "" )
        cmd @= uname;

    if ( upass != "" )
        cmd @= upass;

    AdminCommand(cmd);
    return true;
}

function LoggedIn( string AdminName )
{
    DisableComponent(b_Login);
    DisableComponent(ed_LoginName);
    DisableComponent(ed_LoginPassword);

    EnableComponent(b_Logout);
    UpdateStatus(Repl(LoggedText, "%name%", AdminName));

    SaveCredentials();
}

function LoggedOut()
{
    DisableComponent(b_Logout);
    EnableComponent(b_Login);
    EnableComponent(ed_LoginName);
    EnableComponent(ed_LoginPassword);

    UpdateStatus("");
}

protected function int FindCredentials( coerce string IP, coerce string Port )
{
    local int i;

    for ( i = 0; i < LoginHistory.Length; i++ )
        if ( LoginHistory[i].IP == IP && LoginHistory[i].Port == Port )
            return i;

    return -1;
}

protected function SaveCredentials()
{
    local AutoLoginInfo NewInfo;
    local int i;

    if ( !bStoreLogins )
        return;

    NewInfo.UserName = ed_LoginName.GetText();
    NewInfo.Password = ed_LoginPassword.GetText();
    if ( NewInfo.Password == "" )
        return;

    NewInfo.IP = CurrentIP;
    NewInfo.Port = CurrentPort;

    i = FindCredentials(NewInfo.IP, NewInfo.Port);
    if ( i == -1 )
        i = LoginHistory.Length;

    LoginHistory[i] = NewInfo;
    SaveConfig();
}

defaultproperties
{
     WaitingForLoginText="Please wait while your login credentials are verified..."
     Begin Object Class=moEditBox Name=LoginNameEditbox
         LabelJustification=TXTA_Right
         CaptionWidth=0.200000
         Caption="Login Name: "
         OnCreateComponent=LoginNameEditbox.InternalOnCreateComponent
         Hint="Enter your admin username"
         WinTop=0.091667
         WinLeft=0.089063
         WinWidth=0.895312
         WinHeight=0.098438
         bBoundToParent=Wahr
         bScaleToParent=Wahr
     End Object
     ed_LoginName=moEditBox'GUI2K4.AdminPanelLogin.LoginNameEditbox'

     Begin Object Class=moEditBox Name=LoginPasswordEditBox
         bMaskText=Wahr
         LabelJustification=TXTA_Right
         CaptionWidth=0.200000
         Caption="Login Password: "
         OnCreateComponent=LoginPasswordEditBox.InternalOnCreateComponent
         Hint="Enter your admin password"
         WinTop=0.236667
         WinLeft=0.014062
         WinWidth=0.970312
         WinHeight=0.098437
         bBoundToParent=Wahr
         bScaleToParent=Wahr
     End Object
     ed_LoginPassword=moEditBox'GUI2K4.AdminPanelLogin.LoginPasswordEditBox'

     Begin Object Class=GUIButton Name=LoginButton
         Caption="LOGIN"
         WinTop=0.418750
         WinLeft=0.360938
         WinWidth=0.286607
         WinHeight=0.092188
         bBoundToParent=Wahr
         bScaleToParent=Wahr
         OnClick=AdminPanelLogin.InternalOnClick
         OnKeyEvent=LoginButton.InternalOnKeyEvent
     End Object
     b_Login=GUIButton'GUI2K4.AdminPanelLogin.LoginButton'

     Begin Object Class=GUIButton Name=LogoutButton
         Caption="LOGOUT"
         WinTop=0.418750
         WinLeft=0.360938
         WinWidth=0.286607
         WinHeight=0.092188
         bBoundToParent=Wahr
         bScaleToParent=Wahr
         OnClick=AdminPanelLogin.InternalOnClick
         OnKeyEvent=LogoutButton.InternalOnKeyEvent
     End Object
     b_Logout=GUIButton'GUI2K4.AdminPanelLogin.LogoutButton'

     Begin Object Class=GUILabel Name=StatusLabel
         TextAlign=TXTA_Center
         bMultiLine=Wahr
         FontScale=FNS_Large
         StyleName="TextLabel"
         WinTop=0.585417
         WinLeft=0.005312
         WinWidth=0.992189
         WinHeight=0.407813
     End Object
     l_Status=GUILabel'GUI2K4.AdminPanelLogin.StatusLabel'

     PanelCaption="Login"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fr 30.3.2007 08:44:00.000 - Creation time: Mo 16.4.2007 11:20:44.093 - Created with UnCodeX