Interface
Info
Dependencies:
- AI_Function
- Anim8
- HookEngine
- PermMem
Implementation:
Interface.d on GitHub
This package offers a lot of useful functions to work with the 2D interface.
Initialization
Initialize with LeGo_Interface
and LeGo_PrintS
flag.
Functions
sysGetTime
sysGetTime
Better alternative for MEM_GetSysTime()
from Ikarus.
The function returns elapsed time since game (system) startup.
RGBA
RGBA
Generates a full zColor
.
var int r
Red channel value (0..255)var int g
Green channel value (0..255)var int b
Blue channel value (0..255)var int a
Alpha (0..255, 0 = invisible)
Return value
The function returns a zColor
object.
ChangeAlpha
ChangeAlpha
Overrides the alpha value of a given zColor
.
var int zCol
zColor
to modifyvar int a
New alpha value
Return value
The function returns a modified zColor
object.
GetAlpha
GetAlpha
Returns the alpha value of a given zColor
.
var int zCol
zColor
to get alpha from
Print_CreateText
Print_CreateText
Creates a new zCViewText
on the screen with PermMem that can be freely edited.
var string text
The text of thezCViewText
var string font
Font of text
Return value
The function returns a handle to zCViewText
.
Print_CreateTextPtr
Print_CreateTextPtr
Print_CreateText
but returns pointer to zCViewText
instead of handle.
var string text
The text of thezCViewText
var string font
Font of text
Return value
The function returns a pointer to zCViewText
.
Print_CreateTextPtrColored
Print_CreateTextPtrColored
Print_CreateTextPtr
but with additional parameter to chose color of text.
var string text
The text of thezCViewText
var string font
Font of textvar int color
zColor
e.g. generated with RGBA function
Return value
The function returns a pointer to zCViewText
.
Print_GetText
Print_GetText
Returns zCViewText
instance from handle.
var int hndl
Handle tozCViewText
Print_GetTextPtr
Print_GetTextPtr
Returns zCViewText
pointer from handle.
var int hndl
Handle tozCViewText
Print_DeleteText
Print_DeleteText
Removes a zCViewText
from the screen.
var int hndl
Handle tozCViewText
(formPrint_CreateText
orPrint_Ext
)
Print_SetAlpha
Print_SetAlpha
Changes the alpha value of a given zCViewText
.
var int hndl
Handle tozCViewText
var int a
New alpha value
PrintPtr_SetAlpha
PrintPtr_SetAlpha
Print_SetAlpha
but with pointer to zCViewText
instead of handle.
var int ptr
Pointer tozCViewText
var int a
New alpha value
Print_GetScreenSize
Print_GetScreenSize
Writes the current resolution to the Print_Screen array and the current aspect ratio to Print_Ratio variable.
Print_Screen
Print_Screen
An int array holding the current resolution. (Filled by Print_GetScreenSize
)
-
Print_Screen[PS_X]
is the horizontal resolution -
Print_Screen[PS_Y]
is the vertical resolution
Print_Ratio
Print_Ratio
A float variable that holds the current aspect ratio. (Filled by Print_GetScreenSize
)
PS_VMax
PS_VMax
An int constant that holds the highest possible value of a virtual coordinate.
Print_ToVirtual
Print_ToVirtual
Convents pixel position to a virtual position.
var int pxl
Pixel position to convertvar int dim
PS_X or PS_Y (seePrint_Screen
)
Return value
The function returns a virtual position of a given pixel position.
Print_ToVirtualF
Print_ToVirtualF
Print_ToVirtual
but returns Ikarus float value instead of integer.
var int pxl
Pixel position to convertvar int dim
PS_X or PS_Y (seePrint_Screen
)
Return value
The function returns a virtual position of a given pixel position as Ikarus float.
Print_ToPixel
Print_ToPixel
Convents virtual position to a pixel position.
var int vrt
Virtual position to convertvar int dim
PS_X or PS_Y (seePrint_Screen
)
Return value
The function returns a pixel position of a given virtual position.
Print_ToPixelF
Print_ToPixelF
Print_ToPixel
but returns Ikarus float value instead of integer.
var int vrt
Virtual position to convertvar int dim
PS_X or PS_Y (seePrint_Screen
)
Return value
The function returns a pixel position of a given virtual position as Ikarus float.
Print_ToRatio
Print_ToRatio
Gets the size in the specified dimension in ratioed by the screen.
var int size
Size to convertvar int dim
PS_X or PS_Y (seePrint_Screen
)
Return value
The function returns size correctly calculated to the ratio.
Example
If you have a view and the view you need to be a square of 400 units, you would do:
This is because width is always the max in virtual coordinates - 8192 virtual points and the height has a different height based on the ratio, this function calculates it for you.PS_X
can be used in function, if you already have the height but need the width in the correct ratio.
Print_ToRadian
Print_ToRadian
Converts angle in degrees to radians.
var int angle
Angle in degrees
Return value
The function returns calculated angle in radians.
Print_ToDegree
Print_ToDegree
Converts angle in radians to degrees.
var int angle
Angle in radians
Return value
The function returns calculated angle in degrees.
Print_GetFontPtr
Print_GetFontPtr
Returns a pointer to a zCFont
by its name.
var string font
Name of font
Print_GetFontName
Print_GetFontName
Returns a name of a zCFont
from its pointer.
var int fontPtr
Pointer to font
Print_GetStringWidth
Print_GetStringWidth
Returns the width of a string in pixels.
var string s
Measured stringvar string font
Name of font
Print_GetStringWidthPtr
Print_GetStringWidthPtr
Print_GetStringWidth
but with zCFont
pointer instead of name.
var string s
Measured stringvar int font
zCFont
pointer
Print_GetFontHeight
Print_GetFontHeight
Returns the height of a string in pixels.
var string font
Name of font
Print_Ext
Print_Ext
Like the external PrintScreen
, writes a text on the screen, but with more options.
var int x
X coordinate on the screen (virtual)var int y
Y coordinate on the screen (virtual)var string text
Displayed textvar string font
Name of fontvar int color
zColor
e.g. generated with RGBA functionvar int time
display time in milliseconds (-1 = permanent)
Return value
If time == -1
, a valid handle is returned. If time != -1
, the print is only volatile and no handle is returned.
Print_ExtPxl
Print_ExtPxl
Print_Ext
but with pixel coordinates instead of virtual.
var int x
X coordinate on the screen (pixel)var int y
Y coordinate on the screen (pixel)var string text
Displayed textvar string font
Name of fontvar int color
zColor
e.g. generated with RGBA functionvar int time
display time in milliseconds (-1 = permanent)
Return value
If time == -1
, a valid handle is returned. If time != -1
, the print is only volatile and no handle is returned.
Print_LongestLine
Print_LongestLine
Returns the longest line from text
as a string, using default line separator tilde ~
.
var string text
Measured textvar string font
Name of font
Print_LongestLineExt
Print_LongestLineExt
Returns the longest line from text
as a string, but you specify new line separator.
var string text
Measured textvar string font
Name of fontvar string separator
New line separator
Print_LongestLineLength
Print_LongestLineLength
Returns the longest line width in pixels, using default line separator tilde ~
.
var string text
Measured textvar string font
Name of font
Print_LongestLineLengthExt
Print_LongestLineLengthExt
Returns the longest line width in pixels, but allows you to specify new line separator.
var string text
Measured textvar string font
Name of fontvar string separator
New line separator
Print_TextField
Print_TextField
Creates a text field (view with text) using virtual coordinates.
var int x
X coordinate (virtual)var int y
Y coordinate (virtual)var string text
Text to be printedvar string font
Name of fontvar int height
A specific lineheight
Return value
The function returns a text field pointer. Here is how it is used:
Print_TextFieldPxl
Print_TextFieldPxl
Print_TextField
but with pixel coordinates.
var int x
X coordinate (pixel)var int y
Y coordinate (pixel)var string text
Text to be printedvar string font
Name of font
Return value
The function returns a text field pointer. Look at the Print_TextField
return value to see an example.
Print_TextFieldColored
Print_TextFieldColored
Print_TextField
but you specify the color of text.
var int x
X coordinate (virtual)var int y
Y coordinate (virtual)var string text
Text to be printedvar string font
Name of fontvar int height
A specific lineheight
var int color
zColor
e.g. generated with RGBA function
Return value
The function returns a text field pointer. Look at the Print_TextField
return value to see an example.
PrintS
PrintS
Same function as the external Print
, but with smooth animations. The effect can be changed as desired with the user constants.
var string txt
Printed text
PrintS_Ext
PrintS_Ext
PrintS
but with an additional parameter to choose the color of the text.
var string txt
Printed textvar int color
zColor
e.g. generated with RGBA function
AI_PrintS
AI_PrintS
Version of PrintS
that enqueue in given NPCs AI queue.
var c_npc slf
NPC to whose AI queue the function is enqueuedvar string txt
Printed text
AI_PrintS_Ext
AI_PrintS_Ext
Version of PrintS_Ext
that enqueue in given NPCs AI queue.
var c_npc slf
NPC to whose AI queue the function is enqueuedvar string txt
Printed textvar int color
zColor
e.g. generated with RGBA function
Examples
Manage a print via zCViewText
It is also possible to create the text only via Print_CreateText and set it yourself. In this example, a text should fly over the image from left to right and be deleted again. The movement is handled by Anim8:
Manage a print via zCViewText with LeGo 2.2+
In those days it was perhaps pleasant, but today it is no longer. Anim8 has seen a few improvements with LeGo 2.2 that make it much easier to create the same effect: