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

GUI2K4.UT2K4InGameChat


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
//-----------------------------------------------------------
//
//-----------------------------------------------------------
class UT2K4InGameChat extends FloatingWindow;

var automated GUISectionBackground sB_Main;
var automated moEditBox eb_Send;
var automated GUIScrollTextBox lb_Chat;
var() int OldCMC;

var() editinline array<byte> CloseKey;
var() editinlinenotify color TextColor[3];

function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
    local int i;
    local PlayerController PC;
    local ExtendedConsole MyConsole;

    super.InitComponent(MyController,MyOwner);

    PC = PlayerOwner();
    TextColor[0] = class'SayMessagePlus'.default.RedTeamColor;
    TextColor[1] = class'SayMessagePlus'.default.BlueTeamColor;
    TextColor[2] = class'SayMessagePlus'.default.DrawColor;

    sb_Main.ManageComponent(lb_Chat);
    eb_Send.MyEditBox.OnKeyEvent = InternalOnKeyEvent;
    lb_Chat.MyScrollText.bNeverFocus=true;

    MyConsole = ExtendedConsole(PC.Player.Console);
    if (MyConsole==None)
        return;

    MyConsole.OnChat = HandleChat;
    for (i=0;i<MyConsole.ChatMessages.Length;i++)
    {
        if ( !MyConsole.bTeamChatOnly ||
              PC.PlayerReplicationInfo == None ||
              PC.PlayerReplicationInfo.Team == None ||
              MyConsole.ChatMessages[i].Team == PC.PlayerReplicationInfo.Team.TeamIndex )
            HandleChat(MyConsole.ChatMessages[i].Message, MyConsole.ChatMessages[i].Team);
    }
}

event Opened(GUIComponent Sender)
{
    local int i;
    local string KeyName;
    local array<string> KeyNames;
    local PlayerController PC;

    Super.Opened(Sender);
    PC = PlayerOwner();

    CloseKey.Remove(0, CloseKey.Length);
    KeyName = PC.ConsoleCommand("BINDINGTOKEY InGameChat");
    Split(KeyName, ",", KeyNames);
    for ( i = 0; i < KeyNames.Length; i++ )
        CloseKey[CloseKey.Length] = byte(PC.ConsoleCommand("KEYNUMBER"@KeyNames[i]));

    OldCMC = PC.myHud.ConsoleMessageCount;
    PC.myHUD.ConsoleMessageCount = 0;


    // Advance the cursor position to the end of the text
    lb_Chat.MyScrollText.End();

    FocusFirst(None);
}

function Closed(GUIComponent Sender, bool bCancelled)
{
    Super.Closed(Sender, bCancelled);
    PlayerOwner().MyHud.ConsoleMessageCount = OldCMC;
}

function HandleChat(string Msg, int TeamIndex)
{
    local int i;
    local string str;

    i = InStr( Msg, ":" );
    if ( TeamIndex < 2 && i != -1 )
    {
        str = MakeColorCode(TextColor[TeamIndex]) $ Left(Msg, i) $
              MakeColorCode(TextColor[2]) $ ":" $ Mid(Msg, i+1);
    }
    else str = MakeColorCode(TextColor[2]) $ Msg;
    lb_chat.AddText( str );
}

function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
{
    local string cmd;
    local int i;

    if ( state == 1 )
    {
        for ( i = 0; i < CloseKey.Length; i++ )
            if ( Key == CloseKey[i] )
            {
                Controller.CloseMenu(false);
                return True;
            }
    }

    if ( state == 3 )
    {
        if ( Key == 0x0D )
        {
            cmd = eb_Send.GetText();
            if ( cmd == "" )
                return True;

            if ( Left(cmd,1)=="/" )
                cmd = Mid(cmd,1);
            else if ( Left(cmd,1)=="." )
                cmd = "teamsay" @ Mid( cmd, 1 );
            else
                cmd = "say" @ cmd;

            PlayerOwner().ConsoleCommand(cmd);
            eb_Send.SetText("");
            return true;
        }
    }

    return eb_Send.MyEditBox.InternalOnKeyEvent(key,state,delta);
}

function InternalOnCreateComponent( GUIComponent NewComp, GUIComponent Sender )
{
    if ( NewComp != eb_Send )
        NewComp.bNeverFocus = True;

    Super.InternalOnCreateComponent(NewComp,Sender);
}

defaultproperties
{
     Begin Object Class=AltSectionBackground Name=sbMain
         bFillClient=Wahr
         LeftPadding=0.000000
         RightPadding=0.000000
         WinHeight=1.000000
         bBoundToParent=Wahr
         bScaleToParent=Wahr
         bNeverFocus=Wahr
         OnPreDraw=sbMain.InternalPreDraw
     End Object
     sb_Main=AltSectionBackground'GUI2K4.UT2K4InGameChat.sbMain'

     Begin Object Class=moEditBox Name=ebSend
         CaptionWidth=0.100000
         Caption="Say: "
         OnCreateComponent=ebSend.InternalOnCreateComponent
         Hint="Prefix a message with a dot (.) to send a team message or a slash (/) to send a command."
         WinTop=0.943855
         WinLeft=0.099584
         WinWidth=0.818909
         WinHeight=0.035416
         TabOrder=0
         bBoundToParent=Wahr
         bScaleToParent=Wahr
     End Object
     eb_Send=moEditBox'GUI2K4.UT2K4InGameChat.ebSend'

     Begin Object Class=GUIScrollTextBox Name=lbChat
         bNoTeletype=Wahr
         CharDelay=0.002500
         EOLDelay=0.000000
         Separator="þ"
         OnCreateComponent=lbChat.InternalOnCreateComponent
         FontScale=FNS_Small
         WinTop=0.441667
         WinHeight=0.558333
         bBoundToParent=Wahr
         bScaleToParent=Wahr
         bNeverFocus=Wahr
     End Object
     lb_Chat=GUIScrollTextBox'GUI2K4.UT2K4InGameChat.lbChat'

     WindowName="In-Game Chat"
     bResizeWidthAllowed=Falsch
     bResizeHeightAllowed=Falsch
     DefaultLeft=0.110313
     DefaultTop=0.057916
     DefaultWidth=0.779688
     DefaultHeight=0.847083
     bPersistent=Wahr
     bAllowedAsLast=Wahr
     WinTop=0.057916
     WinLeft=0.110313
     WinWidth=0.779688
     WinHeight=0.847083
}

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:55.921 - Created with UnCodeX