diff --git a/.gitignore b/.gitignore index 84b6d6b..7ebddc7 100755 --- a/.gitignore +++ b/.gitignore @@ -408,4 +408,9 @@ public web_resources/ pc_resources/ resources_hd/ -web_resources_x2/ \ No newline at end of file +web_resources_x2/ + + +.artifacts/ + +*.zip diff --git a/proj-android/app/jni/CMakeLists.txt b/proj-android/app/jni/CMakeLists.txt index ec0946b..efed56f 100644 --- a/proj-android/app/jni/CMakeLists.txt +++ b/proj-android/app/jni/CMakeLists.txt @@ -39,7 +39,8 @@ add_subdirectory("${TP_ROOT}/libpng-1.6.51" libpng-build) # --- SDL2 --- # Android-версия SDL требует специфичных настроек, но add_subdirectory обычно подхватывает их сама add_subdirectory("${TP_ROOT}/SDL-release-2.32.10" sdl-build) -#add_subdirectory("${TP_ROOT}/SDL_mixer-release-2.8.0" sdl-mixer-build) +add_subdirectory("${TP_ROOT}/SDL_mixer-release-2.8.0" sdl-mixer-build) + add_subdirectory("${TP_ROOT}/SDL_ttf-release-2.24.0" sdl-ttf-build) diff --git a/proj-android/app/jni/src/CMakeLists.txt b/proj-android/app/jni/src/CMakeLists.txt index 9497c26..4d66f49 100644 --- a/proj-android/app/jni/src/CMakeLists.txt +++ b/proj-android/app/jni/src/CMakeLists.txt @@ -150,6 +150,7 @@ target_link_libraries(main z SDL2 SDL2_ttf + SDL2_mixer log android OpenSLES @@ -163,6 +164,7 @@ target_link_libraries(main target_include_directories(main PRIVATE #${CMAKE_CURRENT_SOURCE_DIR}/../SDL/include ${CMAKE_CURRENT_SOURCE_DIR}/../../../../thirdparty/SDL_ttf-release-2.24.0/external/freetype/include + #${CMAKE_CURRENT_SOURCE_DIR}/../zlib #${CMAKE_CURRENT_SOURCE_DIR}/../libpng ${CMAKE_CURRENT_SOURCE_DIR}/../../../../thirdparty/eigen-5.0.0 diff --git a/proj-android/app/src/main/assets/audio/13925__adcbicycle__21.ogg b/proj-android/app/src/main/assets/audio/13925__adcbicycle__21.ogg new file mode 100644 index 0000000..5b76eaa --- /dev/null +++ b/proj-android/app/src/main/assets/audio/13925__adcbicycle__21.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9d30306535105c1070730f40aba8894d7c4b19d702bb95ef5ff2c78471b3cd5 +size 7662 diff --git a/proj-android/app/src/main/assets/audio/255571__stradie__flipping-paper.ogg b/proj-android/app/src/main/assets/audio/255571__stradie__flipping-paper.ogg new file mode 100644 index 0000000..cae74b7 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/255571__stradie__flipping-paper.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9442ccf84f7f2e856c16519b0cb060e1b36f4096db7c0a07889c94dd826a77bc +size 45403 diff --git a/proj-android/app/src/main/assets/audio/398751__anthousai__door-lock-01.ogg b/proj-android/app/src/main/assets/audio/398751__anthousai__door-lock-01.ogg new file mode 100644 index 0000000..f79dd21 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/398751__anthousai__door-lock-01.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:659d78850496656075215ccd50ae62a64b4de7e4dc13c3c0191a964822481255 +size 10364 diff --git a/proj-android/app/src/main/assets/audio/459618__n-lerche__blow.ogg b/proj-android/app/src/main/assets/audio/459618__n-lerche__blow.ogg new file mode 100644 index 0000000..957b415 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/459618__n-lerche__blow.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a55d5a4968a28ae948b72d0092b6a64beeb2d14bda4c2010a12890a0a4cec03 +size 42794 diff --git a/proj-android/app/src/main/assets/audio/537061__imafoley__message-pop-sound.ogg b/proj-android/app/src/main/assets/audio/537061__imafoley__message-pop-sound.ogg new file mode 100644 index 0000000..c431da3 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/537061__imafoley__message-pop-sound.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:624b696ed4ffa4e72cbcbc2a7005c7f282b4baaec921bb2be1f6853c3e15b097 +size 7916 diff --git a/proj-android/app/src/main/assets/audio/547041__cogfirestudios__hit-swing-sword-small-3.ogg b/proj-android/app/src/main/assets/audio/547041__cogfirestudios__hit-swing-sword-small-3.ogg new file mode 100644 index 0000000..f1be8e0 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/547041__cogfirestudios__hit-swing-sword-small-3.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd6b8506121e1ac9807a8fb2689f7c0cfca48777c08810b613ba761fc33d76c4 +size 19353 diff --git a/proj-android/app/src/main/assets/audio/587036__antoineromo__bed-sheets.ogg b/proj-android/app/src/main/assets/audio/587036__antoineromo__bed-sheets.ogg new file mode 100644 index 0000000..ed0d4cb --- /dev/null +++ b/proj-android/app/src/main/assets/audio/587036__antoineromo__bed-sheets.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12d04399abfe2441f51dc8b5e268aebc734ba707de161239aa90b808ade630da +size 35946 diff --git a/proj-android/app/src/main/assets/audio/656126__itsthegoodstuff__paging-through-book.ogg b/proj-android/app/src/main/assets/audio/656126__itsthegoodstuff__paging-through-book.ogg new file mode 100644 index 0000000..0f64f91 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/656126__itsthegoodstuff__paging-through-book.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad3034bc469fba569d8569881676c27f5bbec40533d5255291bef6d379bfe4c9 +size 21567 diff --git a/proj-android/app/src/main/assets/audio/702171__foxfire__door-opening.ogg b/proj-android/app/src/main/assets/audio/702171__foxfire__door-opening.ogg new file mode 100644 index 0000000..2c7c861 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/702171__foxfire__door-opening.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e725a730b1387a9df7bb0125f3dd7ccba1ca27e8422ee3c55b3bde4d8ce4124 +size 17136 diff --git a/proj-android/app/src/main/assets/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg b/proj-android/app/src/main/assets/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg new file mode 100644 index 0000000..2ca58ce --- /dev/null +++ b/proj-android/app/src/main/assets/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a548df89a87919e3fd4bde3fa8eb2da883c402b7feeae7c0603d7d98d35399a +size 5105 diff --git a/proj-android/app/src/main/assets/audio/78564__joedeshon__alarm_clock_ticking_02.ogg b/proj-android/app/src/main/assets/audio/78564__joedeshon__alarm_clock_ticking_02.ogg new file mode 100644 index 0000000..4d0cee4 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/78564__joedeshon__alarm_clock_ticking_02.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1756c0ece8080c799cb6ca4911a2c610800089ec6a65c45ba69e990942b7af9 +size 104191 diff --git a/proj-android/app/src/main/assets/audio/831642__ienba__generic-game-pick-up.ogg b/proj-android/app/src/main/assets/audio/831642__ienba__generic-game-pick-up.ogg new file mode 100644 index 0000000..44d62da --- /dev/null +++ b/proj-android/app/src/main/assets/audio/831642__ienba__generic-game-pick-up.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c79391d1f26978900194f9d5af1a0dc59eb62a1572f4f9011d1538a6bf09ffab +size 16067 diff --git a/proj-android/app/src/main/assets/audio/bishkek fight calm.ogg b/proj-android/app/src/main/assets/audio/bishkek fight calm.ogg new file mode 100644 index 0000000..359f9c7 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/bishkek fight calm.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f3f51bbd965dae892a22122d29cb469798d50a723f80ff4dbb2425fbe960137 +size 3888436 diff --git a/proj-android/app/src/main/assets/audio/bishkek fight.ogg b/proj-android/app/src/main/assets/audio/bishkek fight.ogg new file mode 100644 index 0000000..e0bf8a8 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/bishkek fight.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:684877cb31d792870d9552c07b7bdc8827e98101439006e60e9af3c29c294966 +size 4868335 diff --git a/proj-android/app/src/main/assets/audio/bishkek night.ogg b/proj-android/app/src/main/assets/audio/bishkek night.ogg new file mode 100644 index 0000000..ed6c6fa --- /dev/null +++ b/proj-android/app/src/main/assets/audio/bishkek night.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:773637b833576d7075403a8f276551bebd168ac105594dc2e248996039f51551 +size 4204745 diff --git a/proj-android/app/src/main/assets/audio/bishkek univer day.ogg b/proj-android/app/src/main/assets/audio/bishkek univer day.ogg new file mode 100644 index 0000000..0bd8ee2 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/bishkek univer day.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b286bbd8d0e216f0034c6d59b37d1746b4f69048eb90597bb9c838f145dabbc4 +size 5317400 diff --git a/proj-android/app/src/main/assets/audio/main menu final.ogg b/proj-android/app/src/main/assets/audio/main menu final.ogg new file mode 100644 index 0000000..d5deeb0 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/main menu final.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c56cd872468619fea85b89b23b4d175ada3d62eeab3f33d78bf931ac179a5df7 +size 4265537 diff --git a/proj-android/app/src/main/assets/audio/obshaga.ogg b/proj-android/app/src/main/assets/audio/obshaga.ogg new file mode 100644 index 0000000..c2061e7 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/obshaga.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fbb3f0f1d6765f472cf9aa36a3e4b25b8dcd478fc9b25f8d68fd5e3944fcc423 +size 4329675 diff --git a/proj-android/app/src/main/assets/audio/sound_bag001.ogg b/proj-android/app/src/main/assets/audio/sound_bag001.ogg new file mode 100644 index 0000000..be0d04b --- /dev/null +++ b/proj-android/app/src/main/assets/audio/sound_bag001.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e64ea00f0355371d2e1b93818b0c686da6e699e1cdb4de26a1c9dac5640bd0fb +size 16054 diff --git a/proj-android/app/src/main/assets/audio/sound_bag_close.ogg b/proj-android/app/src/main/assets/audio/sound_bag_close.ogg new file mode 100644 index 0000000..217533a --- /dev/null +++ b/proj-android/app/src/main/assets/audio/sound_bag_close.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bcb99f3aa14d4f53ae636fab8fadb0ed19a4be17e994088e7e41e4872002c0be +size 18569 diff --git a/proj-android/app/src/main/assets/audio/sound_bag_open.ogg b/proj-android/app/src/main/assets/audio/sound_bag_open.ogg new file mode 100644 index 0000000..1080147 --- /dev/null +++ b/proj-android/app/src/main/assets/audio/sound_bag_open.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e17ae2d18d36892cbc634cca6b5523293c2737e97e0a94b577a8709823a5db04 +size 17077 diff --git a/src/AudioPlayerAsync.cpp b/src/AudioPlayerAsync.cpp index 6d81403..bbdcc27 100644 --- a/src/AudioPlayerAsync.cpp +++ b/src/AudioPlayerAsync.cpp @@ -2,6 +2,11 @@ #include #include "utils/Utils.h" +#ifdef __ANDROID__ +#include +#endif + + #ifdef __EMSCRIPTEN__ AudioPlayerAsync::AudioPlayerAsync() {} #else @@ -22,33 +27,34 @@ AudioPlayerAsync::~AudioPlayerAsync() { } bool AudioPlayerAsync::init() { - /*if (initialized) return true; + if (initialized) return true; if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { - std::cerr << "SDL_InitSubSystem(SDL_INIT_AUDIO) failed: " << SDL_GetError() << std::endl; + FRG::logger() << "SDL_InitSubSystem(SDL_INIT_AUDIO) failed: " << SDL_GetError() << std::endl; return false; } if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { - std::cerr << "Mix_OpenAudio failed: " << Mix_GetError() << std::endl; + FRG::logger() << "Mix_OpenAudio failed: " << Mix_GetError() << std::endl; return false; } Mix_AllocateChannels(16); initialized = true; - FRG::logger() << "AudioPlayerAsync initialized with SDL2_mixer" << std::endl;*/ + FRG::logger() << "AudioPlayerAsync initialized with SDL2_mixer" << std::endl; return true; } void AudioPlayerAsync::shutdown() { if (!initialized) return; - /* + if (currentMusic_) { Mix_HaltMusic(); Mix_FreeMusic(currentMusic_); currentMusic_ = nullptr; } + currentMusicData_.clear(); { std::lock_guard lock(soundCacheMutex); @@ -61,16 +67,20 @@ void AudioPlayerAsync::shutdown() { Mix_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); initialized = false; - FRG::logger() << "AudioPlayerAsync shutdown" << std::endl;*/ + FRG::logger() << "AudioPlayerAsync shutdown" << std::endl; } void AudioPlayerAsync::playSoundAsync(const std::string& filePath, int loops, int channel) { - /*if (!initialized) { - std::cerr << "AudioPlayerAsync not initialized" << std::endl; + + + if (!initialized) { + FRG::logger() << "AudioPlayerAsync not initialized" << std::endl; return; } + if (!soundEnabled_) return; + auto task = [this, filePath, loops, channel]() { Mix_Chunk* sound = nullptr; { @@ -80,11 +90,34 @@ void AudioPlayerAsync::playSoundAsync(const std::string& filePath, int loops, in sound = it->second; } } - + if (!sound) { +#ifdef __ANDROID__ + + __android_log_print(ANDROID_LOG_ERROR, "Game", + "AudioPlayerAsync::playSoundAsync step x2"); + std::vector buffer = FRG::readFile(filePath); + if (buffer.empty()) { + __android_log_print(ANDROID_LOG_ERROR, "Game", + "AudioPlayerAsync::playSoundAsync step x3"); + FRG::logger() << "Failed to read sound file into buffer: " << filePath << std::endl; + return; + } + __android_log_print(ANDROID_LOG_ERROR, "Game", + "AudioPlayerAsync::playSoundAsync step x4"); + SDL_RWops* rw = SDL_RWFromMem(buffer.data(), buffer.size()); + if (!rw) { + FRG::logger() << "Failed to create RWops from buffer for " << filePath << ": " << SDL_GetError() << std::endl; + return; + } + sound = Mix_LoadWAV_RW(rw, 1); // 1 means it will free rw automatically + FRG::logger() << "sound = Mix_LoadWAV_RW(rw, 1); just fired " << std::endl; + +#else sound = Mix_LoadWAV(filePath.c_str()); +#endif if (!sound) { - std::cerr << "Failed to load sound " << filePath << ": " << Mix_GetError() << std::endl; + FRG::logger() << "Failed to load sound " << filePath << ": " << Mix_GetError() << std::endl; return; } std::lock_guard cacheLock(soundCacheMutex); @@ -93,7 +126,7 @@ void AudioPlayerAsync::playSoundAsync(const std::string& filePath, int loops, in int result = Mix_PlayChannel(channel, sound, loops); if (result == -1) { - std::cerr << "Mix_PlayChannel failed: " << Mix_GetError() << std::endl; + FRG::logger() << "Mix_PlayChannel failed: " << Mix_GetError() << std::endl; } }; @@ -104,11 +137,11 @@ void AudioPlayerAsync::playSoundAsync(const std::string& filePath, int loops, in taskQueue.push(std::move(task)); cv.notify_one(); #endif -*/ + } void AudioPlayerAsync::playMusicAsync(const std::string& filePath, int loops) { - /*if (!initialized) return; + if (!initialized) return; if (filePath == currentTrack) return; @@ -122,14 +155,29 @@ void AudioPlayerAsync::playMusicAsync(const std::string& filePath, int loops) { Mix_FreeMusic(currentMusic_); currentMusic_ = nullptr; } - Mix_Music* music = Mix_LoadMUS(filePath.c_str()); + currentMusicData_.clear(); + + Mix_Music* music = nullptr; +#ifdef __ANDROID__ + currentMusicData_ = FRG::readFile(filePath); + if (!currentMusicData_.empty()) { + SDL_RWops* rw = SDL_RWFromMem(currentMusicData_.data(), currentMusicData_.size()); + if (rw) { + music = Mix_LoadMUS_RW(rw, 1); + } + } +#else + music = Mix_LoadMUS(filePath.c_str()); +#endif + if (!music) { - std::cerr << "Failed to load music " << filePath << ": " << Mix_GetError() << std::endl; + FRG::logger() << "Failed to load music " << filePath << ": " << Mix_GetError() << std::endl; return; } if (Mix_PlayMusic(music, loops) == -1) { - std::cerr << "Mix_PlayMusic failed: " << Mix_GetError() << std::endl; + FRG::logger() << "Mix_PlayMusic failed: " << Mix_GetError() << std::endl; Mix_FreeMusic(music); + currentMusicData_.clear(); return; } currentMusic_ = music; @@ -142,11 +190,11 @@ void AudioPlayerAsync::playMusicAsync(const std::string& filePath, int loops) { taskQueue.push(std::move(task)); cv.notify_one(); #endif -*/ + } void AudioPlayerAsync::stopMusicAsync() { - /*if (!initialized) return; + if (!initialized) return; currentTrack = ""; @@ -159,11 +207,11 @@ void AudioPlayerAsync::stopMusicAsync() { }); cv.notify_one(); #endif -*/ + } void AudioPlayerAsync::pauseMusicAsync() { - /*if (!initialized) return; + if (!initialized) return; #ifdef __EMSCRIPTEN__ Mix_PauseMusic(); #else @@ -173,11 +221,11 @@ void AudioPlayerAsync::pauseMusicAsync() { }); cv.notify_one(); #endif -*/ + } void AudioPlayerAsync::resumeMusicAsync() { - /*if (!initialized) return; + if (!initialized) return; #ifdef __EMSCRIPTEN__ Mix_ResumeMusic(); #else @@ -187,11 +235,11 @@ void AudioPlayerAsync::resumeMusicAsync() { }); cv.notify_one(); #endif -*/ + } void AudioPlayerAsync::setMusicVolume(int volume) { - /* + if (!initialized) return; volume = std::max(0, std::min(128, volume)); musicVolume_ = volume; @@ -204,11 +252,11 @@ void AudioPlayerAsync::setMusicVolume(int volume) { }); cv.notify_one(); #endif -*/ + } void AudioPlayerAsync::setSoundVolume(int volume) { - /* + if (!initialized) return; volume = std::max(0, std::min(128, volume)); soundVolume_ = volume; @@ -221,11 +269,11 @@ void AudioPlayerAsync::setSoundVolume(int volume) { }); cv.notify_one(); #endif -*/ + } void AudioPlayerAsync::crossFadeMusicAsync(const std::string& filePath, int fadeDurationMs, int loops) { - /*if (!initialized) return; + if (!initialized) return; if (filePath == currentTrack) return; currentTrack = filePath; if (!musicEnabled_) return; @@ -241,14 +289,26 @@ void AudioPlayerAsync::crossFadeMusicAsync(const std::string& filePath, int fade } Mix_HaltMusic(); if (currentMusic_) { Mix_FreeMusic(currentMusic_); currentMusic_ = nullptr; } + currentMusicData_.clear(); +#endif + Mix_Music* music = nullptr; +#ifdef __ANDROID__ + currentMusicData_ = FRG::readFile(filePath); + if (!currentMusicData_.empty()) { + SDL_RWops* rw = SDL_RWFromMem(currentMusicData_.data(), currentMusicData_.size()); + if (rw) { + music = Mix_LoadMUS_RW(rw, 1); + } + } +#else + music = Mix_LoadMUS(filePath.c_str()); #endif - Mix_Music* music = Mix_LoadMUS(filePath.c_str()); if (!music) { - std::cerr << "Failed to load music " << filePath << ": " << Mix_GetError() << std::endl; + FRG::logger() << "Failed to load music " << filePath << ": " << Mix_GetError() << std::endl; return; } if (Mix_FadeInMusic(music, loops, fadeDurationMs / 2) == -1) { - std::cerr << "Mix_FadeInMusic failed: " << Mix_GetError() << std::endl; + FRG::logger() << "Mix_FadeInMusic failed: " << Mix_GetError() << std::endl; Mix_FreeMusic(music); return; } @@ -262,11 +322,11 @@ void AudioPlayerAsync::crossFadeMusicAsync(const std::string& filePath, int fade taskQueue.push(std::move(task)); cv.notify_one(); #endif -*/ + } void AudioPlayerAsync::crossFadeMusicFromPositionAsync(const std::string& filePath, int fadeDurationMs, int loops) { - /*if (!initialized) return; + if (!initialized) return; if (filePath == currentTrack) return; currentTrack = filePath; if (!musicEnabled_) return; @@ -288,11 +348,11 @@ void AudioPlayerAsync::crossFadeMusicFromPositionAsync(const std::string& filePa Mix_Music* music = Mix_LoadMUS(filePath.c_str()); if (!music) { - std::cerr << "Failed to load music " << filePath << ": " << Mix_GetError() << std::endl; + FRG::logger() << "Failed to load music " << filePath << ": " << Mix_GetError() << std::endl; return; } if (Mix_FadeInMusicPos(music, loops, fadeDurationMs / 2, position) == -1) { - std::cerr << "Mix_FadeInMusicPos failed: " << Mix_GetError() << std::endl; + FRG::logger() << "Mix_FadeInMusicPos failed: " << Mix_GetError() << std::endl; Mix_FreeMusic(music); return; } @@ -306,11 +366,11 @@ void AudioPlayerAsync::crossFadeMusicFromPositionAsync(const std::string& filePa taskQueue.push(std::move(task)); cv.notify_one(); #endif -*/ + } void AudioPlayerAsync::setMusicEnabled(bool enabled) { - /*if (musicEnabled_ == enabled) return; + if (musicEnabled_ == enabled) return; musicEnabled_ = enabled; if (!initialized) return; @@ -330,7 +390,7 @@ void AudioPlayerAsync::setMusicEnabled(bool enabled) { currentTrack = ""; // clear so crossFadeMusicAsync doesn't bail early crossFadeMusicAsync(track); } - }*/ + } } void AudioPlayerAsync::setSoundEnabled(bool enabled) { diff --git a/src/AudioPlayerAsync.h b/src/AudioPlayerAsync.h index ab7c1a0..6e1b46f 100644 --- a/src/AudioPlayerAsync.h +++ b/src/AudioPlayerAsync.h @@ -1,13 +1,16 @@ #pragma once - -#if 0 +#ifdef __ANDROID__ +#include +#include +#else #include +#include #endif #include #include #include #include -#include +#include #ifndef __EMSCRIPTEN__ #include @@ -53,14 +56,15 @@ private: std::queue> taskQueue; #endif bool stop = false; -#if 0 + std::unordered_map soundCache; std::mutex soundCacheMutex; std::string currentTrack; Mix_Music* currentMusic_ = nullptr; -#endif + std::vector currentMusicData_; + int musicVolume_ = 128; int soundVolume_ = 128; bool musicEnabled_ = true; diff --git a/src/Game.cpp b/src/Game.cpp index c20005a..fae1393 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -1517,41 +1517,23 @@ namespace FRG const int uiX = mx; const int uiY = Environment::projectionHeight - my; - -#ifdef __ANDROID__ - __android_log_print(ANDROID_LOG_ERROR, "Game", - "Game::onPointerDown step 1"); -#endif + menuManager.topUiManager.onTouchDown(fingerId, uiX, uiY); const bool capturedByTopUi = menuManager.topUiManager.isUiInteractionForFinger(fingerId); const bool dialogueActive = currentLocation() && currentLocation()->dialogueSystem.isActive(); if (!dialogueActive && !capturedByTopUi) { -#ifdef __ANDROID__ - __android_log_print(ANDROID_LOG_ERROR, "Game", - "Game::onPointerDown step 2"); -#endif + menuManager.uiManager.onTouchDown(fingerId, uiX, uiY); } st.capturedByUi = capturedByTopUi || (!dialogueActive && menuManager.uiManager.isUiInteractionForFinger(fingerId)); activePointers[fingerId] = st; -#ifdef __ANDROID__ - __android_log_print(ANDROID_LOG_ERROR, "Game", - "Game::onPointerDown step 3"); -#endif + if (st.capturedByUi) { // UI button / slider / text-field grabbed this press; don't drive // gameplay or pinch from it. -#ifdef __ANDROID__ - __android_log_print(ANDROID_LOG_ERROR, "Game", - "Game::onPointerDown step 4"); -#endif return; } -#ifdef __ANDROID__ - __android_log_print(ANDROID_LOG_ERROR, "Game", - "Game::onPointerDown step 5"); -#endif if (countNonUiPointers() >= 2) { // Second finger landed on the gameplay area: switch to pinch-zoom diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index 1a1e1fb..a8e3e1d 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -378,7 +378,7 @@ namespace FRG { -#ifndef EMSCRIPTEN +#if !defined(EMSCRIPTEN) && !defined(__ANDROID__) uiManager.setTextButtonCallback("menuExitButton", [this](const std::string&) { audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg"); Environment::exitGameLoop = true; diff --git a/src/main.cpp b/src/main.cpp index 715bb4b..dfc43df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -206,7 +206,7 @@ int main(int argc, char* argv[]) { "Shadow Over Bishkek", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 0, 0, - SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN + SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE ); if (!FRG::Environment::window) {