UnrealShare
Class UnrealListMenu

source: e:\games\UnrealTournament\UnrealShare\Classes\UnrealListMenu.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Menu
         |
         +--UnrealShare.UnrealMenu
            |
            +--UnrealShare.UnrealListMenu
Direct Known Subclasses:None

class UnrealListMenu
extends UnrealShare.UnrealMenu

//============================================================================= // UnrealListMenu. //=============================================================================
Variables
 int CenterSelection
 int ColumnLines
 int Focus
 string LeftHelpMessage
 string LeftList[33]
 int LeftMax
 int LeftNumDrawn
 int LeftOffset
 int LeftSelection
 string LeftTitle
 float MenuFadeTimes[24]
 PanelWidth, PanelHeight
 float PulseTime
 string RightHelpMessage
 string RightList[33]
 int RightMax
 int RightNumDrawn
 int RightOffset
 int RightSelection
 string RightTitle
 float TitleFadeTime
 bool bPulseDown


Function Summary
 void CenterMenuProcessInput(byte KeyNum, byte ActionNum)
 void DrawBackground(Canvas Canvas)
     
// Background.
 void DrawFadeList(Canvas Canvas, int Spacing, int StartX, int StartY)
     
// Fade list.
 void DrawFadeString(Canvas Canvas, string FadeString, out float, float XStart, float YStart, color DrawColor)
     
// Fades in a string to the specified color.
 void DrawFadeTitle(Canvas Canvas)
     
// Fade title.
 void DrawHelpPanel(Canvas Canvas, int StartY, int XClip)
     
// The help panel for list menus.  Oriented somewhat differently
// because it is not restricted by the green background.
 void DrawLeftList(Canvas Canvas)
 void DrawLeftPanel(Canvas Canvas)
 void DrawLeftTitle(Canvas Canvas)
 void DrawRightList(Canvas Canvas)
 void DrawRightPanel(Canvas Canvas)
 void DrawRightTitle(Canvas Canvas)
 void LeftMenuProcessInput(byte KeyNum, byte ActionNum)
 void MenuProcessInput(byte KeyNum, byte ActionNum)
 void MenuTick(float DeltaTime)
 void RightMenuProcessInput(byte KeyNum, byte ActionNum)



Source Code


