refactor jail_audio: namespace Ja, enum class, tipus sense prefix JA_
This commit is contained in:
@@ -64,12 +64,12 @@ Resource::~Resource() {
|
||||
textures_.clear();
|
||||
|
||||
for (auto &[name, s] : sounds_) {
|
||||
JA_DeleteSound(s);
|
||||
Ja::deleteSound(s);
|
||||
}
|
||||
sounds_.clear();
|
||||
|
||||
for (auto &[name, m] : musics_) {
|
||||
JA_DeleteMusic(m);
|
||||
Ja::deleteMusic(m);
|
||||
}
|
||||
musics_.clear();
|
||||
}
|
||||
@@ -103,14 +103,14 @@ void Resource::preloadResources() {
|
||||
break;
|
||||
}
|
||||
case Asset::Type::SOUND: {
|
||||
JA_Sound_t *s = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
Ja::Sound *s = Ja::loadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
if (s != nullptr) {
|
||||
sounds_[BASE_NAME] = s;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Asset::Type::MUSIC: {
|
||||
JA_Music_t *m = JA_LoadMusic(bytes.data(), (Uint32)bytes.size());
|
||||
Ja::Music *m = Ja::loadMusic(bytes.data(), (Uint32)bytes.size());
|
||||
if (m != nullptr) {
|
||||
musics_[BASE_NAME] = m;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ void Resource::preloadFonts() {
|
||||
// Pass 2b: construye los Menu (dependen de Text+sonidos cargados antes)
|
||||
//
|
||||
// NOTA: Menu::loadFromBytes aún llama internamente a asset->get() y Text/
|
||||
// JA_LoadSound por path. Funciona en modo fallback; en pack estricto requiere
|
||||
// Ja::loadSound por path. Funciona en modo fallback; en pack estricto requiere
|
||||
// que Menu se adapte a cargar desde ResourceHelper. Migración pendiente.
|
||||
void Resource::preloadMenus() {
|
||||
const auto &items = Asset::get()->getAll();
|
||||
@@ -218,7 +218,7 @@ auto Resource::getTexture(const std::string &name) -> Texture * {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
auto Resource::getSound(const std::string &name) -> JA_Sound_t * {
|
||||
auto Resource::getSound(const std::string &name) -> Ja::Sound * {
|
||||
auto it = sounds_.find(name);
|
||||
if (it == sounds_.end()) {
|
||||
std::cerr << "Resource::getSound: missing " << name << '\n';
|
||||
@@ -227,7 +227,7 @@ auto Resource::getSound(const std::string &name) -> JA_Sound_t * {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
auto Resource::getMusic(const std::string &name) -> JA_Music_t * {
|
||||
auto Resource::getMusic(const std::string &name) -> Ja::Music * {
|
||||
auto it = musics_.find(name);
|
||||
if (it == musics_.end()) {
|
||||
std::cerr << "Resource::getMusic: missing " << name << '\n';
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
class Menu;
|
||||
class Text;
|
||||
class Texture;
|
||||
struct JA_Music_t;
|
||||
struct JA_Sound_t;
|
||||
namespace Ja {
|
||||
struct Music;
|
||||
struct Sound;
|
||||
} // namespace Ja
|
||||
|
||||
// Precarga y posee todos los recursos del juego durante toda la vida de la app.
|
||||
// Singleton inicializado desde Director; las escenas consultan handles via get*().
|
||||
@@ -22,8 +24,8 @@ class Resource {
|
||||
static auto get() -> Resource *;
|
||||
|
||||
auto getTexture(const std::string &name) -> Texture *;
|
||||
auto getSound(const std::string &name) -> JA_Sound_t *;
|
||||
auto getMusic(const std::string &name) -> JA_Music_t *;
|
||||
auto getSound(const std::string &name) -> Ja::Sound *;
|
||||
auto getMusic(const std::string &name) -> Ja::Music *;
|
||||
auto getAnimationLines(const std::string &name) -> std::vector<std::string> &;
|
||||
auto getText(const std::string &name) -> Text *; // name sin extensión: "smb2", "nokia2", ...
|
||||
auto getMenu(const std::string &name) -> Menu *; // name sin extensión: "title", "options", ...
|
||||
@@ -44,8 +46,8 @@ class Resource {
|
||||
SDL_Renderer *renderer_;
|
||||
|
||||
std::unordered_map<std::string, Texture *> textures_;
|
||||
std::unordered_map<std::string, JA_Sound_t *> sounds_;
|
||||
std::unordered_map<std::string, JA_Music_t *> musics_;
|
||||
std::unordered_map<std::string, Ja::Sound *> sounds_;
|
||||
std::unordered_map<std::string, Ja::Music *> musics_;
|
||||
std::unordered_map<std::string, std::vector<std::string>> animation_lines_;
|
||||
std::unordered_map<std::string, Text *> texts_;
|
||||
std::unordered_map<std::string, Menu *> menus_;
|
||||
|
||||
Reference in New Issue
Block a user