author | unc0rr |
Sat, 21 Nov 2015 17:07:06 +0300 | |
branch | qmlfrontend |
changeset 11423 | e045dc60c37e |
parent 11415 | 05cf35103206 |
child 11424 | 86c13e5662f1 |
permissions | -rw-r--r-- |
10402 | 1 |
import QtQuick 2.0 |
11415 | 2 |
import Hedgewars.Engine 1.0 |
10402 | 3 |
|
4 |
Rectangle { |
|
10422 | 5 |
id: pages |
6 |
width: 800 |
|
7 |
height: 600 |
|
8 |
||
9 |
property variant pagesList : [ |
|
10 |
"First" |
|
11 |
, "LocalGame" |
|
12 |
, "GameConfig" |
|
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10422
diff
changeset
|
13 |
, "Connect" |
11415 | 14 |
, "LobbyPage" |
10422 | 15 |
]; |
16 |
||
17 |
property string currentPage : "First"; |
|
18 |
||
19 |
Repeater { |
|
20 |
model: pagesList; |
|
10402 | 21 |
|
10422 | 22 |
delegate: Loader { |
23 |
active: false |
|
24 |
asynchronous: true |
|
25 |
anchors.fill: parent |
|
26 |
visible: (currentPage === modelData) |
|
27 |
source: "%1.qml".arg(modelData) |
|
28 |
onVisibleChanged: loadIfNotLoaded(); |
|
29 |
Component.onCompleted: loadIfNotLoaded(); |
|
10402 | 30 |
|
10422 | 31 |
function loadIfNotLoaded () |
32 |
{ |
|
33 |
if (visible && !active) |
|
34 |
active = true; |
|
35 |
} |
|
10420 | 36 |
} |
10402 | 37 |
} |
11415 | 38 |
|
11423 | 39 |
Rectangle { |
40 |
id: warningsBox |
|
41 |
y: parent.height - height |
|
42 |
width: parent.width - 120 |
|
43 |
height: 80 |
|
44 |
anchors.horizontalCenter: parent.horizontalCenter |
|
45 |
color: "#7e3232" |
|
46 |
border.color: "#d3ec2d" |
|
47 |
visible: false |
|
48 |
z: 2 |
|
49 |
||
50 |
function showMessage(message) { |
|
51 |
msgBox.text = message |
|
52 |
visible = true |
|
53 |
} |
|
54 |
||
55 |
Text { |
|
56 |
id: msgBox |
|
57 |
x: 0 |
|
58 |
y: 0 |
|
59 |
height: parent.height |
|
60 |
font.pixelSize: 12 |
|
61 |
wrapMode: Text.Wrap |
|
62 |
} |
|
63 |
HWButton { |
|
64 |
id: closeButton |
|
65 |
x: parent.width - width |
|
66 |
y: 0 |
|
67 |
width: 40 |
|
68 |
height: 40 |
|
69 |
onClicked: warningsBox.visible = false |
|
70 |
} |
|
71 |
} |
|
72 |
||
11415 | 73 |
Connections { |
74 |
target: HWEngine |
|
75 |
onNetConnected: currentPage = "LobbyPage"; |
|
76 |
onNetDisconnected: currentPage = "First"; |
|
11423 | 77 |
onWarningMessage: warningsBox.showMessage(message); |
78 |
onErrorMessage: warningsBox.showMessage(message); |
|
11415 | 79 |
} |
10402 | 80 |
} |