unificats els resources en un namespace

This commit is contained in:
2025-11-11 10:04:57 +01:00
parent 1821b84e73
commit 54fc6d2902
35 changed files with 356 additions and 341 deletions

View File

@@ -11,7 +11,7 @@
#include "core/rendering/screen.hpp" // Para Screen
#include "core/rendering/surface.hpp" // Para Surface
#include "core/rendering/surface_sprite.hpp" // Para SSprite
#include "core/resources/resource.hpp" // Para Resource
#include "core/resources/resource_cache.hpp" // Para Resource
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
#include "core/system/debug.hpp" // Para Debug
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker
@@ -23,7 +23,7 @@
// Constructor
Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
: data_(std::move(std::move(data))) {
auto room = Resource::get()->getRoom(room_path);
auto room = Resource::Cache::get()->getRoom(room_path);
initializeRoom(*room);
openTheJail(); // Abre la Jail si se da el caso
@@ -49,8 +49,8 @@ void Room::initializeRoom(const Data& room) {
tile_set_file_ = room.tile_set_file;
tile_map_file_ = room.tile_map_file;
conveyor_belt_direction_ = room.conveyor_belt_direction;
tile_map_ = Resource::get()->getTileMap(room.tile_map_file);
surface_ = Resource::get()->getSurface(room.tile_set_file);
tile_map_ = Resource::Cache::get()->getTileMap(room.tile_map_file);
surface_ = Resource::Cache::get()->getSurface(room.tile_set_file);
tile_set_width_ = surface_->getWidth() / TILE_SIZE;
is_paused_ = false;
time_accumulator_ = 0.0F;
@@ -930,7 +930,7 @@ auto Room::loadRoomTileFile(const std::string& file_path, bool verbose) -> std::
const std::string FILENAME = file_path.substr(file_path.find_last_of("\\/") + 1);
// Load file using ResourceHelper (supports both filesystem and pack)
auto file_data = Jdd::ResourceHelper::loadFile(file_path);
auto file_data = Resource::Helper::loadFile(file_path);
if (!file_data.empty()) {
// Convert bytes to string and parse
@@ -992,7 +992,7 @@ auto Room::loadRoomFile(const std::string& file_path, bool verbose) -> Data {
room.number = FILE_NAME.substr(0, FILE_NAME.find_last_of('.'));
// Load file using ResourceHelper (supports both filesystem and pack)
auto file_data = Jdd::ResourceHelper::loadFile(file_path);
auto file_data = Resource::Helper::loadFile(file_path);
if (!file_data.empty()) {
// Convert bytes to string and parse

View File

@@ -8,21 +8,21 @@
#include "core/rendering/surface.hpp" // Para Surface
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
#include "core/rendering/text.hpp" // Para Text
#include "core/resources/resource.hpp" // Para Resource
#include "core/resources/resource_cache.hpp" // Para Resource
#include "game/options.hpp" // Para Options, options, Cheat, OptionsGame
#include "utils/defines.hpp" // Para BLOCK
#include "utils/utils.hpp" // Para stringToColor
// Constructor
Scoreboard::Scoreboard(std::shared_ptr<Data> data)
: item_surface_(Resource::get()->getSurface("items.gif")),
: item_surface_(Resource::Cache::get()->getSurface("items.gif")),
data_(std::move(std::move(data))) {
const float SURFACE_WIDTH = Options::game.width;
constexpr float SURFACE_HEIGHT = 6.0F * TILE_SIZE;
// Reserva memoria para los objetos
// auto player_texture = Resource::get()->getSurface(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.gif" : "player.gif");
auto player_animations = Resource::get()->getAnimations(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.ani" : "player.ani");
// auto player_texture = Resource::Cache::get()->getSurface(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.gif" : "player.gif");
auto player_animations = Resource::Cache::get()->getAnimations(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.ani" : "player.ani");
player_sprite_ = std::make_shared<SurfaceAnimatedSprite>(player_animations);
player_sprite_->setCurrentAnimation("walk_menu");
@@ -154,7 +154,7 @@ void Scoreboard::fillTexture() {
}
// Escribe los textos
auto text = Resource::get()->getText("smb2");
auto text = Resource::Cache::get()->getText("smb2");
const std::string TIME_TEXT = std::to_string((clock_.minutes % 100) / 10) + std::to_string(clock_.minutes % 10) + clock_.separator + std::to_string((clock_.seconds % 60) / 10) + std::to_string(clock_.seconds % 10);
const std::string ITEMS_TEXT = std::to_string(data_->items / 100) + std::to_string((data_->items % 100) / 10) + std::to_string(data_->items % 10);
text->writeColored(TILE_SIZE, LINE1, "Items collected ", data_->color);