This commit is contained in:
2025-10-27 18:56:24 +01:00
parent 3179a08dac
commit 5f47c88770
8 changed files with 121 additions and 119 deletions

View File

@@ -2,6 +2,7 @@
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <utility>
#include <vector> // Para vector
#include "core/rendering/surface.hpp" // Para Surface
@@ -17,8 +18,8 @@ struct ResourceSound {
JA_Sound_t* sound; // Objeto con el sonido
// Constructor
ResourceSound(const std::string& name, JA_Sound_t* sound)
: name(name),
ResourceSound(std::string name, JA_Sound_t* sound)
: name(std::move(name)),
sound(sound) {}
};
@@ -28,8 +29,8 @@ struct ResourceMusic {
JA_Music_t* music; // Objeto con la música
// Constructor
ResourceMusic(const std::string& name, JA_Music_t* music)
: name(name),
ResourceMusic(std::string name, JA_Music_t* music)
: name(std::move(name)),
music(music) {}
};
@@ -39,9 +40,9 @@ struct ResourceSurface {
std::shared_ptr<Surface> surface; // Objeto con la surface
// Constructor
ResourceSurface(const std::string& name, std::shared_ptr<Surface> surface)
: name(name),
surface(surface) {}
ResourceSurface(std::string name, std::shared_ptr<Surface> surface)
: name(std::move(name)),
surface(std::move(std::move(surface))) {}
};
// Estructura para almacenar objetos Palette y su nombre
@@ -50,8 +51,8 @@ struct ResourcePalette {
Palette palette; // Paleta
// Constructor
ResourcePalette(const std::string& name, Palette palette)
: name(name),
ResourcePalette(std::string name, Palette palette)
: name(std::move(name)),
palette(palette) {}
};
@@ -61,9 +62,9 @@ struct ResourceTextFile {
std::shared_ptr<TextFile> text_file; // Objeto con los descriptores de la fuente de texto
// Constructor
ResourceTextFile(const std::string& name, std::shared_ptr<TextFile> text_file)
: name(name),
text_file(text_file) {}
ResourceTextFile(std::string name, std::shared_ptr<TextFile> text_file)
: name(std::move(name)),
text_file(std::move(std::move(text_file))) {}
};
// Estructura para almacenar objetos Text y su nombre
@@ -72,9 +73,9 @@ struct ResourceText {
std::shared_ptr<Text> text; // Objeto
// Constructor
ResourceText(const std::string& name, std::shared_ptr<Text> text)
: name(name),
text(text) {}
ResourceText(std::string name, std::shared_ptr<Text> text)
: name(std::move(name)),
text(std::move(std::move(text))) {}
};
// Estructura para almacenar ficheros animaciones y su nombre
@@ -83,9 +84,9 @@ struct ResourceAnimation {
Animations animation; // Objeto con las animaciones
// Constructor
ResourceAnimation(const std::string& name, const Animations& animation)
: name(name),
animation(animation) {}
ResourceAnimation(std::string name, Animations animation)
: name(std::move(name)),
animation(std::move(animation)) {}
};
// Estructura para almacenar ficheros con el mapa de tiles de una habitación y su nombre
@@ -94,8 +95,8 @@ struct ResourceTileMap {
std::vector<int> tile_map; // Vector con los indices del mapa de tiles
// Constructor
ResourceTileMap(const std::string& name, const std::vector<int>& tile_map)
: name(name),
ResourceTileMap(std::string name, const std::vector<int>& tile_map)
: name(std::move(name)),
tile_map(tile_map) {}
};
@@ -105,9 +106,9 @@ struct ResourceRoom {
std::shared_ptr<RoomData> room; // Habitación
// Constructor
ResourceRoom(const std::string& name, std::shared_ptr<RoomData> room)
: name(name),
room(room) {}
ResourceRoom(std::string name, std::shared_ptr<RoomData> room)
: name(std::move(name)),
room(std::move(std::move(room))) {}
};
// Estructura para llevar la cuenta de los recursos cargados
@@ -131,7 +132,7 @@ struct ResourceCount {
}
// Obtiene el porcentaje de recursos cargados
float getPercentage() const {
[[nodiscard]] auto getPercentage() const -> float {
return static_cast<float>(loaded) / static_cast<float>(total);
}
};
@@ -220,37 +221,37 @@ class Resource {
static void destroy();
// [SINGLETON] Con este método obtenemos el objeto resource y podemos trabajar con él
static Resource* get();
static auto get() -> Resource*;
// Obtiene el sonido a partir de un nombre
JA_Sound_t* getSound(const std::string& name);
auto getSound(const std::string& name) -> JA_Sound_t*;
// Obtiene la música a partir de un nombre
JA_Music_t* getMusic(const std::string& name);
auto getMusic(const std::string& name) -> JA_Music_t*;
// Obtiene la surface a partir de un nombre
std::shared_ptr<Surface> getSurface(const std::string& name);
auto getSurface(const std::string& name) -> std::shared_ptr<Surface>;
// Obtiene la paleta a partir de un nombre
Palette getPalette(const std::string& name);
auto getPalette(const std::string& name) -> Palette;
// Obtiene el fichero de texto a partir de un nombre
std::shared_ptr<TextFile> getTextFile(const std::string& name);
auto getTextFile(const std::string& name) -> std::shared_ptr<TextFile>;
// Obtiene el objeto de texto a partir de un nombre
std::shared_ptr<Text> getText(const std::string& name);
auto getText(const std::string& name) -> std::shared_ptr<Text>;
// Obtiene la animación a partir de un nombre
Animations& getAnimations(const std::string& name);
auto getAnimations(const std::string& name) -> Animations&;
// Obtiene el mapa de tiles a partir de un nombre
std::vector<int>& getTileMap(const std::string& name);
auto getTileMap(const std::string& name) -> std::vector<int>&;
// Obtiene la habitación a partir de un nombre
std::shared_ptr<RoomData> getRoom(const std::string& name);
auto getRoom(const std::string& name) -> std::shared_ptr<RoomData>;
// Obtiene todas las habitaciones
std::vector<ResourceRoom>& getRooms();
auto getRooms() -> std::vector<ResourceRoom>&;
// Recarga todos los recursos
void reload();