author | alfadur <mail@none> |
Sat, 08 Apr 2023 16:45:55 +0300 | |
changeset 15949 | 668c88b31dd6 |
parent 15891 | d52f5d8e75e6 |
child 16012 | caba603f461f |
permissions | -rw-r--r-- |
12854 | 1 |
import QtQuick 2.7 |
14143 | 2 |
import Hedgewars.Engine 1.0 |
12854 | 3 |
|
4 |
Page1Form { |
|
15891 | 5 |
focus: true |
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
6 |
|
15891 | 7 |
property HWEngine hwEngine |
8 |
property NetSession netSession |
|
9 |
||
10 |
Component { |
|
11 |
id: hwEngineComponent |
|
14371
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
12 |
|
15891 | 13 |
HWEngine { |
14 |
engineLibrary: "../rust/lib-hedgewars-engine/target/debug/libhedgewars_engine.so" |
|
15 |
dataPath: "../share/hedgewars/Data" |
|
16 |
previewAcceptor: PreviewAcceptor |
|
17 |
onPreviewImageChanged: previewImage.source = "image://preview/image" |
|
18 |
onPreviewIsRendering: previewImage.source = "qrc:/res/iconTime.png" |
|
19 |
} |
|
14371
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
20 |
} |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
21 |
|
15891 | 22 |
Component { |
23 |
id: netSessionComponent |
|
14915 | 24 |
|
15891 | 25 |
NetSession { |
26 |
nickname: "test0272" |
|
27 |
url: "hwnet://gameserver.hedgewars.org:46632" |
|
28 |
} |
|
14915 | 29 |
} |
30 |
||
15891 | 31 |
Component.onCompleted: { |
32 |
hwEngine = hwEngineComponent.createObject() |
|
33 |
} |
|
14371
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14298
diff
changeset
|
34 |
|
15891 | 35 |
tickButton { |
36 |
onClicked: { |
|
37 |
tickButton.visible = false |
|
38 |
gameView.tick(100) |
|
39 |
} |
|
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
40 |
} |
15891 | 41 |
gameButton { |
42 |
visible: !gameView.engineInstance |
|
43 |
onClicked: { |
|
44 |
const engineInstance = hwEngine.runQuickGame() |
|
45 |
gameView.engineInstance = engineInstance |
|
46 |
} |
|
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
47 |
} |
15891 | 48 |
button1 { |
49 |
visible: !gameView.engineInstance |
|
50 |
onClicked: { |
|
51 |
hwEngine.getPreview() |
|
52 |
} |
|
53 |
} |
|
54 |
netButton.onClicked: { |
|
55 |
netSession = netSessionComponent.createObject() |
|
56 |
netSession.open() |
|
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
57 |
} |
15891 | 58 |
|
59 |
Keys.onPressed: { |
|
60 |
if (event.key === Qt.Key_Enter) |
|
61 |
gameView.engineInstance.longEvent(Engine.Attack, Engine.Set) |
|
62 |
} |
|
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14372
diff
changeset
|
63 |
|
15891 | 64 |
Keys.onReleased: { |
65 |
if (event.key === Qt.Key_Enter) |
|
66 |
gameView.engineInstance.longEvent(Engine.Attack, Engine.Unset) |
|
67 |
} |
|
12854 | 68 |
} |