UBrowser
Class UBrowserIRCSystemPage

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

class UBrowserIRCSystemPage
extends UBrowser.UBrowserIRCPageBase


Variables
 string ByText
 string DefaultChannel
 string FullName
 string IsAwayText
 string KickedFromText
 UBrowserIRCLink Link
 string NickName
 string NotInAChannelText
 string OldPlayerName
 UWindowPageControl PageParent
 string Server
 UBrowserIRCSetupClient SetupClient
 UWindowVSplitter Splitter
 string UserIdent
 bool bAway
 bool bConnected


Function Summary
 void BeforePaint(Canvas C, float X, float Y)
 void CTCP(string Channel, string Nick, string Message)
 void ChangeMode(string Channel, string Nick, string Mode)
 void ChangeOp(string Channel, string Nick, bool bOp)
 void ChangeVoice(string Channel, string Nick, bool bVoice)
 void ChangedNick(string OldNick, string NewNick)
 void ChannelAction(string Channel, string Nick, string Text)
 void ChannelText(string Channel, string Nick, string Text)
 void CheckAway()
 void Connect()
 UBrowserIRCPrivPage CreatePrivChannel(string Nick)
 void Created()
 void Disconnect()
 UBrowserIRCChannelPage FindChannelWindow(string Channel)
 UBrowserIRCPrivPage FindPrivateWindow(string Nick)
 void IRCClosed()
 void IRCVisible()
 void IsAway(string Nick, string Message)
 void JoinChannel(string ChannelName)
 void JoinedChannel(string Channel, optional string)
 void KickUser(string Channel, string KickedNick, string Kicker, string Reason)
 void NotifyAfterLevelChange()
 void NotifyQuitUnreal()
 void PartChannel(string ChannelName)
 void PartedChannel(string Channel, optional string)
 void PrivateAction(string Nick, string Text)
 void PrivateText(string Nick, string Text)
 void ProcessInput(string Text)
 void SystemText(string Text)
 void Tick(float Delta)
 void UserInChannel(string Channel, string Nick)
 void UserNotice(string Nick, string Text)
 void UserQuit(string Nick, string Reason)



Source Code


