-
Notifications
You must be signed in to change notification settings - Fork 1
/
net.kv
296 lines (230 loc) · 6.51 KB
/
net.kv
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#:kivy 1.10.0
# Draw dashed lines around every widget
#<Widget>:
# canvas.after:
# Line:
# rectangle: self.x + 1,self.y + 1,self.width - 1,self.height - 1
# dash_offset: 5
# dash_length: 3
<IconButton@Button>:
icon: None
canvas:
Rectangle:
source: self.icon
pos: self.center_x - 10, self.center_y - 10
size: 20, 20
<OptionsDialog>:
auto_dismiss: False
size: 300, 350
size_hint: None, None
title: "New game"
background_color: [0, 0, 0, 1]
options: {'size': size_slider.value, 'difficulty': difficulty_spinner.text, 'wrap': wrap_checkbox.active}
BoxLayout:
orientation: 'vertical'
padding: 20
spacing: 20
BoxLayout:
orientation: 'horizontal'
Label:
size_hint: None, 1
size: self.texture_size
text: "Size"
Slider:
id: size_slider
value: root.options['size']
range: (3, 20)
step: 1
Label:
size_hint: None, 1
size: self.texture_size
text_size: 20, None
halign: 'right'
text: str(size_slider.value)
BoxLayout:
orientation: 'horizontal'
spacing: 60
Label:
size_hint: None, 1
size: self.texture_size
halign: 'left'
text: "Difficulty"
Spinner:
id: difficulty_spinner
sync_height: True
text: root.options['difficulty']
BoxLayout:
orientation: 'horizontal'
Label:
size_hint: None, 1
size: self.texture_size
text: "Wrapping border"
CheckBox:
id: wrap_checkbox
active: root.options['wrap']
Widget:
BoxLayout:
orientation: 'horizontal'
Widget:
Button:
size_hint: None, 1
text: 'Start!'
on_release: root.dismiss()
<PauseDialog>:
auto_dismiss: False
size: 200, 250
size_hint: None, None
background_color: [0, 0, 0, 1]
title: "Game paused"
BoxLayout:
orientation: 'vertical'
padding: 20
spacing: 20
Button:
id: newgame_button
size: 100, 30
size_hint: None, None
pos_hint: {'center_x': 0.5}
text: "New game"
on_release:
root.result = 'new game'
root.dismiss()
Button:
id: reset_button
size: 100, 30
size_hint: None, None
pos_hint: {'center_x': 0.5}
text: "Reset"
on_release:
root.result = 'reset'
root.dismiss()
Button:
id: continue_button
size: 100, 30
size_hint: None, None
pos_hint: {'center_x': 0.5}
text: "Continue"
on_release:
root.result = 'continue'
root.dismiss()
<ResultDialog>:
auto_dismiss: False
size: 200, 250
size_hint: None, None
title: "Puzzle solved"
BoxLayout:
orientation: 'vertical'
padding: 20
spacing: 20
BoxLayout:
orientation: 'horizontal'
Label:
text: "Time"
Label:
id: time
text: "00:00"
BoxLayout:
orientation: 'horizontal'
Label:
text: "Moves"
Label:
id: moves
text: "0 / 0"
BoxLayout:
orientation: 'horizontal'
Label:
text: "Score"
Label:
id: score
text: "0"
Widget:
BoxLayout:
orientation: 'horizontal'
Widget:
Button:
height: 30
size_hint: None, None
text: "New game"
on_release: root.dismiss()
<WallWidget>:
size_hint: None, None
canvas.before:
PushMatrix
Rotate:
angle: self.angle
origin: self.center
canvas.after:
PopMatrix
Image:
pos: self.parent.pos
size: self.parent.size
source: 'atlas://images/40/assets/wall'
<TileWidget>:
size_hint: None, None
canvas.before:
PushMatrix
Rotate:
angle: self.angle
origin: self.center
canvas.after:
PopMatrix
Color:
rgba: 0, 0, 0, 0.3 if self.locked else 0
Rectangle:
pos: self.pos
size: self.size
Image:
pos: self.parent.pos
size: self.parent.size
source: 'atlas://images/40/assets/' + self.parent.link + ('_powered' if self.parent.powered else '')
<SourceWidget>:
Image:
pos: self.parent.pos
size: self.parent.size
source: 'atlas://images/40/assets/source' + ('_powered' if self.parent.powered else '')
<DrainWidget>:
Image:
pos: self.parent.pos
size: self.parent.size
source: 'atlas://images/40/assets/drain' + ('_powered' if self.parent.powered else '')
<RootWidget>:
anchor_x: 'center'
anchor_y: 'center'
canvas.before:
Color:
rgb: 0.18, 0.20, 0.22
Rectangle:
pos: self.pos
size: self.size
<NetGame>:
main_window: main_window
grid: grid
timer: timer
BoxLayout:
id: main_window
orientation: 'vertical'
center: self.parent.center
padding: 20
spacing: 10
width: grid.width + 2 * self.padding[0]
height: grid.height + status_bar.height + 2 * self.padding[0] + self.spacing
RelativeLayout:
id: grid
size_hint: None, None
BoxLayout:
id: status_bar
orientation: 'horizontal'
spacing: 20
size_hint: 1, None
height: max(moves_label.height, pause_button.height)
Label:
id: moves_label
size: self.texture_size
text: str(root.moves) + "/" + str(root.expected_moves)
Timer:
id: timer
IconButton:
id: pause_button
size_hint: None, None
size: 25, 25
icon: 'images/burger.png'