qmlfrontend/main.cpp
changeset 14376 90bd2c331703
parent 14375 ef2fc0210362
child 14377 b6824a53d4b1
--- a/qmlfrontend/main.cpp	Fri Dec 07 13:04:00 2018 +0100
+++ b/qmlfrontend/main.cpp	Fri Dec 07 13:35:08 2018 +0100
@@ -4,7 +4,9 @@
 #include <QQmlApplicationEngine>
 
 #include "engine_interface.h"
+#include "game_view.h"
 #include "hwengine.h"
+#include "preview_acceptor.h"
 
 namespace Engine {
 hedgewars_engine_protocol_version_t* hedgewars_engine_protocol_version;
@@ -18,6 +20,14 @@
 advance_simulation_t* advance_simulation;
 };  // namespace Engine
 
+static QObject* previewacceptor_singletontype_provider(
+    QQmlEngine* engine, QJSEngine* scriptEngine) {
+  Q_UNUSED(scriptEngine)
+
+  PreviewAcceptor* acceptor = new PreviewAcceptor(engine);
+  return acceptor;
+}
+
 void loadEngineLibrary() {
 #ifdef Q_OS_WIN
   QLibrary hwlib("./libhedgewars_engine.dll");
@@ -64,7 +74,14 @@
 
   QQmlApplicationEngine engine;
 
-  HWEngine::exposeToQML();
+  qmlRegisterSingletonType<PreviewAcceptor>(
+      "Hedgewars.Engine", 1, 0, "PreviewAcceptor",
+      previewacceptor_singletontype_provider);
+  qmlRegisterType<HWEngine>("Hedgewars.Engine", 1, 0, "HWEngine");
+  qmlRegisterType<GameView>("Hedgewars.Engine", 1, 0, "GameView");
+  qmlRegisterUncreatableType<EngineInstance>("Hedgewars.Engine", 1, 0,
+                                             "EngineInstance",
+                                             "Create by HWEngine run methods");
 
   engine.load(QUrl(QLatin1String("qrc:/main.qml")));
   if (engine.rootObjects().isEmpty()) return -1;