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