R-Type  2
Doom but in better
Loading...
Searching...
No Matches
Main Class Reference

The Main class is the main class of the program. More...

#include <RealMain.hpp>

Collaboration diagram for Main:
Collaboration graph

Public Member Functions

 Main (const std::string &ip="127.0.0.1", unsigned int port=9000, unsigned int windowWidth=800, unsigned int windowHeight=600, bool windowCursor=true, bool windowFullscreen=false, const std::string &windowTitle="R-Type", unsigned int windowX=0, unsigned int windowY=0, const std::string &windowCursorIcon="NULL", bool imageIsSprite=false, bool spriteStartTop=false, bool spriteStartLeft=false, unsigned int spriteWidth=20, unsigned int spriteHeight=20, unsigned int frameLimit=60, const std::string &configFilePath="client_config.toml", const bool log=false, const bool debug=false, const std::string &player="Player")
 Constructor for the Main class.
 
 ~Main ()
 Destroy the Main:: Main object.
 
void run ()
 This is the function used to start the program's main section.
 
void setIp (const std::string &ip)
 This is the function in charge of setting the ip on which the GUI is going to use to communicate about the server.
 
void setPort (const unsigned int port)
 Set the port on which the GUI is going to connect to.
 
void setWindowWidth (unsigned int width)
 Set the width of the window.
 
void setWindowCursor (bool cursorVisible)
 Set if the cursor is visible when in the window.
 
void setWindowHeight (unsigned int height)
 Set the height of the window.
 
void setWindowFullscreen (bool fullscreen)
 Start the window in full screen mode.
 
void setWindowTitle (const std::string &title)
 Set the title of the window.
 
void setWindowPositionX (unsigned int x)
 Set the X position of the window.
 
void setWindowPositionY (unsigned int y)
 Set the Y position of the window.
 
void setWindowPosition (unsigned int x, unsigned int y)
 Set the position of the window.
 
void setWindowCursorIcon (const std::string cursorImage)
 Set the icon of the cursor (if the user wishes to change the default icon)
 
void setWindowCursorSprite (bool imageIsSprite)
 Set if the image passed is of type sprite or not.
 
void setWindowCursorSpriteWidth (unsigned int spriteWidth)
 Set the height for the sprite's overlay texture, which is used to draw the sprite's texture during animation.
 
void setWindowCursorSpriteReadFromTop (bool spriteStartTop)
 Inform if the animation should start from the top.
 
void setWindowCursorSpriteHeight (unsigned int spriteHeight)
 Set the height for the sprite's overlay texture, which is used to draw the sprite's texture during animation.
 
void setWindowCursorSpriteReadFromLeft (bool spriteStartLeft)
 Inform if the animation should start from the left.
 
void setWindowSize (unsigned int width, unsigned int height)
 The window width and height that will be created.
 
void setFrameLimit (unsigned int frameLimit)
 The function in charge of setting the frame Limit.
 
void setConfigFile (const std::string &configFile)
 This is the function in charge of seting the config filepath.
 
void setLog (const bool debug)
 Toggle the logging mode for the program.
 
void setDebug (const bool debug)
 Toggle the debug mode for the program.
 
void setActiveScreen (const ActiveScreen screen)
 Function in charge of updating the type of screen that is supposed to be displayed as well as change the music based on the active screen.
 
void setPlayer (const std::string &player)
 Sets the player's name.
 
const std::string getIp ()
 Get the value of the ip that was set.
 
const unsigned int getPort ()
 Get the value of the port.
 
unsigned int getWindowWidth ()
 Get the value of the window width.
 
unsigned int getWindowHeight ()
 Get the value of the window height.
 
bool getWindowCursor ()
 Get the status of the window cursor.
 
bool getWindowFullscreen ()
 Get the status of the window (if it is in fullscreen)
 
const std::string & getWindowTitle ()
 Get the title of the window.
 
const std::string & getWindowCursorIcon ()
 Get the icon to display for the window's cursor.
 
bool getWindowCursorSprite ()
 Get the status if the cursor is of type image or spritesheet.
 
bool getWindowCursorSpriteReadFromTop ()
 Get if the program is supposed to read from the top or not.
 
bool getWindowCursorSpriteReadFromLeft ()
 Get if the program is supposed to read from the left or the rigth.
 
unsigned int getWindowCursorSpriteWidth ()
 Get the width of the sprite texture.
 
unsigned int getWindowCursorSpriteHeight ()
 Get the height of the sprite texture.
 
const bool getLog () const
 The function in charge of returning the status of the logging variable.
 
const bool getDebug () const
 The function in charge of returning the status of the debug variable.
 
unsigned int getFrameLimit () const
 Function in charge of returning the current frame limit.
 
std::string getConfigFile () const
 Function in charge of returning the path to the config file.
 
