Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Engine.Canvas


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
//=============================================================================
// 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.
//=============================================================================
class Canvas extends Core.Object
	native
	noexport;

// Modifiable properties.
var const font    DefaultFont;     // Font for DrawText.
var font	Font;
var float   SpaceX, SpaceY;  // Spacing for after Draw*.
var float   OrgX, OrgY;      // Origin for drawing.
var float   ClipX, ClipY;    // Bottom right clipping region.
var float   CurX, CurY;      // Current position for drawing.
var float   Z;               // Z location. 1=no screenflash, 2=yes screenflash.
var byte    Style;           // Drawing style STY_None means don't draw.
var float   CurYL;           // Largest Y size since DrawText.
var color   DrawColor;       // Color for drawing.
var bool    bCenter;         // Whether to center the text.
var bool    bNoSmooth;       // Don't bilinear filter.
var const int SizeX, SizeY;  // Zero-based actual dimensions.

// Stock fonts.
var const font TinyFont, SmallFont, MedFont;
var string DefaultFontName, TinyFontName, SmallFontName, MedFontName;
var Texture WhiteTex;

// Internal.
var const Viewport Viewport; // Viewport that owns the canvas.
var const int      pCanvasUtil; 

// native functions.
native(464) final function StrLen( coerce string String, out float XL, out float YL ); // Wrapped!
native(465) final function DrawText( coerce string Text, optional bool CR );
#if IG_SHARED // david: optional UVs draw entire tile
native(466) final function DrawTile( material Mat, float XL, float YL, optional float U, optional float V, optional float UL, optional float VL );
#else
native(466) final function DrawTile( material Mat, float XL, float YL, float U, float V, float UL, float VL );
#endif
native(467) final function DrawActor( Actor A, bool Wireframe, optional bool ClearZ, optional float DisplayFOV );

native function DrawPositionedActor( Actor A, bool WireFrame, optional bool ClearZ, optional float DisplayFOV, optional Rotator cameraRot, optional float zoom ); 

#if IG_SHARED // Paul: optional UVs draw entire tile
native(468) final function DrawTileClipped( Material Mat, float XL, float YL, optional float U, optional float V, optional float UL, optional float VL );
#else
native(468) final function DrawTileClipped( Material Mat, float XL, float YL, float U, float V, float UL, float VL );
#endif
native(469) final function DrawTextClipped( coerce string Text, optional bool bCheckHotKey );
native(470) final function TextSize( coerce string String, out float XL, out float YL ); // Clipped!
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 );

#if IG_TRIBES3	// Paul: Draw Portal scaled
native final function DrawPortalScaled( int X, int Y, int Width, int Height, actor CamActor, vector CamLocation, rotator CamRotation, optional int FOV, optional bool ClearZ );
#endif

native final function WrapStringToArray(string Text, out array<string> OutArray, float dx, string EOL
#if IG_GUI_LAYOUT //dkaplan - allow checking of html style codes
    , optional bool bIsCodedString
#endif
    );

// jmw - These are two helper functions.  The use the whole texture only.  If you need better support, use DrawTile
native final function DrawTileStretched(material Mat, float XL, float YL);
native final function DrawTileJustified(material Mat, byte Justification, float XL, float YL);
native final function DrawTileScaled(material Mat, float XScale, float YScale);
native final function DrawTextJustified(coerce string String, byte Justification, float x1, float y1, float x2, float y2);

#if IG_SHARED // ckline: more convenient text drawing utils
// Draws a multiline text string with the top-left character of the first line at the specified Origin2D in screen space.
// Newline characters inside the Text string will delineate lines in the rendered output. 
// If BackgroundColor.A != 0, then the area under the text will be filled with that color (but the background will be opaque, ignoring the alpha component).
// Default value of BackgroundColor is (0,0,0,A=0)
// If Wrapped is false (the default), then the text will be clipped to the edges of the viewport rather than wrapped around the side.
// If Centered is false (the default), then the text will be left-justified.
native final function DrawTextMultiline(coerce string Text, vector Origin2D, Color ForegroundColor, optional Color BackgroundColor, optional int Wrapped, optional int Centered);
#endif

// IGA >>> New functions for drawing lines and tiles
native(490) final function DrawArbitraryLine(float X1, float Y1, float X2, float Y2, optional color LineColor);
native(491) final function DrawArbitraryTile(material Mat, float Xone, float Yone, float Xtwo, float Ytwo,
											 float Xthree, float Ythree, float Xfour, float Yfour,
											 float U, float V, float UL, float VL);
// IGA

