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

TribesGUI.TribesIRCPanel


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
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
//====================================================================
//  Specialized utility panel for use on the IRC status page.
//  Contains combo boxes for servers & channels, buttons for join, leave, remove, etc.
//
//  Written by Ron Prestenback
//  (c) 2003, Epic Games, Inc.  All Rights Reserved
// ====================================================================
class TribesIRCPanel extends TribesGUIPanel;


var TribesIRCSystem          tp_System;

// Server/channel selection
var automated	moComboBox	co_Server, co_Channel;
var automated	GUIButton	b_Connect, b_RemServer, b_JoinChannel, b_RemChannel;

var GUIButton SizingButton;
var() globalconfig array<string> ServerHistory, ChannelHistory;

var localized string 			ConnectText;
var localized string 			DisconnectText;

var() noexport transient bool bDirty;

function InitComponent(GUIComponent MyOwner)
{
	local GUIComponent C;

	Super.InitComponent(MyOwner);

	for ( C = MenuOwner; C != None; C = C.MenuOwner )
	{
		if ( TribesIRCSystem(C) != None )
		{
			tp_System = TribesIRCSystem(C);
			break;
		}
	}

	Assert(tp_System != None);
	GetSizingButton();

	// Load server and channel history into combo's
	Log(ServerHistory.Length$" Servers "$ChannelHistory.Length$" Channels",'IRC');

	LoadServerHistory();
	LoadChannelHistory();

}

function LoadServerHistory()
{
	local int i;

	if ( ServerHistory.Length == 0 )
		ResetConfig("ServerHistory");

	co_Server.MyComboBox.List.Clear();
	for ( i = 0; i < ServerHistory.Length; i++ )
		co_Server.AddItem(ServerHistory[i]);
}

function LoadChannelHistory()
{
	local int i;

	if ( ChannelHistory.Length == 0 )
		ResetConfig("ChannelHistory");

	co_Channel.MyComboBox.List.Clear();
	for ( i = 0; i < ChannelHistory.Length; i++ )
		co_Channel.AddItem(ChannelHistory[i]);
}

function GetSizingButton()
{
	local int i;

	for ( i = 0; i < Components.Length; i++ )
	{
		if ( GUIButton(Components[i]) == None )
			continue;

		if ( SizingButton == None || Len(GUIButton(Components[i]).Caption) > Len(SizingButton.Caption) )
			SizingButton = GUIButton(Components[i]);
	}
}

function bool PositionButtons( Canvas C )
{
	// MJ:  We don't support any of this
	//local float X;
	//local float XL, YL;

	//SizingButton.Style.TextSize( C, SizingButton.MenuState, SizingButton.Caption, XL, YL, SizingButton.FontScale );

	//XL += 14;
	//X = b_Connect.ActualLeft();

	//b_Connect.WinWidth = b_Connect.RelativeWidth(XL);
	//b_JoinChannel.WinWidth = b_JoinChannel.RelativeWidth(XL);

	//b_RemServer.WinLeft = b_RemServer.RelativeLeft( X + XL + (XL * 0.1) );
	//b_RemServer.WinWidth = b_RemServer.RelativeWidth( XL );

	//b_RemChannel.WinLeft = b_RemChannel.RelativeLeft( X + XL + (XL * 0.1) );
	//b_RemChannel.WinWidth = b_RemChannel.RelativeWidth( XL );

	return false;
}

function InternalOnChange(GUIComponent Sender)
{
	if ( Sender == co_Server )
		UpdateConnectionStatus(IsCurrentServer(co_Server.GetText()));
}

function bool InternalOnClick(GUIComponent Sender)
{
	local string Str;

	switch ( Sender )
	{
	case b_Connect:
		if( IsCurrentServer(co_Server.GetText()) )
			tp_System.Disconnect();

		else
		{
			tp_System.Connect( co_Server.GetText() );
			if( tp_System.IsConnected() )
			{
				Str = co_Server.GetText();

				// Place server at the most recent position in history
				AddServerToHistory(str);
			}
		}
		break;

	case b_JoinChannel:
		if ( !tp_System.IsConnected() )
			return false;

		Str = co_Channel.GetText();
		if (Str != "")
		{
			tp_System.JoinChannel( Str );

			// place channel name at most recent position in history
			AddChannelToHistory(str);
		}
		break;

	case b_RemServer:
		RemoveServerFromHistory(co_Server.GetText());

		break;

	case b_RemChannel:
		RemoveChannelFromHistory(co_Channel.GetText());
		break;

	}

	return true;
}


function UpdateConnectionStatus( bool NowConnected )
{
	if( NowConnected )
		b_Connect.Caption = DisconnectText;
	else
		b_Connect.Caption = ConnectText;
}

function bool AddChannelToHistory( string NewChannelName, optional int Position )
{
	if ( NewChannelName == "" )
		return false;

	if ( Left(NewChannelName,1) != "#" )
		NewChannelName = "#" $ NewChannelName;

	RemoveChannelFromHistory(NewChannelName);
	if ( Position < 0 || Position >= ChannelHistory.Length )
		Position = ChannelHistory.Length;

	ChannelHistory.Insert(Position,1);
	ChannelHistory[Position] = NewChannelName;

	co_Channel.MyComboBox.List.Insert(Position,NewChannelName);
	co_Channel.Find(NewChannelName, false);

	bDirty = True;
	return true;
}

