qmlfrontend/Page1.qml
author Wuzzy <Wuzzy2@mail.ru>
Sun, 26 May 2019 14:27:55 +0200
changeset 15074 e3b3fa42a93b
parent 14936 a3ad06ac390e
child 15238 b32c52c76977
permissions -rw-r--r--
IsHogLocal: If there's a mission team, only count members in the clan of that team This attends to a hack in some missions which use fake human teams in the enemy clans for animation purposes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12854
28cb18c5e712 Add new qmlfrontend project template
unc0rr
parents:
diff changeset
     1
import QtQuick 2.7
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents: 12854
diff changeset
     2
import Hedgewars.Engine 1.0
12854
28cb18c5e712 Add new qmlfrontend project template
unc0rr
parents:
diff changeset
     3
28cb18c5e712 Add new qmlfrontend project template
unc0rr
parents:
diff changeset
     4
Page1Form {
14875
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
     5
  focus: true
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
     6
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
     7
  property HWEngine hwEngine
14936
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
     8
  property NetSession netSession
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
     9
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    10
  Component {
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    11
    id: hwEngineComponent
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    12
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    13
    HWEngine {
14393
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14392
diff changeset
    14
      engineLibrary: "./libhedgewars_engine.so"
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    15
      previewAcceptor: PreviewAcceptor
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    16
      onPreviewImageChanged: previewImage.source = "image://preview/image"
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    17
      onPreviewIsRendering: previewImage.source = "qrc:/res/iconTime.png"
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    18
    }
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    19
  }
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    20
14936
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    21
  Component {
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    22
    id: netSessionComponent
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    23
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    24
    NetSession {
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    25
      nickname: "test0272"
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    26
      url: "hwnet://gameserver.hedgewars.org:46632"
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    27
    }
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    28
  }
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    29
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    30
  Component.onCompleted: {
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    31
    hwEngine = hwEngineComponent.createObject()
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    32
  }
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    33
14875
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    34
  tickButton {
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    35
    onClicked: {
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    36
      tickButton.visible = false
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    37
      gameView.tick(100)
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    38
    }
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    39
  }
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    40
  gameButton {
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    41
    visible: !gameView.engineInstance
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    42
    onClicked: {
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    43
      var engineInstance = hwEngine.runQuickGame()
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    44
      gameView.engineInstance = engineInstance
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    45
    }
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents: 12854
diff changeset
    46
  }
14875
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    47
  button1 {
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    48
    visible: !gameView.engineInstance
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    49
    onClicked: {
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    50
      hwEngine.getPreview()
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    51
    }
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents: 12854
diff changeset
    52
  }
14936
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    53
  netButton.onClicked: {
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    54
    netSession = netSessionComponent.createObject()
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    55
    netSession.open()
a3ad06ac390e Proof of concept for new net game client
unc0rr
parents: 14875
diff changeset
    56
  }
14875
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    57
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    58
  Keys.onPressed: {
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    59
    if (event.key === Qt.Key_Enter)
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    60
      gameView.engineInstance.longEvent(EngineInstance.Attack,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    61
                                        EngineInstance.Set)
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    62
  }
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    63
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    64
  Keys.onReleased: {
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    65
    if (event.key === Qt.Key_Enter)
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    66
      gameView.engineInstance.longEvent(EngineInstance.Attack,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14393
diff changeset
    67
                                        EngineInstance.Unset)
12854
28cb18c5e712 Add new qmlfrontend project template
unc0rr
parents:
diff changeset
    68
  }
28cb18c5e712 Add new qmlfrontend project template
unc0rr
parents:
diff changeset
    69
}