Hatch Game Engine Documentation v1.4.0
The documentation for the Hatch Game Engine
Loading...
Searching...
No Matches
Application Class Reference

Functions for manipulating and reading runtime information. More...

Public Member Functions

array GetCommandLineArguments ()
 Gets a list of the command line arguments passed to the application.
string GetEngineVersionString ()
 Gets the engine version string.
integer GetEngineVersionMajor ()
 Gets the major engine version.
integer GetEngineVersionMinor ()
 Gets the minor engine version.
integer GetEngineVersionPatch ()
 Gets the minor engine version.
string GetEngineVersionPrerelease ()
 Gets the prerelease engine version.
string GetEngineVersionCodename ()
 Gets the engine version codename.
integer GetTargetFrameRate ()
 Gets the target frame rate of the fixed timestep.
void SetTargetFrameRate (integer framerate)
 Sets the target frame rate of the fixed timestep.
void UseFixedTimestep (boolean useFixedTimestep)
 Enables or disables fixed timestep. This is enabled by default.
decimal GetFPS ()
 Gets the current FPS (frames per second).
void ShowFPSCounter (boolean show)
 Enables or disables the FPS (frames per second) counter.
KeyBind GetKeyBind (KeyBind keyBind)
 Gets a keybind.
void SetKeyBind (KeyBind keyBind, Key keyID)
 Sets a keybind.
void GetGameTitle ()
 Gets the game title of the application.
void GetGameTitleShort ()
 Gets the short game title of the application.
void GetGameVersion ()
 Gets the version of the application.
void GetGameDescription ()
 Gets the description of the game.
void SetGameTitle (string title)
 Sets the title of the game.
void SetGameTitleShort (string title)
 Sets the short title of the game.
void SetGameVersion (string title)
 Sets the version of the game.
void SetGameDescription (string title)
 Sets the description of the game.
void SetCursorVisible (boolean cursorVisible)
 Sets the visibility of the cursor.
boolean GetCursorVisible ()
 Gets the visibility of the cursor.
void Error (string message, boolean detailed=true)
 Shows an error message to the user through a dialog box, if possible. The error message is also logged.
void SetDefaultFont (string font)
 Sets the default font to the given Resource path, or array containing Resource paths.
void SetDefaultFont (array font)
 Sets the default font to the given Resource path, or array containing Resource paths.
boolean ChangeGame (string path, string startingScene, array cmdLineArgs)
 Changes the current game, by loading a data file containing the new game.
void Quit ()
 Closes the application.

Detailed Description

Functions for manipulating and reading runtime information.

Member Function Documentation

◆ ChangeGame()

boolean Application.ChangeGame ( string path,
string startingScene,
array cmdLineArgs )

Changes the current game, by loading a data file containing the new game.

If the path ends with a path separator (/), an entire directory will be loaded as the game instead. Only game:// and user:// URLs are supported (or an absolute path that resolves to those locations).

This is permanent for as long as the application is running, so restarting the application using the associated developer key (KeyBind_DevRestartApp) will reload the current game, and not the one the application started with. Script compiling is also disabled after the game changes.

The change only takes effect after a frame completes.

Note that certain game configurations will persist between games if not set by the new GameConfig:

  • Game-identifying configurations:
    • Game title (including the short game title)
    • Game version
    • Game description
    • Game developer
    • Game identifier
    • Developer identifier
  • Paths:
    • Saves directory
    • Preferences directory
  • Engine configurations:
    • Window size
    • Audio volume
    • Target frame rate
    • Whether fixed timestep was enabled or disabled with useFixedTimestep
    • Settings filename
      this is changed, the current settings are discarded (not saved) and the new settings file is loaded. If the file does not exist, however, default settings will be loaded.

Some of the game's current state also persists between games:

  • Command line arguments (unless cmdLineArgs is passed to this function)
  • Palette colors
  • Whether palette rendering is enabled
  • Whether software rendering was enabled or disabled with useSoftwareRenderer

The following does not persist between games:

  • Any loaded resources
  • Any persistent entities
  • Scripting state

The following cannot be changed between games:

  • Log file name
  • Graphics rendering backend
