-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameSetting.qml
281 lines (230 loc) · 9.82 KB
/
GameSetting.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import QtQuick 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Controls 2.0
Dialog{
id: gameset
visible: false
title: "Game Settings"
width: 640
height: 650
function getBlackAlgo(){
if (blacktypebutton.checkedButton.playertype === 0)
return 0;
else
return blackalgo.checkedButton.alg
}
function getWhiteAlgo(){
if (whitetypebutton.checkedButton.playertype === 0)
return 0;
else
return whitealgo.checkedButton.alg
}
function getWhiteDep(){
if (whitetypebutton.checkedButton.playertype === 0)
return 0;
else
return whitedepthMenu.currentIndex +1;
}
function getBlackDep(){
if (blacktypebutton.checkedButton.playertype === 0)
return 0;
else
return blackdepthMenu.currentIndex +1;
}
contentItem: Column{
spacing: 20
Text {
id: blackp
text: qsTr("<h1>Black player:<h1/> ")
anchors.bottom: blackdepthRow.top
anchors.bottomMargin: 20
x:30
}
Row{
id:blackdepthRow
x:parent.width /2- 100
y:100
Text {
id: blackdepthText
text: qsTr("AI Black Depth: ")
anchors.centerIn: parent
}
ComboBox {
id:blackdepthMenu
width: 200
enabled: false
model: [ "1", "2", "3","4","5","6","7","8","9","10" ]
anchors.left: blackdepthText.right
anchors.baseline: blackdepthText.bottom
}
}
ButtonGroup { id: blacktypebutton }
Column {
id:blackplayertype
anchors.top: blackdepthRow.bottom
anchors.topMargin: 30
anchors.left: blackdepthRow.left
Label {
text: qsTr("Player type:")
}
RadioButton {
checked: true
text: qsTr("Human")
ButtonGroup.group: blacktypebutton
property int playertype: 0
}
RadioButton {
text: qsTr("PC")
ButtonGroup.group: blacktypebutton
property int playertype: 1
onClicked: {
blackdepthMenu.enabled = true
blackalgoCol.visible = true
}
onCheckedChanged: {
blackdepthMenu.enabled = false
blackalgoCol.visible = false
}
}
}
ButtonGroup { id: blackalgo }
Column {
id: blackalgoCol
visible: false
anchors.left: blackplayertype.left
anchors.top:blackplayertype.bottom
Label {
text: qsTr("Algorithm:")
}
RadioButton {
checked: true
text: qsTr("minimax")
ButtonGroup.group: blackalgo
property int alg: 1
}
RadioButton {
text: qsTr("alpha-beta")
ButtonGroup.group: blackalgo
property int alg: 2
}
}
Text {
id: whitep
text: qsTr("<h1>White player:<h1/> ")
anchors.top: blackalgoCol.bottom
anchors.bottomMargin: 20
x:30
}
Row{
id:whitedepthRow
x:parent.width /2- 100
anchors.top: whitep.bottom
Text {
id: whitedepthText
text: qsTr("AI White Depth: ")
anchors.centerIn: parent
}
ComboBox {
id:whitedepthMenu
width: 200
enabled: false
model: [ "1", "2", "3","4","5","6","7","8","9","10" ]
anchors.left: whitedepthText.right
anchors.baseline: whitedepthText.bottom
}
}
ButtonGroup { id: whitetypebutton }
Column {
id:whiteplayertype
anchors.top: whitedepthRow.bottom
anchors.left: whitedepthRow.left
anchors.topMargin: 30
Label {
text: qsTr("Player type:")
}
RadioButton {
checked: true
text: qsTr("Human")
ButtonGroup.group: whitetypebutton
property int playertype: 0
}
RadioButton {
text: qsTr("PC")
ButtonGroup.group: whitetypebutton
property int playertype: 1
onClicked: {
whitedepthMenu.enabled = true
whitealgoCol.visible = true
}
onCheckedChanged: {
whitedepthMenu.enabled = false
whitealgoCol.visible = false
}
}
}
ButtonGroup { id: whitealgo }
Column {
id: whitealgoCol
visible: false
anchors.left: whiteplayertype.left
anchors.top:whiteplayertype.bottom
Label {
text: qsTr("Algorithm:")
}
RadioButton {
checked: true
text: qsTr("minimax")
ButtonGroup.group: whitealgo
property int alg: 1
}
RadioButton {
text: qsTr("alpha-beta")
ButtonGroup.group: whitealgo
property int alg: 2
}
}
MyButton{
id: ret
width: 100
height: 50
customText: "return"
z:2
anchors.right: begin.left
anchors.rightMargin: 40
anchors.bottom: parent.bottom
onButtonClicked: {
gameset.visible = false
}
toolTipText: "Click to return"
}
MyButton{
id: begin
width: 100
height: 50
customText: "begin"
z:2
x:gameset.width / 2 + 25
anchors.bottom: parent.bottom
toolTipText: "Click to begin the game"
onButtonClicked: {
gameBlocks.visible = true
whiteScore.visible = true
blackScore.visible = true
blackCount.visible = true
whiteCount.visible = true
gameset.visible = false
status.visible = true
background.image.visible = false;
background.start.visible = false;
background.textEdit.visible = false;
myBroker.createGame(blacktypebutton.checkedButton.playertype,
whitetypebutton.checkedButton.playertype,
getBlackAlgo(),
getWhiteAlgo(),
getBlackDep(),
getWhiteDep());
console.log("finished creating game !");
}
}
}
}