Engine
Class Canvas

source: e:\games\UnrealTournament\Engine\Classes\Canvas.uc
Core.Object
   |
   +--Engine.Canvas
Direct Known Subclasses:None

class Canvas
extends Core.Object

//============================================================================= // Canvas: A drawing canvas. // This is a built-in Unreal class and it shouldn't be modified. // // Notes. // To determine size of a drawable object, set Style to STY_None, // remember CurX, draw the thing, then inspect CurX and CurYL. //=============================================================================
Variables
 font BigFont
           Big system font.
 ClipX, ClipY
           Bottom right clipping region.
 CurX, CurY
           Current position for drawing.
 float CurYL
           Largest Y size since DrawText.
 color DrawColor
           Color for drawing.
 font Font
           Font for DrawText.
 int FramePtr
           Scene frame pointer.
 font LargeFont
           Large system font.
 font MedFont
           Medium system font.
 OrgX, OrgY
           Origin for drawing.
 int RenderPtr
           Render device pointer, only valid during UGameEngine::Draw
 SizeX, SizeY
           Zero-based actual dimensions.
 font SmallFont
           Small system font.
 SpaceX, SpaceY
           Spacing for after Draw*.
 byte Style
           Drawing style STY_None means don't draw.
 viewport Viewport
           Viewport that owns the canvas.
 float Z
           Z location. 1=no screenflash, 2=yes screenflash.
 bool bCenter
           Whether to center the text.
 bool bNoSmooth
           Don't bilinear filter.


Function Summary
 void DrawActor(Actor A, bool WireFrame, optional bool)
 void DrawClippedActor(Actor A, bool WireFrame, int X, int Y, int XB, int YB, optional bool)
 void DrawIcon(Texture Tex, float Scale)
 void DrawPattern(Texture Tex, float XL, float YL, float Scale)
 void DrawPortal(int X, int Y, int Width, int Height, Actor CamActor, vector CamLocation, rotator CamRotation, optional int, optional bool)
 void DrawRect(Texture Tex, float RectX, float RectY)
 void DrawText(string Text, optional bool)
 void DrawTextClipped(string Text, optional bool)
 void DrawTile(Texture Tex, float XL, float YL, float U, float V, float UL, float VL)
 void DrawTileClipped(Texture Tex, float XL, float YL, float U, float V, float UL, float VL)
 void SetClip(float X, float Y)
 void SetOrigin(float X, float Y)
 void SetPos(float X, float Y)
 void StrLen(string String, out float, out float)
     
// native functions.
 void TextSize(string String, out float, out float)



Source Code


