cmdfx 0.2.1
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
scenes.h File Reference

UI extensions for Scenes in CmdFX. More...

#include "cmdfx/core/scenes.h"
#include "cmdfx/ui/button.h"

Go to the source code of this file.

Macros

#define MAX_BUTTONS_PER_SCENE   128
 The maximum number of buttons per scene.
 

Functions

CmdFX_Button ** Scene_getButtons (int uid)
 Gets the buttons of a scene.
 
int Scene_getButtonsCount (int uid)
 Gets the number of buttons in a scene.
 
int * Scene_getButtonCoordinates (int uid, CmdFX_Button *button)
 Gets the coordinates of a button in a scene.
 
int Scene_addButton (int uid, CmdFX_Button *button, int x, int y)
 Adds a button to a scene.
 
int Scene_removeButton (int uid, CmdFX_Button *button)
 Removes a button from a scene.
 
int Scene_removeButtonAt (int uid, int x, int y)
 Removes a button from a scene at the specified coordinates.
 
int Scene_removeAllButtons (int uid)
 Removes all buttons from a scene.
 

Detailed Description

UI extensions for Scenes in CmdFX.

Author
Gregory Mitchell (me@gm.nosp@m.itch.nosp@m.215.x.nosp@m.yz)
Version
0.2.0
Date
2025-04-26

Macro Definition Documentation

◆ MAX_BUTTONS_PER_SCENE

#define MAX_BUTTONS_PER_SCENE   128

The maximum number of buttons per scene.

This is the maximum number of buttons that can be added to a scene. If this limit is reached, no more buttons can be added to the scene.

Function Documentation

◆ Scene_addButton()

int Scene_addButton ( int uid,
CmdFX_Button * button,
int x,
int y )

Adds a button to a scene.

This function adds a button to a scene. The button is stored in the scene and can be used to interact with the scene. The scene must be registered in order to add buttons to it.

Parameters
uidThe unique identifier of the scene.
buttonThe button to add to the scene.
xThe x-coordinate of the button.
yThe y-coordinate of the button.
Returns
0 if the button was added successfully, or -1 if an error occurred.

◆ Scene_getButtonCoordinates()

int * Scene_getButtonCoordinates ( int uid,
CmdFX_Button * button )

Gets the coordinates of a button in a scene.

This function gets the coordinates of a button in a scene. The coordinates are stored in the scene and can be used to interact with the scene.

The array returned is a pointer to an array of two integers, where X is the first element and Y is the second element. The coordinates are relative to the scene. The array will be freed when the scene is freed, so it should not be freed by the caller. If the button is not found, this function returns NULL.

Parameters
uidThe unique identifier of the scene.
buttonThe button to get the coordinates of.
Returns
A pointer to an array of two integers representing the coordinates of the button.

◆ Scene_getButtons()

CmdFX_Button ** Scene_getButtons ( int uid)

Gets the buttons of a scene.

This function gets the buttons of a scene. The buttons are stored in the scene and can be used to interact with the scene. The scene must be registered in order to add buttons to it.

Parameters
uidThe unique identifier of the scene.
Returns
A pointer to an array of pointers to the buttons in the scene.

◆ Scene_getButtonsCount()

int Scene_getButtonsCount ( int uid)

Gets the number of buttons in a scene.

This function gets the number of buttons in a scene. The buttons are stored in the scene and can be used to interact with the scene. The scene must be registered in order to add buttons to it.

Parameters
uidThe unique identifier of the scene.
Returns
The number of buttons in the scene.

◆ Scene_removeAllButtons()

int Scene_removeAllButtons ( int uid)

Removes all buttons from a scene.

This function removes all buttons from a scene. The buttons are removed from the scene and can no longer be used to interact with the scene, and the array of buttons is freed. The scene must be registered in order to remove buttons from it. The buttons are not freed, only the array of buttons.

Parameters
uidThe unique identifier of the scene.
Returns
0 if all buttons were removed successfully, or -1 if an error occurred.

◆ Scene_removeButton()

int Scene_removeButton ( int uid,
CmdFX_Button * button )

Removes a button from a scene.

This function removes a button from a scene. The button is removed from the scene and can no longer be used to interact with the scene. The scene must be registered in order to remove buttons from it.

Parameters
uidThe unique identifier of the scene.
buttonThe button to remove from the scene.
Returns
0 if the button was removed successfully, or -1 if an error occurred.

◆ Scene_removeButtonAt()

int Scene_removeButtonAt ( int uid,
int x,
int y )

Removes a button from a scene at the specified coordinates.

This function removes a button from a scene at the specified coordinates. The button is removed from the scene and can no longer be used to interact with the scene. The scene must be registered in order to remove buttons from it. The button is not freed, only the array of buttons is freed. The button is removed from the scene and can no longer be used to interact with the scene.

Parameters
uidThe unique identifier of the scene.
xThe x-coordinate of the button to remove.
yThe y-coordinate of the button to remove.
Returns
0 if the button was removed successfully, or -1 if an error occurred.