1 import QtQuick 2.7 |
1 import QtQuick 2.7 |
2 import Hedgewars.Engine 1.0 |
2 import Hedgewars.Engine 1.0 |
3 |
3 |
4 Page1Form { |
4 Page1Form { |
5 focus: true |
5 focus: true |
6 |
6 |
7 property HWEngine hwEngine |
7 property HWEngine hwEngine |
8 property NetSession netSession |
8 property NetSession netSession |
9 |
9 |
10 Component { |
10 Component { |
11 id: hwEngineComponent |
11 id: hwEngineComponent |
12 |
12 |
13 HWEngine { |
13 HWEngine { |
14 engineLibrary: "./libhedgewars_engine.so" |
14 engineLibrary: "../rust/lib-hedgewars-engine/target/debug/libhedgewars_engine.so" |
15 previewAcceptor: PreviewAcceptor |
15 dataPath: "../share/hedgewars/Data" |
16 onPreviewImageChanged: previewImage.source = "image://preview/image" |
16 previewAcceptor: PreviewAcceptor |
17 onPreviewIsRendering: previewImage.source = "qrc:/res/iconTime.png" |
17 onPreviewImageChanged: previewImage.source = "image://preview/image" |
|
18 onPreviewIsRendering: previewImage.source = "qrc:/res/iconTime.png" |
|
19 } |
18 } |
20 } |
19 } |
|
20 |
21 |
21 Component { |
22 Component { |
22 id: netSessionComponent |
23 id: netSessionComponent |
23 |
24 |
24 NetSession { |
25 NetSession { |
25 nickname: "test0272" |
26 nickname: "test0272" |
26 url: "hwnet://gameserver.hedgewars.org:46632" |
27 url: "hwnet://gameserver.hedgewars.org:46632" |
|
28 } |
27 } |
29 } |
28 } |
|
29 |
30 |
30 Component.onCompleted: { |
31 Component.onCompleted: { |
31 hwEngine = hwEngineComponent.createObject() |
32 hwEngine = hwEngineComponent.createObject() |
32 } |
33 } |
33 |
34 |
34 tickButton { |
35 tickButton { |
35 onClicked: { |
36 onClicked: { |
36 tickButton.visible = false |
37 tickButton.visible = false |
37 gameView.tick(100) |
38 gameView.tick(100) |
|
39 } |
38 } |
40 } |
39 } |
41 gameButton { |
40 gameButton { |
42 visible: !gameView.engineInstance |
41 visible: !gameView.engineInstance |
43 onClicked: { |
42 onClicked: { |
44 const engineInstance = hwEngine.runQuickGame() |
43 var engineInstance = hwEngine.runQuickGame() |
45 gameView.engineInstance = engineInstance |
44 gameView.engineInstance = engineInstance |
46 } |
45 } |
47 } |
46 } |
48 button1 { |
47 button1 { |
49 visible: !gameView.engineInstance |
48 visible: !gameView.engineInstance |
50 onClicked: { |
49 onClicked: { |
51 hwEngine.getPreview() |
50 hwEngine.getPreview() |
52 } |
51 } |
53 } |
52 } |
54 netButton.onClicked: { |
53 netButton.onClicked: { |
55 netSession = netSessionComponent.createObject() |
54 netSession = netSessionComponent.createObject() |
56 netSession.open() |
55 netSession.open() |
57 } |
56 } |
|
57 |
58 |
58 Keys.onPressed: { |
59 Keys.onPressed: { |
59 if (event.key === Qt.Key_Enter) |
60 if (event.key === Qt.Key_Enter) |
60 gameView.engineInstance.longEvent(Engine.Attack, Engine.Set) |
61 gameView.engineInstance.longEvent(Engine.Attack, Engine.Set) |
61 } |
62 } |
62 |
63 |
63 Keys.onReleased: { |
64 Keys.onReleased: { |
64 if (event.key === Qt.Key_Enter) |
65 if (event.key === Qt.Key_Enter) |
65 gameView.engineInstance.longEvent(Engine.Attack, Engine.Unset) |
66 gameView.engineInstance.longEvent(Engine.Attack, Engine.Unset) |
66 } |
67 } |
67 } |
68 } |