std::tuple< unsigned int, unsigned int > getWindowPosition ()
 Get the window's position.
 
std::tuple< unsigned int, unsigned int > getWindowSize ()
 Get the windows dimensions.
 
const ActiveScreen getActiveScreen () const
 Function in charge of returning the screen that is currently active.
 
const std::string getActiveScreenAsString () const
 Function in charge of returning the screen that is currently active but here, the type will be converted to the human readable version of the screen type.
 
const std::string getPlayer () const
 Retrieves the player's name.
 

Detailed Description

The Main class is the main class of the program.

Definition at line 54 of file RealMain.hpp.

Constructor & Destructor Documentation

◆ Main()

Main::Main ( const std::string & ip = "127.0.0.1",
unsigned int port = 9000,
unsigned int windowWidth = 800,
unsigned int windowHeight = 600,
bool windowCursor = true,
bool windowFullscreen = false,
const std::string & windowTitle = "R-Type",
unsigned int windowX = 0,
unsigned int windowY = 0,
const std::string & windowCursorIcon = "NULL",
bool imageIsSprite = false,
bool spriteStartTop = false,
bool spriteStartLeft = false,
unsigned int spriteWidth = 20,
unsigned int spriteHeight = 20,
unsigned int frameLimit = 60,
const std::string & configFilePath = "client_config.toml",
const bool log = false,
const bool debug = false,
const std::string & player = "Player" )

Constructor for the Main class.

Parameters
ipThe IP address to use for connections (default: "127.0.0.1").
portThe port number to use for connections (default: 9000).
windowWidthThe width of the application window (default: 800).
windowHeightThe height of the application window (default: 600).
windowCursorWhether the cursor should be visible (default: true).
windowFullscreenWhether the window should start in fullscreen mode (default: false).
windowTitleThe title of the window (default: "R-Type").
windowXThe X position of the window (default: 0).
windowYThe Y position of the window (default: 0).
windowCursorIconPath to the cursor icon image (default: "NULL").
imageIsSpriteWhether the cursor is rendered as a sprite (default: false).
spriteStartTopWhether the sprite rendering starts from the top (default: false).
spriteStartLeftWhether the sprite rendering starts from the left (default: false).
spriteWidthThe width of the sprite (default: 20).
spriteHeightThe height of the sprite (default: 20).
frameLimitThe frame rate limit for the application (default: 60).
configFilePathPath to the configuration file (default: "client_config.toml").
logInform the program if it needs to output logs or not (default: false).
debugWhether debug mode is enabled (default: false).
ipThe IP address to use for connections (default: "127.0.0.1").
portThe port number to use for connections (default: 9000).
windowWidthThe width of the application window (default: 800).
windowHeightThe height of the application window (default: 600).
windowCursorWhether the cursor should be visible (default: true).
windowFullscreenWhether the window should start in fullscreen mode (default: false).
windowTitleThe title of the window (default: "R-Type").
windowXThe X position of the window (default: 0).
windowYThe Y position of the window (default: 0).
windowCursorIconPath to the cursor icon image (default: "NULL").
imageIsSpriteWhether the cursor is rendered as a sprite (default: false).
spriteStartTopWhether the sprite rendering starts from the top (default: false).
spriteStartLeftWhether the sprite rendering starts from the left (default: false).
spriteWidthThe width of the sprite (default: 20).
spriteHeightThe height of the sprite (default: 20).
frameLimitThe frame rate limit for the application (default: 60).
configFilePathPath to the configuration file (default: "client_config.toml").
logInform the program if it needs to output logs or not (default: false).
debugWhether debug mode is enabled (default: false).
usernameThe name of the user that is going to play (default: player)

Definition at line 43 of file MainClass.cpp.

◆ ~Main()

Main::~Main ( )

Destroy the Main:: Main object.

Definition at line 129 of file MainClass.cpp.

Member Function Documentation

◆ getActiveScreen()

const ActiveScreen Main::getActiveScreen ( ) const

Function in charge of returning the screen that is currently active.

Returns
const ActiveScreen

Definition at line 5698 of file MainClass.cpp.

◆ getActiveScreenAsString()

const std::string Main::getActiveScreenAsString ( ) const

Function in charge of returning the screen that is currently active but here, the type will be converted to the human readable version of the screen type.

Returns
const std::string

Definition at line 5710 of file MainClass.cpp.

◆ getConfigFile()

std::string Main::getConfigFile ( ) const

Function in charge of returning the path to the config file.

Returns
std::string

Definition at line 5660 of file MainClass.cpp.

◆ getDebug()

const bool Main::getDebug ( ) const

The function in charge of returning the status of the debug variable.

Returns
true
false

Definition at line 5638 of file MainClass.cpp.

◆ getFrameLimit()

