-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
96 lines (76 loc) · 3.64 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <QApplication>
#include <VPApplication>
#include <QQmlApplicationEngine>
#include <QDebug>
#include <iostream>
#include "server.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
VPApplication vplay;
// QQmlApplicationEngine is the preferred way to start qml projects since Qt 5.2
// if you have older projects using Qt App wizards from previous QtCreator versions than 3.1, please change them to QQmlApplicationEngine
QQmlApplicationEngine engine;
vplay.initialize(&engine);
// use this during development
// for PUBLISHING, use the entry point below
vplay.setMainQmlFileName(QStringLiteral("qml/Main.qml"));
// use this instead of the above call to avoid deployment of the qml files and compile them into the binary with qt's resource system qrc
// this is the preferred deployment option for publishing games to the app stores, because then your qml files and js files are protected
// to avoid deployment of your qml files and images, also comment the DEPLOYMENTFOLDERS command in the .pro file
// also see the .pro file for more details
// vplay.setMainQmlFileName(QStringLiteral("qrc:/qml/Main.qml"));
engine.load(QUrl(vplay.mainQmlFileName()));
for (int i=0;i<engine.rootObjects()[0]->children().size();i++)
{
qDebug() << i;
qDebug() << engine.rootObjects()[0]->children()[i];
qDebug() << engine.rootObjects()[0]->children()[i]->children();
}
// const QObject* item = engine.rootObjects()[0]->children()[10]->children()[10];
// const QMetaObject *meta = item->metaObject();
// QHash<QString, QVariant> list;
// for (int i = 0; i < meta->propertyCount(); i++)
// {
// QMetaProperty property = meta->property(i);
// const char* name = property.name();
// QVariant value = item->property(name);
// list[name] = value;
// }
// QString out;
// QHashIterator<QString, QVariant> i(list);
// while (i.hasNext()) {
// i.next();
// if (!out.isEmpty())
// {
// out += ", ";
// out += " ";
// }
// out.append(i.key());
// out.append(": ");
// out.append(i.value().toString());
// }
// qDebug() << out ;
// gamescene pos at 11, selectlevelscene at 9
auto object = engine.rootObjects()[0]->children()[11]->findChild<QObject*>(QLatin1Literal("Load_BABY"));
auto object_select = engine.rootObjects()[0]->children()[9];
qDebug() << object;
// QVariant returnedValue;
// QVariant msg = "Hello from C++";
// QMetaObject::invokeMethod(object, "myQmlFunction",
// Q_RETURN_ARG(QVariant, returnedValue),
// Q_ARG(QVariant, msg));
// qDebug() << "QML function returned:" << returnedValue.toString();
Server server(0, 7777);
QObject::connect(&server, SIGNAL(userConnected(int)), object_select, SIGNAL(userConnected(int)) );
QObject::connect(&server, SIGNAL(punchChanged(int)), object, SIGNAL(punchHit(int)));
QObject::connect(&server, SIGNAL(actionChanged(int)), object, SIGNAL(actionTake(int)));
QObject::connect(&server, SIGNAL(userDisconnected(int) ), object, SIGNAL(userDisconnected(int)));
Server server_zeus(0, 8888); // user 1 zeus
QObject::connect(&server_zeus, SIGNAL(userConnected(int)), object_select, SIGNAL(userConnected(int)) );
QObject::connect(&server_zeus, SIGNAL(punchChanged(int)), object, SIGNAL(punchHit_zeus(int)));
QObject::connect(&server_zeus, SIGNAL(actionChanged(int)), object, SIGNAL(actionTake_zeus(int)));
QObject::connect(&server_zeus, SIGNAL(userDisconnected(int) ), object, SIGNAL(userDisconnected(int)));
//return 0;
return app.exec();
}