author | nemo |
Sun, 24 Mar 2024 14:33:57 -0400 | |
changeset 16024 | 4c523ed1d35c |
parent 15919 | d52f5d8e75e6 |
child 16041 | caba603f461f |
permissions | -rw-r--r-- |
12854 | 1 |
import QtQuick 2.7 |
14164 | 2 |
import Hedgewars.Engine 1.0 |
12854 | 3 |
|
4 |
Page1Form { |
|
15919 | 5 |
focus: true |
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14393
diff
changeset
|
6 |
|
15919 | 7 |
property HWEngine hwEngine |
8 |
property NetSession netSession |
|
9 |
||
10 |
Component { |
|
11 |
id: hwEngineComponent |
|
14392
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14319
diff
changeset
|
12 |
|
15919 | 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 |
} |
|
14392
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14319
diff
changeset
|
20 |
} |
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14319
diff
changeset
|
21 |
|
15919 | 22 |
Component { |
23 |
id: netSessionComponent |
|
14936 | 24 |
|
15919 | 25 |
NetSession { |
26 |
nickname: "test0272" |
|
27 |
url: "hwnet://gameserver.hedgewars.org:46632" |
|
28 |
} |
|
14936 | 29 |
} |
30 |
||
15919 | 31 |
Component.onCompleted: { |
32 |
hwEngine = hwEngineComponent.createObject() |
|
33 |
} |
|
14392
90bd2c331703
Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents:
14319
diff
changeset
|
34 |
|
15919 | 35 |
tickButton { |
36 |
onClicked: { |
|
37 |
tickButton.visible = false |
|
38 |
gameView.tick(100) |
|
39 |
} |
|
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14393
diff
changeset
|
40 |
} |
15919 | 41 |
gameButton { |
42 |
visible: !gameView.engineInstance |
|
43 |
onClicked: { |
|
44 |
const engineInstance = hwEngine.runQuickGame() |
|
45 |
gameView.engineInstance = engineInstance |
|
46 |
} |
|
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14393
diff
changeset
|
47 |
} |
15919 | 48 |
button1 { |
49 |
visible: !gameView.engineInstance |
|
50 |
onClicked: { |
|
51 |
hwEngine.getPreview() |
|
52 |
} |
|
53 |
} |
|
54 |
netButton.onClicked: { |
|
55 |
netSession = netSessionComponent.createObject() |
|
56 |
netSession.open() |
|
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14393
diff
changeset
|
57 |
} |
15919 | 58 |
|
59 |
Keys.onPressed: { |
|
60 |
if (event.key === Qt.Key_Enter) |
|
61 |
gameView.engineInstance.longEvent(Engine.Attack, Engine.Set) |
|
62 |
} |
|
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14393
diff
changeset
|
63 |
|
15919 | 64 |
Keys.onReleased: { |
65 |
if (event.key === Qt.Key_Enter) |
|
66 |
gameView.engineInstance.longEvent(Engine.Attack, Engine.Unset) |
|
67 |
} |
|
12854 | 68 |
} |