00001	//=============================================================================
00002	// Canvas: A drawing canvas.
00003	// This is a built-in Unreal class and it shouldn't be modified.
00004	//
00005	// Notes.
00006	//   To determine size of a drawable object, set Style to STY_None,
00007	//   remember CurX, draw the thing, then inspect CurX and CurYL.
00008	//=============================================================================
00009	class Canvas extends Object
00010		native
00011		noexport;
00012	
00013	// Objects.
00014	#exec Font Import File=Textures\SmallFont.bmp Name=SmallFont
00015	#exec Font Import File=Textures\MedFont.pcx   Name=MedFont
00016	#exec Font Import File=Textures\LargeFont.pcx Name=LargeFont
00017	#exec Font Import File=Textures\BigFont.pcx   Name=BigFont
00018	
00019	// Modifiable properties.
00020	var font    Font;            // Font for DrawText.
00021	var float   SpaceX, SpaceY;  // Spacing for after Draw*.
00022	var float   OrgX, OrgY;      // Origin for drawing.
00023	var float   ClipX, ClipY;    // Bottom right clipping region.
00024	var float   CurX, CurY;      // Current position for drawing.
00025	var float   Z;               // Z location. 1=no screenflash, 2=yes screenflash.
00026	var byte    Style;           // Drawing style STY_None means don't draw.
00027	var float   CurYL;           // Largest Y size since DrawText.
00028	var color   DrawColor;       // Color for drawing.
00029	var bool    bCenter;         // Whether to center the text.
00030	var bool    bNoSmooth;       // Don't bilinear filter.
00031	var const int SizeX, SizeY;  // Zero-based actual dimensions.
00032	
00033	// Stock fonts.
00034	var font SmallFont;          // Small system font.
00035	var font MedFont;            // Medium system font.
00036	var font BigFont;            // Big system font.
00037	var font LargeFont;          // Large system font.
00038	
00039	// Internal.
00040	var const viewport Viewport; // Viewport that owns the canvas.
00041	var const int FramePtr;      // Scene frame pointer.
00042	var const int RenderPtr;	 // Render device pointer, only valid during UGameEngine::Draw
00043	
00044	// native functions.
00045	native(464) final function StrLen( coerce string String, out float XL, out float YL );
00046	native(465) final function DrawText( coerce string Text, optional bool CR );
00047	native(466) final function DrawTile( texture Tex, float XL, float YL, float U, float V, float UL, float VL );
00048	native(467) final function DrawActor( Actor A, bool WireFrame, optional bool ClearZ );
00049	native(468) final function DrawTileClipped( texture Tex, float XL, float YL, float U, float V, float UL, float VL );
00050	native(469) final function DrawTextClipped( coerce string Text, optional bool bCheckHotKey );
00051	native(470) final function TextSize( coerce string String, out float XL, out float YL );
00052	native(471) final function DrawClippedActor( Actor A, bool WireFrame, int X, int Y, int XB, int YB, optional bool ClearZ );
00053	native(480) final function DrawPortal( int X, int Y, int Width, int Height, actor CamActor, vector CamLocation, rotator CamRotation, optional int FOV, optional bool ClearZ );
00054	
00055	// UnrealScript functions.
00056	event Reset()
00057	{
00058		Font        = Default.Font;
00059		SpaceX      = Default.SpaceX;
00060		SpaceY      = Default.SpaceY;
00061		OrgX        = Default.OrgX;
00062		OrgY        = Default.OrgY;
00063		CurX        = Default.CurX;
00064		CurY        = Default.CurY;
00065		Style       = Default.Style;
00066		DrawColor   = Default.DrawColor;
00067		CurYL       = Default.CurYL;
00068		bCenter     = false;
00069		bNoSmooth   = false;
00070		Z           = 1.0;
00071	}
00072	final function SetPos( float X, float Y )
00073	{
00074		CurX = X;
00075		CurY = Y;
00076	}
00077	final function SetOrigin( float X, float Y )
00078	{
00079		OrgX = X;
00080		OrgY = Y;
00081	}
00082	final function SetClip( float X, float Y )
00083	{
00084		ClipX = X;
00085		ClipY = Y;
00086	}
00087	final function DrawPattern( texture Tex, float XL, float YL, float Scale )
00088	{
00089		DrawTile( Tex, XL, YL, (CurX-OrgX)*Scale, (CurY-OrgY)*Scale, XL*Scale, YL*Scale );
00090	}
00091	final function DrawIcon( texture Tex, float Scale )
00092	{
00093		if ( Tex != None )
00094			DrawTile( Tex, Tex.USize*Scale, Tex.VSize*Scale, 0, 0, Tex.USize, Tex.VSize );
00095	}
00096	final function DrawRect( texture Tex, float RectX, float RectY )
00097	{
00098		DrawTile( Tex, RectX, RectY, 0, 0, Tex.USize, Tex.VSize );
00099	}
00100	
00101	defaultproperties
00102	{
00103	     Z=1.000000
00104	     Style=1
00105	     DrawColor=(R=127,G=127,B=127)
00106	     SmallFont=Font'Engine.SmallFont'
00107	     MedFont=Font'Engine.MedFont'
00108	     BigFont=Font'Engine.BigFont'
00109	     LargeFont=Font'Engine.LargeFont'
00110	}

End Source Code