author | unc0rr |
Sat, 01 Nov 2014 00:23:22 +0300 | |
branch | qmlfrontend |
changeset 10448 | 4cb727e029fa |
parent 10444 | 47a6231f1fc1 |
child 10450 | bf9e30b4ef9b |
permissions | -rw-r--r-- |
10422 | 1 |
import QtQuick 2.0 |
2 |
import Hedgewars.Engine 1.0 |
|
3 |
||
10442 | 4 |
|
10422 | 5 |
Rectangle { |
6 |
HWButton { |
|
7 |
id: btnPreview |
|
8 |
x: 50 |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
9 |
y: 16 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
10 |
width: 256 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
11 |
height: 128 |
10422 | 12 |
|
10432 | 13 |
onClicked: HWEngine.getPreview() |
10422 | 14 |
|
15 |
Connections { |
|
16 |
target: HWEngine |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10422
diff
changeset
|
17 |
onPreviewImageChanged: previewImage.source = "image://preview/" + HWEngine.currentSeed() |
10422 | 18 |
} |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
19 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
20 |
Image { |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
21 |
id: previewImage |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
22 |
x: 0 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
23 |
y: 0 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
24 |
width: 256 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
25 |
height: 128 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
26 |
cache: false |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
27 |
} |
10422 | 28 |
} |
29 |
||
10448 | 30 |
HWButton { |
31 |
id: btnRunGame |
|
32 |
x: 600 |
|
33 |
y: 440 |
|
34 |
width: 32 |
|
35 |
height: 32 |
|
36 |
||
37 |
onClicked: HWEngine.runLocalGame() |
|
38 |
} |
|
39 |
||
10436 | 40 |
Rectangle { |
41 |
x: 320 |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
42 |
y: 16 |
10436 | 43 |
width: 100 |
44 |
height: 256 |
|
45 |
color: "#15193a" |
|
46 |
radius: 8 |
|
47 |
border.width: 4 |
|
48 |
border.color: "#eaea00" |
|
49 |
Image { |
|
50 |
id: themeImage |
|
51 |
x: 0 |
|
52 |
y: 0 |
|
53 |
width: 64 |
|
54 |
height: 64 |
|
55 |
fillMode: Image.Pad |
|
56 |
} |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
57 |
|
10436 | 58 |
ListView { |
59 |
id: themesList |
|
60 |
x: 0 |
|
61 |
y: 64 |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
62 |
width: 100 |
10436 | 63 |
height: 192 |
64 |
highlight: Rectangle { color: "#eaea00"; radius: 4 } |
|
65 |
focus: true |
|
66 |
||
67 |
model: themesModel |
|
68 |
delegate: Rectangle { |
|
69 |
height: 25 |
|
70 |
width: 100 |
|
71 |
color: "transparent" |
|
72 |
Text {id: themeName; text: modelData } |
|
73 |
MouseArea { |
|
74 |
z: 1 |
|
75 |
anchors.fill: parent |
|
76 |
onClicked: { |
|
77 |
themeImage.source = "image://theme/" + themeName.text |
|
78 |
themesList.currentIndex = index |
|
79 |
} |
|
80 |
} |
|
81 |
} |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
82 |
} |
10422 | 83 |
} |
10442 | 84 |
|
85 |
ListView { |
|
86 |
id: playingTeamsList |
|
87 |
x: 440 |
|
88 |
y: 16 |
|
89 |
width: 100 |
|
90 |
height: 192 |
|
91 |
highlight: Rectangle { color: "#eaea00"; radius: 4 } |
|
92 |
focus: true |
|
93 |
clip: true |
|
94 |
||
95 |
model: ListModel { |
|
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
96 |
id: playingTeamsModel |
10442 | 97 |
} |
98 |
||
99 |
delegate: Rectangle { |
|
100 |
id: teamDelegate |
|
101 |
height: 24 |
|
102 |
width: parent.width |
|
103 |
radius: 8 |
|
104 |
border.width: 2 |
|
105 |
border.color: "#eaea00" |
|
106 |
||
107 |
Row { |
|
108 |
Text { text: name } |
|
109 |
} |
|
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
110 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
111 |
MouseArea { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
112 |
z: 1 |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
113 |
anchors.fill: parent |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
114 |
onClicked: HWEngine.tryRemoveTeam(name) |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
115 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
116 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
117 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
118 |
Connections { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
119 |
target: HWEngine |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
120 |
onPlayingTeamAdded: playingTeamsModel.append({"aiLevel": aiLevel, "name": teamName, "local": isLocal}) |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
121 |
onPlayingTeamRemoved: { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
122 |
var i = playingTeamsModel.count - 1; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
123 |
while ((i >= 0) && (playingTeamsModel.get(i).name !== teamName)) --i |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
124 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
125 |
if(i >= 0) playingTeamsModel.remove(i, 1) |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
126 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
127 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
128 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
129 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
130 |
ListView { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
131 |
id: localTeamsList |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
132 |
x: 440 |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
133 |
y: 224 |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
134 |
width: 100 |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
135 |
height: 192 |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
136 |
highlight: Rectangle { color: "#eaea00"; radius: 4 } |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
137 |
focus: true |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
138 |
clip: true |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
139 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
140 |
model: ListModel { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
141 |
id: localTeamsModel |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
142 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
143 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
144 |
delegate: Rectangle { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
145 |
id: localTeamDelegate |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
146 |
height: 24 |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
147 |
width: parent.width |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
148 |
radius: 8 |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
149 |
border.width: 2 |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
150 |
border.color: "#eaea00" |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
151 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
152 |
Row { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
153 |
Text { text: name } |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
154 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
155 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
156 |
MouseArea { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
157 |
z: 1 |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
158 |
anchors.fill: parent |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
159 |
onClicked: HWEngine.tryAddTeam(name) |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
160 |
} |
10442 | 161 |
} |
162 |
||
163 |
Connections { |
|
164 |
target: HWEngine |
|
165 |
onLocalTeamAdded: localTeamsModel.append({"aiLevel": aiLevel, "name": teamName}) |
|
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
166 |
onLocalTeamRemoved: { |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
167 |
var i = localTeamsModel.count - 1; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
168 |
while ((i >= 0) && (localTeamsModel.get(i).name !== teamName)) --i |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
169 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
170 |
if(i >= 0) localTeamsModel.remove(i, 1) |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
171 |
} |
10442 | 172 |
} |
173 |
} |
|
174 |
||
175 |
Component.onCompleted: { |
|
176 |
HWEngine.getTeamsList() |
|
177 |
HWEngine.getPreview() |
|
178 |
} |
|
10422 | 179 |
} |