-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
78 lines (74 loc) · 2.1 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
74
75
76
77
78
#include <iostream>
#include <memory>
#include <thread>
#include <string>
#include <utils.hpp>
#include <game.hpp>
#include <pq2gui.hpp>
#ifdef QT_ENABLED
#include <pq2qt.hpp>
#endif //QT_ENABLED
#ifdef GTK_ENABLED
#include <pq2gtk.hpp>
#endif //GTK_ENABLED
#ifdef COCOA_ENABLED
// #include "pq2cocoa.hpp"
#endif //COCOA_ENABLED
#ifdef WINFORMS_ENABLED
// #include "pq2winforms.hpp"
#endif //WINFORMS_ENABLED
#ifdef NCURSES_ENABLED
#include <pq2ncurses.hpp>
#endif //NCURSES_ENABLED
using namespace std;
int main(const int argc, const char * const *argv) {
string filename;
CommandLineProcessor cmdProcessor("Progress Quest 2 - The Progression", "A streamlined RPG experience", "2025.0");
try {
cmdProcessor.AddValueOnlyOption("savefile", "Load the saved game (optional unless run in daemon mode)");
if (cmdProcessor.Parse(argc, argv) == false) {
return 0;
}
filename = cmdProcessor.GetValueOnlyOptionValue("savefile");
}
catch (BaseOptionExistsException &ex) {
cerr << ex.what() << endl;
cerr << ex.GetConflictMessage() << endl;
return 1;
}
catch (ParseException &ex) {
cerr << ex.what() << endl;
cerr << ex.GetExceptionMessage() << endl;
return 1;
}
catch (CommandLineException &ex) {
cerr << "Unknown error: " << ex.what() << endl;
return 1;
}
auto game = make_shared<Game>();
if (!filename.empty()) {
if (const file::LoadError error = game->LoadGame(filename); error != file::LoadErrorNone) {
cout << "Error loading save " << filename << endl;
return 1;
}
}
unique_ptr<GUI> g;
#ifdef QT_ENABLED
g = make_unique<QTGUI>(game);
#endif //QT_ENABLED
#ifdef GTK_ENABLED
g = make_unique<GTKGUI>(game);
#endif //GTK_ENABLED
#ifdef COCOA_ENABLED
// g = make_unique<CocoaGUI>(game);
#endif //COCOA_ENABLED
#ifdef WINFORMS_ENABLED
// g = make_unique<WinformsGUI>(game);
#endif //WINFORMS_ENABLED
#ifdef NCURSES_ENABLED
g = make_unique<NCursesGUI>(game);
#endif //NCURSES_ENABLED
g->Run();
g.reset();
return 0;
}