Skip to content

View

This package can create textures on the screen and work with them in an extended manner.

Dependencies

Initialization

Initialize with LeGo_View flag.

LeGo_Init(LeGo_View);

Implementation

View.d on GitHub

Functions

View_Create

Creates a zCView with virtual coordinates.

func int View_Create(var int x1, var int y1, var int x2, var int y2) 
Parameters
  • var int x1/var int y1
    Top-left corner coordinates (virtual)
  • var int x2/var int y2
    Bottom-right corner coordinates (virtual)

Return value

The function returns a PermMem handle to a zCView.

View_CreatePxl

Alias for View_Create using pixel coordinates.

func int View_CreatePxl(var int x1, var int y1, var int x2, var int y2) 
Parameters
  • var int x1/var int y1
    Top-left corner coordinates (pixel)
  • var int x2/var int y2
    Bottom-right corner coordinates (pixel)

Return value

The function returns a PermMem handle to a zCView.

View_CreateCenter

Creates a zCView with virtual coordinates centered.

func int View_CreateCenter(var int x, var int y, var int width, var int height)
Parameters
  • var int x
    Horizontal position
  • var int y
    Vertical position
  • var int width
    Width of the view
  • var int height
    Height of the view

Return value

The function returns a PermMem handle to a zCView.

View_CreateCenterPxl

Alias for View_CreateCenter using pixel coordinates.

func int View_CreateCenterPxl(var int x, var int y, var int width, var int height)
Parameters
  • var int x
    Horizontal position
  • var int y
    Vertical position
  • var int width
    Width of the view
  • var int height
    Height of the view

Return value

The function returns a PermMem handle to a zCView.

View_Get

Alias for get form PermMem.

zCView View_Get(var int hndl)
Parameters

View_GetPtr

Alias for getPtr form PermMem.

func int View_GetPtr(var int hndl)
Parameters

View_Render

Renders a zCView. Should be used sparingly, as it works only in specific cases.

func void View_Render(var int hndl)
Parameters

View_SetTexture

Assigns a texture to a view. The key function of this package.

func void View_SetTexture(var int hndl, var string texture)
Parameters
  • var int hndl
    Handle created with View_Create
  • var string texture
    Filename of a texture

View_GetTexture

Gets the name of a previously assigned texture.

func string View_GetTexture(var int hndl)
Parameters

Return value

The function returns the previously assigned texture.

View_SetColor

Sets the color of a view.

func void View_SetColor(var int hndl, var int color)
Parameters
  • var int hndl
    Handle created with View_Create
  • var int color
    zColor, can be created with RGBA

View_GetColor

Gets the color of a view.

func int View_GetColor(var int hndl)
Parameters

Return value

The function returns the full zColor.

View_Open

Opens a view. It will be displayed on the screen.

func void View_Open(var int hndl)
Parameters

View_Close

Closes a view. It disappears from the screen but can still be used.

func void View_Close(var int hndl)
Parameters

View_Delete

Alias for delete.

`zCView` View_Delete(var int hndl)
Parameters

View_Resize

Scales a view to a virtual size. The top-left position of the view remains fixed.

func void View_Resize(var int hndl, var int width, var int height)
Parameters
  • var int hndl
    Handle created with View_Create
  • var int width
    New width of the view
  • var int height
    New height of the view

View_ResizePxl

Alias for View_Resize using pixel coordinates.

func void View_ResizePxl(var int hndl, var int width, var int height)
Parameters
  • var int hndl
    Handle created with View_Create
  • var int width
    New width of the view
  • var int height
    New height of the view

View_Move

Moves the view by virtual units.

func void View_Move(var int hndl, var int x, var int y)
Parameters
  • var int hndl
    Handle created with View_Create
  • var int x
    Shift left/right
  • var int y
    Shift up/down

View_MovePxl

Alias for View_Move using pixel coordinates.

func void View_MovePxl(var int hndl, var int x, var int y)
Parameters
  • var int hndl
    Handle created with View_Create
  • var int x
    Shift left/right
  • var int y
    Shift up/down

View_MoveTo

Moves the top-left corner of the view to a virtual position.

func void View_MoveTo(var int hndl, var int x, var int y)
Parameters
  • var int hndl
    Handle created with View_Create
  • var int x
    New horizontal position (-1 for no change)
  • var int y
    New vertical position (-1 for no change)

View_MoveToPxl

Alias for View_MoveTo using pixel coordinates.

func void View_MoveToPxl(var int hndl, var int x, var int y)
Parameters
  • var int hndl
    Handle created with View_Create
  • var int x
    New horizontal position (-1 for no change)
  • var int y
    New vertical position (-1 for no change)

View_AddText

Adds a text line to the view. The position is virtual and relative to the view's position. If the view is moved, the text moves as well.

func void View_AddText(var int hndl, var int x, var int y, var string text, var string font)
Parameters
  • var int hndl
    Handle created with View_Create
  • var int x
    Horizontal position
  • var int y
    Vertical position
  • var string text
    Added text
  • var string font
    Used Font

View_DeleteText

Removes all text added with View_AddText.

func void View_DeleteText(var int hndl)
Parameters

View_Top

Places the view above all others.

func void View_Top(var int hndl)
Parameters

Examples

Display a texture on the screen

Here a texture should be displayed over the entire screen:

1
2
3
4
5
6
7
func void Example1() {
    var int View; 
    View = View_Create(0, 0, PS_VMax, PS_VMax); // Virtual coordinates
    View_SetTexture(View, "MyTexture.tga"); // Assign a texture to the view
    // display the view on the screen:
    View_Open(View);
};

This would mean that the texture would be permanently visible on the screen (even after loading/saving/restarting). If we want it to disappear we have to use either View_Delete or View_Close.

Display a texture with pixel coordinates

Now a texture should be displayed at the top right and be 256 x 256 pixels in size:

1
2
3
4
5
6
7
func void Example2() {
    Print_GetScreenSize();
    var int View;
    View = View_CreatePxl(Print_Screen[PS_X] - 256, 0, Print_Screen[PS_X], 256); // Pixel coordinates
    View_SetTexture(View, "MYTEXTURE.TGA");
    View_Open(View);
};

To get the size of the screen we use the interface package.