// UnrealScript functions.
event Reset()
{
	Font		= DefaultFont;
	SpaceX      = Default.SpaceX;
	SpaceY      = Default.SpaceY;
	OrgX        = Default.OrgX;
	OrgY        = Default.OrgY;
	CurX        = Default.CurX;
	CurY        = Default.CurY;
	Style       = Default.Style;
	DrawColor   = Default.DrawColor;
	CurYL       = Default.CurYL;
	bCenter     = false;
	bNoSmooth   = false;
	Z           = 1.0;
}
final function SetPos( float X, float Y )
{
	CurX = X;
	CurY = Y;
}
final function SetOrigin( float X, float Y )
{
	OrgX = X;
	OrgY = Y;
}
final function SetClip( float X, float Y )
{
	ClipX = X;
	ClipY = Y;
}
final function DrawPattern( material Tex, float XL, float YL, float Scale )
{
	DrawTile( Tex, XL, YL, (CurX-OrgX)*Scale, (CurY-OrgY)*Scale, XL*Scale, YL*Scale );
}
final function DrawIcon( texture Tex, float Scale )
{
	if ( Tex != None )
		DrawTile( Tex, Tex.USize*Scale, Tex.VSize*Scale, 0, 0, Tex.USize, Tex.VSize );
}
final function DrawRect( texture Tex, float RectX, float RectY )
{
	DrawTile( Tex, RectX, RectY, 0, 0, Tex.USize, Tex.VSize );
}

final function SetDrawColor(byte R, byte G, byte B, optional byte A)
{
	local Color C;
	
	C.R = R;
	C.G = G;
	C.B = B;
	if ( A == 0 )
		A = 255;
	C.A = A;
	DrawColor = C;
}

static final function Color MakeColor(byte R, byte G, byte B, optional byte A)
{
	local Color C;
	
	C.R = R;
	C.G = G;
	C.B = B;
	if ( A == 0 )
		A = 255;
	C.A = A;
	return C;
}

// Draw a vertical line
final function DrawVertical(float X, float height)
{
    SetPos( X, CurY);
    DrawRect(WhiteTex, 1, height);
}

// Draw a horizontal line
final function DrawHorizontal(float Y, float width)
{
    SetPos(CurX, Y);
    DrawRect(WhiteTex, width, 1);
}

// Draw Line is special as it saves it's original position

final function DrawLine(int direction, float size)
{
    local float X, Y;

    // Save current position
    X = CurX;
    Y = CurY;

    switch (direction) 
    {
      case 0:
		  SetPos(X, Y - size);
		  DrawRect(WhiteTex, 2, size);
		  break;
    
      case 1:
		  DrawRect(WhiteTex, 2, size);
		  break;

      case 2:
		  SetPos(X - size, Y);
		  DrawRect(WhiteTex, size, 2);
		  break;
		  
	  case 3:
		  DrawRect(WhiteTex, size, 2);
		  break;
    }
    // Restore position
    SetPos(X, Y);
}

final simulated function DrawBracket(float width, float height, float bracket_size)
{
    local float X, Y;
    X = CurX;
    Y = CurY;

	width  = Max(width,5);
	height = Max(height,5);
	
    DrawLine(3, bracket_size);
    DrawLine(1, bracket_size);
    SetPos(X + width, Y);
    DrawLine(2, bracket_size);
    DrawLine(1, bracket_size);
    SetPos(X + width, Y + height);
    DrawLine(0, bracket_size);
    DrawLine(2, bracket_size);
    SetPos(X, Y + height);
    DrawLine(3, bracket_size);
    DrawLine( 0, bracket_size);

    SetPos(X, Y);
}

final simulated function DrawBox(canvas canvas, float width, float height)
{
	local float X, Y;
	X = canvas.CurX;
	Y = canvas.CurY;
	canvas.DrawRect(WhiteTex, 1, height);
	canvas.DrawRect(WhiteTex, width, 1);
	canvas.SetPos(X + width, Y);
	canvas.DrawRect(WhiteTex, 1, height);
	canvas.SetPos(X, Y + height);
	canvas.DrawRect(WhiteTex, width+1, 1);
	canvas.SetPos(X, Y);
}


defaultproperties
{
     Style=1
	 Z=1
     DrawColor=(R=127,G=127,B=127,A=255)
	 DefaultFontName="Engine_res.Res_DefaultFont"
	 TinyFontName="Engine_res.Res_DefaultFont"
     SmallFontName="Engine_res.Res_DefaultFont"
     MedFontName="Engine_res.Res_DefaultFont"
	 WhiteTex = Texture'engine_res.WhiteSquareTexture'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 16:01:20.000 - Creation time: st 23.5.2018 00:10:42.645 - Created with UnCodeX