afegit define NO_AUDIO
renombrat define DEBUG a _DEBUG
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
#include "resource.h"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_SetRenderDrawColor, SDL_EventType, SDL_PollEvent, SDL_RenderFillRect, SDL_RenderRect, SDLK_ESCAPE, SDL_Event
|
||||
#include <algorithm> // Para find_if, max
|
||||
#include <array> // Para array
|
||||
#include <cstdlib> // Para exit
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <utility> // Para move
|
||||
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_SetRenderDrawColor, SDL_EventType, SDL_PollEvent, SDL_RenderFillRect, SDL_RenderRect, SDLK_ESCAPE, SDL_Event
|
||||
|
||||
#include "asset.h" // Para Asset, AssetType
|
||||
#include "color.h" // Para Color
|
||||
#include <algorithm> // Para find_if, max
|
||||
#include <array> // Para array
|
||||
#include <cstdlib> // Para exit
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <utility> // Para move
|
||||
|
||||
#include "asset.h" // Para Asset, AssetType
|
||||
#include "color.h" // Para Color
|
||||
#ifndef NO_AUDIO
|
||||
#include "external/jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic, JA_LoadSound
|
||||
#include "lang.h" // Para getText
|
||||
#include "param.h" // Para Param, param, ParamResource, ParamGame
|
||||
#include "screen.h" // Para Screen
|
||||
#include "text.h" // Para Text, loadTextFile, TextFile (ptr only)
|
||||
#endif
|
||||
#include "lang.h" // Para getText
|
||||
#include "param.h" // Para Param, param, ParamResource, ParamGame
|
||||
#include "screen.h" // Para Screen
|
||||
#include "text.h" // Para Text, loadTextFile, TextFile (ptr only)
|
||||
|
||||
struct JA_Music_t; // lines 11-11
|
||||
struct JA_Sound_t; // lines 12-12
|
||||
@@ -38,8 +41,10 @@ Resource::~Resource() { clear(); }
|
||||
|
||||
// Vacia todos los vectores de recursos
|
||||
void Resource::clear() {
|
||||
#ifndef NO_AUDIO
|
||||
clearSounds();
|
||||
clearMusics();
|
||||
#endif
|
||||
textures_.clear();
|
||||
text_files_.clear();
|
||||
texts_.clear();
|
||||
@@ -59,8 +64,10 @@ void Resource::load() {
|
||||
screen->setVSync(false);
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** LOADING RESOURCES");
|
||||
loadSounds(); // Carga sonidos
|
||||
loadMusics(); // Carga músicas
|
||||
#ifndef NO_AUDIO
|
||||
loadSounds(); // Carga sonidos
|
||||
loadMusics(); // Carga músicas
|
||||
#endif
|
||||
loadTextures(); // Carga texturas
|
||||
loadTextFiles(); // Carga ficheros de texto
|
||||
loadAnimations(); // Carga animaciones
|
||||
@@ -173,7 +180,9 @@ void Resource::loadSounds() {
|
||||
for (const auto &l : list) {
|
||||
auto name = getFileName(l);
|
||||
updateLoadingProgress(name);
|
||||
#ifndef NO_AUDIO
|
||||
sounds_.emplace_back(name, JA_LoadSound(l.c_str()));
|
||||
#endif
|
||||
printWithDots("Sound : ", name, "[ LOADED ]");
|
||||
}
|
||||
}
|
||||
@@ -187,7 +196,9 @@ void Resource::loadMusics() {
|
||||
for (const auto &l : list) {
|
||||
auto name = getFileName(l);
|
||||
updateLoadingProgress(name);
|
||||
#ifndef NO_AUDIO
|
||||
musics_.emplace_back(name, JA_LoadMusic(l.c_str()));
|
||||
#endif
|
||||
printWithDots("Music : ", name, "[ LOADED ]");
|
||||
}
|
||||
}
|
||||
@@ -338,7 +349,9 @@ void Resource::createText() {
|
||||
void Resource::clearSounds() {
|
||||
for (auto &sound : sounds_) {
|
||||
if (sound.sound != nullptr) {
|
||||
#ifndef NO_AUDIO
|
||||
JA_DeleteSound(sound.sound);
|
||||
#endif
|
||||
sound.sound = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -349,7 +362,9 @@ void Resource::clearSounds() {
|
||||
void Resource::clearMusics() {
|
||||
for (auto &music : musics_) {
|
||||
if (music.music != nullptr) {
|
||||
#ifndef NO_AUDIO
|
||||
JA_DeleteMusic(music.music);
|
||||
#endif
|
||||
music.music = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user