From 12a11a8a6b55f50cc0b60f1456e5b155f3e9b32a Mon Sep 17 00:00:00 2001 From: Yann Date: Sun, 7 Apr 2024 01:53:13 +0200 Subject: [PATCH] merge: merge new shared version --- shared/Doxyfile | 5 + shared/README.md | 27 ++++ shared/games/IEntity.hpp | 51 ++++---- shared/games/IGame.hpp | 91 ++++++------- shared/games/IGameProvider.hpp | 33 ++--- .../games/components/ICollidableComponent.hpp | 23 ++-- shared/games/components/IComponent.hpp | 27 +++- .../components/IDisplayableComponent.hpp | 5 + .../games/components/IKeyboardComponent.hpp | 120 +++++++++++------- .../components/IPositionableComponent.hpp | 11 +- shared/games/components/ISoundComponent.hpp | 91 +++++++------ shared/games/components/ITextComponent.hpp | 36 +++++- shared/games/components/ITextureComponent.hpp | 22 +++- shared/games/types/GameManifest.hpp | 27 ++-- shared/graphics/IFont.hpp | 8 +- shared/graphics/IGraphicsProvider.hpp | 8 +- shared/graphics/ISound.hpp | 20 ++- shared/graphics/ITexture.hpp | 6 +- shared/graphics/IWindow.hpp | 38 ++++-- shared/graphics/events/IEvent.hpp | 44 ++++--- shared/graphics/events/IKeyEvent.hpp | 56 +++++--- shared/graphics/events/IMouseButtonEvent.hpp | 5 + shared/graphics/events/IMouseEvent.hpp | 4 + shared/graphics/exceptions/IFontException.hpp | 4 + .../exceptions/IGraphicsException.hpp | 4 + .../graphics/exceptions/ISoundException.hpp | 4 + .../graphics/exceptions/ITextureException.hpp | 4 + .../graphics/exceptions/IWindowException.hpp | 4 + shared/graphics/types/GraphicsManifest.hpp | 33 +++-- shared/graphics/types/TextProps.hpp | 34 +++-- shared/graphics/types/TextureProps.hpp | 17 ++- shared/types/Color.hpp | 28 ++++ shared/types/Vector.hpp | 43 +++++-- 33 files changed, 625 insertions(+), 308 deletions(-) create mode 100644 shared/Doxyfile diff --git a/shared/Doxyfile b/shared/Doxyfile new file mode 100644 index 0000000..803fea5 --- /dev/null +++ b/shared/Doxyfile @@ -0,0 +1,5 @@ +INPUT = . +RECURSIVE = YES +GENERATE_LATEX = NO +PROJECT_NAME = "Arcade Shared" +USE_MDFILE_AS_MAINPAGE = "README.md" diff --git a/shared/README.md b/shared/README.md index bf34730..6d6163d 100644 --- a/shared/README.md +++ b/shared/README.md @@ -9,3 +9,30 @@ This library contains shared code for the Arcade project in order to unify inter - **[Carapace Retro](https://github.com/G-Epitech)** : [Baptiste Moreau](https://github.com/BxptisteM), [Axel Fradet](https://github.com/AxelF44) & [Suceveanu Dragos](https://github.com/sdragos1) +## How ? + +Our arcade simulator relies on a modular development model, utilizing dynamic libraries to separate game logic from graphical display. This system revolves around two types of libraries: game libraries and graphical libraries. These two libraries operate entirely independently, focusing solely on the principle of getters and setters for data manipulation. + +1. Game Libraries: + +Game libraries are responsible for managing the internal game logic, including gameplay mechanics, collisions, levels, and more. They provide functionalities through getter and setter methods, allowing developers to access and modify game data as needed. + +2. Graphical Libraries: + +On the other hand, graphical libraries handle the visual display of the game. They include features such as sprite rendering, animation management, and special effects. These libraries also interact with the simulator solely through getter and setter methods, enabling the modification of visual properties of game elements. + +3. Core: + +To ensure consistency and communication between game libraries and graphical libraries, a "core" is necessary. This core acts as a central liaison, coordinating game data with graphical display. It retrieves information about the game state from game libraries and passes it to graphical libraries for display. Similarly, it monitors user interactions and updates game data accordingly, ensuring a smooth gaming experience. + +In summary, our arcade simulator relies on a modular development model where game libraries, graphical libraries, and the core interact independently, providing maximum flexibility and enabling developers to create unique and dynamic gaming experiences. + +## Documentation + +If you want the code documentation you can run this command : + +```bash +doxygen Doxyfile +``` + +This command allow you to generate Doxygen documentation. diff --git a/shared/games/IEntity.hpp b/shared/games/IEntity.hpp index 9741616..d0df623 100644 --- a/shared/games/IEntity.hpp +++ b/shared/games/IEntity.hpp @@ -10,35 +10,38 @@ #include #include -namespace shared::games -{ - class IGame; +namespace shared::games { + class IGame; - namespace entity - { - class IEntity; + namespace entity { + class IEntity; - typedef std::shared_ptr EntityPtr; - typedef std::vector EntitiesMap; - } + /// @brief Entity pointer + typedef std::shared_ptr EntityPtr; + /// @brief Entities map pointers + typedef std::vector EntitiesMap; + } - namespace components - { - class IComponent; + namespace components { + class IComponent; - typedef std::vector> ComponentsMap; - } + /// @brief Components map pointers + typedef std::vector> ComponentsMap; + } } -class shared::games::entity::IEntity -{ +/** + * @brief Interface of an entity + * + */ +class shared::games::entity::IEntity { public: - virtual ~IEntity() = default; - - /** - * @brief Get the components of the entity - * - * @return Components of the entity - */ - virtual const components::ComponentsMap &getComponents(void) const noexcept = 0; + virtual ~IEntity() = default; + + /** + * @brief Get the components of the entity + * + * @return Components of the entity + */ + virtual const components::ComponentsMap &getComponents(void) const noexcept = 0; }; diff --git a/shared/games/IGame.hpp b/shared/games/IGame.hpp index 956baab..c03b9ef 100644 --- a/shared/games/IGame.hpp +++ b/shared/games/IGame.hpp @@ -15,58 +15,61 @@ using namespace shared::types; -namespace shared::games -{ - class IGame; +namespace shared::games { + class IGame; - typedef std::chrono::duration DeltaTime; + /// @brief Delta time in milliseconds + typedef std::chrono::duration DeltaTime; } -class shared::games::IGame -{ +/** + * @brief Interface of a game + * + */ +class shared::games::IGame { public: - virtual ~IGame() = default; + virtual ~IGame() = default; - /** - * @brief Compute the game each tick of the program - * - * @param dt Time since last tick (Time in `milliseconds`) - */ - virtual void compute(DeltaTime dt) = 0; + /** + * @brief Compute the game each tick of the program + * + * @param dt Time since last tick (Time in `milliseconds`) + */ + virtual void compute(DeltaTime dt) = 0; - /** - * @brief Manifest with informations of the game - * - * @return Manifest of the game - */ - virtual const GameManifest &getManifest() const noexcept = 0; + /** + * @brief Manifest with informations of the game + * + * @return Manifest of the game + */ + virtual const GameManifest &getManifest() const noexcept = 0; - /** - * @brief Number of tiles that represent the game - * Tile size is managed by the renderer - * - * @return The number of tiles of the game - */ - virtual const Vector2u getSize() const noexcept = 0; + /** + * @brief Number of tiles that represent the game + * Tile size is managed by the renderer + * + * @return The number of tiles of the game + */ + virtual const Vector2u getSize() const noexcept = 0; - /** - * @brief Get fps of the game - * - * @return The number of frame per seconds of the game - */ - virtual const unsigned int getFps() const noexcept = 0; + /** + * @brief Get fps of the game + * + * @return The number of frame per seconds of the game + */ + virtual const unsigned int getFps() const noexcept = 0; - /** - * @brief Get map of entities - * - * @return Entities map of the game - */ - virtual const entity::EntitiesMap &getEntities(void) const = 0; + /** + * @brief Get map of entities + * + * @return Entities map of the game + */ + virtual const entity::EntitiesMap &getEntities(void) const = 0; - /** - * @brief Get the score of the game - * - * @return The score of the game - */ - virtual const int getScore() const noexcept = 0; + /** + * @brief Get the score of the game + * + * @return The score of the game + */ + virtual const int getScore() const noexcept = 0; }; diff --git a/shared/games/IGameProvider.hpp b/shared/games/IGameProvider.hpp index ddb2bcd..2db5dd3 100644 --- a/shared/games/IGameProvider.hpp +++ b/shared/games/IGameProvider.hpp @@ -15,22 +15,25 @@ namespace shared::games { class IGameProvider; } -class shared::games::IGameProvider -{ +/** + * @brief Interface of a game provider + * + */ +class shared::games::IGameProvider { public: - virtual ~IGameProvider() = default; + virtual ~IGameProvider() = default; - /** - * @brief Provides the game manifest - * - * @return Manifest of current game - */ - virtual const GameManifest &getManifest() const noexcept = 0; + /** + * @brief Provides the game manifest + * + * @return Manifest of current game + */ + virtual const GameManifest &getManifest() const noexcept = 0; - /** - * @brief Provides a new instance of the game - * - * @return Created game instance - */ - virtual std::shared_ptr createInstance(void) = 0; + /** + * @brief Provides a new instance of the game + * + * @return Created game instance + */ + virtual std::shared_ptr createInstance(void) = 0; }; diff --git a/shared/games/components/ICollidableComponent.hpp b/shared/games/components/ICollidableComponent.hpp index feec546..0363665 100644 --- a/shared/games/components/ICollidableComponent.hpp +++ b/shared/games/components/ICollidableComponent.hpp @@ -12,18 +12,21 @@ #include "../../types/Vector.hpp" namespace shared::games::components { - class ICollidableComponent; + class ICollidableComponent; } -class shared::games::components::ICollidableComponent: public virtual IPositionableComponent -{ +/** + * @brief Interface of a collidable component + * + */ +class shared::games::components::ICollidableComponent: public virtual IPositionableComponent { public: - virtual ~ICollidableComponent() = default; + virtual ~ICollidableComponent() = default; - /** - * @brief On collide event handler for the component - * @param ctx Context of the game - * @param target Target entity - */ - virtual void onCollide(std::shared_ptr ctx, std::shared_ptr target) = 0; + /** + * @brief On collide event handler for the component + * @param ctx Context of the game + * @param target Target entity + */ + virtual void onCollide(std::shared_ptr ctx, std::shared_ptr target) = 0; }; diff --git a/shared/games/components/IComponent.hpp b/shared/games/components/IComponent.hpp index db6c260..d2299fa 100644 --- a/shared/games/components/IComponent.hpp +++ b/shared/games/components/IComponent.hpp @@ -10,19 +10,32 @@ #include "../IEntity.hpp" namespace shared::games::components { + + /// @brief Enum of component types typedef enum { - TEXTURE, - TEXT, - DISPLAYABLE, - SOUND, - COLLIDABLE, - POSITIONABLE, - KEYBOARD + /// @brief Component type for a texture + TEXTURE, + /// @brief Component type for a text + TEXT, + /// @brief Component type for a displayable + DISPLAYABLE, + /// @brief Component type for a sound + SOUND, + /// @brief Component type for a collidable + COLLIDABLE, + /// @brief Component type for a positionable + POSITIONABLE, + /// @brief Component type for a keyboard + KEYBOARD } ComponentType; class IComponent; } +/** + * @brief Interface of a component + * + */ class shared::games::components::IComponent { public: virtual ~IComponent() = default; diff --git a/shared/games/components/IDisplayableComponent.hpp b/shared/games/components/IDisplayableComponent.hpp index df1f6b1..d16d4ae 100644 --- a/shared/games/components/IDisplayableComponent.hpp +++ b/shared/games/components/IDisplayableComponent.hpp @@ -15,6 +15,10 @@ namespace shared::games::components { class IDisplayableComponent; } +/** + * @brief Interface of a displayable component + * + */ class shared::games::components::IDisplayableComponent : public virtual IPositionableComponent { public: virtual ~IDisplayableComponent() = default; @@ -22,6 +26,7 @@ class shared::games::components::IDisplayableComponent : public virtual IPositio /** * @brief Get Z index that is usefull for display prioroty * + * @return Z index of the entity */ virtual unsigned int &getZIndex() noexcept = 0; diff --git a/shared/games/components/IKeyboardComponent.hpp b/shared/games/components/IKeyboardComponent.hpp index a6bb8f8..0606528 100644 --- a/shared/games/components/IKeyboardComponent.hpp +++ b/shared/games/components/IKeyboardComponent.hpp @@ -11,63 +11,85 @@ #include "IComponent.hpp" namespace shared::games::components { - class IKeyboardComponent; + class IKeyboardComponent; } -class shared::games::components::IKeyboardComponent: public virtual IComponent -{ +/** + * @brief Interface of a keyboard component + * + */ +class shared::games::components::IKeyboardComponent: public virtual IComponent { public: - typedef enum - { - CONTROL, // Control key (`Ctrl`, `Shift`, `Alt`) - ARROW, // Arrow key (`Up`, `Down`, `Left`, `Right`) - FUNC, // Function key (`F1`, `F2`, `F3`, etc.) - CHAR, // Character key (`a`, `1`, `&`, etc.) - UNKNOWN // Unknown key - } KeyType; - typedef enum - { - CTRL, // `Ctrl` key - SHIFT, // `Shift` key - ALT // `Alt` key - } ControlCode; + /// @brief Type of the key + typedef enum { + /// @brief Control key (`Ctrl`, `Shift`, `Alt`) + CONTROL, + /// @brief Arrow key (`Up`, `Down`, `Left`, `Right`) + ARROW, + /// @brief Function key (`F1`, `F2`, `F3`, etc.) + FUNC, + /// @brief Character key (`a`, `1`, `&`, etc.) + CHAR, + /// @brief Unknown key + UNKNOWN + } KeyType; - typedef enum - { - UP, // `Up` arrow key - DOWN, // `Down` arrow key - LEFT, // `Left` arrow key - RIGHT // `Right` arrow key - } ArrowCode; + /// @brief Control key code + typedef enum { + /// @brief `Ctrl` key + CTRL, + /// @brief `Shift` key + SHIFT, + /// @brief `Alt` key + ALT + } ControlCode; - typedef union - { - ControlCode control; // Control key - ArrowCode arrow; // Arrow key - char character; // ASCII character value - unsigned char func; // Function key number - } KeyCode; + /// @brief Arrow key code + typedef enum { + /// @brief `Up` arrow key + UP, + /// @brief `Down` arrow key + DOWN, + /// @brief `Left` arrow key + LEFT, + /// @brief `Right` arrow key + RIGHT + } ArrowCode; - typedef struct - { - KeyCode code; // Key code. Interpretation depends on the type - KeyType type; // Type of the key - } KeyData; + /// @brief Function key code union + typedef union { + /// @brief Function key number + ControlCode control; + /// @brief Control key code + ArrowCode arrow; + /// @brief Arrow key code + char character; + /// @brief Character key code + unsigned char func; + } KeyCode; - virtual ~IKeyboardComponent() = default; + /// @brief Key data + typedef struct { + /// @brief Key code. Interpretation depends on the type + KeyCode code; + /// @brief Type of the key + KeyType type; + } KeyData; - /** - * @brief On key pressed event handler for the entity - * @param ctx Context of the game - * @param keyData Key data of key pressed - */ - virtual void onKeyPress(std::shared_ptr ctx, KeyData keyData) = 0; + virtual ~IKeyboardComponent() = default; - /** - * @brief On key release event handler for the entity - * @param ctx Context of the game - * @param keyData Key data of key released - */ - virtual void onKeyRelease(std::shared_ptr ctx, KeyData keyData) = 0; + /** + * @brief On key pressed event handler for the entity + * @param ctx Context of the game + * @param keyData Key data of key pressed + */ + virtual void onKeyPress(std::shared_ptr ctx, KeyData keyData) = 0; + + /** + * @brief On key release event handler for the entity + * @param ctx Context of the game + * @param keyData Key data of key released + */ + virtual void onKeyRelease(std::shared_ptr ctx, KeyData keyData) = 0; }; diff --git a/shared/games/components/IPositionableComponent.hpp b/shared/games/components/IPositionableComponent.hpp index 8cf9edb..4f1f743 100644 --- a/shared/games/components/IPositionableComponent.hpp +++ b/shared/games/components/IPositionableComponent.hpp @@ -11,12 +11,15 @@ #include "../../types/Vector.hpp" namespace shared::games::components { - class IPositionableComponent; + class IPositionableComponent; } -class shared::games::components::IPositionableComponent: public virtual IComponent -{ - public: +/** + * @brief Interface of a positionable component + * + */ +class shared::games::components::IPositionableComponent: public virtual IComponent { +public: virtual ~IPositionableComponent() = default; /** diff --git a/shared/games/components/ISoundComponent.hpp b/shared/games/components/ISoundComponent.hpp index 43d6f02..a18704e 100644 --- a/shared/games/components/ISoundComponent.hpp +++ b/shared/games/components/ISoundComponent.hpp @@ -12,56 +12,63 @@ #include "../../types/Vector.hpp" namespace shared::games::components { - class ISoundComponent; + class ISoundComponent; - typedef enum - { - PLAY, - PAUSE, - STOP - } SoundState; + /// @brief State of the sound + typedef enum { + /// @brief Sound is playing + PLAY, + /// @brief Sound is paused + PAUSE, + /// @brief Sound is stopped + STOP + } SoundState; - typedef unsigned char SoundVolume; + /// @brief Volume of the sound + typedef unsigned char SoundVolume; } -class shared::games::components::ISoundComponent: public virtual IComponent -{ +/** + * @brief Interface of a sound component + * + */ +class shared::games::components::ISoundComponent: public virtual IComponent { public: - virtual ~ISoundComponent() = default; + virtual ~ISoundComponent() = default; - /** - * @brief Get path of the sound - * - * @return Sound path - */ - virtual const std::string &getPath() const noexcept = 0; + /** + * @brief Get path of the sound + * + * @return Sound path + */ + virtual const std::string &getPath() const noexcept = 0; - /** - * @brief Get state of the sound - * - * @return Sound state - */ - virtual SoundState &getState() noexcept = 0; + /** + * @brief Get state of the sound + * + * @return Sound state + */ + virtual SoundState &getState() noexcept = 0; - /** - * @brief Get volume of the sound - * - * @return Sound volume - */ - virtual SoundVolume &getVolume() noexcept = 0; + /** + * @brief Get volume of the sound + * + * @return Sound volume + */ + virtual SoundVolume &getVolume() noexcept = 0; - /** - * @brief Get loop of the sound - * - * @return Sound loop - */ - virtual bool &getLoop() noexcept = 0; + /** + * @brief Get loop of the sound + * + * @return Sound loop + */ + virtual bool &getLoop() noexcept = 0; - /** - * @brief On state change event handler for the component - * - * @param ctx Context of the game - * @param state New state of the sound - */ - virtual void onStateChange(std::shared_ptr ctx, SoundState state) = 0; + /** + * @brief On state change event handler for the component + * + * @param ctx Context of the game + * @param state New state of the sound + */ + virtual void onStateChange(std::shared_ptr ctx, SoundState state) = 0; }; diff --git a/shared/games/components/ITextComponent.hpp b/shared/games/components/ITextComponent.hpp index 64dd5cf..7015b7c 100644 --- a/shared/games/components/ITextComponent.hpp +++ b/shared/games/components/ITextComponent.hpp @@ -15,31 +15,53 @@ namespace shared::games::components { class ITextComponent; } +/** + * @brief Interface of a text component + * + */ class shared::games::components::ITextComponent : public virtual IDisplayableComponent { public: + + /// @brief Horizontal text alignment typedef enum { + /// @brief Align text to the left LEFT, + /// @brief Align text to the center CENTER, + /// @brief Align text to the right RIGHT } TextAlign; + /// @brief Vertical text alignment typedef enum { + /// @brief Align text to the bottom BOTTOM, + /// @brief Align text to the middle MIDDLE, + /// @brief Align text to the top TOP } TextVerticalAlign; + /// @brief Font properties typedef struct { - std::string path; // Path of the font - unsigned int size; // Font size + /// @brief Path of the font + std::string path; + /// @brief Size of the font + unsigned int size; } TextFontProps; + /// @brief Text properties typedef struct { - std::string content; // Content of the text - TextAlign align; // Alignment of the text - TextVerticalAlign verticalAlign; // Vertical alignment of the text - TextFontProps font; // Font of the text - types::Color color; // Color of the text + /// @brief Content of the text + std::string content; + /// @brief Horizontal alignment of the text + TextAlign align; + /// @brief Vertical alignment of the text + TextVerticalAlign verticalAlign; + /// @brief Font of the text + TextFontProps font; + /// @brief Color of the text + types::Color color; } TextProps; virtual ~ITextComponent() = default; diff --git a/shared/games/components/ITextureComponent.hpp b/shared/games/components/ITextureComponent.hpp index 930215c..35d2755 100644 --- a/shared/games/components/ITextureComponent.hpp +++ b/shared/games/components/ITextureComponent.hpp @@ -14,18 +14,29 @@ namespace shared::games::components { class ITextureComponent; + /// @brief Texture sources typedef struct { - const std::string ascii; // ASCII image representation path - const std::string bin; // Binary image path - Vector2f binTileSize; // Size of the binary tile + /// @brief ASCII image representation path + const std::string ascii; + /// @brief Binary image path + const std::string bin; + /// @brief Size of the binary tile + Vector2f binTileSize; } TextureSources; + /// @brief Texture properties typedef struct { - TextureSources sources; // Sources of textures - Vector2u origin; // Origin of the texture + /// @brief Sources of textures + TextureSources sources; + /// @brief Size of the texture + Vector2u origin; } TextureProps; } +/** + * @brief Interface of a texture component + * + */ class shared::games::components::ITextureComponent : public virtual IDisplayableComponent { public: virtual ~ITextureComponent() = default; @@ -33,6 +44,7 @@ class shared::games::components::ITextureComponent : public virtual IDisplayable /** * @brief Get texture properties * + * @return TextureProps &Texture properties */ virtual TextureProps &getTextureProps() noexcept = 0; }; diff --git a/shared/games/types/GameManifest.hpp b/shared/games/types/GameManifest.hpp index 25da00a..3040ac2 100644 --- a/shared/games/types/GameManifest.hpp +++ b/shared/games/types/GameManifest.hpp @@ -11,17 +11,28 @@ #include namespace shared::games { + + /// @brief Author of the game typedef struct { - std::string name; // Name of the author - std::string email; // Public contact email - std::string website; // Website of the author (`github`, `gitlab`, etc.) + /// @brief Name of the author + std::string name; + /// @brief Public contact email + std::string email; + /// @brief Website of the author (`github`, `gitlab`, etc.) + std::string website; } Author; + /// @brief Game manifest typedef struct { - const std::string name; // Name of the game - const std::string description; // Description of the game - const std::string version; // Version of the game - const std::vector authors; // Authors - const std::string iconPath; // Path of the icon game + /// @brief Name of the game + const std::string name; + /// @brief Description of the game + const std::string description; + /// @brief Version of the game + const std::string version; + /// @brief List of authors of the game + const std::vector authors; + /// @brief Path of the icon game + const std::string iconPath; } GameManifest; } diff --git a/shared/graphics/IFont.hpp b/shared/graphics/IFont.hpp index 63b7829..eaae7ad 100644 --- a/shared/graphics/IFont.hpp +++ b/shared/graphics/IFont.hpp @@ -11,7 +11,11 @@ namespace shared::graphics { class IFont; } +/** + * @brief Interface of a font + * + */ class shared::graphics::IFont { - public: - virtual ~IFont() = default; + public: + virtual ~IFont() = default; }; diff --git a/shared/graphics/IGraphicsProvider.hpp b/shared/graphics/IGraphicsProvider.hpp index 4200a5c..10a6ea4 100644 --- a/shared/graphics/IGraphicsProvider.hpp +++ b/shared/graphics/IGraphicsProvider.hpp @@ -15,11 +15,15 @@ #include "types/GraphicsManifest.hpp" namespace shared::graphics { - class IGraphicsProvider; + class IGraphicsProvider; } +/** + * @brief Interface for the graphics provider + * + */ class shared::graphics::IGraphicsProvider { - public: +public: virtual ~IGraphicsProvider() = default; /** diff --git a/shared/graphics/ISound.hpp b/shared/graphics/ISound.hpp index 00da6af..52d903e 100644 --- a/shared/graphics/ISound.hpp +++ b/shared/graphics/ISound.hpp @@ -7,21 +7,28 @@ #pragma once -namespace shared::graphics -{ - class ISound; +namespace shared::graphics { + class ISound; } +/** + * @brief Interface for the sound object + * + */ class shared::graphics::ISound { - public: +public: virtual ~ISound() = default; + /// @brief Sound volume typedef unsigned char SoundVolume; - typedef enum - { + /// @brief Sound state + typedef enum { + /// @brief Sound is playing PLAY, + /// @brief Sound is paused PAUSE, + /// @brief Sound is stopped STOP } SoundState; @@ -29,7 +36,6 @@ class shared::graphics::ISound { * @brief Get the state of the sound * * @param state State of sound playing - * @return SoundState */ virtual void setState(SoundState state) = 0; diff --git a/shared/graphics/ITexture.hpp b/shared/graphics/ITexture.hpp index f82f3e8..b6ac3ff 100644 --- a/shared/graphics/ITexture.hpp +++ b/shared/graphics/ITexture.hpp @@ -11,7 +11,11 @@ namespace shared::graphics { class ITexture; } +/** + * @brief Interface for the texture object + * + */ class shared::graphics::ITexture { - public: +public: virtual ~ITexture() = default; }; diff --git a/shared/graphics/IWindow.hpp b/shared/graphics/IWindow.hpp index ac1746a..0a2ebe7 100644 --- a/shared/graphics/IWindow.hpp +++ b/shared/graphics/IWindow.hpp @@ -18,25 +18,43 @@ using namespace shared::types; namespace shared::graphics { - class IWindow; + class IWindow; } +/** + * @brief Interface for the window object + * + */ class shared::graphics::IWindow { public: virtual ~IWindow() = default; - typedef enum - { - WINDOWED, - FULLSCREEN + /** + * @brief Window mode + * + */ + typedef enum { + /// @brief Windowed mode + WINDOWED, + /// @brief Fullscreen mode + FULLSCREEN } WindowMode; + /** + * @brief Window initial properties + * + */ typedef struct { - Vector2u size; //Initial size of the window - WindowMode mode; //Initial mode of the window - unsigned int fps; //Initial framerate of the window - const std::string title; //Initial title of the window - const std::string icon; //Initial icon of the window + /// @brief Initial size of the window + Vector2u size; + /// @brief Initial mode of the window + WindowMode mode; + /// @brief Initial framerate of the window + unsigned int fps; + /// @brief Initial title of the window + const std::string title; + /// @brief Initial icon of the window + const std::string icon; } WindowInitProps; /** diff --git a/shared/graphics/events/IEvent.hpp b/shared/graphics/events/IEvent.hpp index 84c9492..cf48dbf 100644 --- a/shared/graphics/events/IEvent.hpp +++ b/shared/graphics/events/IEvent.hpp @@ -9,27 +9,37 @@ #include -namespace shared::graphics::events -{ - class IEvent; +namespace shared::graphics::events { + class IEvent; - typedef enum - { - KEY_PRESS, // Key pressed - KEY_RELEASE, // Key released - MOUSE_BTN_PRESS, // Mouse button pressed - MOUSE_BTN_RELEASE, // Mouse button released - MOUSE_MOVE, // Mouse moved - WINDOW_CLOSE, // Window closed - WINDOW_RESIZE, // Window resized - } EventType; + /// @brief Event type + typedef enum { + /// @brief Key pressed + KEY_PRESS, + /// @brief Key released + KEY_RELEASE, + /// @brief Mouse button pressed + MOUSE_BTN_PRESS, + /// @brief Mouse button released + MOUSE_BTN_RELEASE, + /// @brief Mouse moved + MOUSE_MOVE, + /// @brief Window closed + WINDOW_CLOSE, + /// @brief Window resized + WINDOW_RESIZE, + } EventType; - typedef std::shared_ptr EventPtr; + /// @brief Event pointer + typedef std::shared_ptr EventPtr; } -class shared::graphics::events::IEvent -{ - public: +/** + * @brief Interface for the event object + * + */ +class shared::graphics::events::IEvent { +public: virtual ~IEvent() = default; /** diff --git a/shared/graphics/events/IKeyEvent.hpp b/shared/graphics/events/IKeyEvent.hpp index 81fe453..786bce1 100644 --- a/shared/graphics/events/IKeyEvent.hpp +++ b/shared/graphics/events/IKeyEvent.hpp @@ -13,36 +13,60 @@ namespace shared::graphics::events { class IKeyEvent; } +/** + * @brief Interface for the key event object + * + */ class shared::graphics::events::IKeyEvent : public virtual IEvent { public: virtual ~IKeyEvent() = default; + /// @brief Key type typedef enum { - CONTROL, // Control key (`Ctrl`, `Shift`, `Alt`) - ARROW, // Arrow key (`Up`, `Down`, `Left`, `Right`) - FUNC, // Function key (`F1`, `F2`, `F3`, etc.) - CHAR, // Character key (`a`, `1`, `&`, etc.) - UNKNOWN // Unknown key + /// @brief Control key (`Ctrl`, `Shift`, `Alt`) + CONTROL, + /// @brief Arrow key (`Up`, `Down`, `Left`, `Right`) + ARROW, + /// @brief Function key (`F1`, `F2`, `F3`, etc.) + FUNC, + /// @brief ASCII character key + CHAR, + /// @brief Unknown key + UNKNOWN } KeyType; + /// @brief Control key code typedef enum { - CTRL, // `Ctrl` key - SHIFT, // `Shift` key - ALT // `Alt` key + /// @brief CTRL key + CTRL, + /// @brief SHIFT key + SHIFT, + /// @brief ALT key + ALT } ControlCode; + /// @brief Arrow key code typedef enum { - UP, // `Up` arrow key - DOWN, // `Down` arrow key - LEFT, // `Left` arrow key - RIGHT // `Right` arrow key + /// @brief UP arrow key + UP, + /// @brief DOWN arrow key + DOWN, + /// @brief LEFT arrow key + LEFT, + /// @brief RIGHT arrow key + RIGHT } ArrowCode; + /// @brief Key code typedef union { - ControlCode control; // Control key - ArrowCode arrow; // Arrow key - char character; // ASCII character value - unsigned char func; // Function key number + /// @brief Control key + ControlCode control; + /// @brief Arrow key + ArrowCode arrow; + /// @brief ASCII character value + char character; + /// @brief Function key number + unsigned char func; } KeyCode; /** diff --git a/shared/graphics/events/IMouseButtonEvent.hpp b/shared/graphics/events/IMouseButtonEvent.hpp index bac5eba..b6bbd4d 100644 --- a/shared/graphics/events/IMouseButtonEvent.hpp +++ b/shared/graphics/events/IMouseButtonEvent.hpp @@ -13,10 +13,15 @@ namespace shared::graphics::events{ class IMouseButtonEvent; } +/** + * @brief Interface for the mouse button event object + * + */ class shared::graphics::events::IMouseButtonEvent : public virtual IMouseEvent { public: virtual ~IMouseButtonEvent() = default; + /// @brief Mouse button typedef enum { LEFT, RIGHT diff --git a/shared/graphics/events/IMouseEvent.hpp b/shared/graphics/events/IMouseEvent.hpp index c8d6b03..193955d 100644 --- a/shared/graphics/events/IMouseEvent.hpp +++ b/shared/graphics/events/IMouseEvent.hpp @@ -14,6 +14,10 @@ namespace shared::graphics::events { class IMouseEvent; } +/** + * @brief Interface for the mouse event object + * + */ class shared::graphics::events::IMouseEvent : public virtual IEvent { public: virtual ~IMouseEvent() = default; diff --git a/shared/graphics/exceptions/IFontException.hpp b/shared/graphics/exceptions/IFontException.hpp index 7b875e6..c07f64c 100644 --- a/shared/graphics/exceptions/IFontException.hpp +++ b/shared/graphics/exceptions/IFontException.hpp @@ -13,6 +13,10 @@ namespace shared::graphics::exceptions { class IFontException; } +/** + * @brief Interface for the font exception object + * + */ class shared::graphics::exceptions::IFontException : public virtual IGraphicsException { public: virtual ~IFontException() = default; diff --git a/shared/graphics/exceptions/IGraphicsException.hpp b/shared/graphics/exceptions/IGraphicsException.hpp index a899775..3002ab2 100644 --- a/shared/graphics/exceptions/IGraphicsException.hpp +++ b/shared/graphics/exceptions/IGraphicsException.hpp @@ -13,6 +13,10 @@ namespace shared::graphics::exceptions { class IGraphicsException; } +/** + * @brief Interface for the graphics exception object + * + */ class shared::graphics::exceptions::IGraphicsException: public std::exception { public: /** diff --git a/shared/graphics/exceptions/ISoundException.hpp b/shared/graphics/exceptions/ISoundException.hpp index 2a2e534..572c681 100644 --- a/shared/graphics/exceptions/ISoundException.hpp +++ b/shared/graphics/exceptions/ISoundException.hpp @@ -13,6 +13,10 @@ namespace shared::graphics::exceptions { class ISoundException; } +/** + * @brief Interface for the sound exception object + * + */ class shared::graphics::exceptions::ISoundException : public virtual IGraphicsException { public: virtual ~ISoundException() = default; diff --git a/shared/graphics/exceptions/ITextureException.hpp b/shared/graphics/exceptions/ITextureException.hpp index e894b71..fd7754f 100644 --- a/shared/graphics/exceptions/ITextureException.hpp +++ b/shared/graphics/exceptions/ITextureException.hpp @@ -13,6 +13,10 @@ namespace shared::graphics::exceptions { class ITextureException; } +/** + * @brief Interface for the texture exception object + * + */ class shared::graphics::exceptions::ITextureException : public virtual IGraphicsException { public: virtual ~ITextureException() = default; diff --git a/shared/graphics/exceptions/IWindowException.hpp b/shared/graphics/exceptions/IWindowException.hpp index ae030f3..a42abac 100644 --- a/shared/graphics/exceptions/IWindowException.hpp +++ b/shared/graphics/exceptions/IWindowException.hpp @@ -13,6 +13,10 @@ namespace shared::graphics::exceptions { class IWindowException; } +/** + * @brief Interface for the window exception object + * + */ class shared::graphics::exceptions::IWindowException : public virtual IGraphicsException { public: virtual ~IWindowException() = default; diff --git a/shared/graphics/types/GraphicsManifest.hpp b/shared/graphics/types/GraphicsManifest.hpp index fc45e15..57354e8 100644 --- a/shared/graphics/types/GraphicsManifest.hpp +++ b/shared/graphics/types/GraphicsManifest.hpp @@ -11,18 +11,25 @@ namespace shared::graphics { - typedef struct - { - std::string name; // Name of the author - std::string email; // Public contact email - std::string website; // Website of the author (`github`, `gitlab`, etc.) - } Author; + /// @brief Author of the graphics library + typedef struct { + /// @brief Name of the author + std::string name; + /// @brief Public contact email + std::string email; + /// @brief Website of the author (`github`, `gitlab`, etc.) + std::string website; + } Author; - typedef struct - { - const std::string name; // Name of the graphics library - const std::string description; // Description of the library - const std::string version; // Version of the library - const std::vector authors; // Authors - } GraphicsManifest; + /// @brief Graphics library manifest + typedef struct { + /// @brief Name of the graphics library + const std::string name; + /// @brief Description of the graphics library + const std::string description; + /// @brief Version of the graphics library + const std::string version; + /// @brief List of authors of the graphics library + const std::vector authors; + } GraphicsManifest; } diff --git a/shared/graphics/types/TextProps.hpp b/shared/graphics/types/TextProps.hpp index d405473..3c3828e 100644 --- a/shared/graphics/types/TextProps.hpp +++ b/shared/graphics/types/TextProps.hpp @@ -17,26 +17,44 @@ using namespace shared::types; namespace shared::graphics { + + /// @brief Horizontal alignment of the text typedef enum { + /// @brief Left alignment LEFT, + /// @brief Center alignment CENTER, + /// @brief Right alignment RIGHT } TextAlign; + /// @brief Vertical alignment of the text typedef enum { + /// @brief Bottom alignment BOTTOM, + /// @brief Middle alignment MIDDLE, + /// @brief Top alignment TOP } TextVerticalAlign; + /// @brief Text properties typedef struct { - std::shared_ptr font; // Font of the text - unsigned int fontSize; // Font size - std::string content; // Content of the text - TextAlign align; // Alignment of the text - TextVerticalAlign verticalAlign; // Vertical alignment of the text - types::Color color; // Color of the text - Vector2u size; // Size of the entity - Vector2f position; // Position of the entity + /// @brief Font of the text + std::shared_ptr font; + /// @brief Font size + unsigned int fontSize; + /// @brief Content of the text + std::string content; + /// @brief Horizontal alignment of the text + TextAlign align; + /// @brief Vertical alignment of the text + TextVerticalAlign verticalAlign; + /// @brief Color of the text + types::Color color; + /// @brief Size of the entity + Vector2u size; + /// @brief Position of the entity + Vector2f position; } TextProps; } diff --git a/shared/graphics/types/TextureProps.hpp b/shared/graphics/types/TextureProps.hpp index 5d72157..4b05664 100644 --- a/shared/graphics/types/TextureProps.hpp +++ b/shared/graphics/types/TextureProps.hpp @@ -15,11 +15,18 @@ using namespace shared::types; namespace shared::graphics { + + /// @brief Texture properties typedef struct { - std::shared_ptr texture; // Texture of the entity - Vector2f binTileSize; // Size of a binary tile - Vector2u origin; // Origin of the texture - Vector2u size; // Size of the entity - Vector2f position; // Position of the entity + /// @brief Texture of the entity + std::shared_ptr texture; + /// @brief Size of a binary tile + Vector2f binTileSize; + /// @brief Origin of the texture + Vector2u origin; + /// @brief Size of the entity + Vector2u size; + /// @brief Position of the entity + Vector2f position; } TextureProps; } diff --git a/shared/types/Color.hpp b/shared/types/Color.hpp index b6fe6e2..1d9d49f 100644 --- a/shared/types/Color.hpp +++ b/shared/types/Color.hpp @@ -9,7 +9,16 @@ namespace shared::types { + /// @brief Color type typedef struct ColorType { + /** + * @brief Construct a new Color Type object + * + * @param r Red color value + * @param g Green color value + * @param b Blue color value + * @param a Alpha color value + */ ColorType( unsigned char r, unsigned char g, @@ -17,9 +26,28 @@ namespace shared::types unsigned char a ) : r(r), g(g), b(b), a(a) {} + /** + * @brief Red color value + * + */ unsigned char r; + + /** + * @brief Green color value + * + */ unsigned char g; + + /** + * @brief Blue color value + * + */ unsigned char b; + + /** + * @brief Alpha color value + * + */ unsigned char a; } Color; } diff --git a/shared/types/Vector.hpp b/shared/types/Vector.hpp index 5905a04..177cd23 100644 --- a/shared/types/Vector.hpp +++ b/shared/types/Vector.hpp @@ -7,21 +7,40 @@ #pragma once -namespace shared::types -{ - template - struct Vector; +namespace shared::types { + template + struct Vector; - typedef struct Vector Vector2i; - typedef struct Vector Vector2f; - typedef struct Vector Vector2u; + typedef struct Vector Vector2i; + typedef struct Vector Vector2f; + typedef struct Vector Vector2u; } +/// @brief Vector type +/// @tparam T Type of the vector template -struct shared::types::Vector -{ - Vector(T x, T y) : x(x), y(y){}; +struct shared::types::Vector { + /** + * @brief Construct a new Vector object + * + * @param x X value + * @param y Y value + */ + Vector(T x, T y) : x(x), y(y){}; - T x; - T y; + /** + * @brief X value + * In this Graphical Project, it can be refer as : + * - Width + * - Longitude + */ + T x; + + /** + * @brief Y value + * In this Graphical Project, it can be refer as : + * - Height + * - Latitude + */ + T y; };