Adapting music to web, fixing scripts, fixing bug in initial state

This commit is contained in:
Vladislav Khorev committed 2026-07-24 23:58:29 +03:00
1 parent c3f449b999
commit 5ecf5fb9d7
43 files changed
+875 -388

No files matched your search

+324 -89
View File
@@ -10,8 +10,16 @@
#include <string>
#include <SDL.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
namespace FRG {
#ifdef __EMSCRIPTEN__
//extern Game* Game::s_instance;
#endif
// Localization
static const std::string EMPTY_LANGUAGE_RU = u8"(пусто)";
static const std::string EMPTY_LANGUAGE_EN = "(empty)";
@@ -19,6 +27,11 @@ namespace FRG {
static const std::string BACK_TO_MAIN_MENU_RU = u8"Вернуться в меню";
static const std::string BACK_TO_MAIN_MENU_EN = "Back to Main Menu";
static const std::string MUSIC_DOWNLOAD_ERROR_RU = u8"Ошибка скачивания музыки";
static const std::string MUSIC_DOWNLOAD_NOT_STARTED_RU = u8"Нажмите сюда, чтобы скачать и установить музыку (27 MB).";
static const std::string MUSIC_DOWNLOAD_PROGRESS_PREFIX_RU = u8"Загрузка музыки: ";
//static const std::string MUSIC_DOWNLOAD_COMPLETED_RU = u8"Музыка успешно загружена.";
static int questStatusPriority(Quest::QuestStatus status) {
switch (status) {
@@ -112,6 +125,78 @@ namespace FRG {
}
}
#ifdef __EMSCRIPTEN__
// Коллбэк успешной загрузки music.zip
void MenuManager::onMusicZipLoaded(unsigned /*handle*/, void* /*userData*/, const char* /*filename*/) {
logger() << "File music.zip downloaded successfully to VFS" << std::endl;
FRG::emscriptenSyncFs();
if (Game::s_instance != nullptr)
{
Game::s_instance->menuManager.musicDownloadProgress = 1.f;
Game::s_instance->menuManager.musicDownloadStarted = false;
Game::s_instance->menuManager.musicDownloadError = false;
logger() << "onMusicZipLoaded step 2: " << Game::s_instance->menuManager.lastMusicTrack << std::endl;
if (Game::s_instance->menuManager.lastMusicTrack != "")
{
logger() << "onMusicZipLoaded step 3" << std::endl;
Game::s_instance->menuManager.audioPlayer_.crossFadeMusicAsync(Game::s_instance->menuManager.lastMusicTrack);
}
logger() << "onMusicZipLoaded step 4" << std::endl;
if (Game::s_instance->menuManager.playerInSettingsNoMusic)
{
if (Game::s_instance->menuManager.playerInSettingsNoMusicGraphics)
{
Game::s_instance->menuManager.uiManager.popMenu();
Game::s_instance->menuManager.uiManager.popMenu();
Game::s_instance->menuManager.showSettingsScreen();
Game::s_instance->menuManager.showSettingsGraphicsScreen();
Game::s_instance->menuManager.uiManager.updateAllLayouts();
Game::s_instance->menuManager.topUiManager.updateAllLayouts();
}
else
{
Game::s_instance->menuManager.uiManager.popMenu();
Game::s_instance->menuManager.showSettingsScreen();
Game::s_instance->menuManager.uiManager.updateAllLayouts();
Game::s_instance->menuManager.topUiManager.updateAllLayouts();
}
}
Game::s_instance->menuManager.playerInSettingsNoMusic = false;
Game::s_instance->menuManager.playerInSettingsNoMusicGraphics = false;
//Game::s_instance->menuManager.uiManager.setText("musicDownloadButton", musicDownloadCompleted);
}
}
void MenuManager::onMusicZipError(unsigned /*handle*/, void* /*userData*/, int httpStatus) {
logger() << "Failed to download music.zip, HTTP status: " << httpStatus << std::endl;
if (Game::s_instance != nullptr)
{
std::string musicDownloadError = MUSIC_DOWNLOAD_ERROR_RU;
Game::s_instance->menuManager.musicDownloadStarted = false;
Game::s_instance->menuManager.musicDownloadError = true;
Game::s_instance->menuManager.uiManager.setText("musicDownloadButton",
musicDownloadError);
}
}
void MenuManager::onMusicZipProgress(unsigned /*handle*/, void* /*userData*/, int percentComplete) {
// Прогресс для музыки при необходимости
if (Game::s_instance != nullptr)
{
std::string musicDownloadProgressPrefix = MUSIC_DOWNLOAD_PROGRESS_PREFIX_RU;
Game::s_instance->menuManager.musicDownloadProgress = percentComplete / 100.0f;
Game::s_instance->menuManager.uiManager.setText("musicDownloadButton",
musicDownloadProgressPrefix + std::to_string(percentComplete) + "%");
}
}
#endif
MenuManager::MenuManager(Renderer& iRenderer, GameState& gameState, AudioPlayerAsync& audioPlayer) :
renderer(iRenderer),
gameState_(gameState),
@@ -254,7 +339,13 @@ namespace FRG {
creditsScreenRoot = loadLocalizedUi("resources/w/ui/screen_credits.json", zipFile);
portraitCreditsScreenRoot = loadLocalizedUi("resources/w/ui/portrait_screen_credits.json", zipFile);
#ifdef __EMSCRIPTEN__
settingsScreenNoMusicWebRoot = loadLocalizedUi("resources/w/ui/screen_settings_nomusic_web.json", zipFile);
#endif
settingsScreenRoot = loadLocalizedUi("resources/w/ui/screen_settings.json", zipFile);
settingsGraphicsScreenRoot = loadLocalizedUi("resources/w/ui/screen_settings_graphics.json", zipFile);
languageScreenRoot = loadLocalizedUi("resources/w/ui/screen_language.json", zipFile);
loadSavedGameScreenRoot = loadLocalizedUi("resources/w/ui/screen_load.json", zipFile);
@@ -375,7 +466,8 @@ namespace FRG {
void MenuManager::showMainMenu() {
gameState_.currentLocationName.clear();
audioPlayer_.crossFadeMusicAsync("audio/main menu final.ogg");
audioPlayer_.crossFadeMusicAsync("music/main menu final.ogg");
lastMusicTrack = "music/main menu final.ogg";
uiState_ = GameUiState::MainMenu;
uiManager.clearMenuStack();
@@ -386,36 +478,46 @@ namespace FRG {
uiManager.setTextButtonCallback("menuStartButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
enterGameplay();
});
uiManager.setTextButtonCallback("menuAboutButton", [this](const std::string&) {
showAboutScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuCreditsButton", [this](const std::string&) {
showCreditsScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuSettingsButton", [this](const std::string&) {
#ifdef __EMSCRIPTEN__
std::string musicPath = FRG::getPersistentResourcePath("music.zip");
if (FRG::isZipValid(musicPath)) {
showSettingsScreen();
}
else {
showSettingsNoMusicWebScreen();
}
#else
showSettingsScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
#endif
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuLanguageButton", [this](const std::string&) {
showLanguageScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuLoadButton", [this](const std::string&) {
showLoadGameScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
#if !defined(EMSCRIPTEN) && !defined(__ANDROID__)
uiManager.setTextButtonCallback("menuExitButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
Environment::exitGameLoop = true;
});
#else
@@ -426,7 +528,8 @@ namespace FRG {
void MenuManager::showMenuAfterGameCompleted() {
//gameState_.currentLocationName.clear();
audioPlayer_.crossFadeMusicAsync("audio/main menu final.ogg");
audioPlayer_.crossFadeMusicAsync("music/main menu final.ogg");
lastMusicTrack = "music/main menu final.ogg";
uiState_ = GameUiState::MainMenu;
uiManager.clearMenuStack();
@@ -437,36 +540,36 @@ namespace FRG {
uiManager.setTextButtonCallback("menuStartButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
enterGameplay();
});
uiManager.setTextButtonCallback("menuAboutButton", [this](const std::string&) {
showAboutScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuCreditsButton", [this](const std::string&) {
showCreditsScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuSettingsButton", [this](const std::string&) {
showSettingsScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuLanguageButton", [this](const std::string&) {
showLanguageScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuLoadButton", [this](const std::string&) {
showLoadGameScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
#ifndef EMSCRIPTEN
uiManager.setTextButtonCallback("menuExitButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
Environment::exitGameLoop = true;
});
#else
@@ -479,21 +582,21 @@ namespace FRG {
uiManager.setTextButtonCallback("aboutBackButton", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("steamButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
SDL_OpenURL("https://store.steampowered.com/app/4801010/");
});
uiManager.setTextButtonCallback("telegramButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
SDL_OpenURL("https://telegram.me/fishrungames");
});
uiManager.setTextButtonCallback("discordButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
SDL_OpenURL("https://discord.gg/S8jgGHXjw");
});
}
@@ -503,29 +606,29 @@ namespace FRG {
uiManager.setTextButtonCallback("aboutBackButton", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("steamButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
SDL_OpenURL("https://store.steampowered.com/app/4801010/");
});
#ifdef __ANDROID__
uiManager.setTextButtonCallback("websiteButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
SDL_OpenURL("https://shadowoverbishkek.com/");
});
#endif
uiManager.setTextButtonCallback("telegramButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
SDL_OpenURL("https://telegram.me/fishrungames");
});
uiManager.setTextButtonCallback("discordButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
SDL_OpenURL("https://discord.gg/S8jgGHXjw");
});
}
@@ -561,7 +664,7 @@ namespace FRG {
isPlayerInCreditsMenu = false;
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.updateAllLayouts();
@@ -577,12 +680,12 @@ namespace FRG {
saveSettings();
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("graphicsButton", [this](const std::string&) {
showSettingsGraphicsScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
// Set initial slider positions before registering callbacks so
@@ -658,7 +761,7 @@ namespace FRG {
/*uiManager.setTextButtonColor("musicToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });*/
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("soundToggleButton", [this](const std::string&) {
audioPlayer_.setSoundEnabled(!audioPlayer_.isSoundEnabled());
@@ -667,7 +770,7 @@ namespace FRG {
/*uiManager.setTextButtonColor("soundToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });*/
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
}
@@ -676,9 +779,12 @@ namespace FRG {
uiManager.setTextButtonCallback("settingsBackButton", [this](const std::string&) {
saveSettings();
uiManager.popMenu();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.updateAllLayouts();
topUiManager.updateAllLayouts();
#ifdef __EMSCRIPTEN__
playerInSettingsNoMusicGraphics = false;
#endif
});
@@ -718,7 +824,7 @@ namespace FRG {
uiManager.setTextButtonCallback("fullScreenToggleButton", [this, refreshFullscreenToggle](const std::string&) {
Environment::setFullscreen(!Environment::isFullscreen);
refreshFullscreenToggle();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.updateAllLayouts();
topUiManager.updateAllLayouts();
});
@@ -728,27 +834,148 @@ namespace FRG {
bool newValue = !this->shadowsEnabled;
shadowMapSettingsChangedFunc(newValue);
refreshShadowToggle();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
}
#ifdef __EMSCRIPTEN__
void MenuManager::showSettingsNoMusicWebScreen()
{
playerInSettingsNoMusic = true;
uiManager.pushMenuFromSavedRoot(settingsScreenNoMusicWebRoot);
uiManager.setTextButtonCallback("settingsBackButton", [this](const std::string&) {
saveSettings();
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
playerInSettingsNoMusic = false;
});
uiManager.setTextButtonCallback("graphicsButton", [this](const std::string&) {
playerInSettingsNoMusicGraphics = true;
showSettingsGraphicsScreen();
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
// Set initial slider positions before registering callbacks so
// setSliderValue does not fire an unregistered callback.
const float soundFrac = audioPlayer_.getSoundVolume() / 128.0f;
uiManager.setSliderValue("soundVolumeSlider", soundFrac);
// Localization
if (g_currentLanguage == Language::English)
{
soundVolumePrefix = "Sound volume: ";
soundToggleOn = "Sound: ON";
soundToggleOff = "Sound: OFF";
}
else if (g_currentLanguage == Language::Russian)
{
soundVolumePrefix = u8"Громкость звука: ";
soundToggleOn = u8"Звук: ВКЛ";
soundToggleOff = u8"Звук: ВЫКЛ";
}
static std::string musicDownloadErrorString = u8"Ошибка скачивания музыки";
static std::string musicDownloadNotStartedString = u8"Нажмите сюда, чтобы скачать\nи установить музыку (27 MB).";
static std::string musicDownloadProgressPrefix = u8"Загрузка музыки: ";
// musicDownloadStarted = false;
//musicDownloadError = false;
if (musicDownloadError)
{
uiManager.setText("musicDownloadButton", musicDownloadErrorString);
}
else
{
if (musicDownloadStarted == false)
{
uiManager.setText("musicDownloadButton", musicDownloadNotStartedString);
}
else
{
//uiManager.setText("musicDownloadButton", musicDownloadProgressString);
uiManager.setText("musicDownloadButton",
musicDownloadProgressPrefix + std::to_string(round(musicDownloadProgress*100)) + "%");
}
}
uiManager.setText("soundVolumeText",
soundVolumePrefix + std::to_string(audioPlayer_.getSoundVolume()));
uiManager.setSliderCallback("soundVolumeSlider",
[this](const std::string&, float value) {
const int vol = static_cast<int>(value * 128.0f + 0.5f);
audioPlayer_.setSoundVolume(vol);
uiManager.setText("soundVolumeText",
soundVolumePrefix + std::to_string(vol));
});
// Music on/off toggle — helper to sync button text and color from current state
auto refreshSoundToggle = [this]() {
const bool on = audioPlayer_.isSoundEnabled();
uiManager.setTextButtonText("soundToggleButton", on ? soundToggleOn : soundToggleOff);
/*uiManager.setTextButtonColor("soundToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });*/
};
refreshSoundToggle();
uiManager.setTextButtonCallback("soundToggleButton", [this](const std::string&) {
audioPlayer_.setSoundEnabled(!audioPlayer_.isSoundEnabled());
const bool on = audioPlayer_.isSoundEnabled();
uiManager.setTextButtonText("soundToggleButton", on ? soundToggleOn : soundToggleOff);
/*uiManager.setTextButtonColor("soundToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });*/
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("musicDownloadButton", [this](const std::string&) {
if (musicDownloadStarted) return; // Already downloading, ignore further clicks
musicDownloadStarted = true;
musicDownloadError = false;
std::string musicPath = FRG::getPersistentResourcePath("music.zip");
emscripten_async_wget2(
"music.zip",
musicPath.c_str(),
"GET",
nullptr,
nullptr,
onMusicZipLoaded,
onMusicZipError,
onMusicZipProgress
);
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
}
#endif
void MenuManager::showLanguageScreen() {
uiManager.pushMenuFromSavedRoot(languageScreenRoot);
uiManager.setTextButtonCallback("languageBackButton", [this](const std::string&) {
saveSettings();
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("languageRussianButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
FRG::g_currentLanguage = FRG::Language::Russian;
reloadLocalizedGameContent();
saveSettings();
});
uiManager.setTextButtonCallback("languageEnglishButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
FRG::g_currentLanguage = FRG::Language::English;
reloadLocalizedGameContent();
saveSettings();
@@ -810,7 +1037,7 @@ namespace FRG {
uiManager.setTextButtonCallback("loadBackButton", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
static const char* kSlotButtons[4] = {
@@ -837,7 +1064,7 @@ namespace FRG {
uiManager.setTextButtonText(kSlotButtons[i], label);
}
uiManager.setTextButtonCallback(kSlotButtons[i], [this, slot](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
if (onLoadGame) onLoadGame(slot);
enterGameplay(true);
});
@@ -850,7 +1077,7 @@ namespace FRG {
uiManager.setTextButtonCallback("saveBackButton", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
static const char* kSlotButtons[4] = {
@@ -896,7 +1123,7 @@ namespace FRG {
? emptyText
: localizedLocationName[info.locationName][FRG::g_currentLanguage] + " " + info.savedAt;
uiManager.setTextButtonText(buttonName, label);
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
}
});
}
@@ -941,7 +1168,7 @@ namespace FRG {
selectInventoryItem(i);
//logger() << "Callback called for button number " << i << " END" << std::endl;
audioPlayer_.playSoundAsync("audio/sound_bag001.ogg");
audioPlayer_.playSoundAsync("resources/audio/sound_bag001.ogg");
});
} else {
uiManager.setNodeVisible(btnName, false);
@@ -953,7 +1180,7 @@ namespace FRG {
selectInventoryItem(0);
}
audioPlayer_.playSoundAsync("audio/sound_bag_open.ogg");
audioPlayer_.playSoundAsync("resources/audio/sound_bag_open.ogg");
}
void MenuManager::selectInventoryItem(int index) {
@@ -1005,7 +1232,7 @@ namespace FRG {
for (int i = 0; i < inventoryMenuStackDepth_; ++i) uiManager.popMenu();
inventoryMenuStackDepth_ = 0;
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/sound_bag_close.ogg");
audioPlayer_.playSoundAsync("resources/audio/sound_bag_close.ogg");
}
void MenuManager::openQuestJournal() {
@@ -1021,12 +1248,12 @@ namespace FRG {
uiManager.setButtonCallback("journalExitButton", [this](const std::string&) {
closeQuestJournal();
audioPlayer_.playSoundAsync("audio/656126__itsthegoodstuff__paging-through-book.ogg");
audioPlayer_.playSoundAsync("resources/audio/656126__itsthegoodstuff__paging-through-book.ogg");
});
uiManager.setButtonCallback("journalExitButton2", [this](const std::string&) {
closeQuestJournal();
audioPlayer_.playSoundAsync("audio/656126__itsthegoodstuff__paging-through-book.ogg");
audioPlayer_.playSoundAsync("resources/audio/656126__itsthegoodstuff__paging-through-book.ogg");
});
@@ -1041,7 +1268,7 @@ namespace FRG {
for (int i = 0; i < 9; ++i) {
uiManager.setTextButtonCallback(kItemNames[i], [this, i](const std::string&) {
selectQuestByIndex(i);
audioPlayer_.playSoundAsync("audio/255571__stradie__flipping-paper.ogg");
audioPlayer_.playSoundAsync("resources/audio/255571__stradie__flipping-paper.ogg");
});
}
@@ -1050,7 +1277,7 @@ namespace FRG {
selectQuestByIndex(0);
}
audioPlayer_.playSoundAsync("audio/255571__stradie__flipping-paper.ogg");
audioPlayer_.playSoundAsync("resources/audio/255571__stradie__flipping-paper.ogg");
}
void MenuManager::closeQuestJournal() {
@@ -1101,24 +1328,24 @@ namespace FRG {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setButtonCallback("phoneMessenger", [this](const std::string&) {
openPhoneMessenger();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneBank", [this](const std::string&) {
openPhoneBank();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneVideo", [this](const std::string&) {
openPhoneVideo();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneTaxi", [this](const std::string&) {
openPhoneTaxi();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
if (gameState_.isNight)
@@ -1143,7 +1370,7 @@ namespace FRG {
uiManager.setNodeVisible("phoneTimeDawn", false);
}
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
}
void MenuManager::openPhoneMessenger() {
@@ -1161,23 +1388,23 @@ namespace FRG {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setTextButtonCallback("chat1button", [this](const std::string&) {
gameState_.chatUnread[0] = false;
openPhoneChatFromList(0, isPortraitMode() ? verticalPhoneChat1Root : phoneChat1Root);
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setTextButtonCallback("chat2button", [this](const std::string&) {
gameState_.chatUnread[1] = false;
openPhoneChatFromList(1, isPortraitMode() ? verticalPhoneChat2Root : phoneChat2Root);
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setTextButtonCallback("chat3button", [this](const std::string&) {
gameState_.chatUnread[2] = false;
openPhoneChatFromList(2, isPortraitMode() ? verticalPhoneChat3Root : phoneChat3Root);
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
}
@@ -1213,13 +1440,13 @@ namespace FRG {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setButtonCallback("buttonBack", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
}
@@ -1229,13 +1456,13 @@ namespace FRG {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setButtonCallback("buttonBack", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("videoSkip", [this](const std::string&) {
closePhoneEntirely();
@@ -1252,7 +1479,7 @@ namespace FRG {
}
else
{
audioPlayer_.playSoundAsync("audio/78564__joedeshon__alarm_clock_ticking_02.ogg");
audioPlayer_.playSoundAsync("resources/audio/78564__joedeshon__alarm_clock_ticking_02.ogg");
startNightTransitionFunc();
}
}
@@ -1277,13 +1504,13 @@ namespace FRG {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setButtonCallback("buttonBack", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("mapGo", [this](const std::string&) {
gameState_.tutorialNeedOpenTaxiScreen = false;
@@ -1298,17 +1525,17 @@ namespace FRG {
gameState_.money -= 500;
closePhoneEntirely();
if (startDialogueFunc) startDialogueFunc("dialog_taxi002");
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
}
else
{
closePhoneEntirely();
if (startDialogueFunc) startDialogueFunc("dialog_taxi004");
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
}
});
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
}
void MenuManager::openPhoneChatFromList(int chatIndex, std::shared_ptr<UiNode> chatRoot) {
@@ -1348,12 +1575,12 @@ namespace FRG {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneScreenFromChat();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setTextButtonCallback("chatTitleButton", [this](const std::string&) {
returnToPhoneChatList();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
});
if (chatOpenCallback) {
@@ -1437,37 +1664,37 @@ namespace FRG {
}
void MenuManager::showModalMenuScreen() {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.pushMenuFromSavedRoot(modalMenuRoot);
uiManager.setButtonCallback("modalExitButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.popMenu();
uiManager.updateAllLayouts();
});
uiManager.setButtonCallback("menuCloseButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.popMenu();
uiManager.updateAllLayouts();
});
uiManager.setButtonCallback("menuSaveButton", [this](const std::string&) {
showSaveGameScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setButtonCallback("menuLoadButton", [this](const std::string&) {
showLoadGameScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setButtonCallback("menuSettingsButton", [this](const std::string&) {
showSettingsScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setButtonCallback("menuExitButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.popMenu();
showMainMenu();
});
@@ -1579,29 +1806,35 @@ namespace FRG {
setupGameplayHudCallbacks();
if (gameState_.isDarklands)
{
audioPlayer_.crossFadeMusicAsync("audio/bishkek fight calm.ogg");
audioPlayer_.crossFadeMusicAsync("music/bishkek fight calm.ogg");
lastMusicTrack = "music/bishkek fight calm.ogg";
}
else if (gameState_.isNight)
{
audioPlayer_.crossFadeMusicAsync("audio/bishkek night.ogg");
audioPlayer_.crossFadeMusicAsync("music/bishkek night.ogg");
lastMusicTrack = "music/bishkek night.ogg";
}
else
{
audioPlayer_.crossFadeMusicAsync("audio/bishkek univer day.ogg");
audioPlayer_.crossFadeMusicAsync("music/bishkek univer day.ogg");
lastMusicTrack = "music/bishkek univer day.ogg";
}
} else if (locationName == "uni_interior") {
applyUniIntHud();
if (gameState_.isDarklands)
{
audioPlayer_.crossFadeMusicAsync("audio/bishkek fight calm.ogg");
audioPlayer_.crossFadeMusicAsync("music/bishkek fight calm.ogg");
lastMusicTrack = "music/bishkek fight calm.ogg";
}
else if (gameState_.isNight)
{
audioPlayer_.crossFadeMusicAsync("audio/bishkek night.ogg");
audioPlayer_.crossFadeMusicAsync("music/bishkek night.ogg");
lastMusicTrack = "music/bishkek night.ogg";
}
else
{
audioPlayer_.crossFadeMusicAsync("audio/bishkek univer day.ogg");
audioPlayer_.crossFadeMusicAsync("music/bishkek univer day.ogg");
lastMusicTrack = "music/bishkek univer day.ogg";
}
} else {
// Returning to dorm: reuse step5ab, suppress already-completed hints
@@ -1611,11 +1844,13 @@ namespace FRG {
if (gameState_.isNight)
{
audioPlayer_.crossFadeMusicAsync("audio/bishkek night.ogg");
audioPlayer_.crossFadeMusicAsync("music/bishkek night.ogg");
lastMusicTrack = "music/bishkek night.ogg";
}
else
{
audioPlayer_.crossFadeMusicAsync("audio/obshaga.ogg");
audioPlayer_.crossFadeMusicAsync("music/obshaga.ogg");
lastMusicTrack = "music/obshaga.ogg";
}
}
}
@@ -1844,12 +2079,12 @@ namespace FRG {
uiManager.setButtonCallback("inventoryExitButton", [this](const std::string&) {
closePortraitInventoryItem();
audioPlayer_.playSoundAsync("audio/sound_bag001.ogg");
audioPlayer_.playSoundAsync("resources/audio/sound_bag001.ogg");
});
uiManager.setButtonCallback("inventoryExitButton2", [this](const std::string&) {
closePortraitInventoryItem();
audioPlayer_.playSoundAsync("audio/sound_bag001.ogg");
audioPlayer_.playSoundAsync("resources/audio/sound_bag001.ogg");
});
uiManager.setButtonCallback("inventoryMain", [this](const std::string&) {});
@@ -1880,12 +2115,12 @@ namespace FRG {
uiManager.setButtonCallback("journalItemExitButton", [this](const std::string&) {
closePortraitJournalItem();
audioPlayer_.playSoundAsync("audio/255571__stradie__flipping-paper.ogg");
audioPlayer_.playSoundAsync("resources/audio/255571__stradie__flipping-paper.ogg");
});
uiManager.setButtonCallback("journalItemExitButton2", [this](const std::string&) {
closeQuestJournal();
audioPlayer_.playSoundAsync("audio/656126__itsthegoodstuff__paging-through-book.ogg");
audioPlayer_.playSoundAsync("resources/audio/656126__itsthegoodstuff__paging-through-book.ogg");
});
@@ -2085,7 +2320,7 @@ namespace FRG {
recomputePhoneChatPositions();
}
chatUiManager.startPopIn(nodeName, 300.0f);
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
audioPlayer_.playSoundAsync("resources/audio/537061__imafoley__message-pop-sound.ogg");
}
void MenuManager::setDarklandsMode(bool enabled)