qmlfrontend/Page1.qml
author unC0Rr
Fri, 07 Dec 2018 13:35:08 +0100
changeset 14376 90bd2c331703
parent 14303 00b56ec8b7df
child 14377 b6824a53d4b1
permissions -rw-r--r--
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview

import QtQuick 2.7
import Hedgewars.Engine 1.0

Page1Form {
  property var hwEngine

  Component {
    id: hwEngineComponent

    HWEngine {
      previewAcceptor: PreviewAcceptor
      onPreviewImageChanged: previewImage.source = "image://preview/image"
      onPreviewIsRendering: previewImage.source = "qrc:/res/iconTime.png"
    }
  }

  Component.onCompleted: {
    hwEngine = hwEngineComponent.createObject()
  }

  tickButton.onClicked: {
    gameView.tick(100)
  }
  gameButton.onClicked: {
    var engineInstance = hwEngine.runQuickGame()
    gameView.engineInstance = engineInstance
  }
  button1.onClicked: {
    hwEngine.getPreview()
  }
}