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
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
//-----------------------------------------------------------
//
//-----------------------------------------------------------
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
		WinWidth=1.0
		WinHeight=1.0
		WinLeft=0.0
		Wintop=0.0
		LeftPadding=0
		RightPadding=0
		TopPadding=0
		BottomPadding=0
		bFillClient=true
        bBoundToParent=true
        bScaleToParent=true
        bNeverFocus=true
	End Object
	sb_Main=sbMain

	Begin Object Class=GUIScrollTextBox Name=lbChat
		WinWidth=1.000000
		WinHeight=0.558333
		WinLeft=0.000000
		WinTop=0.441667
		CharDelay=0.0025
		EOLDelay=0
		StyleName="NoBackground"
        bNoTeletype=true
        bNeverFocus=true
        TextAlign=TXTA_Left
        bBoundToParent=true
        bScaleToParent=true
        FontScale=FNS_Small
        Separator="þ"
	End Object
	lb_Chat=lbChat

	Begin Object Class=moEditBox Name=ebSend
		WinWidth=0.818909
		WinHeight=0.035416
		WinLeft=0.099584
		WinTop=0.943855
		bScaleToParent=True
		bBoundToParent=True
		Caption="Say: "
		Hint="Prefix a message with a dot (.) to send a team message or a slash (/) to send a command."
		ComponentWidth=-1
		CaptionWidth=0.1
		bAutoSizeCaption=True
		TabOrder=0
		LabelJustification=TXTA_Left
	End Object
	eb_Send=ebSend

	bRenderWorld=true
    bRequire640x480=false
    bAllowedAsLast=true
	DefaultWidth=0.779688
	DefaultHeight=0.847083
	DefaultLeft=0.110313
	DefaultTop=0.057916
	WinWidth=0.779688
	WinHeight=0.847083
	WinLeft=0.110313
	WinTop=0.057916

	bResizeWidthAllowed=False
	bResizeHeightAllowed=False
	bPersistent=True
 	WindowName="In-Game Chat"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 5.9.2006 22:28:52.000 - Creation time: Do 14.8.2014 09:58:53.423 - Created with UnCodeX