author | unc0rr |
Thu, 26 Nov 2015 20:11:54 +0300 | |
branch | qmlfrontend |
changeset 11432 | 97e3e62ea5f9 |
parent 11426 | ab6a6d9ebfc0 |
child 11433 | bca9afcc3a72 |
permissions | -rw-r--r-- |
10422 | 1 |
import QtQuick 2.0 |
2 |
import Hedgewars.Engine 1.0 |
|
3 |
||
10442 | 4 |
|
10422 | 5 |
Rectangle { |
11426 | 6 |
Column { |
7 |
spacing: 8 |
|
8 |
||
10422 | 9 |
HWButton { |
10 |
id: btnPreview |
|
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
11 |
width: 256 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
12 |
height: 128 |
10422 | 13 |
|
10432 | 14 |
onClicked: HWEngine.getPreview() |
10422 | 15 |
|
16 |
Connections { |
|
17 |
target: HWEngine |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10422
diff
changeset
|
18 |
onPreviewImageChanged: previewImage.source = "image://preview/" + HWEngine.currentSeed() |
10422 | 19 |
} |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
20 |
|
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
21 |
Image { |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
22 |
id: previewImage |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
23 |
x: 0 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
24 |
y: 0 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
25 |
width: 256 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
26 |
height: 128 |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
27 |
cache: false |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10432
diff
changeset
|
28 |
} |
10422 | 29 |
} |
30 |
||
10519 | 31 |
HWComboBox { |
10608 | 32 |
id: cbTheme |
10610
eadf2cea55e0
Finish combobox implementation (except for visual part)
unc0rr
parents:
10608
diff
changeset
|
33 |
width: 256 |
eadf2cea55e0
Finish combobox implementation (except for visual part)
unc0rr
parents:
10608
diff
changeset
|
34 |
height: 64 |
10519 | 35 |
|
36 |
model: themesModel |
|
37 |
delegate: Rectangle { |
|
38 |
height: 25 |
|
39 |
width: 100 |
|
40 |
color: "transparent" |
|
10610
eadf2cea55e0
Finish combobox implementation (except for visual part)
unc0rr
parents:
10608
diff
changeset
|
41 |
|
eadf2cea55e0
Finish combobox implementation (except for visual part)
unc0rr
parents:
10608
diff
changeset
|
42 |
property alias itemIconSource: themeIcon.source |
eadf2cea55e0
Finish combobox implementation (except for visual part)
unc0rr
parents:
10608
diff
changeset
|
43 |
property alias itemText: themeName.text |
eadf2cea55e0
Finish combobox implementation (except for visual part)
unc0rr
parents:
10608
diff
changeset
|
44 |
|
10608 | 45 |
Row { |
10610
eadf2cea55e0
Finish combobox implementation (except for visual part)
unc0rr
parents:
10608
diff
changeset
|
46 |
Image {id: themeIcon; width: height; height: parent.height; source: "image://theme/" + modelData} |
10608 | 47 |
Text {id: themeName; text: modelData } |
48 |
} |
|
10610
eadf2cea55e0
Finish combobox implementation (except for visual part)
unc0rr
parents:
10608
diff
changeset
|
49 |
|
10519 | 50 |
MouseArea { |
51 |
z: 1 |
|
52 |
anchors.fill: parent |
|
53 |
onClicked: { |
|
10608 | 54 |
cbTheme.currentIndex = index |
10519 | 55 |
HWEngine.setTheme(themeName.text) |
56 |
} |
|
57 |
} |
|
11432 | 58 |
|
59 |
Connections { |
|
60 |
target: HWEngine |
|
61 |
onThemeChanged: cbTheme.showItem({"iconSource" : "image://theme/" + theme, "text" : theme}); |
|
62 |
} |
|
10519 | 63 |
} |
64 |
} |
|
65 |
||
10612 | 66 |
HWComboBox { |
67 |
id: cbScript |
|
68 |
width: 256 |
|
11426 | 69 |
height: 32 |
10612 | 70 |
|
71 |
model: scriptsModel |
|
72 |
delegate: Rectangle { |
|
73 |
height: 25 |
|
74 |
width: 100 |
|
75 |
color: "transparent" |
|
76 |
||
77 |
property string itemIconSource: "" |
|
78 |
property alias itemText: scriptName.text |
|
79 |
||
80 |
Row { |
|
81 |
//Image {id: themeIcon; width: height; height: parent.height; source: "image://theme/" + modelData} |
|
82 |
Text {id: scriptName; text: modelData } |
|
83 |
} |
|
84 |
||
85 |
MouseArea { |
|
86 |
z: 1 |
|
87 |
anchors.fill: parent |
|
88 |
onClicked: { |
|
89 |
cbScript.currentIndex = index |
|
90 |
HWEngine.setScript(scriptName.text) |
|
91 |
} |
|
92 |
} |
|
11432 | 93 |
Connections { |
94 |
target: HWEngine |
|
95 |
onScriptChanged: scriptsModel.showItem({"iconSource" : "", "text" : script}); |
|
96 |
} |
|
10436 | 97 |
} |
10612 | 98 |
} |
99 |
||
10616 | 100 |
HWComboBox { |
101 |
id: cbScheme |
|
102 |
width: 256 |
|
11426 | 103 |
height: 32 |
10616 | 104 |
|
105 |
model: schemesModel |
|
106 |
delegate: Rectangle { |
|
107 |
height: 25 |
|
108 |
width: 100 |
|
109 |
color: "transparent" |
|
110 |
||
111 |
property string itemIconSource: "" |
|
112 |
property alias itemText: schemeName.text |
|
113 |
||
114 |
Row { |
|
115 |
//Image {id: themeIcon; width: height; height: parent.height; source: "image://theme/" + modelData} |
|
116 |
Text {id: schemeName; text: modelData } |
|
117 |
} |
|
118 |
||
119 |
MouseArea { |
|
120 |
z: 1 |
|
121 |
anchors.fill: parent |
|
122 |
onClicked: { |
|
123 |
cbScheme.currentIndex = index |
|
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
124 |
HWEngine.setScheme(schemeName.text) |
10616 | 125 |
} |
126 |
} |
|
127 |
} |
|
128 |
} |
|
129 |
||
10442 | 130 |
|
10823 | 131 |
HWComboBox { |
132 |
id: cbAmmo |
|
133 |
width: 256 |
|
11426 | 134 |
height: 32 |
10823 | 135 |
|
10888 | 136 |
model: ammosModel |
10823 | 137 |
delegate: Rectangle { |
138 |
height: 25 |
|
139 |
width: 100 |
|
140 |
color: "transparent" |
|
141 |
||
142 |
property string itemIconSource: "" |
|
143 |
property alias itemText: ammoName.text |
|
144 |
||
145 |
Row { |
|
146 |
//Image {id: themeIcon; width: height; height: parent.height; source: "image://theme/" + modelData} |
|
147 |
Text {id: ammoName; text: modelData } |
|
148 |
} |
|
149 |
||
150 |
MouseArea { |
|
151 |
z: 1 |
|
152 |
anchors.fill: parent |
|
153 |
onClicked: { |
|
154 |
cbAmmo.currentIndex = index |
|
155 |
HWEngine.setAmmo(ammoName.text) |
|
156 |
} |
|
157 |
} |
|
158 |
} |
|
159 |
} |
|
11426 | 160 |
} |
10823 | 161 |
|
10442 | 162 |
ListView { |
163 |
id: playingTeamsList |
|
164 |
x: 440 |
|
165 |
y: 16 |
|
166 |
width: 100 |
|
167 |
height: 192 |
|
168 |
highlight: Rectangle { color: "#eaea00"; radius: 4 } |
|
169 |
focus: true |
|
170 |
clip: true |
|
171 |
||
172 |
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
|
173 |
id: playingTeamsModel |
10442 | 174 |
} |
175 |
||
176 |
delegate: Rectangle { |
|
177 |
id: teamDelegate |
|
178 |
height: 24 |
|
179 |
width: parent.width |
|
180 |
radius: 8 |
|
181 |
border.width: 2 |
|
182 |
border.color: "#eaea00" |
|
183 |
||
184 |
Row { |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
185 |
Rectangle { |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
186 |
height: 20 |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
187 |
width: height |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
188 |
color: teamColor |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
189 |
border.width: 2 |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
190 |
border.color: "#eaea00" |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
191 |
|
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
192 |
MouseArea { |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
193 |
z: 1 |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
194 |
anchors.fill: parent |
10454
2b590e7972b1
Allow using right button or wheel to change team color
unc0rr
parents:
10452
diff
changeset
|
195 |
acceptedButtons: Qt.LeftButton | Qt.RightButton |
2b590e7972b1
Allow using right button or wheel to change team color
unc0rr
parents:
10452
diff
changeset
|
196 |
onClicked: { |
2b590e7972b1
Allow using right button or wheel to change team color
unc0rr
parents:
10452
diff
changeset
|
197 |
if (mouse.button === Qt.LeftButton) |
2b590e7972b1
Allow using right button or wheel to change team color
unc0rr
parents:
10452
diff
changeset
|
198 |
HWEngine.changeTeamColor(name, 1) |
2b590e7972b1
Allow using right button or wheel to change team color
unc0rr
parents:
10452
diff
changeset
|
199 |
else if (mouse.button === Qt.RightButton) |
2b590e7972b1
Allow using right button or wheel to change team color
unc0rr
parents:
10452
diff
changeset
|
200 |
HWEngine.changeTeamColor(name, -1) |
2b590e7972b1
Allow using right button or wheel to change team color
unc0rr
parents:
10452
diff
changeset
|
201 |
} |
2b590e7972b1
Allow using right button or wheel to change team color
unc0rr
parents:
10452
diff
changeset
|
202 |
onWheel: HWEngine.changeTeamColor(name, -wheel.angleDelta.y) |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
203 |
} |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
204 |
} |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
205 |
|
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
206 |
Text { text: name |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
207 |
MouseArea { |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
208 |
z: 1 |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
209 |
anchors.fill: parent |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
210 |
onClicked: HWEngine.tryRemoveTeam(name) |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
211 |
} |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
212 |
} |
10442 | 213 |
} |
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
|
214 |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
215 |
|
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
|
216 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
217 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
218 |
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
|
219 |
target: HWEngine |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
220 |
onPlayingTeamAdded: playingTeamsModel.append({ |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
221 |
"aiLevel": aiLevel |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
222 |
, "name": teamName |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
223 |
, "local": isLocal |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
224 |
, "teamColor": "#000000" |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
225 |
}) |
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
|
226 |
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
|
227 |
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
|
228 |
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
|
229 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
230 |
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
|
231 |
} |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
232 |
onTeamColorChanged: { |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
233 |
var i = playingTeamsModel.count - 1; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
234 |
while ((i >= 0) && (playingTeamsModel.get(i).name !== teamName)) --i |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
235 |
|
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
236 |
if(i >= 0) playingTeamsModel.setProperty(i, "teamColor", colorValue) |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
237 |
} |
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
|
238 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
239 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
240 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
241 |
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
|
242 |
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
|
243 |
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
|
244 |
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
|
245 |
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
|
246 |
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
|
247 |
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
|
248 |
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
|
249 |
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
|
250 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
251 |
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
|
252 |
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
|
253 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
254 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
255 |
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
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
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
|
260 |
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
|
261 |
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
|
262 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
263 |
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
|
264 |
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
|
265 |
} |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
266 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
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
|
271 |
} |
10442 | 272 |
} |
273 |
||
274 |
Connections { |
|
275 |
target: HWEngine |
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
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
|
280 |
|
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
281 |
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
|
282 |
} |
10442 | 283 |
} |
284 |
} |
|
285 |
||
286 |
Component.onCompleted: { |
|
10450 | 287 |
HWEngine.resetGameConfig() |
10442 | 288 |
HWEngine.getTeamsList() |
289 |
HWEngine.getPreview() |
|
290 |
} |
|
10422 | 291 |
} |