Engine
Class Canvas

source: c:\runehov\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
 float AlphaScale
           RUNE: Alpha value used by STY_AlphaBlend
 font BigFont
           Big system font.
 font ButtonFont
           Large system font.
 ClipX, ClipY
           Bottom right clipping region.
 font CredsFont
           Large system font.
 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
 font RuneMedFont
           Large system font.
 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 DrawBox3D(vector Center, vector Extents, int R, int G, int B)
 void DrawClippedActor(Actor A, bool WireFrame, int X, int Y, int XB, int YB, optional bool)
 void DrawIcon(Texture Tex, float Scale)
 void DrawLine(float X1, float Y1, float X2, float Y2, float R, float G, float B)
 void DrawLine3D(vector P1, vector P2, float R, float G, float B)
 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 DrawTextRightJustify(string text, int X, int Y)
 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 DrawTube(vector v1, vector v2, int Radius, int Height, int R, int G, int B)
 void SetClip(float X, float Y)
 void SetOrigin(float X, float Y)
 void SetPos(float X, float Y)
 void Setcolor(float R, float G, float B)
     
// Color components are of the range 0..255
 void StrLen(string String, out float, out float)
     
// native functions.
 void TextSize(string String, out float, out float)
 void TransformPoint(vector P1, out int, out int)



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	/*
00014		Small:	Used for debug hud output
00015		Med:	Used for console text
00016		Big:	Use for menus
00017		Large:	Used for HUD, precaching, loading, etc.
00018	*/
00019	
00020	// Objects.
00021	#exec Font Import File=Textures\SmallFont.bmp Name=SmallFont
00022	#exec Font Import File=Textures\MedFont.pcx   Name=MedFont
00023	//#exec Font Import File=Textures\BigFont.pcx   Name=BigFont
00024	//#exec Font Import File=Textures\LargeFont.pcx Name=LargeFont
00025	
00026	
00027	// RUNE fonts
00028	// NOTE: To hard code a color use the suffix:  FontR=200 FontG=0 FontB=0
00029	#exec new TrueTypeFontFactory Name=RuneMed   FontName="PR Uncial Alternate Capitals" Height=12 AntiAlias=1 CharactersPerPage=64
00030	#exec new TrueTypeFontFactory Name=RuneBig   FontName="PR Uncial Alternate Capitals" Height=14 AntiAlias=1 CharactersPerPage=64
00031	#exec new TrueTypeFontFactory Name=RuneCred  FontName="PR Uncial Alternate Capitals" Height=20 AntiAlias=1 CharactersPerPage=64
00032	#exec new TrueTypeFontFactory Name=RuneCred2 FontName="PR Uncial Alternate Capitals" Height=24 AntiAlias=1 CharactersPerPage=64
00033	#exec new TrueTypeFontFactory Name=RuneLarge FontName="PR Uncial Alternate Capitals" Height=36 AntiAlias=1 CharactersPerPage=16
00034	
00035	#exec new TrueTypeFontFactory Name=Haettenschweiler16  FontName="Haettenschweiler" Height=16 AntiAlias=1 CharactersPerPage=64
00036	
00037	#exec new TrueTypeFontFactory Name=RuneButton FontName="PR Uncial Alternate Capitals" Height=18 AntiAlias=1 CharactersPerPage=64
00038	//#exec new TrueTypeFontFactory Name=RuneButton FontName="Lucida Sans Unicode" Height=24 AntiAlias=1 CharactersPerPage=64 List ="00 04"
00039	
00040	// Font Use:
00041	//	SmallFont			Debugging, Scoreboard ping
00042	//	MedFont				Tab text, Scoreboard, Paused
00043	//	RuneButton			Menu Buttons
00044	//	RuneMed				Menus
00045	//	RuneBig				Menus, RuneMessages
00046	//	RuneLarge			Progress Messages
00047	//	Haettenschweiler16	Subtitles, Toplines
00048	//	??					Credits
00049	//
00050	//	Unused: ??: RuneCred, RuneCred2
00051	
00052	
00053	
00054	// Modifiable properties.
00055	var font    Font;            // Font for DrawText.
00056	var float   SpaceX, SpaceY;  // Spacing for after Draw*.
00057	var float   OrgX, OrgY;      // Origin for drawing.
00058	var float   ClipX, ClipY;    // Bottom right clipping region.
00059	var float   CurX, CurY;      // Current position for drawing.
00060	var float   Z;               // Z location. 1=no screenflash, 2=yes screenflash.
00061	var byte    Style;           // Drawing style STY_None means don't draw.
00062	var float   CurYL;           // Largest Y size since DrawText.
00063	var color   DrawColor;       // Color for drawing.
00064	var bool    bCenter;         // Whether to center the text.
00065	var bool    bNoSmooth;       // Don't bilinear filter.
00066	var const int SizeX, SizeY;  // Zero-based actual dimensions.
00067	var float	AlphaScale;		 // RUNE:  Alpha value used by STY_AlphaBlend
00068	
00069	// Stock fonts.
00070	var font SmallFont;          // Small system font.
00071	var font MedFont;            // Medium system font.
00072	var font BigFont;            // Big system font.
00073	var font LargeFont;          // Large system font.
00074	var font RuneMedFont;
00075	var font CredsFont;
00076	var font ButtonFont;
00077	
00078	// Internal.
00079	var const viewport Viewport; // Viewport that owns the canvas.
00080	var const int FramePtr;      // Scene frame pointer.
00081	var const int RenderPtr;	 // Render device pointer, only valid during UGameEngine::Draw
00082	
00083	// native functions.
00084	native(464) final function StrLen( coerce string String, out float XL, out float YL );
00085	native(465) final function DrawText( coerce string Text, optional bool CR );
00086	native(466) final function DrawTile( texture Tex, float XL, float YL, float U, float V, float UL, float VL );
00087	native(467) final function DrawActor( Actor A, bool WireFrame, optional bool ClearZ );
00088	native(468) final function DrawTileClipped( texture Tex, float XL, float YL, float U, float V, float UL, float VL );
00089	native(469) final function DrawTextClipped( coerce string Text, optional bool bCheckHotKey );
00090	native(470) final function TextSize( coerce string String, out float XL, out float YL );
00091	native(471) final function DrawClippedActor( Actor A, bool WireFrame, int X, int Y, int XB, int YB, optional bool ClearZ );
00092	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 );
00093	native(490) final function DrawLine( float X1, float Y1, float X2, float Y2, float R, float G, float B );
00094	native(491) final function DrawLine3D( vector P1, vector P2, float R, float G, float B );
00095	native(492) final function TransformPoint( vector P1, out int X, out int Y );
00096	
00097	
00098	final function DrawTextRightJustify(string text, int X, int Y)
00099	{
00100		local float w,h;
00101		StrLen(text, w, h);
00102		SetPos(X-w, Y);
00103		DrawText(text);
00104	}
00105	
00106	
00107	// UnrealScript functions.
00108	event Reset()
00109	{
00110		Font        = Default.Font;
00111		SpaceX      = Default.SpaceX;
00112		SpaceY      = Default.SpaceY;
00113		OrgX        = Default.OrgX;
00114		OrgY        = Default.OrgY;
00115		CurX        = Default.CurX;
00116		CurY        = Default.CurY;
00117		Style       = Default.Style;
00118		DrawColor   = Default.DrawColor;
00119		CurYL       = Default.CurYL;
00120		bCenter     = false;
00121		bNoSmooth   = false;
00122		Z           = 1.0;
00123	}
00124	final function SetPos( float X, float Y )
00125	{
00126		CurX = X;
00127		CurY = Y;
00128	}
00129	final function SetOrigin( float X, float Y )
00130	{
00131		OrgX = X;
00132		OrgY = Y;
00133	}
00134	final function SetClip( float X, float Y )
00135	{
00136		ClipX = X;
00137		ClipY = Y;
00138	}
00139	final function DrawPattern( texture Tex, float XL, float YL, float Scale )
00140	{
00141		DrawTile( Tex, XL, YL, (CurX-OrgX)*Scale, (CurY-OrgY)*Scale, XL*Scale, YL*Scale );
00142	}
00143	final function DrawIcon( texture Tex, float Scale )
00144	{
00145		if ( Tex != None )
00146			DrawTile( Tex, Tex.USize*Scale, Tex.VSize*Scale, 0, 0, Tex.USize, Tex.VSize );
00147	}
00148	final function DrawRect( texture Tex, float RectX, float RectY )
00149	{
00150		DrawTile( Tex, RectX, RectY, 0, 0, Tex.USize, Tex.VSize );
00151	}
00152	
00153	final function DrawBox3D( vector Center, vector Extents, int R, int G, int B )
00154	{
00155		local vector bX,bY,bZ;
00156		
00157		bX = vect(0,0,0); bX.X = Extents.X;
00158		bY = vect(0,0,0); bY.Y = Extents.Y;
00159		bZ = vect(0,0,0); bZ.Z = Extents.Z;
00160	
00161		// Top	
00162		DrawLine3D(Center+bZ+bX, Center+bZ+bY, R, G, B);
00163		DrawLine3D(Center+bZ+bY, Center+bZ-bX, R, G, B);
00164		DrawLine3D(Center+bZ-bX, Center+bZ-bY, R, G, B);
00165		DrawLine3D(Center+bZ-bY, Center+bZ+bX, R, G, B);
00166		
00167		// Bottom
00168		DrawLine3D(Center-bZ+bX, Center-bZ+bY, R, G, B);
00169		DrawLine3D(Center-bZ+bY, Center-bZ-bX, R, G, B);
00170		DrawLine3D(Center-bZ-bX, Center-bZ-bY, R, G, B);
00171		DrawLine3D(Center-bZ-bY, Center-bZ+bX, R, G, B);
00172	
00173		// Sides
00174		DrawLine3D(Center+bZ+bX, Center-bZ+bX, R, G, B);
00175		DrawLine3D(Center+bZ+bY, Center-bZ+bY, R, G, B);
00176		DrawLine3D(Center+bZ-bX, Center-bZ-bX, R, G, B);
00177		DrawLine3D(Center+bZ-bY, Center-bZ-bY, R, G, B);
00178	}
00179	
00180	final function DrawTube(vector v1, vector v2, int Radius, int Height, int R, int G, int B)
00181	{
00182		local vector p1, p2, tX, tY, tZ, tocorner1, tocorner2, tocorner3, tocorner4;
00183		local rotator toend;
00184	
00185		toend = rotator(v2 - v1);
00186		GetAxes(toend, tX, tY, tZ);
00187	
00188		tocorner1 =  tY*Radius + tZ*Height;
00189		tocorner2 =  tY*Radius - tZ*Height;
00190		tocorner3 = -tY*Radius - tZ*Height;
00191		tocorner4 = -tY*Radius + tZ*Height;
00192	
00193		// Length of box
00194		DrawLine3D( v1 + tocorner1, v2 + tocorner1, R, G, B);
00195		DrawLine3D( v1 + tocorner2, v2 + tocorner2, R, G, B);
00196		DrawLine3D( v1 + tocorner3, v2 + tocorner3, R, G, B);
00197		DrawLine3D( v1 + tocorner4, v2 + tocorner4, R, G, B);
00198	
00199		// End cap 1
00200		DrawLine3D( v1+tocorner1, v1+tocorner2, R, G, B);
00201		DrawLine3D( v1+tocorner2, v1+tocorner3, R, G, B);
00202		DrawLine3D( v1+tocorner3, v1+tocorner4, R, G, B);
00203		DrawLine3D( v1+tocorner4, v1+tocorner1, R, G, B);
00204	
00205		// End cap 2
00206		DrawLine3D( v2+tocorner1, v2+tocorner2, R, G, B);
00207		DrawLine3D( v2+tocorner2, v2+tocorner3, R, G, B);
00208		DrawLine3D( v2+tocorner3, v2+tocorner4, R, G, B);
00209		DrawLine3D( v2+tocorner4, v2+tocorner1, R, G, B);
00210	}
00211	
00212	// Color components are of the range 0..255
00213	final function Setcolor(float R, float G, float B)
00214	{
00215		DrawColor.R = R;
00216		DrawColor.G = G;
00217		DrawColor.B = B;
00218	}
00219	
00220	defaultproperties
00221	{
00222	     Z=1.000000
00223	     Style=1
00224	     DrawColor=(R=127,G=127,B=127)
00225	     AlphaScale=1.000000
00226	     SmallFont=Font'Engine.SmallFont'
00227	     MedFont=Font'Engine.MedFont'
00228	     BigFont=Font'Engine.Haettenschweiler16'
00229	     LargeFont=Font'Engine.RuneLarge'
00230	     RuneMedFont=Font'Engine.RuneMed'
00231	     CredsFont=Font'Engine.RuneCred'
00232	     ButtonFont=Font'Engine.RuneButton'
00233	}

End Source Code