Remove sound menu and show proper msgs if sound is off (#9069)

This commit is contained in:
Wuzzy 2020-04-13 20:26:54 +02:00 committed by GitHub
parent 27d611fe55
commit 7e21b3cd48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1922,14 +1922,20 @@ void Game::processKeyInput()
toggleFast(); toggleFast();
} else if (wasKeyDown(KeyType::NOCLIP)) { } else if (wasKeyDown(KeyType::NOCLIP)) {
toggleNoClip(); toggleNoClip();
#if USE_SOUND
} else if (wasKeyDown(KeyType::MUTE)) { } else if (wasKeyDown(KeyType::MUTE)) {
if (g_settings->getBool("enable_sound")) {
bool new_mute_sound = !g_settings->getBool("mute_sound"); bool new_mute_sound = !g_settings->getBool("mute_sound");
g_settings->setBool("mute_sound", new_mute_sound); g_settings->setBool("mute_sound", new_mute_sound);
if (new_mute_sound) if (new_mute_sound)
m_game_ui->showTranslatedStatusText("Sound muted"); m_game_ui->showTranslatedStatusText("Sound muted");
else else
m_game_ui->showTranslatedStatusText("Sound unmuted"); m_game_ui->showTranslatedStatusText("Sound unmuted");
} else {
m_game_ui->showTranslatedStatusText("Sound system is disabled");
}
} else if (wasKeyDown(KeyType::INC_VOLUME)) { } else if (wasKeyDown(KeyType::INC_VOLUME)) {
if (g_settings->getBool("enable_sound")) {
float new_volume = rangelim(g_settings->getFloat("sound_volume") + 0.1f, 0.0f, 1.0f); float new_volume = rangelim(g_settings->getFloat("sound_volume") + 0.1f, 0.0f, 1.0f);
wchar_t buf[100]; wchar_t buf[100];
g_settings->setFloat("sound_volume", new_volume); g_settings->setFloat("sound_volume", new_volume);
@ -1937,7 +1943,11 @@ void Game::processKeyInput()
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100)); swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
delete[] str; delete[] str;
m_game_ui->showStatusText(buf); m_game_ui->showStatusText(buf);
} else {
m_game_ui->showTranslatedStatusText("Sound system is disabled");
}
} else if (wasKeyDown(KeyType::DEC_VOLUME)) { } else if (wasKeyDown(KeyType::DEC_VOLUME)) {
if (g_settings->getBool("enable_sound")) {
float new_volume = rangelim(g_settings->getFloat("sound_volume") - 0.1f, 0.0f, 1.0f); float new_volume = rangelim(g_settings->getFloat("sound_volume") - 0.1f, 0.0f, 1.0f);
wchar_t buf[100]; wchar_t buf[100];
g_settings->setFloat("sound_volume", new_volume); g_settings->setFloat("sound_volume", new_volume);
@ -1945,6 +1955,14 @@ void Game::processKeyInput()
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100)); swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
delete[] str; delete[] str;
m_game_ui->showStatusText(buf); m_game_ui->showStatusText(buf);
} else {
m_game_ui->showTranslatedStatusText("Sound system is disabled");
}
#else
} else if (wasKeyDown(KeyType::MUTE) || wasKeyDown(KeyType::INC_VOLUME)
|| wasKeyDown(KeyType::DEC_VOLUME)) {
m_game_ui->showTranslatedStatusText("Sound system is not supported on this build");
#endif
} else if (wasKeyDown(KeyType::CINEMATIC)) { } else if (wasKeyDown(KeyType::CINEMATIC)) {
toggleCinematic(); toggleCinematic();
} else if (wasKeyDown(KeyType::SCREENSHOT)) { } else if (wasKeyDown(KeyType::SCREENSHOT)) {
@ -4162,8 +4180,12 @@ void Game::showPauseMenu()
} }
#ifndef __ANDROID__ #ifndef __ANDROID__
#if USE_SOUND
if (g_settings->getBool("enable_sound")) {
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;" os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
<< strgettext("Sound Volume") << "]"; << strgettext("Sound Volume") << "]";
}
#endif
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;" os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;"
<< strgettext("Change Keys") << "]"; << strgettext("Change Keys") << "]";
#endif #endif