cmdfx 0.2.1
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
CmdFX::Scene Class Referencefinal

A C++ wrapper around a CmdFX_Scene struct. More...

#include <scenes.hpp>

Public Member Functions

 Scene (CmdFX_Scene *scene)
 
 Scene (int width, int height)
 
 Scene (int width, int height, char c, char *ansi, int z)
 
 Scene (std::vector< std::string > data, std::vector< std::vector< std::string > > ansi)
 
 Scene (char **data, char ***ansi)
 
CmdFX_ScenegetScene ()
 Get the Scene object associated with this class.
 
int getX () const
 
int getY () const
 
int getWidth () const
 
int getHeight () const
 
int getZ () const
 
int getUniqueId () const
 Gets the unique identifier of the scene.
 
std::vector< std::string > getData ()
 Get the data of a scene as a 1D vector of strings.
 
int setData (char **data)
 
int setData (std::vector< std::string > data)
 Sets the data of a scene.
 
std::vector< std::vector< std::string > > getAnsi ()
 Gets the ANSI data of a scene as a 2D vector of strings.
 
int setAnsi (char ***ansi)
 
int setAnsi (std::vector< std::vector< std::string > > ansi)
 Sets the ANSI data of a scene.
 
int appendAnsi (char ***ansi)
 
int appendAnsi (std::vector< std::vector< std::string > > ansi)
 Appends the ANSI data to the current ANSI data of the scene.
 
int setForeground (int x, int y, int width, int height, int rgb)
 
int setForegroundAll (int rgb)
 
int setBackground (int x, int y, int width, int height, int rgb)
 
int setBackgroundAll (int rgb)
 
int clear ()
 
int draw (int x, int y)
 
int drawPortion (int x, int y, int sx, int sy, int width, int height)
 
bool isOnTop () const
 
bool isOnTopAt (int x, int y) const
 
bool isOnBottom () const
 
bool isOnBottomAt (int x, int y) const
 
int remove ()
 
bool isEmpty () const
 
int switchTo (int x, int y)
 
int registerScene ()
 Registers the scene to be drawn on the screen.
 
int unregisterScene ()
 Unregisters the scene from being drawn on the screen.
 
int scroll (int dx, int dy)
 Scrolls the scene by the specified amount.
 

Static Public Member Functions

static std::unique_ptr< ScenegetSceneAt (int x, int y)
 
static int drawRegistered (int uid, int x, int y)
 
static int switchToRegistered (int uid, int x, int y)
 
static int scroll (int uid, int dx, int dy)
 

Detailed Description

A C++ wrapper around a CmdFX_Scene struct.

This class is a wrapper around the CmdFX_Scene struct. It provides a constructor and destructor for the scene, as well as methods to get and set the scene's data. The destructor will free the scene's memory when the object is destroyed.

Member Function Documentation

◆ appendAnsi()

int CmdFX::Scene::appendAnsi ( std::vector< std::vector< std::string > > ansi)
inline

Appends the ANSI data to the current ANSI data of the scene.

Parameters
ansiThe ANSI data to append.
Returns
The result of the operation.

◆ getAnsi()

std::vector< std::vector< std::string > > CmdFX::Scene::getAnsi ( )
inline

Gets the ANSI data of a scene as a 2D vector of strings.

Returns
The ANSI data of the scene.

◆ getData()

std::vector< std::string > CmdFX::Scene::getData ( )
inline

Get the data of a scene as a 1D vector of strings.

Returns
The data of the scene.

◆ getScene()

CmdFX_Scene * CmdFX::Scene::getScene ( )
inline

Get the Scene object associated with this class.

Returns
The scene object.

◆ getUniqueId()

int CmdFX::Scene::getUniqueId ( ) const
inline

Gets the unique identifier of the scene.

This function returns the unique identifier of the scene, which is used to register and unregister the scene for drawing on the screen. If the scene has not been registered, this will return -1.

Returns
The unique identifier of the scene.

◆ registerScene()

int CmdFX::Scene::registerScene ( )
inline

Registers the scene to be drawn on the screen.

Returns
scene->uid if the scene was registered successfully, or -1 if an error occurred.

◆ scroll()

int CmdFX::Scene::scroll ( int dx,
int dy )
inline

Scrolls the scene by the specified amount.

This function scrolls the scene by the specified amount in the x and y directions. The amount is specified by the dx and dy parameters, which represent the amount to scroll in the x and y directions, respectively. This requires the scene to be registered with the Scene Engine.

Parameters
dxThe amount to scroll in the x direction.
dyThe amount to scroll in the y direction.
Returns
0 if the scene was scrolled successfully, or -1 if an error occurred.

◆ setAnsi()

int CmdFX::Scene::setAnsi ( std::vector< std::vector< std::string > > ansi)
inline

Sets the ANSI data of a scene.

Parameters
ansiThe ANSI data to set.
Returns
The result of the operation.

◆ setData()

int CmdFX::Scene::setData ( std::vector< std::string > data)
inline

Sets the data of a scene.

Parameters
dataThe data to set.
Returns
The result of the operation.

◆ unregisterScene()

int CmdFX::Scene::unregisterScene ( )
inline

Unregisters the scene from being drawn on the screen.

Returns
The unique identifier of the scene before it was unregistered, or -1 if an error occurred.

The documentation for this class was generated from the following file: