123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726 |
- // SuperTux
- // Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
- // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation, either version 3 of the License, or
- // (at your option) any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with this program. If not, see <http://www.gnu.org/licenses/>.
- #include "supertux/menu/options_menu.hpp"
- #include "audio/sound_manager.hpp"
- #include "gui/dialog.hpp"
- #include "gui/item_goto.hpp"
- #include "gui/item_stringselect.hpp"
- #include "gui/item_toggle.hpp"
- #include "gui/menu_item.hpp"
- #include "gui/menu_manager.hpp"
- #include "supertux/gameconfig.hpp"
- #include "supertux/game_session.hpp"
- #include "supertux/globals.hpp"
- #include "supertux/menu/menu_storage.hpp"
- #include "supertux/title_screen.hpp"
- #include "util/gettext.hpp"
- #include "util/log.hpp"
- #include "video/renderer.hpp"
- #include "video/video_system.hpp"
- #include "video/viewport.hpp"
- #include <sstream>
- #ifdef __EMSCRIPTEN__
- #include <emscripten.h>
- #include <emscripten/html5.h>
- #endif
- bool
- OptionsMenu::less_than_volume(const std::string& lhs, const std::string& rhs)
- {
- int lhs_i, rhs_i;
- if (sscanf(lhs.c_str(), "%i", &lhs_i) == 1 &&
- sscanf(rhs.c_str(), "%i", &rhs_i) == 1)
- {
- return lhs_i < rhs_i;
- }
- return false;
- }
- OptionsMenu::OptionsMenu(Type type, bool complete) :
- m_magnifications(),
- m_aspect_ratios(),
- m_window_resolutions(),
- m_resolutions(),
- m_vsyncs(),
- m_sound_volumes(),
- m_music_volumes(),
- m_mobile_control_scales()
- {
- switch (type) // Insert label and menu items, appropriate for the chosen OptionsMenu type
- {
- case LOCALE: /** LOCALE */
- {
- insert_label(_("Locale"));
- if (complete)
- {
- add_submenu(_("Select Language"), MenuStorage::LANGUAGE_MENU)
- .set_help(_("Select a different language to display text in"));
- add_submenu(_("Language Packs"), MenuStorage::LANGPACK_MENU)
- .set_help(_("Language packs contain up-to-date translations"));
- }
- break;
- }
- case VIDEO: /** VIDEO */
- {
- insert_label(_("Video"));
- #if !defined(HIDE_NONMOBILE_OPTIONS) && !defined(__EMSCRIPTEN__)
- add_toggle(MNID_FULLSCREEN,_("Window Resizable"), &g_config->window_resizable)
- .set_help(_("Allow window resizing, might require a restart to take effect"));
- add_window_resolutions();
- add_toggle(MNID_FULLSCREEN,_("Fullscreen"), &g_config->use_fullscreen)
- .set_help(_("Fill the entire screen"));
- add_resolutions();
- #endif
- #if 0
- #ifdef __EMSCRIPTEN__
- add_toggle(MNID_FIT_WINDOW, _("Fit to browser"), &g_config->fit_window)
- .set_help(_("Fit the resolution to the size of your browser"));
- #endif
- #endif
- add_magnification();
- add_vsync();
- #if !defined(HIDE_NONMOBILE_OPTIONS) && !defined(__EMSCRIPTEN__)
- add_aspect_ratio();
- #endif
- add_submenu(_("Change Video System"), MenuStorage::MenuId::VIDEO_SYSTEM_MENU)
- .set_help(_("Change video system used to render graphics"));
- break;
- }
- case AUDIO: /** AUDIO */
- {
- insert_label(_("Audio"));
- if (SoundManager::current()->is_audio_enabled())
- {
- add_toggle(MNID_SOUND, _("Sound"), &g_config->sound_enabled)
- .set_help(_("Disable all sound effects"));
- add_toggle(MNID_MUSIC, _("Music"), &g_config->music_enabled)
- .set_help(_("Disable all music"));
- add_sound_volume();
- add_music_volume();
- }
- else
- {
- add_inactive( _("Sound (disabled)"));
- add_inactive( _("Music (disabled)"));
- }
- break;
- }
- case CONTROLS: /** CONTROLS */
- {
- insert_label(_("Controls"));
- // Separated both translation strings so the latter can be removed if it is
- // no longer true, without requiring a new round of translating
- add_toggle(MNID_RUMBLING, _("Enable Rumbling Controllers"), &g_config->multiplayer_buzz_controllers)
- .set_help(_("Enable vibrating the game controllers.") + " " + _("This feature is currently only used in the multiplayer options menu."));
- add_submenu(_("Setup Keyboard"), MenuStorage::KEYBOARD_MENU)
- .set_help(_("Configure key-action mappings"));
- #ifndef UBUNTU_TOUCH
- add_submenu(_("Setup Joystick"), MenuStorage::JOYSTICK_MENU)
- .set_help(_("Configure joystick control-action mappings"));
- #endif
- break;
- }
- case EXTRAS: /** EXTRAS */
- {
- insert_label(_("Extras"));
- if (complete)
- add_submenu(_("Select Profile"), MenuStorage::PROFILE_MENU)
- .set_help(_("Select a profile to play with"));
- #ifndef UBUNTU_TOUCH
- add_submenu(_("Multiplayer settings"), MenuStorage::MULTIPLAYER_MENU)
- .set_help(_("Configure settings specific to multiplayer"));
- #endif
- add_toggle(MNID_TRANSITIONS, _("Enable transitions"), &g_config->transitions_enabled)
- .set_help(_("Enable screen transitions and smooth menu animation"));
- add_toggle(MNID_CUSTOM_TITLE_LEVELS, _("Custom title screen levels"), &g_config->custom_title_levels)
- .set_help(_("Allow overriding the title screen level, when loading certain worlds"));
- if (g_config->is_christmas() || g_config->christmas_mode)
- add_toggle(MNID_CHRISTMAS_MODE, _("Christmas Mode"), &g_config->christmas_mode);
- add_submenu(_("Integrations and presence"), MenuStorage::INTEGRATIONS_MENU)
- .set_help(_("Manage whether SuperTux should display the levels you play on your social media profiles (Discord)"));
- if (g_config->developer_mode)
- add_submenu(_("Menu Customization"), MenuStorage::CUSTOM_MENU_MENU)
- .set_help(_("Customize the appearance of the menus"));
- break;
- }
- case ADVANCED: /** ADVANCED */
- {
- insert_label(_("Advanced"));
- #ifndef HIDE_NONMOBILE_OPTIONS
- if (g_config->developer_mode)
- #endif
- add_toggle(MNID_DEVELOPER_MODE, _("Developer Mode"), &g_config->developer_mode);
- add_toggle(MNID_CONFIRMATION_DIALOG, _("Confirmation Dialog"), &g_config->confirmation_dialog).set_help(_("Confirm aborting level"));
- add_toggle(MNID_PAUSE_ON_FOCUSLOSS, _("Pause on focus loss"), &g_config->pause_on_focusloss)
- .set_help(_("Automatically pause the game when the window loses focus"));
- add_toggle(MNID_CUSTOM_CURSOR, _("Use custom mouse cursor"), &g_config->custom_mouse_cursor).set_help(_("Whether the game renders its own cursor or uses the system's cursor"));
- #ifndef __EMSCRIPTEN__
- add_toggle(MNID_RELEASE_CHECK, _("Check for new releases"), &g_config->do_release_check)
- .set_help(_("Allows the game to perform checks for new SuperTux releases on startup and notify if any found."));
- #endif
- break;
- }
- }
- add_hl();
- add_back(_("Back"));
- on_window_resize();
- }
- OptionsMenu::~OptionsMenu()
- {
- }
- void
- OptionsMenu::insert_label(const std::string& text)
- {
- add_label(text);
- add_hl();
- }
- void
- OptionsMenu::add_magnification()
- {
- // These values go from screen:640/projection:1600 to
- // screen:1600/projection:640 (i.e. 640, 800, 1024, 1280, 1600)
- m_magnifications.list.push_back(_("auto"));
- #ifndef HIDE_NONMOBILE_OPTIONS
- m_magnifications.list.push_back("40%");
- m_magnifications.list.push_back("50%");
- m_magnifications.list.push_back("62.5%");
- m_magnifications.list.push_back("80%");
- #endif
- m_magnifications.list.push_back("100%");
- m_magnifications.list.push_back("125%");
- m_magnifications.list.push_back("160%");
- m_magnifications.list.push_back("200%");
- m_magnifications.list.push_back("250%");
- // Gets the actual magnification:
- if (g_config->magnification != 0.0f) //auto
- {
- std::ostringstream out;
- out << (g_config->magnification*100) << "%";
- std::string magn = out.str();
- int count = 0;
- for (const auto& magnification : m_magnifications.list)
- {
- if (magnification == magn)
- {
- m_magnifications.next = count;
- magn.clear();
- break;
- }
- ++count;
- }
- if (!magn.empty()) // Current magnification not found
- {
- m_magnifications.next = static_cast<int>(m_magnifications.list.size());
- m_magnifications.list.push_back(magn);
- }
- }
- add_string_select(MNID_MAGNIFICATION, _("Magnification"), &m_magnifications.next, m_magnifications.list)
- .set_help(_("Change the magnification of the game area"));
- }
- void
- OptionsMenu::add_aspect_ratio()
- {
- m_aspect_ratios.list.push_back(_("auto"));
- m_aspect_ratios.list.push_back("5:4");
- m_aspect_ratios.list.push_back("4:3");
- m_aspect_ratios.list.push_back("16:10");
- m_aspect_ratios.list.push_back("16:9");
- m_aspect_ratios.list.push_back("1368:768");
- // Gets the actual aspect ratio:
- if (g_config->aspect_size != Size(0, 0)) //auto
- {
- std::ostringstream out;
- out << g_config->aspect_size.width << ":" << g_config->aspect_size.height;
- std::string aspect_ratio = out.str();
- int count = 0;
- for (const auto& ratio : m_aspect_ratios.list)
- {
- if (ratio == aspect_ratio)
- {
- aspect_ratio.clear();
- m_aspect_ratios.next = count;
- break;
- }
- ++count;
- }
- if (!aspect_ratio.empty()) // Current aspect ratio not found
- {
- m_aspect_ratios.next = static_cast<int>(m_aspect_ratios.list.size());
- m_aspect_ratios.list.push_back(aspect_ratio);
- }
- }
- add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"), &m_aspect_ratios.next, m_aspect_ratios.list)
- .set_help(_("Adjust the aspect ratio"));
- }
- void
- OptionsMenu::add_window_resolutions()
- {
- m_window_resolutions.list = { "640x480", "854x480", "800x600", "1280x720", "1280x800",
- "1440x900", "1920x1080", "1920x1200", "2560x1440" };
- m_window_resolutions.next = -1;
- Size window_size = VideoSystem::current()->get_window_size();
- std::ostringstream out;
- out << window_size.width << "x" << window_size.height;
- std::string window_size_text = out.str();
- for (size_t i = 0; i < m_window_resolutions.list.size(); ++i)
- {
- if (m_window_resolutions.list[i] == window_size_text)
- {
- m_window_resolutions.next = static_cast<int>(i);
- break;
- }
- }
- if (m_window_resolutions.next == -1) // Current window resolution not found
- {
- m_window_resolutions.list.insert(m_window_resolutions.list.begin(), window_size_text);
- m_window_resolutions.next = 0;
- }
- add_string_select(MNID_WINDOW_RESOLUTION, _("Window Resolution"), &m_window_resolutions.next, m_window_resolutions.list)
- .set_help(_("Resize the window to the given size"));
- }
- void
- OptionsMenu::add_resolutions()
- {
- int display_mode_count = SDL_GetNumDisplayModes(0);
- std::string last_display_mode;
- for (int i = 0; i < display_mode_count; ++i)
- {
- SDL_DisplayMode mode;
- int ret = SDL_GetDisplayMode(0, i, &mode);
- if (ret != 0)
- {
- log_warning << "failed to get display mode: " << SDL_GetError() << std::endl;
- }
- else
- {
- std::ostringstream out;
- out << mode.w << "x" << mode.h;
- if (mode.refresh_rate)
- out << "@" << mode.refresh_rate;
- if (last_display_mode == out.str())
- continue;
- last_display_mode = out.str();
- m_resolutions.list.insert(m_resolutions.list.begin(), out.str());
- }
- }
- m_resolutions.list.push_back("Desktop");
- std::string fullscreen_size_str = _("Desktop");
- std::ostringstream out;
- if (g_config->fullscreen_size != Size(0, 0))
- {
- out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height;
- if (g_config->fullscreen_refresh_rate)
- out << "@" << g_config->fullscreen_refresh_rate;
- fullscreen_size_str = out.str();
- }
- int count = 0;
- for (const auto& res : m_resolutions.list)
- {
- if (res == fullscreen_size_str)
- {
- fullscreen_size_str.clear();
- m_resolutions.next = count;
- break;
- }
- ++count;
- }
- if (!fullscreen_size_str.empty()) // Current resolution not found
- {
- m_resolutions.next = static_cast<int>(m_resolutions.list.size());
- m_resolutions.list.push_back(fullscreen_size_str);
- }
- add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Fullscreen Resolution"), &m_resolutions.next, m_resolutions.list)
- .set_help(_("Determine the resolution used in fullscreen mode (you must toggle fullscreen to complete the change)"));
- }
- void
- OptionsMenu::add_vsync()
- {
- m_vsyncs.list.push_back(_("on"));
- m_vsyncs.list.push_back(_("off"));
- m_vsyncs.list.push_back(_("adaptive"));
- const int mode = VideoSystem::current()->get_vsync();
- switch (mode)
- {
- case -1:
- m_vsyncs.next = 2;
- break;
- case 0:
- m_vsyncs.next = 1;
- break;
- case 1:
- m_vsyncs.next = 0;
- break;
- default:
- log_warning << "Unknown swap mode: " << mode << std::endl;
- m_vsyncs.next = 0;
- }
- add_string_select(MNID_VSYNC, _("VSync"), &m_vsyncs.next, m_vsyncs.list)
- .set_help(_("Set the VSync mode"));
- }
- void
- OptionsMenu::add_sound_volume()
- {
- m_sound_volumes.list = { "0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%" };
- std::ostringstream sound_vol_stream;
- sound_vol_stream << g_config->sound_volume << "%";
- std::string sound_vol_string = sound_vol_stream.str();
- if (std::find(m_sound_volumes.list.begin(),
- m_sound_volumes.list.end(), sound_vol_string) == m_sound_volumes.list.end())
- {
- m_sound_volumes.list.push_back(sound_vol_string);
- }
- std::sort(m_sound_volumes.list.begin(), m_sound_volumes.list.end(), less_than_volume);
- std::ostringstream out;
- out << g_config->sound_volume << "%";
- std::string sound_volume = out.str();
- int count = 0;
- for (const auto& volume : m_sound_volumes.list)
- {
- if (volume == sound_volume)
- {
- sound_volume.clear();
- m_sound_volumes.next = count;
- break;
- }
- ++count;
- }
- add_string_select(MNID_SOUND_VOLUME, _("Sound Volume"), &m_sound_volumes.next, m_sound_volumes.list)
- .set_help(_("Adjust sound volume"));
- }
- void
- OptionsMenu::add_music_volume()
- {
- m_music_volumes.list = { "0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%" };
- std::ostringstream music_vol_stream;
- music_vol_stream << g_config->music_volume << "%";
- std::string music_vol_string = music_vol_stream.str();
- if (std::find(m_music_volumes.list.begin(),
- m_music_volumes.list.end(), music_vol_string) == m_music_volumes.list.end())
- {
- m_music_volumes.list.push_back(music_vol_string);
- }
- std::sort(m_music_volumes.list.begin(), m_music_volumes.list.end(), less_than_volume);
- std::ostringstream out;
- out << g_config->music_volume << "%";
- std::string music_volume = out.str();
- int count = 0;
- for (const auto& volume : m_music_volumes.list)
- {
- if (volume == music_volume)
- {
- music_volume.clear();
- m_music_volumes.next = count;
- break;
- }
- ++count;
- }
- add_string_select(MNID_MUSIC_VOLUME, _("Music Volume"), &m_music_volumes.next, m_music_volumes.list)
- .set_help(_("Adjust music volume"));
- }
- void
- OptionsMenu::add_mobile_control_scales()
- {
- for (unsigned i = 50; i <= 300; i += 25)
- {
- m_mobile_control_scales.list.push_back(std::to_string(i) + "%");
- if (i == static_cast<unsigned>(g_config->m_mobile_controls_scale * 100))
- m_mobile_control_scales.next = (i - 50) / 25;
- }
- add_string_select(MNID_MOBILE_CONTROLS_SCALE, _("On-screen controls scale"), &m_mobile_control_scales.next, m_mobile_control_scales.list);
- }
- void
- OptionsMenu::on_window_resize()
- {
- set_center_pos(static_cast<float>(SCREEN_WIDTH) / 2.0f,
- static_cast<float>(SCREEN_HEIGHT) / 2.0f + 15.0f);
- }
- void
- OptionsMenu::menu_action(MenuItem& item)
- {
- switch (item.get_id()) {
- case MNID_ASPECTRATIO:
- {
- if (m_aspect_ratios.next == 0)
- {
- g_config->aspect_size = Size(0, 0); // Magic values
- VideoSystem::current()->apply_config();
- MenuManager::instance().on_window_resize();
- }
- else if (sscanf(m_aspect_ratios.list[m_aspect_ratios.next].c_str(), "%d:%d",
- &g_config->aspect_size.width, &g_config->aspect_size.height) == 2)
- {
- VideoSystem::current()->apply_config();
- MenuManager::instance().on_window_resize();
- }
- else
- {
- log_fatal << "Invalid aspect ratio " << m_aspect_ratios.list[m_aspect_ratios.next] << " specified" << std::endl;
- assert(false);
- }
- }
- break;
- case MNID_MAGNIFICATION:
- if (m_magnifications.next == 0)
- {
- g_config->magnification = 0.0f; // Magic value
- }
- else if (sscanf(m_magnifications.list[m_magnifications.next].c_str(), "%f", &g_config->magnification) == 1)
- {
- g_config->magnification /= 100.0f;
- }
- VideoSystem::current()->apply_config();
- MenuManager::instance().on_window_resize();
- break;
- case MNID_WINDOW_RESIZABLE:
- if (!g_config->window_resizable)
- m_resolutions.next = 0;
- break;
- case MNID_WINDOW_RESOLUTION:
- {
- int width;
- int height;
- if (sscanf(m_window_resolutions.list[m_window_resolutions.next].c_str(), "%dx%d",
- &width, &height) != 2)
- {
- log_fatal << "can't parse " << m_window_resolutions.list[m_window_resolutions.next] << std::endl;
- }
- else
- {
- g_config->window_size = Size(width, height);
- VideoSystem::current()->apply_config();
- MenuManager::instance().on_window_resize();
- }
- }
- break;
- case MNID_FULLSCREEN_RESOLUTION:
- {
- int width;
- int height;
- int refresh_rate;
- if (m_resolutions.list[m_resolutions.next] == "Desktop")
- {
- g_config->fullscreen_size.width = 0;
- g_config->fullscreen_size.height = 0;
- g_config->fullscreen_refresh_rate = 0;
- }
- else if (sscanf(m_resolutions.list[m_resolutions.next].c_str(), "%dx%d@%d",
- &width, &height, &refresh_rate) == 3)
- {
- // do nothing, changes are only applied when toggling fullscreen mode
- g_config->fullscreen_size.width = width;
- g_config->fullscreen_size.height = height;
- g_config->fullscreen_refresh_rate = refresh_rate;
- }
- else if (sscanf(m_resolutions.list[m_resolutions.next].c_str(), "%dx%d",
- &width, &height) == 2)
- {
- g_config->fullscreen_size.width = width;
- g_config->fullscreen_size.height = height;
- g_config->fullscreen_refresh_rate = 0;
- }
- }
- break;
- #ifdef __EMSCRIPTEN__
- case MNID_FIT_WINDOW:
- {
- // Emscripten's Clang detects the "$" in the macro as part of C++ code
- // although it isn't even Javascript, it's Emscripten's way to pass
- // arguments from C++ to Javascript
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
- int resultds = EM_ASM_INT({
- if (window.supertux_setAutofit)
- window.supertux_setAutofit($0);
- return !!window.supertux_setAutofit;
- }, g_config->fit_window);
- #pragma GCC diagnostic pop
- if (!resultds)
- {
- Dialog::show_message(_("The game couldn't detect your browser resolution.\n"
- "This most likely happens because it is not embedded\n"
- "in the SuperTux custom HTML template.\n"));
- }
- }
- break;
- #endif
- case MNID_VSYNC:
- {
- int vsync = 0;
- switch (m_vsyncs.next)
- {
- case 2:
- vsync = -1;
- break;
- case 1:
- vsync = 0;
- break;
- case 0:
- vsync = 1;
- break;
- default:
- assert(false);
- break;
- }
- g_config->vsync = vsync;
- VideoSystem::current()->set_vsync(vsync);
- }
- break;
- case MNID_FULLSCREEN:
- VideoSystem::current()->apply_config();
- MenuManager::instance().on_window_resize();
- g_config->save();
- break;
- case MNID_SOUND:
- SoundManager::current()->enable_sound(g_config->sound_enabled);
- g_config->save();
- break;
- case MNID_SOUND_VOLUME:
- if (sscanf(m_sound_volumes.list[m_sound_volumes.next].c_str(), "%i", &g_config->sound_volume) == 1)
- {
- bool sound_enabled = g_config->sound_volume > 0 ? true : false;
- SoundManager::current()->enable_sound(sound_enabled);
- SoundManager::current()->set_sound_volume(g_config->sound_volume);
- g_config->save();
- }
- break;
- case MNID_MUSIC:
- SoundManager::current()->enable_music(g_config->music_enabled);
- g_config->save();
- break;
- case MNID_MUSIC_VOLUME:
- if (sscanf(m_music_volumes.list[m_music_volumes.next].c_str(), "%i", &g_config->music_volume) == 1)
- {
- bool music_enabled = g_config->music_volume > 0 ? true : false;
- SoundManager::current()->enable_music(music_enabled);
- SoundManager::current()->set_music_volume(g_config->music_volume);
- g_config->save();
- }
- break;
- case MNID_CUSTOM_TITLE_LEVELS:
- TitleScreen::current()->refresh_level();
- break;
- case MNID_CUSTOM_CURSOR:
- SDL_ShowCursor(g_config->custom_mouse_cursor ? 0 : 1);
- break;
- case MNID_MOBILE_CONTROLS_SCALE:
- if (sscanf(m_mobile_control_scales.list[m_mobile_control_scales.next].c_str(), "%f", &g_config->m_mobile_controls_scale) == EOF)
- g_config->m_mobile_controls_scale = 1; // if sscanf fails revert to default scale
- else
- g_config->m_mobile_controls_scale /= 100.0f;
- break;
- default:
- break;
- }
- }
- /* EOF */
|