added libs and oalist
[mines3d.git] / main.cpp
blobcecc1be352140a33bbad8f3714382b58eb9cbe5e
1 /*
2 * File: main.cpp
3 * Author: Petr Kubiznak,...
4 */
6 #include "ui/console/console.h"
7 #include "ui/qt/qt_gui.h"
8 #include "exceptions/GeneralException.h"
9 #include <iostream>
10 #include <cstring>
11 using namespace std;
13 /* -------------------------------------------------------------------------- */
15 /* tiskne kratkou napovedu */
16 void printHelp() {
17 cout << endl << "NAME" << endl;
18 cout << "\tMines3D - Search mines in three dimensions!" << endl << endl;
20 cout << "SYNOPSIS:" << endl;
21 cout << "\tmines3d [OPTION]" << endl << endl;
23 cout << "OPTIONS" << endl;
24 cout << "\t-console" << endl << "\t\tRun in a console mode. Implicitly, the program starts in a graphic mode." << endl << endl;
25 cout << "\t-help" << endl << "\t\tDisplays this help." << endl << endl;
27 cout << "CREDITS" << endl;
28 cout << "\t\302\251 Petr Kubiz\305\210\303\241k, Czech Technical University in Prague, 2010" << endl;
29 cout << "\tCreated as a semestral project on subject Y36PJC." << endl << endl;
30 cout << "\tThanks to Petra Mertl\303\255kov\303\241 for a theme suggestion and long-term support." << endl << endl;
33 /* -------------------------------------------------------------------------- */
35 int main(int argc, char *argv[]) {
36 try {
37 switch(argc) {
38 case 1:
39 cout << "Starting graphical mode." << endl;
40 cout << "To run in a text mode, use argument \"-console\"." << endl;
41 qtMain(argc, argv);
42 break;
44 case 2:
45 if(!strcmp(argv[1], "-console")) { consoleMain(); break; } //spusteni programu v console modu
46 if(!strcmp(argv[1], "-help")) { printHelp(); break; }
48 default:
49 cerr << "Invalid calling seqence." << endl;
50 cerr << "Call \"" << argv[0] << "\" to run the program." << endl;
51 cerr << "Use \"-help\" argument to display help." << endl;
52 return 1;
53 break;
55 } catch(GeneralException e) {
56 cerr << "Program terminated incorrectly with error message:" << endl
57 << e.errText << " (" << e.errCode << ")" << endl;
58 } catch(...) {
59 cerr << "Program terminated incorrectly with unknown error." << endl;
62 return 0;