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 
17 #ifndef HEADER_SUPERTUX_SUPERTUX_COMMAND_LINE_ARGUMENTS_HPP
18 #define HEADER_SUPERTUX_SUPERTUX_COMMAND_LINE_ARGUMENTS_HPP
19 
20 #include <boost/optional.hpp>
21 #include <vector>
22 
23 #include "math/size.hpp"
24 #include "math/vector.hpp"
25 #include "util/log.hpp"
26 #include "video/video_system.hpp"
27 
28 class Config;
29 
30 /** Command line argument parsing */
31 class CommandLineArguments final
32 {
33 public:
34   enum Action
35   {
36     NO_ACTION,
37     PRINT_VERSION,
38     PRINT_HELP,
39     PRINT_DATADIR,
40     PRINT_ACKNOWLEDGEMENTS
41   };
42 
43 private:
44   Action m_action;
45   LogLevel m_log_level;
46 
47 public:
48   boost::optional<std::string> datadir;
49   boost::optional<std::string> userdir;
50 
51   boost::optional<Size> fullscreen_size;
52   boost::optional<int> fullscreen_refresh_rate;
53   boost::optional<Size> window_size;
54   boost::optional<Size> aspect_size;
55 
56   // boost::optional<float> magnification;
57 
58   boost::optional<bool> use_fullscreen;
59   boost::optional<VideoSystem::Enum> video;
60   // boost::optional<bool> try_vsync;
61   boost::optional<bool> show_fps;
62   boost::optional<bool> show_player_pos;
63   boost::optional<bool> sound_enabled;
64   boost::optional<bool> music_enabled;
65 
66   // boost::optional<int> random_seed;
67 
68   std::vector<std::string> filenames;
69   boost::optional<bool> enable_script_debugger;
70   boost::optional<std::string> start_demo;
71   boost::optional<std::string> record_demo;
72   boost::optional<Vector> tux_spawn_pos;
73   boost::optional<std::string> sector;
74   boost::optional<std::string> spawnpoint;
75 
76   boost::optional<bool> developer_mode;
77 
78   boost::optional<bool> christmas_mode;
79 
80   boost::optional<std::string> repository_url;
81 
82   boost::optional<bool> editor;
83   boost::optional<bool> resave;
84 
85   // boost::optional<std::string> locale;
86 
87 public:
88   CommandLineArguments();
89 
get_action() const90   Action get_action() const { return m_action; }
get_log_level() const91   LogLevel get_log_level() const { return m_log_level; }
92 
93   void parse_args(int argc, char** argv);
94 
95   void print_help(const char* arg0) const;
96   void print_version() const;
97   void print_datadir() const;
98   void print_acknowledgements() const;
99 
100   void merge_into(Config& config);
101 
102 private:
103   CommandLineArguments(const CommandLineArguments&) = delete;
104   CommandLineArguments& operator=(const CommandLineArguments&) = delete;
105 };
106 
107 #endif
108 
109 /* EOF */
110