UBrowser
Class UBrowserIRCSetupClient

source: e:\games\UnrealTournament\UBrowser\Classes\UBrowserIRCSetupClient.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowClientWindow
            |
            +--UWindow.UWindowDialogClientWindow
               |
               +--UBrowser.UBrowserIRCSetupClient
Direct Known Subclasses:None

class UBrowserIRCSetupClient
extends UWindow.UWindowDialogClientWindow


Variables
 UWindowComboControl ChannelCombo
 string ChannelHelp
 string ChannelText
 UWindowMessageBox ConfirmJoin
 UWindowSmallButton ConnectButton
 string ConnectHelp
 string ConnectText
 string DisconnectHelp
 string DisconnectText
 string IRCChannelHistory[10]
 string IRCServerHistory[10]
 UWindowComboControl ServerCombo
 string ServerHelp
 string ServerText
 UBrowserIRCSystemPage SystemPage
 string WarningText
 string WarningTitle
 bool bHasReadWarning


Function Summary
 void BeforePaint(Canvas C, float X, float Y)
 void Created()
 void DoJoin()
 void MessageBoxDone(UWindowMessageBox W, MessageBoxResult Result)
 void NewIRCServer(string S)
 void Notify(UWindowDialogControl C, byte E)
 void Paint(Canvas C, float X, float Y)
 void SaveChannelCombo()
 void SaveServerCombo()



Source Code


