command_line_arguments.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // SuperTux
  2. // Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
  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. #ifndef HEADER_SUPERTUX_SUPERTUX_COMMAND_LINE_ARGUMENTS_HPP
  17. #define HEADER_SUPERTUX_SUPERTUX_COMMAND_LINE_ARGUMENTS_HPP
  18. #include <optional>
  19. #include <vector>
  20. #include "math/size.hpp"
  21. #include "math/vector.hpp"
  22. #include "util/log.hpp"
  23. #include "video/video_system.hpp"
  24. class Config;
  25. /** Command line argument parsing */
  26. class CommandLineArguments final
  27. {
  28. public:
  29. enum Action
  30. {
  31. NO_ACTION,
  32. PRINT_VERSION,
  33. PRINT_HELP,
  34. PRINT_DATADIR,
  35. PRINT_ACKNOWLEDGEMENTS
  36. };
  37. private:
  38. Action m_action;
  39. LogLevel m_log_level;
  40. public:
  41. std::optional<std::string> datadir;
  42. std::optional<std::string> userdir;
  43. std::optional<Size> fullscreen_size;
  44. std::optional<int> fullscreen_refresh_rate;
  45. std::optional<Size> window_size;
  46. std::optional<Size> aspect_size;
  47. // std::optional<float> magnification;
  48. std::optional<bool> use_fullscreen;
  49. std::optional<VideoSystem::Enum> video;
  50. // std::optional<bool> try_vsync;
  51. std::optional<bool> show_fps;
  52. std::optional<bool> show_player_pos;
  53. std::optional<bool> sound_enabled;
  54. std::optional<bool> music_enabled;
  55. // std::optional<int> random_seed;
  56. std::vector<std::string> filenames;
  57. std::optional<bool> enable_script_debugger;
  58. std::optional<Vector> tux_spawn_pos;
  59. std::optional<std::string> sector;
  60. std::optional<std::string> spawnpoint;
  61. std::optional<bool> developer_mode;
  62. std::optional<bool> christmas_mode;
  63. std::optional<std::string> repository_url;
  64. std::optional<bool> editor;
  65. std::optional<bool> resave;
  66. // std::optional<std::string> locale;
  67. public:
  68. CommandLineArguments();
  69. Action get_action() const { return m_action; }
  70. LogLevel get_log_level() const { return m_log_level; }
  71. void parse_args(int argc, char** argv);
  72. void print_help(const char* arg0) const;
  73. void print_version() const;
  74. void print_datadir() const;
  75. void print_acknowledgements() const;
  76. void merge_into(Config& config);
  77. private:
  78. CommandLineArguments(const CommandLineArguments&) = delete;
  79. CommandLineArguments& operator=(const CommandLineArguments&) = delete;
  80. };
  81. #endif
  82. /* EOF */