author | Wuzzy <Wuzzy2@mail.ru> |
Tue, 07 May 2019 19:39:08 +0200 | |
changeset 14900 | 505c8d101be3 |
parent 14854 | aed75d439027 |
child 14915 | a3ad06ac390e |
permissions | -rw-r--r-- |
12854 | 1 |
import QtQuick 2.7 |
14143 | 2 |
import Hedgewars.Engine 1.0 |
12854 | 3 |
|
4 |
Page1Form { |
|
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
5 |
focus: true |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
6 |
|
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
7 |
property HWEngine hwEngine |
14371
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
8 |
|
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
9 |
Component { |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
10 |
id: hwEngineComponent |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
11 |
|
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
12 |
HWEngine { |
14372
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14371
diff
changeset
|
13 |
engineLibrary: "./libhedgewars_engine.so" |
14371
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
14 |
previewAcceptor: PreviewAcceptor |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
15 |
onPreviewImageChanged: previewImage.source = "image://preview/image" |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
16 |
onPreviewIsRendering: previewImage.source = "qrc:/res/iconTime.png" |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
17 |
} |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
18 |
} |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
19 |
|
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
20 |
Component.onCompleted: { |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
21 |
hwEngine = hwEngineComponent.createObject() |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
22 |
} |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
23 |
|
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
24 |
tickButton { |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
25 |
onClicked: { |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
26 |
tickButton.visible = false |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
27 |
gameView.tick(100) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
28 |
} |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
29 |
} |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
30 |
gameButton { |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
31 |
visible: !gameView.engineInstance |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
32 |
onClicked: { |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
33 |
var engineInstance = hwEngine.runQuickGame() |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
34 |
gameView.engineInstance = engineInstance |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
35 |
} |
14143 | 36 |
} |
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
37 |
button1 { |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
38 |
visible: !gameView.engineInstance |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
39 |
onClicked: { |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
40 |
hwEngine.getPreview() |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
41 |
} |
14143 | 42 |
} |
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
43 |
|
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
44 |
Keys.onPressed: { |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
45 |
if (event.key === Qt.Key_Enter) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
46 |
gameView.engineInstance.longEvent(EngineInstance.Attack, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
47 |
EngineInstance.Set) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
48 |
} |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
49 |
|
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
50 |
Keys.onReleased: { |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
51 |
if (event.key === Qt.Key_Enter) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
52 |
gameView.engineInstance.longEvent(EngineInstance.Attack, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
53 |
EngineInstance.Unset) |
12854 | 54 |
} |
55 |
} |