00001	class UBrowserIRCSystemPage expands UBrowserIRCPageBase;
00002	
00003	var UBrowserIRCLink Link;
00004	var UWindowPageControl PageParent;
00005	
00006	var string	Server;
00007	var string DefaultChannel;
00008	
00009	var config string	NickName;
00010	var config string	FullName;
00011	var config string	OldPlayerName;
00012	var config string	UserIdent;
00013	
00014	var UWindowVSplitter Splitter;
00015	var UBrowserIRCSetupClient SetupClient;
00016	
00017	var bool bConnected;
00018	var bool bAway;
00019	
00020	var localized string NotInAChannelText;
00021	var localized string KickedFromText;
00022	var localized string ByText;
00023	var localized string IsAwayText;
00024	
00025	function Created()
00026	{
00027		Super.Created();
00028	
00029		Splitter = UWindowVSplitter(CreateWindow(class'UWindowVSplitter', 0, 0, WinWidth, WinHeight));
00030		SetupClient = UBrowserIRCSetupClient(Splitter.CreateWindow(class'UBrowserIRCSetupClient', 0, 0, WinWidth, WinHeight, Self));
00031	
00032		TextArea.SetParent(Splitter);
00033		Splitter.TopClientWindow = SetupClient;
00034		Splitter.BottomClientWindow = TextArea;
00035		Splitter.SplitPos = 45;
00036		Splitter.MaxSplitPos = 45;
00037		Splitter.MinWinHeight = 0;
00038		Splitter.bSizable = True;
00039		Splitter.bBottomGrow = True;
00040	
00041		Setup();
00042	}
00043	
00044	function BeforePaint(Canvas C, float X, float Y)
00045	{
00046		Super.BeforePaint(C, X, Y);
00047	
00048		Splitter.SetSize(WinWidth, WinHeight - EditControl.WinHeight);
00049	}
00050	
00051	function ProcessInput(string Text)
00052	{
00053		if(Left(Text, 1) != "/")
00054			SystemText("*** "$NotInAChannelText);
00055		else
00056			Link.SendCommandText(Mid(Text, 1));
00057	}
00058	
00059	function UBrowserIRCChannelPage FindChannelWindow(string Channel)
00060	{
00061		local UWindowPageControlPage P;
00062		local UBrowserIRCChannelPage Chan;
00063	
00064		for(P = PageParent.FirstPage(); P != None; P = P.NextPage())
00065		{
00066			Chan = UBrowserIRCChannelPage(P.Page);
00067			if(Chan != None && (Chan.ChannelName ~= Channel))
00068				return Chan;
00069		}
00070	
00071		return None;
00072	}
00073	
00074	function UBrowserIRCPrivPage FindPrivateWindow(string Nick)
00075	{
00076		local UWindowPageControlPage P;
00077		local UBrowserIRCPrivPage Priv;
00078	
00079		for(P = PageParent.FirstPage(); P != None; P = P.NextPage())
00080		{
00081			Priv = UBrowserIRCPrivPage(P.Page);
00082			if(Priv != None && (Priv.PrivNick ~= Nick))
00083				return Priv;
00084		}
00085	
00086		return CreatePrivChannel(Nick);
00087	}
00088	
00089	function Connect()
00090	{
00091		local int i;
00092		if(Link != None)
00093			Disconnect();
00094	
00095		if(GetPlayerOwner().PlayerReplicationInfo.PlayerName != OldPlayerName)
00096		{
00097			NickName = GetPlayerOwner().PlayerReplicationInfo.PlayerName;
00098			OldPlayerName = NickName;
00099			if(FullName == "")
00100				FullName = NickName;
00101			SaveConfig();
00102		}
00103	
00104		if(UserIdent == "")
00105		{
00106			UserIdent = "u";
00107			for(i=0;i<7;i++)
00108				UserIdent = UserIdent $ Chr((Rand(10)+48));
00109	
00110			Log("Created new UserIdent: "$UserIdent);
00111			SaveConfig();
00112		}
00113	
00114		Link = GetPlayerOwner().GetEntryLevel().Spawn(class'UBrowserIRCLink');
00115		Link.Connect(Self, Server, NickName, UserIdent, FullName, DefaultChannel);
00116		bConnected = True;
00117	}
00118	
00119	function JoinChannel(string ChannelName)
00120	{
00121		local UBrowserIRCChannelPage P;
00122	
00123		P = FindChannelWindow(ChannelName);
00124		if(P == None)
00125			Link.JoinChannel(ChannelName);
00126		else
00127			PageParent.GotoTab(P.OwnerTab, True);
00128	}
00129	
00130	function PartChannel(string ChannelName)
00131	{
00132		local UBrowserIRCChannelPage P;
00133	
00134		P = FindChannelWindow(ChannelName);
00135		if(P != None)
00136			Link.PartChannel(ChannelName);
00137	}
00138	
00139	function Disconnect()
00140	{
00141		local UWindowPageControlPage P, Next;
00142	
00143		if(Link != None)
00144		{
00145			// don't localize - sent to other clients
00146			Link.DisconnectReason = "Disconnected";
00147			Link.DestroyLink();
00148		}
00149		Link = None;
00150		
00151		P = PageParent.FirstPage();
00152		while( P != None )
00153		{
00154			Next = P.NextPage();
00155	
00156			if(P.Page != Self)
00157				PageParent.DeletePage(P);
00158	
00159			P = Next;
00160		}
00161	
00162		SystemText( "Server disconnected" );
00163		bConnected = False;
00164	}
00165	
00166	function NotifyQuitUnreal()
00167	{
00168		Super.NotifyQuitUnreal();
00169	
00170		if(Link != None)
00171		{
00172			// don't localize - sent to other clients
00173			Link.DisconnectReason = "Exit Game";
00174			Link.DestroyLink();
00175		}
00176	}
00177	
00178	function SystemText(string Text)
00179	{
00180		// FIXME!! should do something better with this
00181	
00182		if(Text != "You have been marked as being away" &&
00183	       Text != "You are no longer marked as being away")
00184				TextArea.AddText(Text);
00185	}
00186	
00187	function ChannelText(string Channel, string Nick, string Text)
00188	{
00189		local UBrowserIRCChannelPage P;
00190	
00191		P = FindChannelWindow(Channel);
00192		if(P != None)
00193			P.ChannelText(Nick, Text);
00194	}
00195	
00196	function PrivateText(string Nick, string Text)
00197	{
00198		FindPrivateWindow(Nick).PrivateText(Nick, Text);
00199	}
00200	
00201	function UBrowserIRCPrivPage CreatePrivChannel(string Nick)
00202	{
00203		local UBrowserIRCPrivPage P;
00204	
00205		P = UBrowserIRCPrivPage(PageParent.AddPage(Nick, class'UBrowserIRCPrivPage').Page);
00206		P.SystemPage = Self;
00207		P.PrivNick = Nick;
00208		P.Setup();
00209	
00210		return P;
00211	}
00212	
00213	function ChannelAction(string Channel, string Nick, string Text)
00214	{
00215		local UBrowserIRCChannelPage P;
00216	
00217		P = FindChannelWindow(Channel);
00218		if(P != None)
00219			P.ChannelAction(Nick, Text);
00220	}
00221	
00222	function PrivateAction(string Nick, string Text)
00223	{
00224		FindPrivateWindow(Nick).PrivateAction(Nick, Text);
00225	}
00226	
00227	function JoinedChannel(string Channel, optional string Nick)
00228	{
00229		local UBrowserIRCChannelPage P;
00230		local UBrowserIRCChannelPage W;
00231		local UWindowPageControlPage NewPage;
00232	
00233		if(Nick == "")
00234		{
00235			NewPage = PageParent.AddPage(Channel, class'UBrowserIRCChannelPage');
00236			P = UBrowserIRCChannelPage(NewPage.Page);
00237			P.SystemPage = Self;
00238			P.ChannelName = Channel;
00239			P.Setup();
00240			PageParent.GotoTab(NewPage, True);
00241		}
00242	
00243		if(Nick == "")
00244			Nick = NickName;
00245	
00246		W = FindChannelWindow(Channel);
00247		if(W != None)
00248			W.JoinedChannel(Nick);
00249	}
00250	
00251	function KickUser(string Channel, string KickedNick, string Kicker, string Reason)
00252	{
00253		local UWindowPageControlPage P;
00254		local UBrowserIRCChannelPage W;
00255	
00256		W = FindChannelWindow(Channel);
00257	
00258		if(KickedNick == NickName)
00259		{
00260			P = PageParent.GetPage(Channel);
00261			if(P != None)
00262				PageParent.DeletePage(P);
00263			SystemText("*** "$KickedFromText@Channel@ByText@Kicker$" ("$Reason$")");
00264		}
00265		else
00266		{
00267			if(W != None)
00268				W.KickUser(KickedNick, Kicker, Reason);
00269		}
00270	}
00271	
00272	function UserInChannel(string Channel, string Nick)
00273	{
00274		local UBrowserIRCChannelPage W;
00275		W = FindChannelWindow(Channel);
00276		if(W != None)
00277			W.UserInChannel(Nick);
00278	}
00279	
00280	function PartedChannel(string Channel, optional string Nick)
00281	{
00282		local UWindowPageControlPage P;
00283		local UBrowserIRCChannelPage W;
00284	
00285		W = FindChannelWindow(Channel);
00286	
00287		if(Nick == "")
00288		{
00289			P = PageParent.GetPage(Channel);
00290			if(P != None)
00291				PageParent.DeletePage(P);
00292		}
00293		else
00294		{
00295			if(W != None)
00296				W.PartedChannel(Nick);
00297		}
00298	}
00299	
00300	function ChangedNick(string OldNick, string NewNick)
00301	{
00302		local UWindowPageControlPage P;
00303		local UBrowserIRCChannelPage Chan;
00304		local UBrowserIRCPrivPage Priv;
00305	
00306		if(OldNick == NickName)
00307		{
00308			NickName = NewNick;
00309			Link.NickName = NewNick;
00310			SaveConfig();
00311		}
00312		
00313		for(P = PageParent.FirstPage(); P != None; P = P.NextPage())
00314		{
00315			Chan = UBrowserIRCChannelPage(P.Page);
00316			if(Chan != None && Chan.UserList.FindNick(OldNick) != None)
00317				Chan.ChangedNick(OldNick, NewNick);
00318	
00319			Priv = UBrowserIRCPrivPage(P.Page);
00320			if(Priv != None && Priv.PrivNick == OldNick)
00321			{
00322				P.Caption = NewNick;
00323				Priv.ChangedNick(OldNick, NewNick);
00324			}
00325		}
00326	}
00327	
00328	function UserQuit(string Nick, string Reason)
00329	{
00330		local UWindowPageControlPage P;
00331		local UBrowserIRCChannelPage Chan;
00332		local UBrowserIRCPrivPage Priv;
00333	
00334		for(P = PageParent.FirstPage(); P != None; P = P.NextPage())
00335		{
00336			Chan = UBrowserIRCChannelPage(P.Page);
00337			if(Chan != None && Chan.UserList.FindNick(Nick) != None)
00338				Chan.UserQuit(Nick, Reason);
00339	
00340			Priv = UBrowserIRCPrivPage(P.Page);
00341			if(Priv != None && Priv.PrivNick == Nick)
00342				Priv.UserQuit(Nick, Reason);
00343		}
00344	}
00345	
00346	function UserNotice(string Nick, string Text)
00347	{
00348		local UWindowPageControlPage P;
00349		local UBrowserIRCChannelPage Chan;
00350		local UBrowserIRCPrivPage Priv;
00351	
00352		for(P = PageParent.FirstPage(); P != None; P = P.NextPage())
00353		{
00354			Chan = UBrowserIRCChannelPage(P.Page);
00355			if(Chan != None && Chan.UserList.FindNick(Nick) != None)
00356				Chan.UserNotice(Nick, Text);
00357	
00358			Priv = UBrowserIRCPrivPage(P.Page);
00359			if(Priv != None && Priv.PrivNick == Nick)
00360				Priv.UserNotice(Nick, Text);
00361		}
00362	}
00363	
00364	function ChangeMode(string Channel, string Nick, string Mode)
00365	{
00366		local UBrowserIRCChannelPage W;
00367		W = FindChannelWindow(Channel);
00368		if(W != None)
00369			W.ChangeMode(Nick, Mode);
00370	}
00371	
00372	function ChangeOp(string Channel, string Nick, bool bOp)
00373	{
00374		local UBrowserIRCChannelPage W;
00375		W = FindChannelWindow(Channel);
00376		if(W != None)
00377			W.ChangeOp(Nick, bOp);
00378	}
00379	
00380	function ChangeVoice(string Channel, string Nick, bool bVoice)
00381	{
00382		local UBrowserIRCChannelPage W;
00383		W = FindChannelWindow(Channel);
00384		if(W != None)
00385			W.ChangeVoice(Nick, bVoice);
00386	}
00387	
00388	function Tick(float Delta)
00389	{
00390		if(bConnected && GetPlayerOwner().PlayerReplicationInfo.PlayerName != OldPlayerName)
00391		{
00392			OldPlayerName = GetPlayerOwner().PlayerReplicationInfo.PlayerName;
00393			Link.SetNick(OldPlayerName);
00394			SystemText("SetNick: "$OldPlayerName);
00395		}
00396	
00397		Super.Tick(Delta);
00398	}
00399	
00400	function IsAway(string Nick, string Message)
00401	{
00402		local UBrowserIRCPrivPage W;
00403	
00404		W = FindPrivateWindow(Nick);
00405		
00406		if(W != None)
00407			W.IsAway(Nick, Message);
00408		else
00409			SystemText(Nick@IsAwayText$": "$Message);
00410	}
00411	
00412	function IRCVisible()
00413	{
00414		if(bAway)
00415		{
00416			if(bConnected)
00417				Link.SetAway("");
00418			bAway = False;
00419		}
00420	}
00421	
00422	function IRCClosed()
00423	{
00424		CheckAway();
00425	}
00426	
00427	function NotifyAfterLevelChange()
00428	{
00429		Super.NotifyAfterLevelChange();
00430		CheckAway();
00431	}
00432	
00433	function CheckAway()
00434	{
00435		local string URL;
00436	
00437		if( bConnected )
00438		{
00439			bAway = True;
00440	
00441			URL = GetLevel().GetAddressURL();
00442			if(InStr(URL, ":") > 0)
00443				Link.SetAway("unreal://"$URL);
00444			else
00445			if(!Root.bWindowVisible)
00446				Link.SetAway("local game");
00447			else
00448				Link.SetAway("in menus");
00449		}
00450	}
00451	
00452	function CTCP(string Channel, string Nick, string Message)
00453	{
00454		if(Channel == "" || Channel == NickName)
00455			SystemText("["$Nick$": "$Message$"]");
00456		else
00457			SystemText("["$Nick$":"$Channel$" "$Message$"]");
00458	}
00459	
00460	defaultproperties
00461	{
00462	     NotInAChannelText="Not in a channel!"
00463	     KickedFromText="You were kicked from"
00464	     ByText="by"
00465	     IsAwayText="is away"
00466	     RightClickMenuClass=Class'UBrowser.UBrowserIRCSystemMenu'
00467	}

End Source Code