author | unc0rr |
Sat, 21 Nov 2015 23:56:41 +0300 | |
branch | qmlfrontend |
changeset 11429 | 86c13e5662f1 |
parent 11428 | e045dc60c37e |
child 11435 | f88b3948adf3 |
permissions | -rw-r--r-- |
10402 | 1 |
#include <QLibrary> |
2 |
#include <QtQml> |
|
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
3 |
#include <QDebug> |
10420 | 4 |
#include <QPainter> |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
5 |
#include <QUuid> |
10402 | 6 |
|
7 |
#include "hwengine.h" |
|
10420 | 8 |
#include "previewimageprovider.h" |
10436 | 9 |
#include "themeiconprovider.h" |
10402 | 10 |
|
11 |
extern "C" { |
|
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
12 |
RunEngine_t *flibRunEngine; |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
13 |
registerUIMessagesCallback_t *flibRegisterUIMessagesCallback; |
10430 | 14 |
setSeed_t *flibSetSeed; |
15 |
getSeed_t *flibGetSeed; |
|
10456 | 16 |
setTheme_t *flibSetTheme; |
10612 | 17 |
setScript_t *flibSetScript; |
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
18 |
setScheme_t *flibSetScheme; |
10888 | 19 |
setAmmo_t *flibSetAmmo; |
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
20 |
getPreview_t *flibGetPreview; |
10432 | 21 |
runQuickGame_t *flibRunQuickGame; |
10448 | 22 |
runLocalGame_t *flibRunLocalGame; |
10416 | 23 |
flibInit_t *flibInit; |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
24 |
flibFree_t *flibFree; |
10450 | 25 |
resetGameConfig_t * flibResetGameConfig; |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
26 |
getThemesList_t *flibGetThemesList; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
27 |
freeThemesList_t *flibFreeThemesList; |
10436 | 28 |
getThemeIcon_t *flibGetThemeIcon; |
10517 | 29 |
getScriptsList_t *flibGetScriptsList; |
10616 | 30 |
getSchemesList_t *flibGetSchemesList; |
10888 | 31 |
getAmmosList_t *flibGetAmmosList; |
10442 | 32 |
getTeamsList_t *flibGetTeamsList; |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
33 |
tryAddTeam_t * flibTryAddTeam; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
34 |
tryRemoveTeam_t * flibTryRemoveTeam; |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
35 |
changeTeamColor_t * flibChangeTeamColor; |
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
36 |
|
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
37 |
connectOfficialServer_t * flibConnectOfficialServer; |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
38 |
passNetData_t * flibPassNetData; |
11421 | 39 |
sendChatLine_t * flibSendChatLine; |
11428 | 40 |
joinRoom_t * flibJoinRoom; |
11429 | 41 |
partRoom_t * flibPartRoom; |
10402 | 42 |
} |
10420 | 43 |
|
11429 | 44 |
Q_DECLARE_METATYPE(MessageType) |
10430 | 45 |
|
10420 | 46 |
HWEngine::HWEngine(QQmlEngine *engine, QObject *parent) : |
47 |
QObject(parent), |
|
48 |
m_engine(engine) |
|
10402 | 49 |
{ |
10430 | 50 |
qRegisterMetaType<MessageType>("MessageType"); |
51 |
||
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
52 |
QLibrary hwlib("./libhwengine.so"); |
10402 | 53 |
|
54 |
if(!hwlib.load()) |
|
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
55 |
qWarning() << "Engine library not found" << hwlib.errorString(); |
10402 | 56 |
|
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
57 |
flibRunEngine = (RunEngine_t*) hwlib.resolve("RunEngine"); |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
58 |
flibRegisterUIMessagesCallback = (registerUIMessagesCallback_t*) hwlib.resolve("registerUIMessagesCallback"); |
10430 | 59 |
flibGetSeed = (getSeed_t*) hwlib.resolve("getSeed"); |
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
60 |
flibGetPreview = (getPreview_t*) hwlib.resolve("getPreview"); |
10432 | 61 |
flibRunQuickGame = (runQuickGame_t*) hwlib.resolve("runQuickGame"); |
10448 | 62 |
flibRunLocalGame = (runLocalGame_t*) hwlib.resolve("runLocalGame"); |
10416 | 63 |
flibInit = (flibInit_t*) hwlib.resolve("flibInit"); |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
64 |
flibFree = (flibFree_t*) hwlib.resolve("flibFree"); |
10416 | 65 |
|
10612 | 66 |
flibSetSeed = (setSeed_t*) hwlib.resolve("setSeed"); |
67 |
flibSetTheme = (setTheme_t*) hwlib.resolve("setTheme"); |
|
68 |
flibSetScript = (setScript_t*) hwlib.resolve("setScript"); |
|
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
69 |
flibSetScheme = (setScheme_t*) hwlib.resolve("setScheme"); |
10888 | 70 |
flibSetAmmo = (setAmmo_t*) hwlib.resolve("setAmmo"); |
10612 | 71 |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
72 |
flibGetThemesList = (getThemesList_t*) hwlib.resolve("getThemesList"); |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
73 |
flibFreeThemesList = (freeThemesList_t*) hwlib.resolve("freeThemesList"); |
10436 | 74 |
flibGetThemeIcon = (getThemeIcon_t*) hwlib.resolve("getThemeIcon"); |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
75 |
|
10517 | 76 |
flibGetScriptsList = (getScriptsList_t*) hwlib.resolve("getScriptsList"); |
10616 | 77 |
flibGetSchemesList = (getSchemesList_t*) hwlib.resolve("getSchemesList"); |
10888 | 78 |
flibGetAmmosList = (getAmmosList_t*) hwlib.resolve("getAmmosList"); |
10517 | 79 |
|
10450 | 80 |
flibResetGameConfig = (resetGameConfig_t*) hwlib.resolve("resetGameConfig"); |
10442 | 81 |
flibGetTeamsList = (getTeamsList_t*) hwlib.resolve("getTeamsList"); |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
82 |
flibTryAddTeam = (tryAddTeam_t*) hwlib.resolve("tryAddTeam"); |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
83 |
flibTryRemoveTeam = (tryRemoveTeam_t*) hwlib.resolve("tryRemoveTeam"); |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
84 |
flibChangeTeamColor = (changeTeamColor_t*) hwlib.resolve("changeTeamColor"); |
10442 | 85 |
|
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
86 |
flibConnectOfficialServer = (connectOfficialServer_t*) hwlib.resolve("connectOfficialServer"); |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
87 |
flibPassNetData = (passNetData_t*) hwlib.resolve("passNetData"); |
11421 | 88 |
flibSendChatLine = (sendChatLine_t*) hwlib.resolve("sendChatLine"); |
11428 | 89 |
flibJoinRoom = (joinRoom_t*) hwlib.resolve("joinRoom"); |
11429 | 90 |
flibPartRoom = (partRoom_t*) hwlib.resolve("partRoom"); |
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
91 |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
92 |
flibInit("/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GC/share/hedgewars/Data", "/usr/home/unC0Rr/.hedgewars"); |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
93 |
flibRegisterUIMessagesCallback(this, &guiMessagesCallback); |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
94 |
|
10436 | 95 |
ThemeIconProvider * themeIcon = (ThemeIconProvider *)m_engine->imageProvider(QLatin1String("theme")); |
96 |
themeIcon->setFileContentsFunction(flibGetThemeIcon); |
|
97 |
||
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
98 |
fillModels(); |
10402 | 99 |
} |
100 |
||
101 |
HWEngine::~HWEngine() |
|
102 |
{ |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
103 |
flibFree(); |
10402 | 104 |
} |
105 |
||
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
106 |
void HWEngine::getPreview() |
10402 | 107 |
{ |
10430 | 108 |
flibSetSeed(QUuid::createUuid().toString().toLatin1()); |
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
109 |
flibGetPreview(); |
10402 | 110 |
} |
111 |
||
10432 | 112 |
void HWEngine::runQuickGame() |
113 |
{ |
|
114 |
flibSetSeed(QUuid::createUuid().toString().toLatin1()); |
|
115 |
flibRunQuickGame(); |
|
116 |
} |
|
117 |
||
10448 | 118 |
void HWEngine::runLocalGame() |
119 |
{ |
|
120 |
flibRunLocalGame(); |
|
121 |
} |
|
122 |
||
123 |
||
10402 | 124 |
static QObject *hwengine_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) |
125 |
{ |
|
126 |
Q_UNUSED(scriptEngine) |
|
127 |
||
10420 | 128 |
HWEngine *hwengine = new HWEngine(engine); |
10402 | 129 |
return hwengine; |
130 |
} |
|
131 |
||
132 |
void HWEngine::exposeToQML() |
|
133 |
{ |
|
134 |
qDebug("HWEngine::exposeToQML"); |
|
135 |
qmlRegisterSingletonType<HWEngine>("Hedgewars.Engine", 1, 0, "HWEngine", hwengine_singletontype_provider); |
|
136 |
} |
|
10416 | 137 |
|
138 |
||
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
139 |
void HWEngine::guiMessagesCallback(void *context, MessageType mt, const char * msg, uint32_t len) |
10420 | 140 |
{ |
141 |
HWEngine * obj = (HWEngine *)context; |
|
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
142 |
QByteArray b = QByteArray(msg, len); |
10420 | 143 |
|
11420 | 144 |
//qDebug() << "FLIPC in" << b.size() << b; |
10420 | 145 |
|
10430 | 146 |
QMetaObject::invokeMethod(obj, "engineMessageHandler", Qt::QueuedConnection, Q_ARG(MessageType, mt), Q_ARG(QByteArray, b)); |
10416 | 147 |
} |
148 |
||
10430 | 149 |
void HWEngine::engineMessageHandler(MessageType mt, const QByteArray &msg) |
10416 | 150 |
{ |
10430 | 151 |
switch(mt) |
10426 | 152 |
{ |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
153 |
case MSG_PREVIEW: { |
10426 | 154 |
PreviewImageProvider * preview = (PreviewImageProvider *)m_engine->imageProvider(QLatin1String("preview")); |
155 |
preview->setPixmap(msg); |
|
156 |
emit previewImageChanged(); |
|
10430 | 157 |
break; |
10426 | 158 |
} |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
159 |
case MSG_ADDPLAYINGTEAM: { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
160 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
161 |
emit playingTeamAdded(l[1], l[0].toInt(), true); |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
162 |
break; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
163 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
164 |
case MSG_REMOVEPLAYINGTEAM: { |
11420 | 165 |
emit playingTeamRemoved(QString::fromUtf8(msg)); |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
166 |
break; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
167 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
168 |
case MSG_ADDTEAM: { |
11420 | 169 |
emit localTeamAdded(QString::fromUtf8(msg), 0); |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
170 |
break; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
171 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
172 |
case MSG_REMOVETEAM: { |
11420 | 173 |
emit localTeamRemoved(QString::fromUtf8(msg)); |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
174 |
break; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
175 |
} |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
176 |
case MSG_TEAMCOLOR: { |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
177 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
178 |
emit teamColorChanged(l[0], QColor::fromRgba(l[1].toInt()).name()); |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
179 |
break; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
180 |
} |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
181 |
case MSG_NETDATA: { |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
182 |
flibPassNetData(msg.constData()); |
11420 | 183 |
break; |
184 |
} |
|
185 |
case MSG_CONNECTED: { |
|
186 |
emit netConnected(); |
|
187 |
break; |
|
188 |
} |
|
189 |
case MSG_DISCONNECTED: { |
|
190 |
emit netDisconnected(QString::fromUtf8(msg)); |
|
191 |
break; |
|
192 |
} |
|
193 |
case MSG_ADDLOBBYCLIENT: { |
|
194 |
emit lobbyClientAdded(QString::fromUtf8(msg)); |
|
195 |
break; |
|
196 |
} |
|
197 |
case MSG_REMOVELOBBYCLIENT: { |
|
11428 | 198 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
199 |
emit lobbyClientRemoved(l[0], l[1]); |
|
11420 | 200 |
break; |
201 |
} |
|
202 |
case MSG_LOBBYCHATLINE: { |
|
203 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
|
204 |
emit lobbyChatLine(l[0], l[1]); |
|
205 |
break; |
|
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
206 |
} |
11429 | 207 |
case MSG_ADDROOMCLIENT: { |
208 |
emit roomClientAdded(QString::fromUtf8(msg)); |
|
209 |
break; |
|
210 |
} |
|
211 |
case MSG_REMOVEROOMCLIENT: { |
|
212 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
|
213 |
emit roomClientRemoved(l[0], l[1]); |
|
214 |
break; |
|
215 |
} |
|
216 |
case MSG_ROOMCHATLINE: { |
|
217 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
|
218 |
emit roomChatLine(l[0], l[1]); |
|
219 |
break; |
|
220 |
} |
|
11423 | 221 |
case MSG_ADDROOM: { |
222 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
|
223 |
emit roomAdded(0, l[1], l[2].toInt(), l[3].toInt(), l[4], l[5], l[6], l[7], l[8]); |
|
224 |
break; |
|
225 |
} |
|
226 |
case MSG_UPDATEROOM: { |
|
11427 | 227 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
228 |
emit roomUpdated(l[0], 0, l[2], l[3].toInt(), l[4].toInt(), l[5], l[6], l[7], l[8], l[9]); |
|
11423 | 229 |
break; |
230 |
} |
|
231 |
case MSG_REMOVEROOM: { |
|
11424 | 232 |
emit roomRemoved(QString::fromUtf8(msg)); |
11423 | 233 |
break; |
234 |
} |
|
11428 | 235 |
case MSG_ERROR: { |
236 |
emit errorMessage(QString::fromUtf8(msg)); |
|
237 |
break; |
|
238 |
} |
|
239 |
case MSG_WARNING: { |
|
240 |
emit warningMessage(QString::fromUtf8(msg)); |
|
241 |
break; |
|
242 |
} |
|
11429 | 243 |
case MSG_MOVETOLOBBY: { |
244 |
emit movedToLobby(); |
|
245 |
break; |
|
246 |
} |
|
247 |
case MSG_MOVETOROOM: { |
|
248 |
emit movedToRoom(); |
|
249 |
break; |
|
250 |
} |
|
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
251 |
} |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
252 |
} |
10416 | 253 |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
254 |
QString HWEngine::currentSeed() |
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
255 |
{ |
10430 | 256 |
return QString::fromLatin1(flibGetSeed()); |
10416 | 257 |
} |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
258 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
259 |
void HWEngine::fillModels() |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
260 |
{ |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
261 |
QStringList resultModel; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
262 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
263 |
char ** themes = flibGetThemesList(); |
10616 | 264 |
for (char **i = themes; *i != NULL; i++) |
265 |
resultModel << QString::fromUtf8(*i); |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
266 |
flibFreeThemesList(themes); |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
267 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
268 |
m_engine->rootContext()->setContextProperty("themesModel", QVariant::fromValue(resultModel)); |
10612 | 269 |
|
10616 | 270 |
// scripts model |
10612 | 271 |
resultModel.clear(); |
10616 | 272 |
for (char **i = flibGetScriptsList(); *i != NULL; i++) |
273 |
resultModel << QString::fromUtf8(*i); |
|
10612 | 274 |
|
275 |
m_engine->rootContext()->setContextProperty("scriptsModel", QVariant::fromValue(resultModel)); |
|
10616 | 276 |
|
277 |
// schemes model |
|
278 |
resultModel.clear(); |
|
279 |
for (char **i = flibGetSchemesList(); *i != NULL; i++) |
|
280 |
resultModel << QString::fromUtf8(*i); |
|
281 |
||
282 |
m_engine->rootContext()->setContextProperty("schemesModel", QVariant::fromValue(resultModel)); |
|
10888 | 283 |
|
284 |
// ammos model |
|
285 |
resultModel.clear(); |
|
286 |
for (char **i = flibGetAmmosList(); *i != NULL; i++) |
|
287 |
resultModel << QString::fromUtf8(*i); |
|
288 |
||
289 |
m_engine->rootContext()->setContextProperty("ammosModel", QVariant::fromValue(resultModel)); |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
290 |
} |
10442 | 291 |
|
292 |
void HWEngine::getTeamsList() |
|
293 |
{ |
|
294 |
char ** teams = flibGetTeamsList(); |
|
295 |
for (char **i = teams; *i != NULL; i++) { |
|
296 |
QString team = QString::fromUtf8(*i); |
|
297 |
||
298 |
emit localTeamAdded(team, 0); |
|
299 |
} |
|
300 |
} |
|
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
301 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
302 |
void HWEngine::tryAddTeam(const QString &teamName) |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
303 |
{ |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
304 |
flibTryAddTeam(teamName.toUtf8().constData()); |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
305 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
306 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
307 |
void HWEngine::tryRemoveTeam(const QString &teamName) |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
308 |
{ |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
309 |
flibTryRemoveTeam(teamName.toUtf8().constData()); |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
310 |
} |
10450 | 311 |
|
312 |
void HWEngine::resetGameConfig() |
|
313 |
{ |
|
314 |
flibResetGameConfig(); |
|
315 |
} |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
316 |
|
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
317 |
void HWEngine::changeTeamColor(const QString &teamName, int dir) |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
318 |
{ |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
319 |
flibChangeTeamColor(teamName.toUtf8().constData(), dir); |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
320 |
} |
10456 | 321 |
|
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
322 |
void HWEngine::connect(const QString &host, quint16 port) |
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
323 |
{ |
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
324 |
flibConnectOfficialServer(); |
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
325 |
} |
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
326 |
|
11421 | 327 |
void HWEngine::sendChatMessage(const QString &msg) |
328 |
{ |
|
329 |
flibSendChatLine(msg.toUtf8().constData()); |
|
330 |
} |
|
331 |
||
11428 | 332 |
void HWEngine::joinRoom(const QString &roomName) |
333 |
{ |
|
334 |
flibJoinRoom(roomName.toUtf8().constData()); |
|
335 |
} |
|
336 |
||
11429 | 337 |
void HWEngine::partRoom(const QString &message) |
338 |
{ |
|
339 |
flibPartRoom(message.toUtf8().constData()); |
|
340 |
} |
|
341 |
||
10456 | 342 |
void HWEngine::setTheme(const QString &theme) |
343 |
{ |
|
344 |
flibSetTheme(theme.toUtf8().constData()); |
|
345 |
} |
|
10612 | 346 |
|
347 |
void HWEngine::setScript(const QString &script) |
|
348 |
{ |
|
349 |
flibSetScript(script.toUtf8().constData()); |
|
350 |
} |
|
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
351 |
|
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
352 |
void HWEngine::setScheme(const QString &scheme) |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
353 |
{ |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
354 |
flibSetScheme(scheme.toUtf8().constData()); |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
355 |
} |
10888 | 356 |
|
357 |
void HWEngine::setAmmo(const QString &ammo) |
|
358 |
{ |
|
359 |
flibSetAmmo(ammo.toUtf8().constData()); |
|
360 |
} |