![]() |
R-Type
2
Doom but in better
|
The Main class is the main class of the program. More...
#include <RealMain.hpp>
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. | |
The Main class is the main class of the program.
Definition at line 54 of file RealMain.hpp.
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.
ip | The IP address to use for connections (default: "127.0.0.1"). |
port | The port number to use for connections (default: 9000). |
windowWidth | The width of the application window (default: 800). |
windowHeight | The height of the application window (default: 600). |
windowCursor | Whether the cursor should be visible (default: true). |
windowFullscreen | Whether the window should start in fullscreen mode (default: false). |
windowTitle | The title of the window (default: "R-Type"). |
windowX | The X position of the window (default: 0). |
windowY | The Y position of the window (default: 0). |
windowCursorIcon | Path to the cursor icon image (default: "NULL"). |
imageIsSprite | Whether the cursor is rendered as a sprite (default: false). |
spriteStartTop | Whether the sprite rendering starts from the top (default: false). |
spriteStartLeft | Whether the sprite rendering starts from the left (default: false). |
spriteWidth | The width of the sprite (default: 20). |
spriteHeight | The height of the sprite (default: 20). |
frameLimit | The frame rate limit for the application (default: 60). |
configFilePath | Path to the configuration file (default: "client_config.toml"). |
log | Inform the program if it needs to output logs or not (default: false). |
debug | Whether debug mode is enabled (default: false). |
ip | The IP address to use for connections (default: "127.0.0.1"). |
port | The port number to use for connections (default: 9000). |
windowWidth | The width of the application window (default: 800). |
windowHeight | The height of the application window (default: 600). |
windowCursor | Whether the cursor should be visible (default: true). |
windowFullscreen | Whether the window should start in fullscreen mode (default: false). |
windowTitle | The title of the window (default: "R-Type"). |
windowX | The X position of the window (default: 0). |
windowY | The Y position of the window (default: 0). |
windowCursorIcon | Path to the cursor icon image (default: "NULL"). |
imageIsSprite | Whether the cursor is rendered as a sprite (default: false). |
spriteStartTop | Whether the sprite rendering starts from the top (default: false). |
spriteStartLeft | Whether the sprite rendering starts from the left (default: false). |
spriteWidth | The width of the sprite (default: 20). |
spriteHeight | The height of the sprite (default: 20). |
frameLimit | The frame rate limit for the application (default: 60). |
configFilePath | Path to the configuration file (default: "client_config.toml"). |
log | Inform the program if it needs to output logs or not (default: false). |
debug | Whether debug mode is enabled (default: false). |
username | The name of the user that is going to play (default: player) |
Definition at line 43 of file MainClass.cpp.
Main::~Main | ( | ) |
Destroy the Main:: Main object.
Definition at line 129 of file MainClass.cpp.
const ActiveScreen Main::getActiveScreen | ( | ) | const |
Function in charge of returning the screen that is currently active.
Definition at line 5698 of file MainClass.cpp.
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.
Definition at line 5710 of file MainClass.cpp.
std::string Main::getConfigFile | ( | ) | const |
Function in charge of returning the path to the config file.
Definition at line 5660 of file MainClass.cpp.
const bool Main::getDebug | ( | ) | const |
The function in charge of returning the status of the debug variable.
Definition at line 5638 of file MainClass.cpp.
unsigned int Main::getFrameLimit | ( | ) | const |
Function in charge of returning the current frame limit.
Definition at line 5649 of file MainClass.cpp.
const std::string Main::getIp | ( | ) |
Get the value of the ip that was set.
Definition at line 5489 of file MainClass.cpp.
const bool Main::getLog | ( | ) | const |
The function in charge of returning the status of the logging variable.
Definition at line 5627 of file MainClass.cpp.
const std::string Main::getPlayer | ( | ) | const |
Retrieves the player's name.
This function returns the name of the current player.
Definition at line 5722 of file MainClass.cpp.
const unsigned int Main::getPort | ( | ) |
bool Main::getWindowCursor | ( | ) |
Get the status of the window cursor.
Definition at line 5530 of file MainClass.cpp.
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.
Definition at line 5563 of file MainClass.cpp.
bool Main::getWindowCursorSprite | ( | ) |
Get the status if the cursor is of type image or spritesheet.
Definition at line 5574 of file MainClass.cpp.
unsigned int Main::getWindowCursorSpriteHeight | ( | ) |
Get the height of the sprite texture.
Definition at line 5616 of file MainClass.cpp.
bool Main::getWindowCursorSpriteReadFromLeft | ( | ) |
Get if the program is supposed to read from the left or the rigth.
Definition at line 5596 of file MainClass.cpp.
bool Main::getWindowCursorSpriteReadFromTop | ( | ) |
Get if the program is supposed to read from the top or not.
Definition at line 5585 of file MainClass.cpp.
unsigned int Main::getWindowCursorSpriteWidth | ( | ) |
Get the width of the sprite texture.
Definition at line 5606 of file MainClass.cpp.
bool Main::getWindowFullscreen | ( | ) |
Get the status of the window (if it is in fullscreen)
Definition at line 5541 of file MainClass.cpp.
unsigned int Main::getWindowHeight | ( | ) |
Get the value of the window height.
Definition at line 5519 of file MainClass.cpp.
std::tuple< unsigned int, unsigned int > Main::getWindowPosition | ( | ) |
Get the window's position.
The order of the tuple is x,y
Definition at line 5672 of file MainClass.cpp.
std::tuple< unsigned int, unsigned int > Main::getWindowSize | ( | ) |
Get the windows dimensions.
The order of the tuple is width, height
Definition at line 5686 of file MainClass.cpp.
const std::string & Main::getWindowTitle | ( | ) |
Get the title of the window.
Definition at line 5551 of file MainClass.cpp.
unsigned int Main::getWindowWidth | ( | ) |
Get the value of the window width.
Definition at line 5509 of file MainClass.cpp.
void Main::run | ( | ) |
This is the function used to start the program's main section.
Definition at line 5205 of file MainClass.cpp.
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.
screen | of 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.
void Main::setConfigFile | ( | const std::string & | configFile | ) |
This is the function in charge of seting the config filepath.
configFile |
Definition at line 5431 of file MainClass.cpp.
void Main::setDebug | ( | const bool | debug | ) |
Toggle the debug mode for the program.
debug |
Definition at line 5453 of file MainClass.cpp.
void Main::setFrameLimit | ( | unsigned int | frameLimit | ) |
The function in charge of setting the frame Limit.
frameLimit |
Definition at line 5418 of file MainClass.cpp.
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.
ip | : std::string |
CustomExceptions::IncorrectIp(ip) | : This error is thrown if the ip format is wrong. |
Definition at line 5221 of file MainClass.cpp.
void Main::setLog | ( | const bool | log | ) |
Toggle the logging mode for the program.
log |
Definition at line 5442 of file MainClass.cpp.
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.
player | The name of the player to set. If empty, the default name "Player" is used. |
Definition at line 4374 of file MainClass.cpp.
void Main::setPort | ( | const unsigned int | port | ) |
Set the port on which the GUI is going to connect to.
port |
CustomExceptions::InvalidPort(port) | This error is thrown if the port format is incorrect |
Definition at line 5238 of file MainClass.cpp.
void Main::setWindowCursor | ( | bool | cursorVisible | ) |
Set if the cursor is visible when in the window.
cursorVisible |
Definition at line 5273 of file MainClass.cpp.
void Main::setWindowCursorIcon | ( | const std::string | cursorImage | ) |
Set the icon of the cursor (if the user wishes to change the default icon)
cursorImage |
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.
void Main::setWindowCursorSprite | ( | bool | imageIsSprite | ) |
Set if the image passed is of type sprite or not.
imageIsSprite |
Definition at line 5354 of file MainClass.cpp.
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.
spriteHeight |
Definition at line 5396 of file MainClass.cpp.
void Main::setWindowCursorSpriteReadFromLeft | ( | bool | spriteStartLeft | ) |
Inform if the animation should start from the left.
spriteStartLeft |
Definition at line 5385 of file MainClass.cpp.
void Main::setWindowCursorSpriteReadFromTop | ( | bool | spriteStartTop | ) |
Inform if the animation should start from the top.
spriteStartTop |
Definition at line 5375 of file MainClass.cpp.
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.
spriteWidth |
Definition at line 5365 of file MainClass.cpp.
void Main::setWindowFullscreen | ( | bool | fullscreen | ) |
Start the window in full screen mode.
fullscreen |
Definition at line 5283 of file MainClass.cpp.
void Main::setWindowHeight | ( | unsigned int | height | ) |
void Main::setWindowPosition | ( | unsigned int | x, |
unsigned int | y ) |
Set the position of the window.
x | The x position of the window. |
y | The y position of the window. |
Definition at line 5304 of file MainClass.cpp.
void Main::setWindowPositionX | ( | unsigned int | x | ) |
Set the X position of the window.
x | The x position of the window. |
Definition at line 5315 of file MainClass.cpp.
void Main::setWindowPositionY | ( | unsigned int | y | ) |
Set the Y position of the window.
y | The y position of the window. |
Definition at line 5325 of file MainClass.cpp.
void Main::setWindowSize | ( | unsigned int | width, |
unsigned int | height ) |
The window width and height that will be created.
width | |
height |
Definition at line 5407 of file MainClass.cpp.
void Main::setWindowTitle | ( | const std::string & | title | ) |
void Main::setWindowWidth | ( | unsigned int | width | ) |