Parameters
pathThe path of the data file to load.
startingSceneThe filename of the scene file to load upon changing the game. Note that restarting the game will load the starting scene defined in its GameConfig instead. Passing null to this argument is equivalent to not passing it at all.
cmdLineArgsAn array of strings containing the command line arguments to pass to the new game. If any of the values are not strings, they will be converted to a string representation. If this argument is not given, the current command line arguments will be passed to the new game.
Returns
Returns whether the game will change.

◆ Error()

void Application.Error ( string message,
boolean detailed = true )

Shows an error message to the user through a dialog box, if possible. The error message is also logged.

Parameters
messageThe error message to show to the user.
detailedWhether to show the stack trace alongside the error.

◆ GetCommandLineArguments()

array Application.GetCommandLineArguments ( )

Gets a list of the command line arguments passed to the application.

Returns
Returns an array of string values.

◆ GetCursorVisible()

boolean Application.GetCursorVisible ( )

Gets the visibility of the cursor.

Returns
Returns whether the cursor is visible.

◆ GetEngineVersionCodename()

string Application.GetEngineVersionCodename ( )

Gets the engine version codename.

Returns
Returns a string value, or null.

◆ GetEngineVersionMajor()

integer Application.GetEngineVersionMajor ( )

Gets the major engine version.

Returns
Returns an integer value.

◆ GetEngineVersionMinor()

integer Application.GetEngineVersionMinor ( )

Gets the minor engine version.

Returns
Returns an integer value.

◆ GetEngineVersionPatch()

integer Application.GetEngineVersionPatch ( )

Gets the minor engine version.

Returns
Returns an integer value.

◆ GetEngineVersionPrerelease()

string Application.GetEngineVersionPrerelease ( )

Gets the prerelease engine version.

Returns
Returns a string value, or null.

◆ GetEngineVersionString()

string Application.GetEngineVersionString ( )

Gets the engine version string.

Returns
Returns a string value.

◆ GetFPS()

decimal Application.GetFPS ( )

Gets the current FPS (frames per second).

Returns
Returns a decimal value.

◆ GetKeyBind()

KeyBind Application.GetKeyBind ( KeyBind keyBind)

Gets a keybind.

Parameters
keyBindThe keybind.
Returns
Returns the key ID of the keybind.

◆ GetTargetFrameRate()

integer Application.GetTargetFrameRate ( )

Gets the target frame rate of the fixed timestep.

Returns
Returns an integer value.

◆ SetCursorVisible()

void Application.SetCursorVisible ( boolean cursorVisible)

Sets the visibility of the cursor.

Parameters
cursorVisibleWhether the cursor is visible.

◆ SetDefaultFont() [1/2]

void Application.SetDefaultFont ( array font)

Sets the default font to the given Resource path, or array containing Resource paths.

Parameters
fontThe list of fonts. Passing null to this argument will change the default font to the one the application was built with, if one is present.

◆ SetDefaultFont() [2/2]

void Application.SetDefaultFont ( string font)

Sets the default font to the given Resource path, or array containing Resource paths.

Parameters
fontThe font. Passing null to this argument will change the default font to the one the application was built with, if one is present.

◆ SetGameDescription()

void Application.SetGameDescription ( string title)

Sets the description of the game.

Parameters
titleGame description.

◆ SetGameTitle()

void Application.SetGameTitle ( string title)

Sets the title of the game.

Parameters
titleGame title.

◆ SetGameTitleShort()

void Application.SetGameTitleShort ( string title)

Sets the short title of the game.

Parameters
titleShort game title.

◆ SetGameVersion()

void Application.SetGameVersion ( string title)

Sets the version of the game.

Parameters
titleGame version.

◆ SetKeyBind()

void Application.SetKeyBind ( KeyBind keyBind,
Key keyID )

Sets a keybind.

Parameters
keyBindThe keybind.
keyIDThe key ID.

◆ SetTargetFrameRate()

void Application.SetTargetFrameRate ( integer framerate)

Sets the target frame rate of the fixed timestep.

Parameters
framerateThe target frame rate.

◆ ShowFPSCounter()

void Application.ShowFPSCounter ( boolean show)

Enables or disables the FPS (frames per second) counter.

Parameters
showWhether to show the FPS counter.

◆ UseFixedTimestep()

void Application.UseFixedTimestep ( boolean useFixedTimestep)

Enables or disables fixed timestep. This is enabled by default.

Parameters
useFixedTimestepWhether to use fixed timestep.