arreglos d'estil en source/core/resources

This commit is contained in:
2025-11-18 12:41:30 +01:00
parent 4477cc4bbc
commit b7db34cdf7
9 changed files with 135 additions and 295 deletions
+15 -21
View File
@@ -148,7 +148,7 @@ auto Cache::getText(const std::string& name) -> std::shared_ptr<Text> {
}
// Obtiene los datos de animación parseados a partir de un nombre
auto Cache::getAnimationData(const std::string& name) -> const ResourceAnimation& {
auto Cache::getAnimationData(const std::string& name) -> const AnimationResource& {
auto it = std::ranges::find_if(animations_, [&name](const auto& a) { return a.name == name; });
if (it != animations_.end()) {
@@ -172,7 +172,7 @@ auto Cache::getRoom(const std::string& name) -> std::shared_ptr<Room::Data> {
}
// Obtiene todas las habitaciones
auto Cache::getRooms() -> std::vector<ResourceRoom>& {
auto Cache::getRooms() -> std::vector<RoomResource>& {
return rooms_;
}
@@ -197,7 +197,7 @@ void Cache::loadSounds() {
sound = JA_LoadSound(l.c_str());
}
sounds_.emplace_back(name, sound);
sounds_.emplace_back(SoundResource{name, sound});
printWithDots("Sound : ", name, "[ LOADED ]");
updateLoadingProgress();
}
@@ -224,7 +224,7 @@ void Cache::loadMusics() {
music = JA_LoadMusic(l.c_str());
}
musics_.emplace_back(name, music);
musics_.emplace_back(MusicResource{name, music});
printWithDots("Music : ", name, "[ LOADED ]");
updateLoadingProgress(1);
}
@@ -238,7 +238,7 @@ void Cache::loadSurfaces() {
for (const auto& l : list) {
auto name = getFileName(l);
surfaces_.emplace_back(name, std::make_shared<Surface>(l));
surfaces_.emplace_back(SurfaceResource{name, std::make_shared<Surface>(l)});
surfaces_.back().surface->setTransparentColor(0);
updateLoadingProgress();
}
@@ -261,7 +261,7 @@ void Cache::loadPalettes() {
for (const auto& l : list) {
auto name = getFileName(l);
palettes_.emplace_back(name, readPalFile(l));
palettes_.emplace_back(ResourcePalette{name, readPalFile(l)});
updateLoadingProgress();
}
}
@@ -274,7 +274,7 @@ void Cache::loadTextFiles() {
for (const auto& l : list) {
auto name = getFileName(l);
text_files_.emplace_back(name, Text::loadTextFile(l));
text_files_.emplace_back(TextFileResource{name, Text::loadTextFile(l)});
updateLoadingProgress();
}
}
@@ -291,7 +291,7 @@ void Cache::loadAnimations() {
// Cargar bytes del archivo YAML sin parsear (carga lazy)
auto yaml_bytes = Helper::loadFile(l);
animations_.emplace_back(name, yaml_bytes);
animations_.emplace_back(AnimationResource{name, yaml_bytes});
printWithDots("Animation : ", name, "[ LOADED ]");
updateLoadingProgress();
}
@@ -305,7 +305,7 @@ void Cache::loadRooms() {
for (const auto& l : list) {
auto name = getFileName(l);
rooms_.emplace_back(name, std::make_shared<Room::Data>(Room::loadYAML(l)));
rooms_.emplace_back(RoomResource{name, std::make_shared<Room::Data>(Room::loadYAML(l))});
printWithDots("Room : ", name, "[ LOADED ]");
updateLoadingProgress();
}
@@ -313,15 +313,9 @@ void Cache::loadRooms() {
void Cache::createText() {
struct ResourceInfo {
std::string key; // Identificador del recurso
std::string texture_file; // Nombre del archivo de textura
std::string text_file; // Nombre del archivo de texto
// Constructor para facilitar la creación de objetos ResourceInfo
ResourceInfo(std::string k, std::string t_file, std::string txt_file)
: key(std::move(k)),
texture_file(std::move(t_file)),
text_file(std::move(txt_file)) {}
std::string key{}; // Identificador del recurso
std::string texture_file{}; // Nombre del archivo de textura
std::string text_file{}; // Nombre del archivo de texto
};
std::cout << "\n>> CREATING TEXT_OBJECTS" << '\n';
@@ -334,7 +328,7 @@ void Cache::createText() {
{"8bithud", "8bithud.gif", "8bithud.txt"}};
for (const auto& res_info : resources) {
texts_.emplace_back(res_info.key, std::make_shared<Text>(getSurface(res_info.texture_file), getTextFile(res_info.text_file)));
texts_.emplace_back(TextResource{res_info.key, std::make_shared<Text>(getSurface(res_info.texture_file), getTextFile(res_info.text_file))});
printWithDots("Text : ", res_info.key, "[ DONE ]");
}
}
@@ -374,13 +368,13 @@ void Cache::calculateTotal() {
List::Type::ANIMATION,
List::Type::ROOM};
size_t total = 0;
int total = 0;
for (const auto& asset_type : asset_types) {
auto list = List::get()->getListByType(asset_type);
total += list.size();
}
count_ = ResourceCount(total, 0);
count_ = ResourceCount{total, 0};
}
// Muestra el progreso de carga