mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 10:13:42 +00:00
Cleanup of documentation and refactoring
renamed TextureEnumBase.h to Textures.h improved some of the doxygen documentation
This commit is contained in:
parent
7dbcfe876c
commit
4ead20ecb7
@ -5,7 +5,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "TextureEnumBase.h"
|
#include "Textures.h"
|
||||||
#include "AnimationHandler.h"
|
#include "AnimationHandler.h"
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "Direction.h"
|
#include "Direction.h"
|
||||||
@ -35,8 +35,9 @@ private:
|
|||||||
int textureXOffset;
|
int textureXOffset;
|
||||||
int textureYOffset;
|
int textureYOffset;
|
||||||
|
|
||||||
//should be changed in the future as this is only for the tiles
|
//might be a better solution as this variable is only used for the loading of the tmx map
|
||||||
const char* path;
|
//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:
|
public:
|
||||||
SpriteComponent(Textures texture, int zIndex);
|
SpriteComponent(Textures texture, int zIndex);
|
||||||
|
|||||||
@ -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;
|
|
||||||
@ -6,7 +6,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "TextureEnumBase.h"
|
#include "Textures.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class TextureManager
|
* \class TextureManager
|
||||||
@ -16,12 +16,8 @@
|
|||||||
* and rendering in the engine. It provides functions to add, load, and draw textures
|
* and rendering in the engine. It provides functions to add, load, and draw textures
|
||||||
* from files, as well as manage sprite sheets.
|
* from files, as well as manage sprite sheets.
|
||||||
*
|
*
|
||||||
* It uses two caches: one for regular textures (`texture_cache`) and one for
|
* \sa \ref Textures "Textures" are used to identify textures within the engine.
|
||||||
* map tile textures (`mapTile_texture_cache`). This allows for efficient texture reuse
|
* It is expected that they are implemented within the games scope.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TextureManager
|
class TextureManager
|
||||||
@ -43,7 +39,7 @@ class TextureManager
|
|||||||
* \param filePath The file path to the texture file.
|
* \param filePath The file path to the texture file.
|
||||||
*
|
*
|
||||||
* This function loads the texture from the specified file and stores it in
|
* 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);
|
void addSingleTexture(Textures texture, const char* filePath);
|
||||||
|
|
||||||
@ -52,8 +48,8 @@ class TextureManager
|
|||||||
* \param textures A map of texture identifiers and corresponding file paths.
|
* \param textures A map of texture identifiers and corresponding file paths.
|
||||||
*
|
*
|
||||||
* This function iterates over the provided map of textures and loads each
|
* This function iterates over the provided map of textures and loads each
|
||||||
* texture using `addSingleTexture`. It allows developers to add several
|
* texture using `addSingleTexture`. It allows for several
|
||||||
* textures at once.
|
* textures to be added at once.
|
||||||
*/
|
*/
|
||||||
void addTextures(const std::map<Textures, const char*>& textures);
|
void addTextures(const std::map<Textures, const char*>& textures);
|
||||||
|
|
||||||
@ -62,7 +58,7 @@ class TextureManager
|
|||||||
* \param texture The texture identifier.
|
* \param texture The texture identifier.
|
||||||
* \return A pointer to the `SDL_Texture` if found, or `nullptr` if not found.
|
* \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
|
* corresponding `SDL_Texture*`. If the texture is not found, it logs an error
|
||||||
* message and returns `nullptr`.
|
* message and returns `nullptr`.
|
||||||
*/
|
*/
|
||||||
@ -73,7 +69,7 @@ class TextureManager
|
|||||||
/*!
|
/*!
|
||||||
* \brief Loads a map tile texture from the file system and caches it.
|
* \brief Loads a map tile texture from the file system and caches it.
|
||||||
* \param path The file path to the texture.
|
* \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
|
* 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.
|
* loads the texture from the file system and stores it in the cache.
|
||||||
|
|||||||
14
include/Textures.h
Normal file
14
include/Textures.h
Normal file
@ -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;
|
||||||
@ -6,7 +6,7 @@
|
|||||||
#include <magic_enum/magic_enum.hpp>
|
#include <magic_enum/magic_enum.hpp>
|
||||||
|
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "TextureEnumBase.h"
|
#include "Textures.h"
|
||||||
|
|
||||||
class SpriteComponent;
|
class SpriteComponent;
|
||||||
class TransformComponent;
|
class TransformComponent;
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
#include "PowerupComponent.h"
|
#include "PowerupComponent.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "TextureEnumBase.h"
|
#include "Textures.h"
|
||||||
|
|
||||||
AssetManager::AssetManager(Manager* manager) : man(manager) {}
|
AssetManager::AssetManager(Manager* manager) : man(manager) {}
|
||||||
|
|
||||||
|
|||||||
@ -5,9 +5,7 @@
|
|||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "TransformComponent.h"
|
#include "TransformComponent.h"
|
||||||
#include "SpriteComponent.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<int, std::pair<Textures, bool>>* textureDict)
|
TileComponent::TileComponent(int x, int y, int w, int h, int id, const std::map<int, std::pair<Textures, bool>>* textureDict)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user