UnrealShare
Class UnrealShortMenu

source: e:\games\UnrealTournament\UnrealShare\Classes\UnrealShortMenu.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Menu
         |
         +--UnrealShare.UnrealMenu
            |
            +--UnrealShare.UnrealShortMenu
Direct Known Subclasses:UnrealIndivBotMenu, UnrealPlayerMenu

class UnrealShortMenu
extends UnrealShare.UnrealMenu

//============================================================================= // UnrealShortMenu // // Short menus, like the player mesh/skin selection screen and the // individual bot configuration screen. These menus do not have a background. //=============================================================================
Variables
 float MenuFadeTimes[24]
 float PulseTime
 float TitleFadeTime
 bool bPulseDown


Function Summary
 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 short menus.  Oriented somewhat differently
// because it is not restricted by the green background.
 void MenuTick(float DeltaTime)
     
// Short menus are used for displaying a mesh and some information
// about that mesh (for example, picking your class and skin before
// a game or setting up bots).  This rotates the displayed mesh.



Source Code


00001	//=============================================================================
00002	// UnrealShortMenu
00003	//
00004	// Short menus, like the player mesh/skin selection screen and the
00005	// individual bot configuration screen. These menus do not have a background.
00006	//=============================================================================
00007	class UnrealShortMenu extends UnrealMenu;
00008	
00009	var float PulseTime;
00010	var bool bPulseDown;
00011	var float TitleFadeTime;
00012	var float MenuFadeTimes[24];
00013	
00014	// Fade title.
00015	function DrawFadeTitle(canvas Canvas)
00016	{
00017		local float XL, YL;
00018		local color DrawColor;
00019	
00020		Canvas.Font = Font'WhiteFont';
00021		Canvas.StrLen(MenuTitle, XL, YL);
00022	
00023		DrawColor.R = 0;
00024		DrawColor.G = 255;
00025		DrawColor.B = 0;
00026		
00027		DrawFadeString(Canvas, MenuTitle, TitleFadeTime, Canvas.ClipX/2 - XL/2, 32, DrawColor);
00028	}
00029	
00030	// Fade list.
00031	function DrawFadeList(canvas Canvas, int Spacing, int StartX, int StartY)
00032	{
00033		local int i;
00034		local color DrawColor;
00035		
00036		Canvas.Font = Font'WhiteFont';
00037		for (i=0; i< (MenuLength); i++ )
00038		{
00039			if (i == Selection - 1)
00040			{
00041				DrawColor.R = PulseTime * 10;
00042				DrawColor.G = 255;
00043				DrawColor.B = PulseTime * 10;
00044			} else {
00045				DrawColor.R = 0;
00046				DrawColor.G = 150;
00047				DrawColor.B = 0;
00048			}
00049			DrawFadeString(Canvas, MenuList[i + 1], MenuFadeTimes[i + 1], StartX, StartY + Spacing * i, DrawColor);
00050		}
00051	}
00052	
00053	// Fades in a string to the specified color.
00054	function DrawFadeString( canvas Canvas, string FadeString, out float FadeTime, float XStart, float YStart, color DrawColor )
00055	{
00056		local float FadeCount, XL, YL;
00057		local int FadeChar;
00058		
00059		Canvas.SetPos(XStart, YStart);
00060		Canvas.DrawColor = DrawColor;
00061		
00062		if (FadeTime == -1.0)
00063		{
00064			// If first update, just set the FadeTime to zero.
00065			FadeTime = 0.0;
00066			return;
00067		} else if (FadeTime == -2.0) {
00068			Canvas.SetPos(XStart, YStart);
00069			Canvas.DrawColor = DrawColor;
00070			Canvas.DrawText(FadeString, false);
00071			return;
00072		}
00073		
00074		// Update FadeString.
00075		for ( FadeChar = 0; FadeTime - (FadeChar * 0.1) > 0.0; FadeChar++ )
00076		{
00077			FadeCount = FadeTime - (FadeChar * 0.1);
00078			if (FadeCount > 1.0)
00079				FadeCount = 1.0;
00080				
00081			if ((FadeChar == Len(FadeString) - 1) && (255 * (1.0 - FadeCount) == 0))
00082				FadeTime = -2.0;
00083	
00084			Canvas.DrawColor.R = Max(255 * (1.0 - FadeCount), DrawColor.R);
00085			Canvas.DrawColor.G = Max(255 * (1.0 - FadeCount), DrawColor.G);
00086			Canvas.DrawColor.B = Max(255 * (1.0 - FadeCount), DrawColor.B);
00087			Canvas.DrawText(Mid(FadeString, FadeChar, 1));
00088			Canvas.StrLen(Left(FadeString, FadeChar+1), XL, YL);
00089			Canvas.SetPos(XStart + XL, YStart);
00090		}
00091	}
00092	
00093	// The help panel for short menus.  Oriented somewhat differently
00094	// because it is not restricted by the green background.
00095	function DrawHelpPanel(canvas Canvas, int StartY, int XClip)
00096	{
00097		local int StartX;
00098	
00099		StartX = 0.5 * Canvas.ClipX - 128;
00100	
00101		Canvas.bCenter = false;
00102		Canvas.Font = Canvas.MedFont;
00103		Canvas.SetOrigin(StartX + 18, StartY + 16);
00104		Canvas.SetClip(XClip,64);
00105		Canvas.SetPos(0,0);
00106		Canvas.Style = 1;	
00107		if ( Selection < 20 )
00108			Canvas.DrawText(HelpMessage[Selection], False);	
00109		Canvas.SetPos(0,32);
00110	}
00111	
00112	// Short menus are used for displaying a mesh and some information
00113	// about that mesh (for example, picking your class and skin before
00114	// a game or setting up bots).  This rotates the displayed mesh.
00115	function MenuTick( float DeltaTime )
00116	{
00117		local rotator newRot;
00118		local float RemainingTime;
00119	
00120		if ( Level.Pauser == "" )
00121			return;
00122	
00123		// Update PulseTime.
00124		if (bPulseDown)
00125		{
00126			if (PulseTime > 0.0)
00127			{
00128				PulseTime -= DeltaTime * 30;
00129				if (PulseTime < 0.0)
00130					PulseTime = 0.0;
00131			} else {
00132				PulseTime = 0.0;
00133				bPulseDown = false;
00134			}
00135		} else {
00136			if (PulseTime < 25.5)
00137			{
00138				PulseTime += DeltaTime * 30;
00139				if (PulseTime > 25.5)
00140					PulseTime = 25.5;
00141			} else {
00142				PulseTime = 25.5;
00143				bPulseDown = true;
00144			}
00145		}
00146	
00147		// explicit rotation, since game is paused
00148		newRot = Rotation;
00149		newRot.Yaw = newRot.Yaw + RotationRate.Yaw * DeltaTime;
00150		SetRotation(newRot);
00151	
00152		//explicit animation
00153		RemainingTime = DeltaTime * 0.5;
00154		while ( RemainingTime > 0 )
00155		{
00156			if ( AnimFrame < 0 )
00157			{
00158				AnimFrame += TweenRate * RemainingTime;
00159				if ( AnimFrame > 0 )
00160					RemainingTime = AnimFrame/TweenRate;
00161				else
00162					RemainingTime = 0;
00163			}
00164			else
00165			{
00166				AnimFrame += AnimRate * RemainingTime;
00167				if ( AnimFrame > 1 )
00168				{
00169					RemainingTime = (AnimFrame - 1)/AnimRate;
00170					AnimFrame = 0;
00171				}
00172				else
00173					RemainingTime = 0;
00174			}
00175		}
00176	}
00177	
00178	defaultproperties
00179	{
00180	}

End Source Code