neteja tidy (29 → 0) i migració JA_* → Ja::

This commit is contained in:
2026-05-16 18:40:00 +02:00
parent 75fd037251
commit d1cf6f5529
22 changed files with 798 additions and 745 deletions
+23 -21
View File
@@ -9,7 +9,7 @@
#include <stdexcept> // Para runtime_error
#include <utility>
#include "core/audio/jail_audio.hpp" // Para JA_DeleteMusic, JA_DeleteSound, JA_Loa...
#include "core/audio/jail_audio.hpp" // Para Ja::deleteMusic, Ja::deleteSound, JA_Loa...
#include "core/rendering/screen.hpp" // Para Screen
#include "core/rendering/text.hpp" // Para Text, loadTextFile
#include "core/resources/resource_helper.hpp" // Para Helper
@@ -21,8 +21,10 @@
#include "utils/defines.hpp" // Para WINDOW_CAPTION
#include "utils/utils.hpp" // Para getFileName, printWithDots, PaletteColor
#include "version.h" // Para Version::GIT_HASH
struct JA_Music_t; // lines 17-17
struct JA_Sound_t; // lines 18-18
namespace Ja {
struct Music;
struct Sound;
} // namespace Ja
namespace Resource {
@@ -88,7 +90,7 @@ namespace Resource {
}
// Obtiene el sonido a partir de un nombre
auto Cache::getSound(const std::string& name) -> JA_Sound_t* {
auto Cache::getSound(const std::string& name) -> Ja::Sound* {
auto it = std::ranges::find_if(sounds_, [&name](const auto& s) -> bool { return s.name == name; });
if (it != sounds_.end()) {
@@ -103,7 +105,7 @@ namespace Resource {
}
// Obtiene la música a partir de un nombre
auto Cache::getMusic(const std::string& name) -> JA_Music_t* {
auto Cache::getMusic(const std::string& name) -> Ja::Music* {
auto it = std::ranges::find_if(musics_, [&name](const auto& m) -> bool { return m.name == name; });
if (it != musics_.end()) {
@@ -261,17 +263,17 @@ namespace Resource {
for (const auto& l : list) {
try {
auto name = getFileName(l);
JA_Sound_t* sound = nullptr;
Ja::Sound* sound = nullptr;
// Try loading from resource pack first
auto audio_data = Helper::loadFile(l);
if (!audio_data.empty()) {
sound = JA_LoadSound(audio_data.data(), static_cast<Uint32>(audio_data.size()));
sound = Ja::loadSound(audio_data.data(), static_cast<Uint32>(audio_data.size()));
}
// Fallback to file path if memory loading failed
if (sound == nullptr) {
sound = JA_LoadSound(l.c_str());
sound = Ja::loadSound(l.c_str());
}
if (sound == nullptr) {
@@ -296,17 +298,17 @@ namespace Resource {
for (const auto& l : list) {
try {
auto name = getFileName(l);
JA_Music_t* music = nullptr;
Ja::Music* music = nullptr;
// Try loading from resource pack first
auto audio_data = Helper::loadFile(l);
if (!audio_data.empty()) {
music = JA_LoadMusic(audio_data.data(), static_cast<Uint32>(audio_data.size()));
music = Ja::loadMusic(audio_data.data(), static_cast<Uint32>(audio_data.size()));
}
// Fallback to file path if memory loading failed
if (music == nullptr) {
music = JA_LoadMusic(l.c_str());
music = Ja::loadMusic(l.c_str());
}
if (music == nullptr) {
@@ -448,10 +450,10 @@ namespace Resource {
// Vacía el vector de sonidos
void Cache::clearSounds() {
// Itera sobre el vector y libera los recursos asociados a cada JA_Sound_t
// Itera sobre el vector y libera los recursos asociados a cada Ja::Sound
for (auto& sound : sounds_) {
if (sound.sound != nullptr) {
JA_DeleteSound(sound.sound);
Ja::deleteSound(sound.sound);
sound.sound = nullptr;
}
}
@@ -460,10 +462,10 @@ namespace Resource {
// Vacía el vector de musicas
void Cache::clearMusics() {
// Itera sobre el vector y libera los recursos asociados a cada JA_Music_t
// Itera sobre el vector y libera los recursos asociados a cada Ja::Music
for (auto& music : musics_) {
if (music.music != nullptr) {
JA_DeleteMusic(music.music);
Ja::deleteMusic(music.music);
music.music = nullptr;
}
}
@@ -592,9 +594,9 @@ namespace Resource {
auto path = List::get()->get(name);
try {
auto bytes = Helper::loadFile(path);
JA_Sound_t* sound = nullptr;
if (!bytes.empty()) { sound = JA_LoadSound(bytes.data(), static_cast<Uint32>(bytes.size())); }
if (sound == nullptr) { sound = JA_LoadSound(path.c_str()); }
Ja::Sound* sound = nullptr;
if (!bytes.empty()) { sound = Ja::loadSound(bytes.data(), static_cast<Uint32>(bytes.size())); }
if (sound == nullptr) { sound = Ja::loadSound(path.c_str()); }
if (sound == nullptr) { throw std::runtime_error("Failed to decode audio file"); }
it->sound = sound;
std::cout << "[lazy] Sound loaded: " << name << '\n';
@@ -609,9 +611,9 @@ namespace Resource {
auto path = List::get()->get(name);
try {
auto bytes = Helper::loadFile(path);
JA_Music_t* music = nullptr;
if (!bytes.empty()) { music = JA_LoadMusic(bytes.data(), static_cast<Uint32>(bytes.size())); }
if (music == nullptr) { music = JA_LoadMusic(path.c_str()); }
Ja::Music* music = nullptr;
if (!bytes.empty()) { music = Ja::loadMusic(bytes.data(), static_cast<Uint32>(bytes.size())); }
if (music == nullptr) { music = Ja::loadMusic(path.c_str()); }
if (music == nullptr) { throw std::runtime_error("Failed to decode music file"); }
it->music = music;
std::cout << "[lazy] Music loaded: " << name << '\n';