arreglos pa NO integrar jail_audio en ResourceHelper
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <cstdlib> // Para exit
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <utility> // Para move
|
||||
#include <fstream> // Para ofstream
|
||||
|
||||
#include "asset.h" // Para Asset
|
||||
#include "color.h" // Para Color
|
||||
@@ -17,10 +18,27 @@
|
||||
#include "param.h" // Para Param, param, ParamResource, ParamGame
|
||||
#include "screen.h" // Para Screen
|
||||
#include "text.h" // Para Text
|
||||
#include "resource_helper.h" // Para ResourceHelper
|
||||
|
||||
struct JA_Music_t; // lines 11-11
|
||||
struct JA_Sound_t; // lines 12-12
|
||||
|
||||
// Helper para cargar archivos de audio desde pack o filesystem
|
||||
namespace {
|
||||
std::string createTempAudioFile(const std::string& file_path) {
|
||||
auto resource_data = ResourceHelper::loadFile(file_path);
|
||||
if (!resource_data.empty()) {
|
||||
// Crear archivo temporal
|
||||
std::string temp_path = "/tmp/ccae_audio_" + std::to_string(std::hash<std::string>{}(file_path));
|
||||
std::ofstream temp_file(temp_path, std::ios::binary);
|
||||
temp_file.write(reinterpret_cast<const char*>(resource_data.data()), resource_data.size());
|
||||
temp_file.close();
|
||||
return temp_path;
|
||||
}
|
||||
return file_path; // Usar ruta original si no está en pack
|
||||
}
|
||||
}
|
||||
|
||||
// Declaraciones de funciones que necesitas implementar en otros archivos
|
||||
|
||||
// Singleton
|
||||
@@ -293,7 +311,8 @@ auto Resource::loadSoundLazy(const std::string &name) -> JA_Sound_t * {
|
||||
auto sound_list = Asset::get()->getListByType(Asset::Type::SOUND);
|
||||
for (const auto &file : sound_list) {
|
||||
if (getFileName(file) == name) {
|
||||
return JA_LoadSound(file.c_str());
|
||||
std::string audio_path = createTempAudioFile(file);
|
||||
return JA_LoadSound(audio_path.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -306,7 +325,8 @@ auto Resource::loadMusicLazy(const std::string &name) -> JA_Music_t * {
|
||||
auto music_list = Asset::get()->getListByType(Asset::Type::MUSIC);
|
||||
for (const auto &file : music_list) {
|
||||
if (getFileName(file) == name) {
|
||||
return JA_LoadMusic(file.c_str());
|
||||
std::string audio_path = createTempAudioFile(file);
|
||||
return JA_LoadMusic(audio_path.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -448,7 +468,8 @@ void Resource::loadSounds() {
|
||||
auto name = getFileName(l);
|
||||
updateLoadingProgress(name);
|
||||
#ifndef NO_AUDIO
|
||||
sounds_.emplace_back(name, JA_LoadSound(l.c_str()));
|
||||
std::string audio_path = createTempAudioFile(l);
|
||||
sounds_.emplace_back(name, JA_LoadSound(audio_path.c_str()));
|
||||
#else
|
||||
sounds_.emplace_back(name, nullptr);
|
||||
#endif
|
||||
@@ -466,7 +487,8 @@ void Resource::loadMusics() {
|
||||
auto name = getFileName(l);
|
||||
updateLoadingProgress(name);
|
||||
#ifndef NO_AUDIO
|
||||
musics_.emplace_back(name, JA_LoadMusic(l.c_str()));
|
||||
std::string audio_path = createTempAudioFile(l);
|
||||
musics_.emplace_back(name, JA_LoadMusic(audio_path.c_str()));
|
||||
#else
|
||||
musics_.emplace_back(name, nullptr);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user