Always snap to grid

UE1:NBSPBadge (Class)

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 13:39, 1 April 2009 by Azura (Talk | contribs) (Created page with '== Purpose == This class is used to display a logo. == Variables == == Discussion == == Possible improvements == == Complete source code == <uscript>//=====================...')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

This class is used to display a logo.

Variables

Discussion

Possible improvements

Complete source code

//=============================================================================
// NBSPBadge ==> NoBullShitPlus v1.09
//=============================================================================
 
class NBSPBadge extends Mutator;
 
#exec Texture Import File=../NBSP_Forced109/Classes/NoBullShitPlus.pcx Name=NBSPShield Mips=Off
 
enum EDrawState {
	DRAW_BLANK,
	DRAW_FADE_IN,
	DRAW_DISPLAY,
	DRAW_FADE_OUT,
	DRAW_DONE
};
 
var private string VersionStr;			// Holds the version code from VUC++
var PlayerPawn PP;
var private bool bDrawSplash;
var private EDrawState DrawState;
var private float DrawTime;
var private float DrawTick;
var private bool bInitialized;
var private string zzMsg;
var private float WaitTime, FadeInTime, AliveTime, FadeOutTime;
 
simulated function PostRender (private Canvas Canvas)
{
	Super.PostRender(Canvas);
 
	//Do Mutator				
	if (( PP != None ) && 
		( PP.PlayerReplicationInfo != None ) &&
		( DrawState != DRAW_DONE ))
	{
		if (  !bDrawSplash )
		{
			bDrawSplash=True;
			DrawState=DRAW_BLANK;
			DrawTick=0.06;
			SetTimer(DrawTick,True);
		}
		else
		{
			DrawSplash(Canvas);
		}
	}
 
	if ( NextMutator != None )
		NextMutator.PostRender(Canvas);
}
 
simulated function DrawSplash (private Canvas Canvas)
{
	local Font PreviousFont;
	local bool PreviousCenter;
	local Color PreviousColor;
	local byte PreviousStyle;
	local float zzX,zzY;
 
	if ( DrawState != DRAW_BLANK )
	{
		PreviousCenter=Canvas.bCenter;
		PreviousColor=Canvas.DrawColor;
		PreviousFont=Canvas.Font;
		PreviousStyle=Canvas.Style;
		Canvas.Reset();
		Canvas.SetPos(12.00,80.00);
		zzX = 10; // Canvas.ClipX / 2;
		zzY = Canvas.ClipY - 128;
 
		switch (DrawState)
		{
			case DRAW_FADE_IN:
				Canvas.Style=ERenderStyle.STY_Translucent;
				Canvas.DrawColor = ChallengeHud(PP.myHUD).WhiteColor * DrawTime;
				break;
 
			case DRAW_DISPLAY:
				Canvas.Style=ERenderStyle.STY_Translucent;
				Canvas.DrawColor = ChallengeHud(PP.myHUD).WhiteColor;	
				break;
 
			case DRAW_FADE_OUT:
				Canvas.Style=ERenderStyle.STY_Translucent;
				Canvas.DrawColor = ChallengeHud(PP.myHUD).WhiteColor * (FadeOutTime - DrawTime);
				break;
 
			default:
		}
 
		if (!bInitialized)
			zzMsg = "Initiating...";
		else
			zzMsg = "This Server Is Protected!";
 
		Canvas.SetPos(zzX,zzY);
		Canvas.DrawIcon(texture'NBSPShield',1.00);
		Canvas.SetPos(zzX+70,zzY+36);
		Canvas.Font = ChallengeHUD(PP.myHUD).MyFonts.GetSmallestFont(Canvas.ClipX);
		Canvas.DrawText(zzMsg);
		Canvas.SetPos(zzX+70,zzY+10);
		Canvas.Font = ChallengeHUD(PP.myHUD).MyFonts.GetMediumFont(Canvas.ClipX);		
		Canvas.DrawText(VersionStr);
		Canvas.Style = ERenderStyle.STY_Normal;
	}
}
 
simulated function Timer ()
{
	DrawTime=DrawTime + DrawTick;
 
	switch (DrawState)
	{
		case DRAW_BLANK:
			if ( DrawTime >= WaitTime )
			{
				DrawState=DRAW_FADE_IN;
				DrawTime=0.00;
			}
			break;
 
		case DRAW_FADE_IN:
			if ( DrawTime >= FadeInTime )
			{
				if (!bInitialized) { bInitialized=True; }
				PP.ClientPlaySound(Sound'SpeechWindowClick',False);
				DrawState=DRAW_DISPLAY;
				DrawTime=0.00;
			}
			break;
 
		case DRAW_DISPLAY:
			if (( PP != None ) && 
				( PP.PlayerReplicationInfo != None ) &&
				( PP.PlayerReplicationInfo.bWaitingPlayer ) &&
				( PP.GameReplicationInfo.GameClass != "RocketArena.RocketArenaGame"))
			{
				DrawTime=0.00;
			}
 
			if ( DrawTime >= AliveTime )
			{
				DrawState=DRAW_FADE_OUT;
				DrawTime=0.00;
			}
 
			break;
 
		case DRAW_FADE_OUT:
			if ( DrawTime >= FadeOutTime )
			{
				DrawState=DRAW_DONE;
				DrawTime=0.00;
			}
			break;
 
		case DRAW_DONE:
			SetTimer(0.00,False);
			break;
 
		default:
	}
 
	Super.Timer();
}
 
defaultproperties
{
     VersionStr="NoBullShitPlus v1.09"
     RemoteRole=ROLE_SimulatedProxy
     bAlwaysRelevant=True
     bNetTemporary=True
     WaitTime=0.20 
     FadeInTime=1.00 
     AliveTime=3.50 
     FadeOutTime=1.00
}