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