From 4ead20ecb7a9fb760a928480bff6137f8aaaa89e Mon Sep 17 00:00:00 2001 From: freezarite Date: Sun, 1 Dec 2024 14:39:45 +0100 Subject: [PATCH] Cleanup of documentation and refactoring renamed TextureEnumBase.h to Textures.h improved some of the doxygen documentation --- include/SpriteComponent.h | 7 ++++--- include/TextureEnumBase.h | 18 ------------------ include/TextureManager.h | 20 ++++++++------------ include/Textures.h | 14 ++++++++++++++ include/TileComponent.h | 2 +- src/AssetManager.cpp | 2 +- src/TileComponent.cpp | 2 -- 7 files changed, 28 insertions(+), 37 deletions(-) delete mode 100644 include/TextureEnumBase.h create mode 100644 include/Textures.h diff --git a/include/SpriteComponent.h b/include/SpriteComponent.h index 444663d..fae052f 100644 --- a/include/SpriteComponent.h +++ b/include/SpriteComponent.h @@ -5,7 +5,7 @@ #include #include -#include "TextureEnumBase.h" +#include "Textures.h" #include "AnimationHandler.h" #include "Component.h" #include "Direction.h" @@ -35,8 +35,9 @@ private: int textureXOffset; int textureYOffset; - //should be changed in the future as this is only for the tiles - const char* path; + //might be a better solution as this variable is only used for the loading of the tmx map + //TODO: improve this in the future + const char* path; //empty string if texture has a texture enum value, otherwise the path of the texture public: SpriteComponent(Textures texture, int zIndex); diff --git a/include/TextureEnumBase.h b/include/TextureEnumBase.h deleted file mode 100644 index e9e5d9a..0000000 --- a/include/TextureEnumBase.h +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * \file Textures.h - * \brief Forward declaration of the \c Textures enum class. - * - * This file contains a forward declaration of the \c Textures enum class, which is used as a base - * class for texture identifiers in the engine. It allows developers to define their own set of texture - * types in their own implementation, providing flexibility in texture management within the engine. - * - * \details - * The \c Textures enum class is intended to be implemented by the developer within their own scope. - * This allows for customized texture entries to be defined based on the specific needs of the project. - * The base declaration ensures that the enum class can be referenced and used consistently throughout - * the engine while leaving the details of the texture identifiers up to the implementation. - */ - -#pragma once - -enum class Textures; \ No newline at end of file diff --git a/include/TextureManager.h b/include/TextureManager.h index 8789a2c..24614e5 100644 --- a/include/TextureManager.h +++ b/include/TextureManager.h @@ -6,7 +6,7 @@ #include #include #include -#include "TextureEnumBase.h" +#include "Textures.h" /*! * \class TextureManager @@ -16,12 +16,8 @@ * and rendering in the engine. It provides functions to add, load, and draw textures * from files, as well as manage sprite sheets. * - * It uses two caches: one for regular textures (`texture_cache`) and one for - * map tile textures (`mapTile_texture_cache`). This allows for efficient texture reuse - * and management across different parts of the game. - * - * \note Textures are identified by an enum class `Textures` which is user-defined. - * Developers are expected to define the texture types in their own implementation. + * \sa \ref Textures "Textures" are used to identify textures within the engine. + * It is expected that they are implemented within the games scope. */ class TextureManager @@ -43,7 +39,7 @@ class TextureManager * \param filePath The file path to the texture file. * * This function loads the texture from the specified file and stores it in - * the `texture_cache`. If loading the texture fails, an exception is thrown. + * a cache. If loading the texture fails, an exception is thrown. */ void addSingleTexture(Textures texture, const char* filePath); @@ -52,8 +48,8 @@ class TextureManager * \param textures A map of texture identifiers and corresponding file paths. * * This function iterates over the provided map of textures and loads each - * texture using `addSingleTexture`. It allows developers to add several - * textures at once. + * texture using `addSingleTexture`. It allows for several + * textures to be added at once. */ void addTextures(const std::map& textures); @@ -62,7 +58,7 @@ class TextureManager * \param texture The texture identifier. * \return A pointer to the `SDL_Texture` if found, or `nullptr` if not found. * - * This function looks up a texture in the `texture_cache` and returns the + * This function looks up a texture within the cache and returns the * corresponding `SDL_Texture*`. If the texture is not found, it logs an error * message and returns `nullptr`. */ @@ -73,7 +69,7 @@ class TextureManager /*! * \brief Loads a map tile texture from the file system and caches it. * \param path The file path to the texture. - * \return A pointer to the `SDL_Texture` representing the map tile. + * \return `SDL_Texture*` representing the map tile. * * This function checks if the map tile texture is already cached. If not, it * loads the texture from the file system and stores it in the cache. diff --git a/include/Textures.h b/include/Textures.h new file mode 100644 index 0000000..eb63dfd --- /dev/null +++ b/include/Textures.h @@ -0,0 +1,14 @@ +#pragma once + +/*! + * \class Textures + * \brief Forward declaration of the \c Textures enum class. + * + * The \c Textures enum class is intended to be implemented within the game scope. + * This allows for customized texture entries to be defined based on the specific needs of the project. + * The base declaration ensures that the enum class can be referenced and used consistently throughout + * the engine while leaving the details of the texture identifiers up to the implementation. + * \sa \ref TextureManager "TextureManager" for how the enum is used. + */ + +enum class Textures; \ No newline at end of file diff --git a/include/TileComponent.h b/include/TileComponent.h index 627bb93..0cff1b8 100644 --- a/include/TileComponent.h +++ b/include/TileComponent.h @@ -6,7 +6,7 @@ #include #include "Component.h" -#include "TextureEnumBase.h" +#include "Textures.h" class SpriteComponent; class TransformComponent; diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp index 9ac14c1..273e345 100644 --- a/src/AssetManager.cpp +++ b/src/AssetManager.cpp @@ -15,7 +15,7 @@ #include "PowerupComponent.h" #include -#include "TextureEnumBase.h" +#include "Textures.h" AssetManager::AssetManager(Manager* manager) : man(manager) {} diff --git a/src/TileComponent.cpp b/src/TileComponent.cpp index 5f36e2f..324c621 100644 --- a/src/TileComponent.cpp +++ b/src/TileComponent.cpp @@ -5,9 +5,7 @@ #include "Entity.h" #include "TransformComponent.h" #include "SpriteComponent.h" -#include "TileComponent.h" -#include "TextureEnumBase.h" TileComponent::TileComponent(int x, int y, int w, int h, int id, const std::map>* textureDict) {