-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
55 lines (43 loc) · 986 Bytes
/
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
#include <QApplication>
#include <iostream>
#include <sstream>
#include <QDebug>
#include "view/invadeui.h"
#include "view/invadeconnection.h"
#include "model/unittype.h"
#include "model/position.h"
#include "model/unit.h"
#include "model/player.h"
#include "model/board.h"
#include "network/serverinvadeUI.h"
#include "network/serverinvadecli.h"
#include "network/clientinvade.h"
int main(int argc, char * argv[]) {
srand(time(NULL));
Images::reload();
if( argc >= 2 ) {
QCoreApplication a(argc, argv);
std::istringstream ss(argv[1]);
int port;
if (!(ss >> port)) {
qDebug() << "Invalide port";
return 1;
}
ServerInvadeCLI cli{port};
return a.exec();
} else {
QApplication a(argc, argv);
QWidget * w;
InvadeConnection c;
if( c.exec() == QDialog::Rejected ) {
return 0;
}
if( c.server() ) {
w = new ServerInvadeUI{ c.port() };
} else {
w = new InvadeUI{ c.name(), c.host(), c.port() };
}
w->show();
return a.exec();
}
}