Skip to content

Global #macros

Grisgram edited this page Feb 26, 2024 · 10 revisions

raptor defines some controller objects including the GameController and the RoomController objects. For each of them, a #macro exists for easier access. The macros are named the same as their respective object except uppercase, and they always point to the active instance of their object.

GAMECONTROLLER

You can access this from anywhere in your game. It holds the active GameController object which was persistently created in rmStartup.


ROOMCONTROLLER

The RoomController object is not persistent, and it must not be persistent! With this macro you can always access the controller of the currently active room.

"Why may a RoomController not be persistent?"

Because of the processing queues from the Animation and StateMachine subsystems. They must be cleaned up explicitly when a room ends. This is why the project template declares its own controller object in each room. They are all children of RoomController.


STATEMACHINES

A globally managed ListPool that controls all running StateMachine instances. It is declared in the RoomController object.

ANIMATIONS

A globally managed ListPool that controls all running Animation instances. It is declared in the RoomController object.


GLOBALDATA

This macro holds a global empty struct {} when the game starts. Put all of your global variables that must be saved/restored through the Savegame System into GLOBALDATA. The Savegame System persists this struct in and restores it from the savegame file.


SAVEGAME_SAVE_IN_PROGRESS

This holds a boolean that returns true while the Savegame System is serializing your object data to the savegame file.
See the documentation of the Savegame System for more details about how and when you might want to use this.

SAVEGAME_LOAD_IN_PROGRESS

This holds a boolean that returns true while the Savegame System is serializing your object data from the savegame file and is actively creating your game objects.
See the documentation of the Savegame System for more details about how and when you might want to use this.


GUI_RUNTIME_CONFIG

This global holds a configuration struct that is used by many raptor components, mostly the controls. You can adapt the values for the needs of your game.

Best place to do so is the onGameStart callback in the Game_Configuration script in the _GAME_SETUP_ section of the project template.

These values and methods are available in GUI_RUNTIME_CONFIG:

Name Type Description
tooltip_delay_frames Value Number of frames to wait when the mouse hovers over an item before the tooltip is shown.
Default: 30 Frames (0.5 seconds)
text_cursor_blink_speed Value The interval of the text cursor in the InputBox.
Default: 30 Frames (0.5 seconds)
text_key_repeat_delay Value Number of frames to wait when a key is held down until the InputBox starts repeating that key.
Default: 30 Frames (0.5 seconds)
text_key_repeat_interval Value Interval in frames for how fast keys shall be repeated.
Default: 2 Frames (30 chars/second -- this is windows default)
gui_scale_set(xscale,yscale) Method Scale the UI layer. Default: 1 for both dimensions
gui_scale_disable_maximize Method Reset UI to default. This calls display_set_gui_maximise with (-1,-1) parameters

Getting started

Raptor Modules

Clone this wiki locally