unsigned int Main::getFrameLimit ( ) const

Function in charge of returning the current frame limit.

Returns
unsigned int

Definition at line 5649 of file MainClass.cpp.

◆ getIp()

const std::string Main::getIp ( )

Get the value of the ip that was set.

Returns
const std::string

Definition at line 5489 of file MainClass.cpp.

◆ getLog()

const bool Main::getLog ( ) const

The function in charge of returning the status of the logging variable.

Returns
true
false

Definition at line 5627 of file MainClass.cpp.

◆ getPlayer()

const std::string Main::getPlayer ( ) const

Retrieves the player's name.

This function returns the name of the current player.

Returns
A string containing the player's name.

Definition at line 5722 of file MainClass.cpp.

◆ getPort()

const unsigned int Main::getPort ( )

Get the value of the port.

Returns
const unsigned int

Definition at line 5499 of file MainClass.cpp.

◆ getWindowCursor()

bool Main::getWindowCursor ( )

Get the status of the window cursor.

Returns
true
false

Definition at line 5530 of file MainClass.cpp.

◆ getWindowCursorIcon()

const std::string & Main::getWindowCursorIcon ( )

Get the icon to display for the window's cursor.

The string represents a path to the image/sprite file to load.

Returns
const std::string

Definition at line 5563 of file MainClass.cpp.

◆ getWindowCursorSprite()

bool Main::getWindowCursorSprite ( )

Get the status if the cursor is of type image or spritesheet.

Returns
true
false

Definition at line 5574 of file MainClass.cpp.

◆ getWindowCursorSpriteHeight()

unsigned int Main::getWindowCursorSpriteHeight ( )

Get the height of the sprite texture.

Returns
unsigned int

Definition at line 5616 of file MainClass.cpp.

◆ getWindowCursorSpriteReadFromLeft()

bool Main::getWindowCursorSpriteReadFromLeft ( )

Get if the program is supposed to read from the left or the rigth.

Returns
true
false

Definition at line 5596 of file MainClass.cpp.

◆ getWindowCursorSpriteReadFromTop()

bool Main::getWindowCursorSpriteReadFromTop ( )

Get if the program is supposed to read from the top or not.

Returns
true
false

Definition at line 5585 of file MainClass.cpp.

◆ getWindowCursorSpriteWidth()

unsigned int Main::getWindowCursorSpriteWidth ( )

Get the width of the sprite texture.

Returns
unsigned int

Definition at line 5606 of file MainClass.cpp.

◆ getWindowFullscreen()

bool Main::getWindowFullscreen ( )

Get the status of the window (if it is in fullscreen)

Returns
true
false

Definition at line 5541 of file MainClass.cpp.

◆ getWindowHeight()

unsigned int Main::getWindowHeight ( )

Get the value of the window height.

Returns
unsigned int

Definition at line 5519 of file MainClass.cpp.

◆ getWindowPosition()

std::tuple< unsigned int, unsigned int > Main::getWindowPosition ( )

Get the window's position.

The order of the tuple is x,y

Returns
std::tuple<unsigned int, unsigned int>

Definition at line 5672 of file MainClass.cpp.

◆ getWindowSize()

std::tuple< unsigned int, unsigned int > Main::getWindowSize ( )

Get the windows dimensions.

The order of the tuple is width, height

Returns
std::tuple<unsigned int, unsigned int>

Definition at line 5686 of file MainClass.cpp.

◆ getWindowTitle()

const std::string & Main::getWindowTitle ( )

Get the title of the window.

Returns
const std::string&

Definition at line 5551 of file MainClass.cpp.

◆ getWindowWidth()

unsigned int Main::getWindowWidth ( )

Get the value of the window width.

Returns
unsigned int

Definition at line 5509 of file MainClass.cpp.

◆ run()

void Main::run ( )

This is the function used to start the program's main section.

Returns
int The status of the execution of that section of the program.

Definition at line 5205 of file MainClass.cpp.

◆ setActiveScreen()

void Main::setActiveScreen ( const ActiveScreen screen)

Function in charge of updating the type of screen that is supposed to be displayed as well as change the music based on the active screen.

Parameters
screenof type Active screen which informs the program of the current screen type that needs to be processed.

Definition at line 5466 of file MainClass.cpp.

◆ setConfigFile()

void Main::setConfigFile ( const std::string & configFile)

This is the function in charge of seting the config filepath.

Parameters
configFile

Definition at line 5431 of file MainClass.cpp.

◆ setDebug()

void Main::setDebug ( const bool debug)

Toggle the debug mode for the program.

Parameters
debug

Definition at line 5453 of file MainClass.cpp.

◆ setFrameLimit()

void Main::setFrameLimit ( unsigned int frameLimit)

The function in charge of setting the frame Limit.

