Skip to content

Commit 7e21b3c

Browse files
authoredApr 13, 2020
Remove sound menu and show proper msgs if sound is off (#9069)
1 parent 27d611f commit 7e21b3c

File tree

1 file changed

+44
-22
lines changed

1 file changed

+44
-22
lines changed
 

Diff for: ‎src/client/game.cpp

+44-22
Original file line numberDiff line numberDiff line change
@@ -1922,29 +1922,47 @@ void Game::processKeyInput()
19221922
toggleFast();
19231923
} else if (wasKeyDown(KeyType::NOCLIP)) {
19241924
toggleNoClip();
1925+
#if USE_SOUND
19251926
} else if (wasKeyDown(KeyType::MUTE)) {
1926-
bool new_mute_sound = !g_settings->getBool("mute_sound");
1927-
g_settings->setBool("mute_sound", new_mute_sound);
1928-
if (new_mute_sound)
1929-
m_game_ui->showTranslatedStatusText("Sound muted");
1930-
else
1931-
m_game_ui->showTranslatedStatusText("Sound unmuted");
1927+
if (g_settings->getBool("enable_sound")) {
1928+
bool new_mute_sound = !g_settings->getBool("mute_sound");
1929+
g_settings->setBool("mute_sound", new_mute_sound);
1930+
if (new_mute_sound)
1931+
m_game_ui->showTranslatedStatusText("Sound muted");
1932+
else
1933+
m_game_ui->showTranslatedStatusText("Sound unmuted");
1934+
} else {
1935+
m_game_ui->showTranslatedStatusText("Sound system is disabled");
1936+
}
19321937
} else if (wasKeyDown(KeyType::INC_VOLUME)) {
1933-
float new_volume = rangelim(g_settings->getFloat("sound_volume") + 0.1f, 0.0f, 1.0f);
1934-
wchar_t buf[100];
1935-
g_settings->setFloat("sound_volume", new_volume);
1936-
const wchar_t *str = wgettext("Volume changed to %d%%");
1937-
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
1938-
delete[] str;
1939-
m_game_ui->showStatusText(buf);
1938+
if (g_settings->getBool("enable_sound")) {
1939+
float new_volume = rangelim(g_settings->getFloat("sound_volume") + 0.1f, 0.0f, 1.0f);
1940+
wchar_t buf[100];
1941+
g_settings->setFloat("sound_volume", new_volume);
1942+
const wchar_t *str = wgettext("Volume changed to %d%%");
1943+
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
1944+
delete[] str;
1945+
m_game_ui->showStatusText(buf);
1946+
} else {
1947+
m_game_ui->showTranslatedStatusText("Sound system is disabled");
1948+
}
19401949
} else if (wasKeyDown(KeyType::DEC_VOLUME)) {
1941-
float new_volume = rangelim(g_settings->getFloat("sound_volume") - 0.1f, 0.0f, 1.0f);
1942-
wchar_t buf[100];
1943-
g_settings->setFloat("sound_volume", new_volume);
1944-
const wchar_t *str = wgettext("Volume changed to %d%%");
1945-
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
1946-
delete[] str;
1947-
m_game_ui->showStatusText(buf);
1950+
if (g_settings->getBool("enable_sound")) {
1951+
float new_volume = rangelim(g_settings->getFloat("sound_volume") - 0.1f, 0.0f, 1.0f);
1952+
wchar_t buf[100];
1953+
g_settings->setFloat("sound_volume", new_volume);
1954+
const wchar_t *str = wgettext("Volume changed to %d%%");
1955+
swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, myround(new_volume * 100));
1956+
delete[] str;
1957+
m_game_ui->showStatusText(buf);
1958+
} else {
1959+
m_game_ui->showTranslatedStatusText("Sound system is disabled");
1960+
}
1961+
#else
1962+
} else if (wasKeyDown(KeyType::MUTE) || wasKeyDown(KeyType::INC_VOLUME)
1963+
|| wasKeyDown(KeyType::DEC_VOLUME)) {
1964+
m_game_ui->showTranslatedStatusText("Sound system is not supported on this build");
1965+
#endif
19481966
} else if (wasKeyDown(KeyType::CINEMATIC)) {
19491967
toggleCinematic();
19501968
} else if (wasKeyDown(KeyType::SCREENSHOT)) {
@@ -4162,8 +4180,12 @@ void Game::showPauseMenu()
41624180
}
41634181

41644182
#ifndef __ANDROID__
4165-
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
4166-
<< strgettext("Sound Volume") << "]";
4183+
#if USE_SOUND
4184+
if (g_settings->getBool("enable_sound")) {
4185+
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
4186+
<< strgettext("Sound Volume") << "]";
4187+
}
4188+
#endif
41674189
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;"
41684190
<< strgettext("Change Keys") << "]";
41694191
#endif

0 commit comments

Comments
 (0)