This commit is contained in:
2025-11-19 20:43:20 +01:00
parent 35ef99cf7c
commit 5337e3b4e5
8 changed files with 112 additions and 47 deletions
+17 -17
View File
@@ -197,7 +197,7 @@ void Cache::loadSounds() {
sound = JA_LoadSound(l.c_str());
}
sounds_.emplace_back(SoundResource{name, sound});
sounds_.emplace_back(SoundResource{.name = name, .sound = sound});
printWithDots("Sound : ", name, "[ LOADED ]");
updateLoadingProgress();
}
@@ -224,7 +224,7 @@ void Cache::loadMusics() {
music = JA_LoadMusic(l.c_str());
}
musics_.emplace_back(MusicResource{name, music});
musics_.emplace_back(MusicResource{.name = name, .music = 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(SurfaceResource{name, std::make_shared<Surface>(l)});
surfaces_.emplace_back(SurfaceResource{.name = name, .surface = 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(ResourcePalette{name, readPalFile(l)});
palettes_.emplace_back(ResourcePalette{.name = name, .palette = readPalFile(l)});
updateLoadingProgress();
}
}
@@ -274,7 +274,7 @@ void Cache::loadTextFiles() {
for (const auto& l : list) {
auto name = getFileName(l);
text_files_.emplace_back(TextFileResource{name, Text::loadTextFile(l)});
text_files_.emplace_back(TextFileResource{.name = name, .text_file = 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(AnimationResource{name, yaml_bytes});
animations_.emplace_back(AnimationResource{.name = name, .yaml_data = 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(RoomResource{name, std::make_shared<Room::Data>(Room::loadYAML(l))});
rooms_.emplace_back(RoomResource{.name = name, .room = std::make_shared<Room::Data>(Room::loadYAML(l))});
printWithDots("Room : ", name, "[ LOADED ]");
updateLoadingProgress();
}
@@ -313,22 +313,22 @@ 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
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';
std::vector<ResourceInfo> resources = {
{"aseprite", "aseprite.gif", "aseprite.txt"},
{"gauntlet", "gauntlet.gif", "gauntlet.txt"},
{"smb2", "smb2.gif", "smb2.txt"},
{"subatomic", "subatomic.gif", "subatomic.txt"},
{"8bithud", "8bithud.gif", "8bithud.txt"}};
{.key = "aseprite", .texture_file = "aseprite.gif", .text_file = "aseprite.txt"},
{.key = "gauntlet", .texture_file = "gauntlet.gif", .text_file = "gauntlet.txt"},
{.key = "smb2", .texture_file = "smb2.gif", .text_file = "smb2.txt"},
{.key = "subatomic", .texture_file = "subatomic.gif", .text_file = "subatomic.txt"},
{.key = "8bithud", .texture_file = "8bithud.gif", .text_file = "8bithud.txt"}};
for (const auto& res_info : resources) {
texts_.emplace_back(TextResource{res_info.key, std::make_shared<Text>(getSurface(res_info.texture_file), getTextFile(res_info.text_file))});
texts_.emplace_back(TextResource{.name = res_info.key, .text = std::make_shared<Text>(getSurface(res_info.texture_file), getTextFile(res_info.text_file))});
printWithDots("Text : ", res_info.key, "[ DONE ]");
}
}
@@ -374,7 +374,7 @@ void Cache::calculateTotal() {
total += list.size();
}
count_ = ResourceCount{total, 0};
count_ = ResourceCount{.total = total, .loaded = 0};
}
// Muestra el progreso de carga