video_system_menu.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SuperTux
  2. // Copyright (C) 2022 mrkubax10 <mrkubax10@onet.pl>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #include "supertux/menu/video_system_menu.hpp"
  17. #include <fmt/format.h>
  18. #include "gui/dialog.hpp"
  19. #include "gui/menu_item.hpp"
  20. #include "supertux/globals.hpp"
  21. #include "supertux/gameconfig.hpp"
  22. #include "util/gettext.hpp"
  23. #include "video/video_system.hpp"
  24. VideoSystemMenu::VideoSystemMenu()
  25. {
  26. refresh();
  27. }
  28. void
  29. VideoSystemMenu::refresh()
  30. {
  31. add_label(_("Select Video System"));
  32. add_inactive(fmt::format(_("Used video system: {}"), VideoSystem::get_video_string(g_config->video)));
  33. add_hl();
  34. std::vector<std::string> video_systems = VideoSystem::get_available_video_systems();
  35. for(unsigned i = 0; i < video_systems.size(); i++)
  36. add_entry(static_cast<int>(i), video_systems[i]);
  37. add_hl();
  38. add_back(_("Back"));
  39. }
  40. void
  41. VideoSystemMenu::menu_action(MenuItem& item)
  42. {
  43. if (item.get_id() >= 0)
  44. {
  45. g_config->video = VideoSystem::get_video_system(item.get_text());
  46. Dialog::show_message(_("Restart game for the changes to take effect"), false, false, []
  47. {
  48. MenuManager::instance().pop_menu();
  49. });
  50. }
  51. }
  52. /* EOF */