00001	//=============================================================================
00002	// UnrealListMenu.
00003	//=============================================================================
00004	class UnrealListMenu extends UnrealMenu;
00005	
00006	#exec TEXTURE IMPORT NAME="ListMenuTop" FILE="Textures\menu-t.pcx" MIPS=off
00007	#exec TEXTURE IMPORT NAME="ListMenuMiddle" FILE="Textures\menu-m.pcx" MIPS=off
00008	#exec TEXTURE IMPORT NAME="ListMenuBottom" FILE="Textures\menu-b.pcx" MIPS=off
00009	
00010	#exec TEXTURE IMPORT NAME=ArrowDL FILE=TEXTURES\ARROW-DL.PCX GROUP="Icons" MIPS=OFF
00011	#exec TEXTURE IMPORT NAME=ArrowDR FILE=TEXTURES\ARROW-DR.PCX GROUP="Icons" MIPS=OFF
00012	#exec TEXTURE IMPORT NAME=ArrowUL FILE=TEXTURES\ARROW-UL.PCX GROUP="Icons" MIPS=OFF
00013	#exec TEXTURE IMPORT NAME=ArrowUR FILE=TEXTURES\ARROW-UR.PCX GROUP="Icons" MIPS=OFF
00014	
00015	var float PulseTime;
00016	var bool bPulseDown;
00017	var float TitleFadeTime;
00018	var float MenuFadeTimes[24];
00019	var() localized string LeftHelpMessage;
00020	var() localized string LeftList[33];
00021	var() localized string LeftTitle;
00022	var int LeftOffset;
00023	var int LeftSelection;
00024	var int LeftMax;
00025	var int LeftNumDrawn;
00026	var() localized string RightHelpMessage;
00027	var() localized string RightList[33];
00028	var() localized string RightTitle;
00029	var int RightOffset;
00030	var int RightSelection;
00031	var int RightMax;
00032	var int RightNumDrawn;
00033	var int Focus;
00034	var int CenterSelection;
00035	var float PanelWidth, PanelHeight;
00036	var int ColumnLines;
00037	
00038	function LeftMenuProcessInput( byte KeyNum, byte ActionNum )
00039	{
00040		Super.MenuProcessInput( KeyNum, ActionNum );
00041	}
00042	
00043	function CenterMenuProcessInput( byte KeyNum, byte ActionNum )
00044	{
00045		Super.MenuProcessInput( KeyNum, ActionNum );
00046	}
00047	
00048	function RightMenuProcessInput( byte KeyNum, byte ActionNum )
00049	{
00050		Super.MenuProcessInput( KeyNum, ActionNum );
00051	}
00052	
00053	function MenuProcessInput( byte KeyNum, byte ActionNum )
00054	{
00055		switch (Focus)
00056		{
00057			case -1:
00058				LeftMenuProcessInput( KeyNum, ActionNum );
00059				break;
00060			case 0:
00061				CenterMenuProcessInput( KeyNum, ActionNum );
00062				break;
00063			case 1:
00064				RightMenuProcessInput( KeyNum, ActionNum );
00065				break;
00066		}
00067	}
00068	
00069	// Background.
00070	function DrawBackground(canvas Canvas)
00071	{
00072		local float OldX, OldY;
00073		local int NumTiles, i;
00074		
00075		Canvas.DrawColor.R = 255;
00076		Canvas.DrawColor.G = 255;
00077		Canvas.DrawColor.B = 255;
00078	
00079		NumTiles = PanelHeight / 64.0;
00080		
00081		OldX = Canvas.CurX;
00082		OldY = Canvas.CurY;	
00083		Canvas.DrawIcon(texture'ListMenuTop', 1.0);
00084		NumTiles--;
00085		for (i=1; i<NumTiles; i++)
00086		{
00087			Canvas.SetPos(OldX, OldY + 64.0*i);
00088			Canvas.DrawIcon(texture'ListMenuMiddle', 1.0);
00089		}
00090		Canvas.SetPos(OldX, OldY + 64.0*NumTiles);
00091		Canvas.DrawIcon(texture'ListMenuBottom', 1.0);
00092	}
00093	
00094	// Fade title.
00095	function DrawFadeTitle(canvas Canvas)
00096	{
00097		local float XL, YL;
00098		local color DrawColor;
00099	
00100		Canvas.Font = Font'WhiteFont';
00101		Canvas.StrLen(MenuTitle, XL, YL);
00102	
00103		DrawColor.R = 192;
00104		DrawColor.G = 192;
00105		DrawColor.B = 192;
00106		
00107		DrawFadeString(Canvas, MenuTitle, TitleFadeTime, Canvas.ClipX/2 - XL/2, 32, DrawColor);
00108	}
00109	
00110	// Fade list.
00111	function DrawFadeList(canvas Canvas, int Spacing, int StartX, int StartY)
00112	{
00113		local int i;
00114		local color DrawColor;
00115		
00116		Canvas.Font = Font'WhiteFont';
00117		for (i=0; i< (MenuLength); i++ )
00118		{
00119			if (i == Selection - 1)
00120			{
00121				DrawColor.R = PulseTime * 10;
00122				DrawColor.G = 255;
00123				DrawColor.B = PulseTime * 10;
00124			} else {
00125				DrawColor.R = 0;
00126				DrawColor.G = 150;
00127				DrawColor.B = 0;
00128			}
00129			DrawFadeString(Canvas, MenuList[i + 1], MenuFadeTimes[i + 1], StartX, StartY + Spacing * i, DrawColor);
00130		}
00131	}
00132	
00133	// Fades in a string to the specified color.
00134	function DrawFadeString( canvas Canvas, string FadeString, out float FadeTime, float XStart, float YStart, color DrawColor )
00135	{
00136		local float FadeCount, XL, YL;
00137		local int FadeChar;
00138		
00139		Canvas.SetPos(XStart, YStart);
00140		Canvas.DrawColor = DrawColor;
00141		
00142		if (FadeTime == -1.0)
00143		{
00144			// If first update, just set the FadeTime to zero.
00145			FadeTime = 0.0;
00146			return;
00147		} else if (FadeTime == -2.0) {
00148			Canvas.SetPos(XStart, YStart);
00149			Canvas.DrawColor = DrawColor;
00150			Canvas.DrawText(FadeString, false);
00151			return;
00152		}
00153		
00154		// Update FadeString.
00155		for ( FadeChar = 0; FadeTime - (FadeChar * 0.1) > 0.0; FadeChar++ )
00156		{
00157			FadeCount = FadeTime - (FadeChar * 0.1);
00158			if (FadeCount > 1.0)
00159				FadeCount = 1.0;
00160				
00161			if ((FadeChar == Len(FadeString) - 1) && (255 * (1.0 - FadeCount) == 0))
00162				FadeTime = -2.0;
00163	
00164			Canvas.DrawColor.R = Max(255 * (1.0 - FadeCount), DrawColor.R);
00165			Canvas.DrawColor.G = Max(255 * (1.0 - FadeCount), DrawColor.G);
00166			Canvas.DrawColor.B = Max(255 * (1.0 - FadeCount), DrawColor.B);
00167			Canvas.DrawText(Mid(FadeString, FadeChar, 1));
00168			Canvas.StrLen(Left(FadeString, FadeChar+1), XL, YL);
00169			Canvas.SetPos(XStart + XL, YStart);
00170		}
00171	}
00172	
00173	function DrawLeftTitle(canvas Canvas)
00174	{
00175		local float XL, YL;
00176	
00177		Canvas.DrawColor.R = 255;
00178		Canvas.DrawColor.G = 255;
00179		Canvas.DrawColor.B = 255;
00180		Canvas.StrLen(LeftTitle, XL, YL);
00181		Canvas.SetPos(64 + (PanelWidth/2 - XL/2), 126-YL);
00182		Canvas.DrawText(LeftTitle, false);
00183	}
00184	
00185	function DrawLeftList(canvas Canvas)
00186	{
00187		local float XL, YL;
00188		local int i;
00189	
00190		LeftNumDrawn = 0;
00191		for ( i=LeftOffset+1; i<ColumnLines+LeftOffset; i++ )
00192		{
00193			if ( (Focus == -1) && (Selection == i) )
00194			{
00195				Canvas.DrawColor.R = PulseTime * 10;
00196				Canvas.DrawColor.G = 255;
00197				Canvas.DrawColor.B = PulseTime * 10;
00198			} else {
00199				Canvas.DrawColor.R = 0;
00200				Canvas.DrawColor.G = 255;
00201				Canvas.DrawColor.B = 0;
00202			}
00203			Canvas.Font = Font'WhiteFont';
00204			Canvas.StrLen(LeftList[i], XL, YL);
00205			Canvas.SetPos(64 + (PanelWidth/2 - XL/2), 128 + ((i-LeftOffset)*2*YL));
00206			Canvas.DrawText(LeftList[i], false);
00207			LeftNumDrawn++;
00208		}
00209		LeftNumDrawn--;
00210	}
00211	
00212	function DrawLeftPanel(canvas Canvas)
00213	{
00214		// DrawLeftTitle
00215		DrawLeftTitle(Canvas);
00216	
00217		// DrawLeftBackground
00218		Canvas.SetPos(64, 128);
00219		DrawBackground(Canvas);
00220	
00221		// DrawLeftList
00222		DrawLeftList(Canvas);
00223	}
00224	
00225	function DrawRightTitle(canvas Canvas)
00226	{
00227		local float XL, YL;
00228		local int i;
00229	
00230		Canvas.DrawColor.R = 255;
00231		Canvas.DrawColor.G = 255;
00232		Canvas.DrawColor.B = 255;
00233		Canvas.StrLen(RightTitle, XL, YL);
00234		Canvas.SetPos(Canvas.ClipX - 64 - PanelWidth + (PanelWidth/2 - XL/2), 126-YL);
00235		Canvas.DrawText(RightTitle, false);
00236	}
00237	
00238	function DrawRightList(canvas Canvas)
00239	{
00240		local float XL, YL;
00241		local int i;
00242	
00243		RightNumDrawn = 0;
00244		for ( i=RightOffset+1; i<ColumnLines+RightOffset; i++ )
00245		{
00246			if ( (Focus == 1) && (Selection == i) )
00247			{
00248				Canvas.DrawColor.R = PulseTime * 10;
00249				Canvas.DrawColor.G = 255;
00250				Canvas.DrawColor.B = PulseTime * 10;
00251			} else {
00252				Canvas.DrawColor.R = 0;
00253				Canvas.DrawColor.G = 255;
00254				Canvas.DrawColor.B = 0;
00255			}
00256			Canvas.Font = Font'WhiteFont';
00257			Canvas.StrLen(RightList[i], XL, YL);
00258			Canvas.SetPos(Canvas.ClipX - 64 - PanelWidth + (PanelWidth/2 - XL/2), 128 + ((i-RightOffset)*2*YL));
00259			Canvas.DrawText(RightList[i], false);
00260			RightNumDrawn++;
00261		}
00262		RightNumDrawn--;
00263	}
00264	
00265	function DrawRightPanel(canvas Canvas)
00266	{
00267		// DrawRightTitle
00268		DrawRightTitle(Canvas);
00269	
00270		// DrawRightBackground
00271		Canvas.SetPos(Canvas.ClipX - 64 - PanelWidth, 128);
00272		DrawBackground(Canvas);
00273	
00274		// DrawRightList
00275		DrawRightList(Canvas);
00276	}
00277	
00278	// The help panel for list menus.  Oriented somewhat differently
00279	// because it is not restricted by the green background.
00280	function DrawHelpPanel(canvas Canvas, int StartY, int XClip)
00281	{
00282		local int StartX;
00283	
00284		StartX = 0.5 * Canvas.ClipX - 128;
00285	
00286		Canvas.bCenter = false;
00287		Canvas.Font = Canvas.MedFont;
00288		Canvas.SetOrigin(StartX + 18, StartY + 16);
00289		Canvas.SetClip(XClip,64);
00290		Canvas.SetPos(0,0);
00291		Canvas.Style = 1;
00292		switch (Focus)
00293		{
00294			case -1:
00295				Canvas.DrawText(LeftHelpMessage, False);
00296				break;
00297			case 0:
00298				if ( Selection < 20 )
00299					Canvas.DrawText(HelpMessage[Selection], False);
00300				break;
00301			case 1:
00302				Canvas.DrawText(RightHelpMessage, False);
00303				break;
00304		}
00305		Canvas.SetPos(0,32);
00306	}
00307	
00308	function MenuTick( float DeltaTime )
00309	{
00310		if ( Level.Pauser == "" )
00311			return;
00312	
00313		// Update PulseTime.
00314		if (bPulseDown)
00315		{
00316			if (PulseTime > 0.0)
00317			{
00318				PulseTime -= DeltaTime * 30;
00319				if (PulseTime < 0.0)
00320					PulseTime = 0.0;
00321			} else {
00322				PulseTime = 0.0;
00323				bPulseDown = false;
00324			}
00325		} else {
00326			if (PulseTime < 25.5)
00327			{
00328				PulseTime += DeltaTime * 30;
00329				if (PulseTime > 25.5)
00330					PulseTime = 25.5;
00331			} else {
00332				PulseTime = 25.5;
00333				bPulseDown = true;
00334			}
00335		}
00336	}
00337	
00338	defaultproperties
00339	{
00340	}

End Source Code