function bool RemoveChannelFromHistory( string ChannelName )
{
	local int i;

	if ( Left(ChannelName,1) != "#" )
		ChannelName = "#" $ ChannelName;

	i = FindChannelHistoryIndex(ChannelName);
	if ( i != -1 )
	{
		ChannelHistory.Remove(i,1);
		co_Channel.RemoveItem(i,1);
		bDirty = True;
		return true;
	}

	return false;
}

function bool AddServerToHistory( string NewServerName, optional int Position )
{
	if ( NewServerName == "" )
		return false;

	RemoveServerFromHistory(NewServerName);
	if ( Position < 0 || Position >= ServerHistory.Length )
		Position = ServerHistory.Length;

	ServerHistory.Insert(Position,1);
	ServerHistory[Position] = NewServerName;

	co_Server.MyComboBox.List.Insert(Position,NewServerName);
	co_Server.Find(NewServerName, false);

	bDirty = True;
	return true;
}

function bool RemoveServerFromHistory( string ServerName )
{
	local int i;

	if ( ServerName == "" )
		return false;

	i = FindServerHistoryIndex(ServerName);
	if ( i != -1 )
	{
		ServerHistory.Remove(i,1);
		co_Server.RemoveItem(i,1);
		bDirty = true;
		return true;
	}

	return false;
}

// =====================================================================================================================
//  Utility functions
// =====================================================================================================================
function int FindServerHistoryIndex( string ServerName )
{
	local int i;

	for(i=0; i<ServerHistory.Length; i++)
		if( ServerHistory[i] ~= ServerName )
			return i;

	return -1;
}

function int FindChannelHistoryIndex( string ChannelName )
{
	local int i;

	for(i=0; i<ChannelHistory.Length; i++)
		if( ChannelHistory[i] ~= ChannelName )
			return i;

	return -1;
}

function bool IsCurrentServer( string ServerAddress )
{
	if ( tp_System == None || !tp_System.IsConnected() ||
		 tp_System.Link == None || tp_System.Link.ServerAddress == "" ||
		 ServerAddress == "" )
		return False;

	return InStr(ServerAddress, tp_System.Link.ServerAddress) != -1;
}

event Free( optional bool bForce )
{
	Super.Free( bForce );
	if ( bDirty )
		SaveConfig();
}

DefaultProperties
{
	OnPreDraw=PositionButtons
	ServerHistory(0)="irc.enterthegame.com"
	ServerHistory(1)="irc.utchat.com"

	ChannelHistory(0)="#ut"

	ConnectText="CONNECT"
	DisconnectText="DISCONNECT"

	//Begin Object class=moComboBox Name=MyServerCombo
	//	Caption="Server"
	//	WinTop=0.102967
	//	WinLeft=0.150000
	//	WinWidth=0.400000
	//	WinHeight=0.3
	//	CaptionWidth=0.25
	//	TabOrder=0
	//	RenderWeight=3
	//	bHeightFromComponent=False
	//	bBoundToParent=True
	//	bScaleToParent=True
	//	OnChange=InternalOnChange
	//End Object

	//Begin Object class=moComboBox Name=MyChannelCombo
	//	Caption="Channel"
	//	bAutoSizeCaption=True
	//	WinTop=0.5
	//	WinLeft=0.15
	//	WinWidth=0.4
	//	WinHeight=0.3
	//	CaptionWidth=0.25
	//	TabOrder=1
	//	RenderWeight=3
	//	bHeightFromComponent=False
	//	bBoundToParent=True
	//	bScaleToParent=True
	//End Object

	//Begin Object Class=GUIButton Name=MyConnectButton
	//	Caption="CONNECT"
	//	WinWidth=0.2
	//	WinHeight=0.3
	//	WinLeft=0.56
	//	WinTop=0.1
	//	TabOrder=2
	//	RenderWeight=3
	//	bBoundToParent=True
	//	bScaleToParent=True
	//	OnClick=InternalOnClick
	//End Object

	//Begin Object Class=GUIButton Name=MyJoinChannelButton
	//	Caption="JOIN"
	//	WinWidth=0.2
	//	WinHeight=0.3
	//	WinLeft=0.56
	//	WinTop=0.5
	//	TabOrder=3
	//	RenderWeight=3
	//	bBoundToParent=True
	//	bScaleToParent=True
	//	OnClick=InternalOnClick
	//End Object

	//Begin Object Class=GUIButton Name=MyRemoveServerButton
	//	Caption="REMOVE"
	//	WinWidth=0.2
	//	WinHeight=0.3
	//	WinLeft=0.77
	//	WinTop=0.1
	//	TabOrder=4
	//	RenderWeight=3
	//	bBoundToParent=True
	//	bScaleToParent=True
	//	OnClick=InternalOnClick
	//End Object

	//Begin Object Class=GUIButton Name=MyRemoveChannelButton
	//	Caption="REMOVE"
	//	WinWidth=0.2
	//	WinHeight=0.3
	//	WinLeft=0.77
	//	WinTop=0.5
	//	TabOrder=5
	//	RenderWeight=3
	//	bBoundToParent=True
	//	bScaleToParent=True
	//	OnClick=InternalOnClick
	//End Object

	//co_Server=MyServerCombo
	//co_Channel=MyChannelCombo
	//b_Connect=MyConnectButton
	//b_RemServer=MyRemoveServerButton
	//b_JoinChannel=MyJoinChannelButton
	//b_RemChannel=MyRemoveChannelButton
}

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