author | unc0rr |
Sat, 21 Nov 2015 12:40:33 +0300 | |
branch | qmlfrontend |
changeset 11422 | c6c6a4b32cea |
parent 11419 | 8a5cc31483c6 |
child 11423 | e045dc60c37e |
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; |
11416 | 39 |
sendChatLine_t * flibSendChatLine; |
10402 | 40 |
} |
10420 | 41 |
|
10430 | 42 |
Q_DECLARE_METATYPE(MessageType); |
43 |
||
10420 | 44 |
HWEngine::HWEngine(QQmlEngine *engine, QObject *parent) : |
45 |
QObject(parent), |
|
46 |
m_engine(engine) |
|
10402 | 47 |
{ |
10430 | 48 |
qRegisterMetaType<MessageType>("MessageType"); |
49 |
||
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
50 |
QLibrary hwlib("./libhwengine.so"); |
10402 | 51 |
|
52 |
if(!hwlib.load()) |
|
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
53 |
qWarning() << "Engine library not found" << hwlib.errorString(); |
10402 | 54 |
|
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
55 |
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
|
56 |
flibRegisterUIMessagesCallback = (registerUIMessagesCallback_t*) hwlib.resolve("registerUIMessagesCallback"); |
10430 | 57 |
flibGetSeed = (getSeed_t*) hwlib.resolve("getSeed"); |
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
58 |
flibGetPreview = (getPreview_t*) hwlib.resolve("getPreview"); |
10432 | 59 |
flibRunQuickGame = (runQuickGame_t*) hwlib.resolve("runQuickGame"); |
10448 | 60 |
flibRunLocalGame = (runLocalGame_t*) hwlib.resolve("runLocalGame"); |
10416 | 61 |
flibInit = (flibInit_t*) hwlib.resolve("flibInit"); |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
62 |
flibFree = (flibFree_t*) hwlib.resolve("flibFree"); |
10416 | 63 |
|
10612 | 64 |
flibSetSeed = (setSeed_t*) hwlib.resolve("setSeed"); |
65 |
flibSetTheme = (setTheme_t*) hwlib.resolve("setTheme"); |
|
66 |
flibSetScript = (setScript_t*) hwlib.resolve("setScript"); |
|
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
67 |
flibSetScheme = (setScheme_t*) hwlib.resolve("setScheme"); |
10888 | 68 |
flibSetAmmo = (setAmmo_t*) hwlib.resolve("setAmmo"); |
10612 | 69 |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
70 |
flibGetThemesList = (getThemesList_t*) hwlib.resolve("getThemesList"); |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
71 |
flibFreeThemesList = (freeThemesList_t*) hwlib.resolve("freeThemesList"); |
10436 | 72 |
flibGetThemeIcon = (getThemeIcon_t*) hwlib.resolve("getThemeIcon"); |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
73 |
|
10517 | 74 |
flibGetScriptsList = (getScriptsList_t*) hwlib.resolve("getScriptsList"); |
10616 | 75 |
flibGetSchemesList = (getSchemesList_t*) hwlib.resolve("getSchemesList"); |
10888 | 76 |
flibGetAmmosList = (getAmmosList_t*) hwlib.resolve("getAmmosList"); |
10517 | 77 |
|
10450 | 78 |
flibResetGameConfig = (resetGameConfig_t*) hwlib.resolve("resetGameConfig"); |
10442 | 79 |
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
|
80 |
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
|
81 |
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
|
82 |
flibChangeTeamColor = (changeTeamColor_t*) hwlib.resolve("changeTeamColor"); |
10442 | 83 |
|
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
84 |
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
|
85 |
flibPassNetData = (passNetData_t*) hwlib.resolve("passNetData"); |
11416 | 86 |
flibSendChatLine = (sendChatLine_t*) hwlib.resolve("sendChatLine"); |
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
87 |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
88 |
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
|
89 |
flibRegisterUIMessagesCallback(this, &guiMessagesCallback); |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
90 |
|
10436 | 91 |
ThemeIconProvider * themeIcon = (ThemeIconProvider *)m_engine->imageProvider(QLatin1String("theme")); |
92 |
themeIcon->setFileContentsFunction(flibGetThemeIcon); |
|
93 |
||
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
94 |
fillModels(); |
10402 | 95 |
} |
96 |
||
97 |
HWEngine::~HWEngine() |
|
98 |
{ |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
99 |
flibFree(); |
10402 | 100 |
} |
101 |
||
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
102 |
void HWEngine::getPreview() |
10402 | 103 |
{ |
10430 | 104 |
flibSetSeed(QUuid::createUuid().toString().toLatin1()); |
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
105 |
flibGetPreview(); |
10402 | 106 |
} |
107 |
||
10432 | 108 |
void HWEngine::runQuickGame() |
109 |
{ |
|
110 |
flibSetSeed(QUuid::createUuid().toString().toLatin1()); |
|
111 |
flibRunQuickGame(); |
|
112 |
} |
|
113 |
||
10448 | 114 |
void HWEngine::runLocalGame() |
115 |
{ |
|
116 |
flibRunLocalGame(); |
|
117 |
} |
|
118 |
||
119 |
||
10402 | 120 |
static QObject *hwengine_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) |
121 |
{ |
|
122 |
Q_UNUSED(scriptEngine) |
|
123 |
||
10420 | 124 |
HWEngine *hwengine = new HWEngine(engine); |
10402 | 125 |
return hwengine; |
126 |
} |
|
127 |
||
128 |
void HWEngine::exposeToQML() |
|
129 |
{ |
|
130 |
qDebug("HWEngine::exposeToQML"); |
|
131 |
qmlRegisterSingletonType<HWEngine>("Hedgewars.Engine", 1, 0, "HWEngine", hwengine_singletontype_provider); |
|
132 |
} |
|
10416 | 133 |
|
134 |
||
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
135 |
void HWEngine::guiMessagesCallback(void *context, MessageType mt, const char * msg, uint32_t len) |
10420 | 136 |
{ |
137 |
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
|
138 |
QByteArray b = QByteArray(msg, len); |
10420 | 139 |
|
11415 | 140 |
//qDebug() << "FLIPC in" << b.size() << b; |
10420 | 141 |
|
10430 | 142 |
QMetaObject::invokeMethod(obj, "engineMessageHandler", Qt::QueuedConnection, Q_ARG(MessageType, mt), Q_ARG(QByteArray, b)); |
10416 | 143 |
} |
144 |
||
10430 | 145 |
void HWEngine::engineMessageHandler(MessageType mt, const QByteArray &msg) |
10416 | 146 |
{ |
10430 | 147 |
switch(mt) |
10426 | 148 |
{ |
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
|
149 |
case MSG_PREVIEW: { |
10426 | 150 |
PreviewImageProvider * preview = (PreviewImageProvider *)m_engine->imageProvider(QLatin1String("preview")); |
151 |
preview->setPixmap(msg); |
|
152 |
emit previewImageChanged(); |
|
10430 | 153 |
break; |
10426 | 154 |
} |
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
|
155 |
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
|
156 |
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
|
157 |
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
|
158 |
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
|
159 |
} |
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 |
case MSG_REMOVEPLAYINGTEAM: { |
11415 | 161 |
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
|
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_ADDTEAM: { |
11415 | 165 |
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
|
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_REMOVETEAM: { |
11415 | 169 |
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
|
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 |
} |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
172 |
case MSG_TEAMCOLOR: { |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
173 |
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
|
174 |
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
|
175 |
break; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
176 |
} |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
177 |
case MSG_NETDATA: { |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
178 |
flibPassNetData(msg.constData()); |
11415 | 179 |
break; |
180 |
} |
|
181 |
case MSG_CONNECTED: { |
|
182 |
emit netConnected(); |
|
183 |
break; |
|
184 |
} |
|
185 |
case MSG_DISCONNECTED: { |
|
186 |
emit netDisconnected(QString::fromUtf8(msg)); |
|
187 |
break; |
|
188 |
} |
|
189 |
case MSG_ADDLOBBYCLIENT: { |
|
190 |
emit lobbyClientAdded(QString::fromUtf8(msg)); |
|
191 |
break; |
|
192 |
} |
|
193 |
case MSG_REMOVELOBBYCLIENT: { |
|
194 |
emit lobbyClientRemoved(QString::fromUtf8(msg)); |
|
195 |
break; |
|
196 |
} |
|
197 |
case MSG_LOBBYCHATLINE: { |
|
198 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
|
199 |
emit lobbyChatLine(l[0], l[1]); |
|
200 |
break; |
|
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10896
diff
changeset
|
201 |
} |
11418 | 202 |
case MSG_ADDROOM: { |
203 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
|
204 |
emit roomAdded(0, l[1], l[2].toInt(), l[3].toInt(), l[4], l[5], l[6], l[7], l[8]); |
|
205 |
break; |
|
206 |
} |
|
207 |
case MSG_UPDATEROOM: { |
|
11422 | 208 |
QStringList l = QString::fromUtf8(msg).split('\n'); |
209 |
emit roomUpdated(l[0], 0, l[2], l[3].toInt(), l[4].toInt(), l[5], l[6], l[7], l[8], l[9]); |
|
11418 | 210 |
break; |
211 |
} |
|
212 |
case MSG_REMOVEROOM: { |
|
11419 | 213 |
emit roomRemoved(QString::fromUtf8(msg)); |
11418 | 214 |
break; |
215 |
} |
|
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
|
216 |
} |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
217 |
} |
10416 | 218 |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
219 |
QString HWEngine::currentSeed() |
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10420
diff
changeset
|
220 |
{ |
10430 | 221 |
return QString::fromLatin1(flibGetSeed()); |
10416 | 222 |
} |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
223 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
224 |
void HWEngine::fillModels() |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
225 |
{ |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
226 |
QStringList resultModel; |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
227 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
228 |
char ** themes = flibGetThemesList(); |
10616 | 229 |
for (char **i = themes; *i != NULL; i++) |
230 |
resultModel << QString::fromUtf8(*i); |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
231 |
flibFreeThemesList(themes); |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
232 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
233 |
m_engine->rootContext()->setContextProperty("themesModel", QVariant::fromValue(resultModel)); |
10612 | 234 |
|
10616 | 235 |
// scripts model |
10612 | 236 |
resultModel.clear(); |
10616 | 237 |
for (char **i = flibGetScriptsList(); *i != NULL; i++) |
238 |
resultModel << QString::fromUtf8(*i); |
|
10612 | 239 |
|
240 |
m_engine->rootContext()->setContextProperty("scriptsModel", QVariant::fromValue(resultModel)); |
|
10616 | 241 |
|
242 |
// schemes model |
|
243 |
resultModel.clear(); |
|
244 |
for (char **i = flibGetSchemesList(); *i != NULL; i++) |
|
245 |
resultModel << QString::fromUtf8(*i); |
|
246 |
||
247 |
m_engine->rootContext()->setContextProperty("schemesModel", QVariant::fromValue(resultModel)); |
|
10888 | 248 |
|
249 |
// ammos model |
|
250 |
resultModel.clear(); |
|
251 |
for (char **i = flibGetAmmosList(); *i != NULL; i++) |
|
252 |
resultModel << QString::fromUtf8(*i); |
|
253 |
||
254 |
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
|
255 |
} |
10442 | 256 |
|
257 |
void HWEngine::getTeamsList() |
|
258 |
{ |
|
259 |
char ** teams = flibGetTeamsList(); |
|
260 |
for (char **i = teams; *i != NULL; i++) { |
|
261 |
QString team = QString::fromUtf8(*i); |
|
262 |
||
263 |
emit localTeamAdded(team, 0); |
|
264 |
} |
|
265 |
} |
|
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
|
266 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
267 |
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
|
268 |
{ |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
269 |
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
|
270 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
271 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
272 |
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
|
273 |
{ |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
274 |
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
|
275 |
} |
10450 | 276 |
|
277 |
void HWEngine::resetGameConfig() |
|
278 |
{ |
|
279 |
flibResetGameConfig(); |
|
280 |
} |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
281 |
|
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
282 |
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
|
283 |
{ |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
284 |
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
|
285 |
} |
10456 | 286 |
|
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
287 |
void HWEngine::connect(const QString &host, quint16 port) |
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
288 |
{ |
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
289 |
flibConnectOfficialServer(); |
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
290 |
} |
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
291 |
|
11416 | 292 |
void HWEngine::sendChatMessage(const QString &msg) |
293 |
{ |
|
294 |
flibSendChatLine(msg.toUtf8().constData()); |
|
295 |
} |
|
296 |
||
10456 | 297 |
void HWEngine::setTheme(const QString &theme) |
298 |
{ |
|
299 |
flibSetTheme(theme.toUtf8().constData()); |
|
300 |
} |
|
10612 | 301 |
|
302 |
void HWEngine::setScript(const QString &script) |
|
303 |
{ |
|
304 |
flibSetScript(script.toUtf8().constData()); |
|
305 |
} |
|
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
306 |
|
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
307 |
void HWEngine::setScheme(const QString &scheme) |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
308 |
{ |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
309 |
flibSetScheme(scheme.toUtf8().constData()); |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
310 |
} |
10888 | 311 |
|
312 |
void HWEngine::setAmmo(const QString &ammo) |
|
313 |
{ |
|
314 |
flibSetAmmo(ammo.toUtf8().constData()); |
|
315 |
} |