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
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
//=============================================================================
// 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 Object
    native
    noexport;

// added for drawing solid primatives.
#exec TEXTURE IMPORT NAME=WhiteTexture FILE=Textures\White.tga MIPS=0
#exec TEXTURE IMPORT NAME=BlackTexture FILE=Textures\Black.tga MIPS=0
#exec TEXTURE IMPORT NAME=GrayTexture  FILE=Textures\Gray.tga MIPS=0

// simple default font, so various stuff doesn't crash
#exec Font Import File=Textures\SmallFont.bmp Name="DefaultFont"

// Modifiable properties.
var font    Font;            // Font for DrawText.
var float   FontScaleX, FontScaleY; // Scale for DrawText & DrawTextClipped. // gam
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.
var Plane   ColorModulate;   // sjs - Modulate all colors by this before rendering
var bool    bForceAlpha;     // Force all drawing to be alpha'ed
var float   ForcedAlpha;     // How much to force

var bool    bRenderLevel;    // gam - Will render the level if enabled.

// Stock fonts.
var font TinyFont, SmallFont, MedFont;
var localized string TinyFontName, SmallFontName, MedFontName;

// Internal.
var const viewport Viewport; // Viewport that owns the canvas.
var const pointer      pCanvasUtil; // sjs

// 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 );
native(466) final function DrawTile( material Mat, float XL, float YL, float U, float V, float UL, float VL );
native(467) final function DrawActor( Actor A, bool WireFrame, optional bool ClearZ, optional float DisplayFOV );
native(468) final function DrawTileClipped( Material Mat, float XL, float YL, float U, float V, float UL, float VL );
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 );
native final function vector WorldToScreen( vector WorldLoc );
native final function GetCameraLocation( out vector CameraLocation, out rotator CameraRotation );

native final function SetScreenLight( int index, vector Position, color lightcolor, float radius );
native final function SetScreenProjector( int index, vector Position, color color, float radius, texture tex );
native final function DrawScreenActor( Actor A, optional float FOV, optional bool WireFrame, optional bool ClearZ );
native final function Clear(optional bool ClearRGB, optional bool ClearZ);
native final function WrapStringToArray(string Text, out array<string> OutArray, float dx, optional string EOL);
static native final function WrapText( out String Text, out String Line, float dx, Font F, float FontScaleX );


// jmw - These are two helper functions.  The use the whole texture only.  If you need better support, use DrawTile

native final function DrawTilePartialStretched( Material Mat, float XL, float YL ); // rjp
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);
native final function DrawActorClipped( Actor A, bool WireFrame, float Left, float Top, float Width, float Height, optional bool ClearZ, optional float DisplayFOV);

// UnrealScript functions.
event Reset()
{
    Font        = Default.Font;
    FontScaleX  = Default.FontScaleX; // gam
    FontScaleY  = Default.FontScaleY; // gam
    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;
    ColorModulate = Default.ColorModulate; // sjs
}
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)
{
    local float cX,cY;
    
    CX = CurX; CY = CurY;
    CurX = X;
    DrawTile(Texture'engine.WhiteSquareTexture', 2, height, 0, 0, 2, 2);
    CurX = CX; CurY = CY;
}

// Draw a horizontal line
final function DrawHorizontal(float Y, float width)
{
    local float cx,cy;
    CX = CurX; CY = CurY;
    CurY = Y;
    DrawTile(Texture'engine.WhiteSquareTexture', width, 2, 0, 0, 2, 2);
    CurX = CX; CurY = CY;
}

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

final function DrawLine(int direction, float size)
{
    local float cx,cy;
    CX = CurX; CY = CurY;

    switch (direction)
    {
        case 0:
            CurY-=Size;
            DrawVertical(CurX,size);
            break;
        case 1:
            DrawVertical(CurX,size);
            break;
        case 2:
            CurX-=Size;
            DrawHorizontal(CurY,size);
            break;
        case 3:
            DrawHorizontal(CurY,size);
            break;
    }
    CurX = CX; CurY = CY;
}

final simulated function DrawBracket(float width, float height, float bracket_size)
{
    local float x,y;
    Width  = max(width,5);
    Height = max(height,5);

    x = curX;   Y = curY;

    DrawHorizontal(CurY,bracket_size);
    DrawHorizontal(CurY+Height,bracket_size);
    DrawVertical(CurX,bracket_size);
    DrawVertical(CurX+Width,bracket_size);

    CurY = Y + Height-bracket_size;
    DrawVertical(CurX,Bracket_size);
    DrawVertical(CurX+Width,Bracket_Size);

    CurX = X+Width-Bracket_Size;
    DrawHorizontal(Y,Bracket_Size);
    DrawHorizontal(Y+Height, Bracket_Size);

}

final simulated function DrawBox(canvas canvas, float width, float height)
{
    DrawHorizontal(CurY,Width);
    DrawHorizontal(CurY+Height,Width);
    DrawVertical(CurX,Height);
    DrawVertical(CurX+Width,Height);
}

simulated function DrawScreenText (String Text, float X, float Y, EDrawPivot Pivot)
{
    local int TextScreenWidth, TextScreenHeight;
    local float UL, VL;

    X *= SizeX;
    Y *= SizeY;

    TextSize (Text, UL, VL);

    TextScreenWidth = UL;
    TextScreenHeight = VL;

    switch (Pivot)
    {
        case DP_UpperLeft:
            break;

        case DP_UpperMiddle:
            X -= TextScreenWidth / 2;
            break;

        case DP_UpperRight:
            X -= TextScreenWidth;
            break;

        case DP_MiddleRight:
            X -= TextScreenWidth;
            Y -= TextScreenHeight / 2;
            break;

        case DP_LowerRight:
            X -= TextScreenWidth;
            Y -= TextScreenHeight;
            break;

        case DP_LowerMiddle:
            X -= TextScreenWidth / 2;
            Y -= TextScreenHeight;
            break;

        case DP_LowerLeft:
            Y -= TextScreenHeight;
            break;

        case DP_MiddleLeft:
            Y -= TextScreenHeight / 2;
            break;

        case DP_MiddleMiddle:
            X -= TextScreenWidth / 2;
            Y -= TextScreenHeight / 2;
            break;
    }

    SetPos (X, Y);
    DrawTextClipped (Text);
}

defaultproperties
{
     Font=Font'Engine.DefaultFont'
     FontScaleX=1.000000
     FontScaleY=1.000000
     Z=1.000000
     Style=1
     DrawColor=(B=127,G=127,R=127,A=255)
     ColorModulate=(W=1.000000,X=1.000000,Y=1.000000,Z=1.000000)
     bRenderLevel=True
     TinyFontName="UT2003Fonts.FontMono"
     SmallFontName="UT2003Fonts.FontMono"
     MedFontName="UT2003Fonts.FontMono800x600"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 23/10/2006 20:25:16.000 - Creation time: Wed 7/2/2007 19:16:35.562 - Created with UnCodeX