UBrowser
Class UBrowserMainClientWindow

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

class UBrowserMainClientWindow
extends UWindow.UWindowClientWindow

//============================================================================= // UBrowserMainClientWindow - The main client area //=============================================================================
Variables
 UBrowserServerListWindow FactoryWindows[50]
 string FavoriteServersClass
 UBrowserInfoWindow InfoWindow
 UWindowPageControlPage LANPage
 string LANTabName
 IRC, MOTD
 IRCName, MOTDName
 UWindowTabControlItem PageBeforeLAN
 UWindowPageControl PageControl
 name ServerListNames[50]
 string ServerListWindowClass
 string UpdateServerClass
 bool bKeepMasterServer


Function Summary
 void Created()
 void NewIRCServer(string S)
 void NewMasterServer(string M)
 void Paint(Canvas C, float X, float Y)
 void Resized()
 void SaveConfigs()
 void SelectInternet()
 void SelectLAN()



Source Code


00001	//=============================================================================
00002	// UBrowserMainClientWindow - The main client area
00003	//=============================================================================
00004	class UBrowserMainClientWindow extends UWindowClientWindow;
00005	
00006	var globalconfig string		LANTabName;
00007	var globalconfig name ServerListNames[50];
00008	var globalconfig bool bKeepMasterServer;
00009	
00010	var UWindowPageControl		PageControl;
00011	var UWindowPageControlPage	Favorites, IRC, MOTD;
00012	var localized string		FavoritesName, IRCName, MOTDName;
00013	var string					ServerListWindowClass;
00014	var string					FavoriteServersClass;
00015	var string					UpdateServerClass;
00016	var UWindowPageControlPage	LANPage;
00017	var UWindowTabControlItem	PageBeforeLAN;
00018	var UBrowserServerListWindow FactoryWindows[50];
00019	var UBrowserInfoWindow		InfoWindow;
00020	
00021	function Created() 
00022	{
00023		local int i, f, j;
00024		local UWindowPageControlPage P;
00025		local UBrowserServerListWindow W;
00026		local class<UBrowserServerListWindow> C;
00027		local class<UBrowserFavoriteServers> FC;
00028		local class<UBrowserUpdateServerWindow> MC;
00029		local string NextWindowClass, NextWindowDesc;
00030	
00031		Super.Created();
00032	
00033		InfoWindow = UBrowserInfoWindow(Root.CreateWindow(class'UBrowserInfoWindow', 10, 40, 310, 170));
00034		InfoWindow.HideWindow();
00035	
00036		PageControl = UWindowPageControl(CreateWindow(class'UWindowPageControl', 0, 0, WinWidth, WinHeight));
00037		PageControl.SetMultiLine(True);
00038	
00039		// Add MOTD
00040		MC = class<UBrowserUpdateServerWindow>(DynamicLoadObject(UpdateServerClass, class'Class'));
00041		MOTD = PageControl.AddPage(MOTDName, MC);
00042	
00043		IRC = PageControl.AddPage(IRCName, class'UBrowserIRCWindow');
00044	
00045		// Add favorites
00046		FC = class<UBrowserFavoriteServers>(DynamicLoadObject(FavoriteServersClass, class'Class'));
00047		Favorites = PageControl.AddPage(FavoritesName, FC);
00048	
00049		C = class<UBrowserServerListWindow>(DynamicLoadObject(ServerListWindowClass, class'Class'));
00050	
00051		for(i=0; i<50; i++)
00052		{
00053			if(ServerListNames[i] == '')
00054				break;
00055	
00056			P = PageControl.AddPage("", C, ServerListNames[i]);
00057			if(string(ServerListNames[i]) ~= LANTabName)
00058				LANPage = P;
00059	
00060			W = UBrowserServerListWindow(P.Page);
00061			if(W.bHidden)
00062				PageControl.DeletePage(P);
00063	
00064			if(W.ServerListTitle != "")
00065				P.SetCaption(W.ServerListTitle);
00066			else
00067				P.SetCaption(Localize("ServerListTitles", string(ServerListNames[i]), "UBrowser"));
00068	
00069			FactoryWindows[i] = W;
00070		}
00071	
00072		// Load custom UBrowser pages
00073		if(i < 50)
00074		{
00075			j = 0;
00076			GetPlayerOwner().GetNextIntDesc(ServerListWindowClass, j, NextWindowClass, NextWindowDesc); 
00077			while( NextWindowClass != "" && i < 50 )
00078			{
00079				C = class<UBrowserServerListWindow>(DynamicLoadObject(NextWindowClass, class'Class'));
00080				if( C != None )
00081				{
00082					ServerListNames[i] = '';
00083					P = PageControl.AddPage("", C);
00084					W = UBrowserServerListWindow(P.Page);
00085					if(W.bHidden)
00086						PageControl.DeletePage(P);
00087					if(W.ServerListTitle != "")
00088						P.SetCaption(W.ServerListTitle);
00089					else
00090						P.SetCaption(NextWindowDesc);
00091					FactoryWindows[i] = W;	
00092					i++;
00093				}
00094				j++;
00095				GetPlayerOwner().GetNextIntDesc(ServerListWindowClass, j, NextWindowClass, NextWindowDesc); 
00096			}
00097		}
00098	}
00099	
00100	function SelectLAN()
00101	{
00102		if(LANPage != None)
00103		{
00104			PageBeforeLAN = PageControl.SelectedTab;
00105			PageControl.GotoTab(LANPage, True);
00106		}
00107	}
00108	
00109	function SelectInternet()
00110	{
00111		if(PageBeforeLAN != None && PageControl.SelectedTab == LANPage)
00112			PageControl.GotoTab(PageBeforeLAN, True);
00113		PageBeforeLAN = None;
00114	}
00115	
00116	function NewMasterServer(string M)
00117	{
00118		local int i, j;
00119		local string NewServers[10];
00120		local string T;
00121		local bool bHadNewServer;
00122	
00123		i = 0;
00124		while(M != "")
00125		{
00126			j = InStr(M, Chr(13));
00127			if(j != -1)
00128			{
00129				T = Left(M, j);
00130				M = Mid(M, j+1);
00131			}
00132			else
00133			{
00134				T = M;
00135				M = "";
00136			}
00137			if(T != "")
00138				NewServers[i++] = T;
00139		}	
00140	
00141		if(!bKeepMasterServer)
00142		{
00143			for(i=0; i<20; i++)
00144			{
00145				if(ServerListNames[i] == 'UBrowserAll')
00146				{
00147					bHadNewServer = False;
00148					for(j=0; j<9; j++)
00149					{
00150						if(FactoryWindows[i].ListFactories[j] != NewServers[j])
00151						{
00152							Log("Received new master server ["$j$"] from UpdateServer: "$NewServers[j]);
00153							FactoryWindows[i].ListFactories[j] = NewServers[j];
00154							FactoryWindows[i].ListFactories[j+1] = "";
00155							bHadNewServer = True;
00156						}
00157					}
00158					if(bHadNewServer)
00159					{
00160						if(FactoryWindows[i].bHadInitialRefresh)
00161							FactoryWindows[i].Refresh(False, True);
00162						FactoryWindows[i].SaveConfig();
00163					}
00164				}
00165			}
00166		}
00167	}
00168	
00169	function NewIRCServer(string S)
00170	{
00171		UBrowserIRCWindow(IRC.Page).SystemPage.SetupClient.NewIRCServer(S);
00172	}
00173	
00174	function Paint(Canvas C, float X, float Y)
00175	{
00176		DrawStretchedTexture(C, 0, 0, WinWidth, WinHeight, Texture'BlackTexture');
00177	}
00178	
00179	function Resized()
00180	{
00181		Super.Resized();
00182		PageControl.SetSize(WinWidth, WinHeight);
00183	}
00184	
00185	function SaveConfigs()
00186	{
00187		SaveConfig();
00188	}
00189	
00190	defaultproperties
00191	{
00192	     LANTabName="UBrowserLAN"
00193	     ServerListNames(0)=UBrowserUT
00194	     ServerListNames(1)=UBrowserLAN
00195	     ServerListNames(2)=UBrowserPopulated
00196	     ServerListNames(3)=UBrowserDeathmatch
00197	     ServerListNames(4)=UBrowserTeamGames
00198	     ServerListNames(5)=UBrowserCTF
00199	     ServerListNames(6)=UBrowserDOM
00200	     ServerListNames(7)=UBrowserAS
00201	     ServerListNames(8)=UBrowserLMS
00202	     ServerListNames(9)=UBrowserAll
00203	     FavoritesName="Favorites"
00204	     IRCName="Chat"
00205	     MOTDName="News"
00206	     ServerListWindowClass="UBrowser.UBrowserServerListWindow"
00207	     FavoriteServersClass="UBrowser.UBrowserFavoriteServers"
00208	     UpdateServerClass="UBrowser.UBrowserUpdateServerWindow"
00209	}

End Source Code