forked from jaildesigner-jailgames/jaildoctors_dilemma
actualitzada la carpeta release a SDL3
migrat a resources.pack
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#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_helper.hpp" // Para ResourceHelper
|
||||
#include "core/system/debug.hpp" // Para Debug
|
||||
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker
|
||||
#include "game/gameplay/scoreboard.hpp" // Para ScoreboardData
|
||||
@@ -946,16 +947,21 @@ auto Room::setItem(Item::Data* item, const std::string& key, const std::string&
|
||||
auto Room::loadRoomTileFile(const std::string& file_path, bool verbose) -> std::vector<int> {
|
||||
std::vector<int> tile_map_file;
|
||||
const std::string FILENAME = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
std::ifstream file(file_path);
|
||||
|
||||
// El fichero se puede abrir
|
||||
if (file.good()) {
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto file_data = jdd::ResourceHelper::loadFile(file_path);
|
||||
|
||||
if (!file_data.empty()) {
|
||||
// Convert bytes to string and parse
|
||||
std::string content(file_data.begin(), file_data.end());
|
||||
std::istringstream stream(content);
|
||||
std::string line;
|
||||
|
||||
// Procesa el fichero linea a linea
|
||||
while (std::getline(file, line)) { // Lee el fichero linea a linea
|
||||
while (std::getline(stream, line)) { // Lee el fichero linea a linea
|
||||
if (line.find("data encoding") != std::string::npos) {
|
||||
// Lee la primera linea
|
||||
std::getline(file, line);
|
||||
std::getline(stream, line);
|
||||
while (line != "</data>") { // Procesa lineas mientras haya
|
||||
std::stringstream ss(line);
|
||||
std::string tmp;
|
||||
@@ -964,18 +970,15 @@ auto Room::loadRoomTileFile(const std::string& file_path, bool verbose) -> std::
|
||||
}
|
||||
|
||||
// Lee la siguiente linea
|
||||
std::getline(file, line);
|
||||
std::getline(stream, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cierra el fichero
|
||||
if (verbose) {
|
||||
std::cout << "TileMap loaded: " << FILENAME.c_str() << '\n';
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
else { // El fichero no se puede abrir
|
||||
if (verbose) {
|
||||
std::cout << "Warning: Unable to open " << FILENAME.c_str() << " file" << '\n';
|
||||
@@ -995,20 +998,24 @@ auto Room::loadRoomFile(const std::string& file_path, bool verbose) -> Data {
|
||||
const std::string FILE_NAME = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
room.number = FILE_NAME.substr(0, FILE_NAME.find_last_of('.'));
|
||||
|
||||
std::ifstream file(file_path);
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto file_data = jdd::ResourceHelper::loadFile(file_path);
|
||||
|
||||
// El fichero se puede abrir
|
||||
if (file.good()) {
|
||||
if (!file_data.empty()) {
|
||||
// Convert bytes to string and parse
|
||||
std::string content(file_data.begin(), file_data.end());
|
||||
std::istringstream stream(content);
|
||||
std::string line;
|
||||
|
||||
// Procesa el fichero linea a linea
|
||||
while (std::getline(file, line)) {
|
||||
while (std::getline(stream, line)) {
|
||||
// Si la linea contiene el texto [enemy] se realiza el proceso de carga de un enemigo
|
||||
if (line == "[enemy]") {
|
||||
room.enemies.push_back(loadEnemyFromFile(file, FILE_NAME, verbose));
|
||||
room.enemies.push_back(loadEnemyFromFile(stream, FILE_NAME, verbose));
|
||||
}
|
||||
// Si la linea contiene el texto [item] se realiza el proceso de carga de un item
|
||||
else if (line == "[item]") {
|
||||
room.items.push_back(loadItemFromFile(file, FILE_NAME, verbose));
|
||||
room.items.push_back(loadItemFromFile(stream, FILE_NAME, verbose));
|
||||
}
|
||||
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
||||
else {
|
||||
@@ -1019,14 +1026,11 @@ auto Room::loadRoomFile(const std::string& file_path, bool verbose) -> Data {
|
||||
}
|
||||
}
|
||||
|
||||
// Cierra el fichero
|
||||
if (verbose) {
|
||||
std::cout << "Room loaded: " << FILE_NAME.c_str() << '\n';
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
// El fichero no se puede abrir
|
||||
else {
|
||||
else { // El fichero no se puede abrir
|
||||
std::cout << "Warning: Unable to open " << FILE_NAME.c_str() << " file" << '\n';
|
||||
}
|
||||
|
||||
@@ -1049,7 +1053,7 @@ void Room::logUnknownParameter(const std::string& file_name, const std::string&
|
||||
}
|
||||
|
||||
// Carga un bloque [enemy]...[/enemy] desde un archivo
|
||||
auto Room::loadEnemyFromFile(std::ifstream& file, const std::string& file_name, bool verbose) -> Enemy::Data {
|
||||
auto Room::loadEnemyFromFile(std::istream& file, const std::string& file_name, bool verbose) -> Enemy::Data {
|
||||
Enemy::Data enemy;
|
||||
enemy.flip = false;
|
||||
enemy.mirror = false;
|
||||
@@ -1069,7 +1073,7 @@ auto Room::loadEnemyFromFile(std::ifstream& file, const std::string& file_name,
|
||||
}
|
||||
|
||||
// Carga un bloque [item]...[/item] desde un archivo
|
||||
auto Room::loadItemFromFile(std::ifstream& file, const std::string& file_name, bool verbose) -> Item::Data {
|
||||
auto Room::loadItemFromFile(std::istream& file, const std::string& file_name, bool verbose) -> Item::Data {
|
||||
Item::Data item;
|
||||
item.counter = 0;
|
||||
item.color1 = stringToColor("yellow");
|
||||
|
||||
Reference in New Issue
Block a user