-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
73 lines (63 loc) · 2.15 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
This file is part of Heroes of Wesnoth.
Copyright (C) 2007, 2008, 2009 Jon Ander Peñalba <[email protected]>
Heroes of Wesnoth is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
Heroes of Wesnoth 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 Heroes of Wesnoth. If not, see <http://www.gnu.org/licenses/>
*/
/// @file
/// The main function.
/// @author Jonan
#include <cstdlib>
#include <iostream>
#include "boot.hpp"
#include "menu_main.hpp"
int main(int argc, char *argv[]) {
// Default options
bool start_game = true;
bool fullscreen = false;
int width = 1024;
int height = 768;
// Check the programs arguments
for (int i=1; i<argc; i++) {
const std::string argument(argv[i]);
if (argument == "-fs" || argument == "--full-screen") {
fullscreen = true;
} else if ( argument == "-r" || argument == "--resolution") {
if ( argc > i+2 ) {
width = atoi(argv[i+1]);
height = atoi(argv[i+2]);
if (!width || !height) { // Go back to default
width = 1024;
height = 768;
}
i += 2; // Jump to next arg
}
} else {
/// @todo Change version
std::cout << "\nHeroes of Wesnoth v0.1.2\n"
<< "\nusage: heroes [OPTIONS]\n"
<< " -fs, --full-screen\n"
<< " starts the game in full screen mode.\n\n"
<< " -r HORIZONTAL_RESOLUTION VERTICAL_RESOLUTION\n"
<< " starts the game with the given resolution.\n\n"
<< " -h, --help\n"
<< " prints this message and exits.\n"
<< std::endl;
start_game = false;
}
}
if (start_game) {
// Start the game engine
boot(fullscreen, width, height);
// Start the main menu
startMainMenu();
}
return EXIT_SUCCESS;
}