Parameters
frameLimit

Definition at line 5418 of file MainClass.cpp.

◆ setIp()

void Main::setIp ( const std::string & ip)

This is the function in charge of setting the ip on which the GUI is going to use to communicate about the server.

Parameters
ip: std::string
Exceptions
CustomExceptions::IncorrectIp(ip): This error is thrown if the ip format is wrong.

Definition at line 5221 of file MainClass.cpp.

◆ setLog()

void Main::setLog ( const bool log)

Toggle the logging mode for the program.

Parameters
log

Definition at line 5442 of file MainClass.cpp.

◆ setPlayer()

void Main::setPlayer ( const std::string & player)

Sets the player's name.

This function assigns a name to the player. If the provided name is empty, it defaults the player's name to "Player" and logs a warning message.

Parameters
playerThe name of the player to set. If empty, the default name "Player" is used.

Definition at line 4374 of file MainClass.cpp.

◆ setPort()

void Main::setPort ( const unsigned int port)

Set the port on which the GUI is going to connect to.

Parameters
port
Exceptions
CustomExceptions::InvalidPort(port)This error is thrown if the port format is incorrect

Definition at line 5238 of file MainClass.cpp.

◆ setWindowCursor()

void Main::setWindowCursor ( bool cursorVisible)

Set if the cursor is visible when in the window.

Parameters
cursorVisible

Definition at line 5273 of file MainClass.cpp.

◆ setWindowCursorIcon()

void Main::setWindowCursorIcon ( const std::string cursorImage)

Set the icon of the cursor (if the user wishes to change the default icon)

Parameters
cursorImage
Exceptions
CustomExceptions::FileNotFound(cursorImage)This error is thrown if the path to the file is invalid or the file cannot be opened.

Definition at line 5338 of file MainClass.cpp.

◆ setWindowCursorSprite()

void Main::setWindowCursorSprite ( bool imageIsSprite)

Set if the image passed is of type sprite or not.

Parameters
imageIsSprite

Definition at line 5354 of file MainClass.cpp.

◆ setWindowCursorSpriteHeight()

void Main::setWindowCursorSpriteHeight ( unsigned int spriteHeight)

Set the height for the sprite's overlay texture, which is used to draw the sprite's texture during animation.

Parameters
spriteHeight

Definition at line 5396 of file MainClass.cpp.

◆ setWindowCursorSpriteReadFromLeft()

void Main::setWindowCursorSpriteReadFromLeft ( bool spriteStartLeft)

Inform if the animation should start from the left.

Parameters
spriteStartLeft

Definition at line 5385 of file MainClass.cpp.

◆ setWindowCursorSpriteReadFromTop()

void Main::setWindowCursorSpriteReadFromTop ( bool spriteStartTop)

Inform if the animation should start from the top.

Parameters
spriteStartTop

Definition at line 5375 of file MainClass.cpp.

◆ setWindowCursorSpriteWidth()

void Main::setWindowCursorSpriteWidth ( unsigned int spriteWidth)

Set the height for the sprite's overlay texture, which is used to draw the sprite's texture during animation.

Parameters
spriteWidth

Definition at line 5365 of file MainClass.cpp.

◆ setWindowFullscreen()

void Main::setWindowFullscreen ( bool fullscreen)

Start the window in full screen mode.

Parameters
fullscreen

Definition at line 5283 of file MainClass.cpp.

◆ setWindowHeight()

void Main::setWindowHeight ( unsigned int height)

Set the height of the window.

Parameters
height

Definition at line 5263 of file MainClass.cpp.

◆ setWindowPosition()

void Main::setWindowPosition ( unsigned int x,
unsigned int y )

Set the position of the window.

Parameters
xThe x position of the window.
yThe y position of the window.

Definition at line 5304 of file MainClass.cpp.

◆ setWindowPositionX()

void Main::setWindowPositionX ( unsigned int x)

Set the X position of the window.

Parameters
xThe x position of the window.

Definition at line 5315 of file MainClass.cpp.

◆ setWindowPositionY()

void Main::setWindowPositionY ( unsigned int y)

Set the Y position of the window.

Parameters
yThe y position of the window.

Definition at line 5325 of file MainClass.cpp.

◆ setWindowSize()

void Main::setWindowSize ( unsigned int width,
unsigned int height )

The window width and height that will be created.

Parameters
width
height

Definition at line 5407 of file MainClass.cpp.

◆ setWindowTitle()

void Main::setWindowTitle ( const std::string & title)

Set the title of the window.

Parameters
title

Definition at line 5293 of file MainClass.cpp.

◆ setWindowWidth()

void Main::setWindowWidth ( unsigned int width)

Set the width of the window.

Parameters
width

Definition at line 5253 of file MainClass.cpp.


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