UBrowser
Class UBrowserPlayerList

source: c:\runehov\UBrowser\Classes\UBrowserPlayerList.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowList
         |
         +--UBrowser.UBrowserPlayerList
Direct Known Subclasses:None

class UBrowserPlayerList
extends UWindow.UWindowList

//============================================================================= // UBrowserPlayerList - The player list returned by the server. //=============================================================================
Variables
 string PlayerFace
 int PlayerFrags
 int PlayerID
 string PlayerMesh
 string PlayerName
 int PlayerPing
 string PlayerSkin
 string PlayerTeam
 int SortColumn
 bool bDescending


Function Summary
 int Compare(UWindowList T, UWindowList B)
 UBrowserPlayerList FindID(int ID)
 void SortByColumn(int Column)



Source Code


00001	//=============================================================================
00002	// UBrowserPlayerList - The player list returned by the server.
00003	//=============================================================================
00004	class UBrowserPlayerList extends UWindowList;
00005	
00006	var string			PlayerName;
00007	var string			PlayerMesh;
00008	var string			PlayerSkin;
00009	var string			PlayerFace;
00010	var string			PlayerTeam;
00011	var int				PlayerFrags;
00012	var int				PlayerPing;
00013	var int				PlayerID;
00014	
00015	// Sentinel Only
00016	var int				SortColumn;
00017	var bool			bDescending;
00018	
00019	
00020	function SortByColumn(int Column)
00021	{
00022		if(SortColumn == Column)
00023		{
00024			bDescending = !bDescending;
00025		}
00026		else
00027		{
00028			SortColumn = Column;
00029			bDescending = False;
00030		}
00031	
00032		Sort();
00033	}
00034	
00035	function int Compare(UWindowList T, UWindowList B)
00036	{
00037		local int Result;
00038		local UBrowserPlayerList PT, PB;
00039	
00040		if(B == None) return -1; 
00041	
00042		PT = UBrowserPlayerList(T);
00043		PB = UBrowserPlayerList(B);
00044	
00045		switch(UBrowserPlayerList(Sentinel).SortColumn)
00046		{
00047		case 0:
00048			if(Caps(PT.PlayerName) < Caps(PB.PlayerName))
00049				Result = -1;
00050			else
00051			if(PT.PlayerName > PB.PlayerName)
00052				Result = 1;
00053			else
00054				Result = (PT.PlayerPing - PB.PlayerPing);
00055			break;
00056		case 1:
00057			if(PT.PlayerFrags > PB.PlayerFrags)
00058				Result = -1;
00059			else
00060			if(PT.PlayerFrags < PB.PlayerFrags)
00061				Result = 1;
00062			else
00063			{
00064				if(PT.PlayerName < PB.PlayerName)
00065					Result = -1;
00066				else
00067					Result = 1;
00068			}
00069			break;
00070		case 2:
00071			if(PT.PlayerPing < PB.PlayerPing)
00072				Result = -1;
00073			else
00074			if(PT.PlayerPing > PB.PlayerPing)
00075				Result = 1;
00076			else
00077			{
00078				if(PT.PlayerName < PB.PlayerName)
00079					Result = -1;
00080				else
00081					Result = 1;
00082			}
00083			break;
00084		case 3:
00085			if(PT.PlayerTeam > PB.PlayerTeam)
00086				Result = -1;
00087			else if(PT.PlayerTeam < PB.PlayerTeam)
00088				Result = 1;
00089			else
00090			{
00091				if(PT.PlayerName < PB.PlayerName)
00092					Result = -1;
00093				else
00094					Result = 1;
00095			}
00096			break;
00097		case 4:
00098			if(PT.PlayerMesh < PB.PlayerMesh)
00099				Result = -1;
00100			else
00101			if(PT.PlayerMesh > PB.PlayerMesh)
00102				Result = 1;
00103			else
00104			{
00105				if(PT.PlayerName < PB.PlayerName)
00106					Result = -1;
00107				else
00108					Result = 1;
00109			}
00110			break;
00111		case 5:
00112			if(PT.PlayerSkin < PB.PlayerSkin)
00113				Result = -1;
00114			else
00115			if(PT.PlayerSkin > PB.PlayerSkin)
00116				Result = 1;
00117			else
00118			{
00119				if(PT.PlayerName < PB.PlayerName)
00120					Result = -1;
00121				else
00122					Result = 1;
00123			}
00124			break;
00125		case 6:
00126			if(PT.PlayerFace < PB.PlayerFace)
00127				Result = -1;
00128			else
00129			if(PT.PlayerFace > PB.PlayerFace)
00130				Result = 1;
00131			else
00132			{
00133				if(PT.PlayerSkin < PB.PlayerSkin)
00134					Result = -1;
00135				else
00136				if(PT.PlayerSkin > PB.PlayerSkin)
00137					Result = 1;
00138				else
00139				{
00140					if(PT.PlayerName < PB.PlayerName)
00141						Result = -1;
00142					else
00143						Result = 1;
00144				}
00145			}
00146			break;
00147		case 7:
00148			if(PT.PlayerID < PB.PlayerID)
00149				Result = -1;
00150			else
00151			if(PT.PlayerID > PB.PlayerID)
00152				Result = 1;
00153			else
00154			{
00155				if(PT.PlayerName < PB.PlayerName)
00156					Result = -1;
00157				else
00158					Result = 1;
00159			}
00160			break;
00161		}
00162	
00163		if(UBrowserPlayerList(Sentinel).bDescending) Result = -Result;
00164	
00165		return Result;
00166	}
00167	
00168	function UBrowserPlayerList FindID(int ID)
00169	{
00170		local UBrowserPlayerList l;
00171	
00172		l = UBrowserPlayerList(Next);
00173		while(l != None)
00174		{
00175			if(l.PlayerID == ID) return l;
00176			l = UBrowserPlayerList(l.Next);
00177		}
00178		return None;
00179	}
00180	
00181	defaultproperties
00182	{
00183	     SortColumn=1
00184	}

End Source Code