00001	class UBrowserIRCSetupClient expands UWindowDialogClientWindow;
00002	
00003	var UWindowComboControl ServerCombo;
00004	var UWindowComboControl ChannelCombo;
00005	var UWindowSmallButton ConnectButton;
00006	
00007	var config string		IRCServerHistory[10];
00008	var config string		IRCChannelHistory[10];
00009	var config bool			bHasReadWarning;
00010	
00011	var localized string	ServerText;
00012	var localized string	ChannelText;
00013	var localized string	ServerHelp;
00014	var localized string	ChannelHelp;
00015	
00016	var localized string	ConnectText;
00017	var localized string	DisconnectText;
00018	var localized string	ConnectHelp;
00019	var localized string	DisconnectHelp;
00020	
00021	var localized string	WarningText;
00022	var localized string	WarningTitle;
00023	
00024	var UWindowMessageBox ConfirmJoin;
00025	var UBrowserIRCSystemPage SystemPage;
00026	
00027	function Created()
00028	{
00029		local Color TC;
00030		local int i;
00031	
00032		Super.Created();
00033	
00034		SystemPage = UBrowserIRCSystemPage(OwnerWindow);
00035	
00036		ServerCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', 10, 5, 250, 1));
00037		ServerCombo.EditBoxWidth = 160;
00038		ServerCombo.SetText(ServerText);
00039		ServerCombo.SetHelpText(ServerHelp);
00040		ServerCombo.SetFont(F_Normal);
00041		ServerCombo.SetEditable(True);
00042		for (i=0; i<10; i++)
00043			if (IRCServerHistory[i] != "")
00044				ServerCombo.AddItem(IRCServerHistory[i]);
00045	
00046		TC.R = 255;
00047		TC.G = 255;
00048		TC.B = 255;
00049		ServerCombo.SetTextColor(TC);
00050		ServerCombo.SetSelectedIndex(0);
00051	
00052		ChannelCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', 10, 25, 180, 1));
00053		ChannelCombo.EditBoxWidth = 90;
00054		ChannelCombo.SetText(ChannelText);
00055		ChannelCombo.SetHelpText(ChannelHelp);
00056		ChannelCombo.SetFont(F_Normal);
00057		ChannelCombo.SetEditable(True);
00058		for (i=0; i<10; i++)
00059			if (IRCChannelHistory[i] != "")
00060				ChannelCombo.AddItem(IRCChannelHistory[i]);
00061		ChannelCombo.SetSelectedIndex(0);
00062		ChannelCombo.SetTextColor(TC);
00063	
00064		ConnectButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', 196, 26, 64, 16));
00065		ConnectButton.bIgnoreLDoubleclick = True;
00066	}
00067	
00068	function BeforePaint(Canvas C, float X, float Y)
00069	{
00070		Super.BeforePaint(C, X, Y);
00071	
00072		if(SystemPage.bConnected)
00073		{
00074			ConnectButton.SetText(DisconnectText);
00075			ConnectButton.SetHelpText(DisconnectHelp);
00076		}
00077		else
00078		{
00079			ConnectButton.SetText(ConnectText);
00080			ConnectButton.SetHelpText(ConnectHelp);
00081		}
00082	
00083		ConnectButton.AutoWidth(C);
00084	
00085	}
00086	
00087	function Paint(Canvas C, float X, float Y)
00088	{
00089		DrawStretchedTexture(C, 0, 0, WinWidth, WinHeight, Texture'BlackTexture');
00090	}
00091	
00092	function DoJoin()
00093	{
00094		SystemPage.Server = ServerCombo.GetValue();
00095		SystemPage.DefaultChannel = ChannelCombo.GetValue();
00096		SystemPage.Connect();
00097	
00098		SaveServerCombo();
00099		SaveChannelCombo();
00100		SaveConfig();
00101	}
00102	
00103	function MessageBoxDone(UWindowMessageBox W, MessageBoxResult Result)
00104	{
00105		if(W == ConfirmJoin && Result == MR_Yes)
00106		{
00107			bHasReadWarning = True;		
00108			DoJoin();
00109		}
00110	}
00111	
00112	function Notify(UWindowDialogControl C, byte E)
00113	{
00114		Super.Notify(C, E);
00115	
00116		if(C == ConnectButton && E == DE_Click)
00117		{
00118			if(SystemPage.bConnected)
00119				SystemPage.Disconnect();
00120			else
00121			{
00122				if(bHasReadWarning)
00123					DoJoin();
00124				else
00125					ConfirmJoin = MessageBox(WarningTitle, WarningText, MB_YesNo, MR_No);
00126			}
00127		}
00128	
00129		if(C == ChannelCombo && E == DE_EnterPressed)
00130		{
00131			SystemPage.JoinChannel(ChannelCombo.GetValue());
00132			SaveChannelCombo();
00133			SaveConfig();
00134		}
00135	}
00136	
00137	function NewIRCServer(string S)
00138	{
00139		if(ServerCombo.List.Items.Count() == 1 && ServerCombo.GetValue() != S)
00140		{
00141			Log("Received new IRC server from UpdateServer: "$S);
00142			ServerCombo.Clear();
00143			ServerCombo.AddItem(S);
00144			ServerCombo.SetSelectedIndex(0);
00145			SaveServerCombo();
00146			SaveConfig();
00147		}
00148	}
00149	
00150	function SaveServerCombo()
00151	{
00152		local UWindowComboListItem Item;
00153		local int i;
00154	
00155		ServerCombo.RemoveItem(ServerCombo.FindItemIndex(ServerCombo.GetValue()));
00156		ServerCombo.InsertItem(ServerCombo.GetValue());
00157		while(ServerCombo.List.Items.Count() > 10)
00158			ServerCombo.List.Items.Last.Remove();
00159	
00160		Item = UWindowComboListItem(ServerCombo.List.Items.Next);
00161		for (i=0; i<10; i++)
00162		{
00163			if(Item != None)
00164			{
00165				IRCServerHistory[i] = Item.Value;
00166				Item = UWindowComboListItem(Item.Next);
00167			}
00168			else
00169				IRCServerHistory[i] = "";
00170		}			
00171	}
00172	
00173	function SaveChannelCombo()
00174	{
00175		local UWindowComboListItem Item;
00176		local int i;
00177	
00178		ChannelCombo.RemoveItem(ChannelCombo.FindItemIndex(ChannelCombo.GetValue()));
00179		ChannelCombo.InsertItem(ChannelCombo.GetValue());
00180		while(ChannelCombo.List.Items.Count() > 10)
00181			ChannelCombo.List.Items.Last.Remove();
00182	
00183		Item = UWindowComboListItem(ChannelCombo.List.Items.Next);
00184		for (i=0; i<10; i++)
00185		{
00186			if(Item != None)
00187			{
00188				IRCChannelHistory[i] = Item.Value;
00189				Item = UWindowComboListItem(Item.Next);
00190			}
00191			else
00192				IRCChannelHistory[i] = "";
00193		}			
00194	}
00195	
00196	defaultproperties
00197	{
00198	     IRCServerHistory(0)="irc.gameslink.net"
00199	     IRCChannelHistory(0)="#utgames"
00200	     IRCChannelHistory(1)="#utchat"
00201	     IRCChannelHistory(2)="#utmods"
00202	     IRCChannelHistory(3)="#utlevels"
00203	     IRCChannelHistory(4)="#uthelp"
00204	     ServerText="IRC Server"
00205	     ChannelText="Default Channel"
00206	     ServerHelp="Choose an IRC server from the list or type in your own IRC server name or IP address."
00207	     ChannelHelp="Choose a default channel to join once the server has connected, or type in your own channel name."
00208	     ConnectText="Connect"
00209	     DisconnectText="Logoff"
00210	     ConnectHelp="Connect to the IRC chat server."
00211	     DisconnectHelp="Disconnect from the IRC chat server."
00212	     WarningText="The Chat facility will connect you to the Internet Relay Chat (IRC) network.\n\nEpic Games is not responsible for the content of any channels in IRC. You enter these channels at your own risk.\n\nAre you sure you still want to connect?"
00213	     WarningTitle="Warning"
00214	}

End Source Code