-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
748 lines (719 loc) · 23.9 KB
/
main.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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
import QtQuick 2.12
import QtQuick.Window 2.3
//import QtQuick.VirtualKeyboard 2.4
import QtQuick.Controls.Material 2.3
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.11
Window {
id: window
width: 1000
height: 500
visible: true
Material.theme: Material.Light
property int index_a: 0
property int index_b: 0
property string new_game_name: ""
Image {
id: backgroundimage
anchors.fill: parent
source: "/icon/66908482_p0_waifu2x_art_scale_tta_1.png"
fillMode: Image.PreserveAspectCrop
}
ToolBar {
id: toptoolbar
z: 10
width: parent.width
height: 51
Label {
id: title
x: font.pointSize*0.3
text: "MCinaBox"
font.pixelSize: 40
}
ToolButton {
id: back_button
x: parent.width-width
width: parent.height
visible: game_stackView.depth != 1
text: "\u25C4"
font.pixelSize: 25
onReleased: {
game_stackView.pop()
if (game_stackView.depth == 2) game_stackView.pop() //no more depth plz
}
}
ToolButton {
id: refresh_button
x: game_stackView.depth == 1 ? parent.width-width : back_button.x-width
width: parent.height
text: "\u21BA"
font.pixelSize: 25
onReleased: {
if (game_stackView.depth == 1 ) game_version_manager.fresh_game_version_list()
}
}
Label {
id: progressbar
x: parent.width/2
height: parent.height
width: contentWidth
text: qsTr("无下载")
font.pixelSize: 30
Connections {
target: checker
onFresh_downloaded: progressbar.text = qsTr("下载中")+checker.to_downloaded()+"/"+checker.to_total()
onDownload_Completed: progressbar.text = qsTr("下载完成")
}
}
}
ToolBar {
id: bottomtoolbar
z: 10
y: parent.height-height
height: 51
width: parent.width
Label {
id: game_version_label
x: 5
text: qsTr("请选择游戏版本")
font.pixelSize: 34
}
Button {
x: window.width*0.99-width
height: bottomtoolbar.height
width: 150
Material.background: Material.accent
text: qsTr("开始游戏")
font.pointSize: 19
}
}
Rectangle {
id: rectangle
x: 0
y: toptoolbar.height
width: 200
height: window.height
color: "#90ffffff"
Flickable {
id: leftlist
anchors.fill: parent
contentWidth: width
contentHeight: height
flickableDirection: Flickable.VerticalFlick
Button {
id: add_user_button
z: 2
Material.background: "#88ffffff"
y: 0
width: parent.width
height: 50
text: qsTr("添加用户")
font.pointSize: 15
Image {
x:5
y:10
width: 30
height: 30
source: "/icon/81718551_p0.jpg"
}
onClicked: {
add_user.open()
}
}
Button {
id: delete_user_button
z: 1
Material.background: "#88ffffff"
y: 38
width: parent.width
height: 50
text: qsTr("删除用户")
font.pointSize: 15
Image {
x:5
y:10
width: 30
height: 30
source: "/icon/81718551_p0.jpg"
}
onClicked: (user_list.count==0)? {} : (user_list.currentIndex==-1)? {} : delete_user.open()
}
Rectangle {
color: "#80ffffff"
z: 0
y: 76
width: parent.width
height: user_list.contentHeight
ListView {
id: user_list
anchors.fill: parent
spacing: -12
interactive: false
model: user_manager.user_name_list
currentIndex: -1
delegate: Button {
id: each_user_button
width: parent.width
height: 50
Material.background: highlighted? "#60E91E63" : "#00000000"
text: modelData
font.pointSize: 18
onClicked: {
if (user_list.currentIndex!=-1) user_list.currentItem.highlighted = false
user_list.currentIndex = index
user_list.currentItem.highlighted = true
}
}
}
}
Button {
id: game_setting_button
Material.background: "#88ffffff"
z: 1
y: user_list.y+user_list.height+80
width: parent.width
height: 50
text: qsTr("游戏设置")
font.pointSize: 15
Image {
x:5
y:10
width: 30
height: 30
source: "/icon/81718551_p0.jpg"
}
}
Button {
enabled: game_stackView.depth==1 ? true : false
Material.background: "#88ffffff"
z: 0
y: user_list.y+user_list.height+118
width: parent.width
text: qsTr("添加游戏")
font.pointSize: 15
Image {
x:5
y:10
width: 30
height: 30
source: "/icon/81718551_p0.jpg"
}
onClicked: {
game_stackView.push(busy_page)
install_new_game.get_new_game_list()
}
}
Button {
Material.background: "#88ffffff"
z: -1
y: user_list.y+user_list.height+160
width: parent.width
text: qsTr("关于")
font.pointSize: 15
}
}
}
Popup {
id: add_user
x: (window.width-width)/2
y: (window.height-height)/2.6
width: window.width*0.8
height: window.height*0.4
Label {
x: parent.width*0.1
y: parent.height*0.1
width: parent.width*0.6
height: (user_name.text=="")? contentWidth : user_name.contentHeight
text: (user_name.text=="")? qsTr("用户名") : ""
clip: false
font.pointSize: 20
TextInput {
id: user_name
height: parent.implicitHeight
width: parent.width
font.letterSpacing: 0.2
selectByMouse: true
font.pointSize: 20
Rectangle {
y: parent.contentHeight
width: parent.width
height: 1.5
color: Material.accentColor
}
}
}
Label {
enabled: false
x: parent.width*0.1
y: parent.height*0.45
width: parent.width*0.6
height: (user_password.text=="")? contentWidth : user_password.contentHeight
text: (user_password.text=="")? qsTr("密码(暂未实现)") : ""
clip: false
font.pointSize: 20
TextInput {
id: user_password
height: parent.implicitHeight
width: parent.width
font.letterSpacing: 0.2
selectByMouse: true
font.pointSize: 20
Rectangle {
y: parent.contentHeight
width: parent.width
height: 1.5
color: Material.accentColor
}
}
}
Label{
enabled: false
x: parent.width*0.1
y: parent.height*0.8
width: parent.width*0.6
height: (user_logging_method.text=="")? contentWidth : user_logging_method.contentHeight
text: (user_logging_method.text=="")? qsTr("登录方式(暂未实现)") : ""
clip: false
font.pointSize: 20
TextInput {
id: user_logging_method
height: parent.implicitHeight
width: parent.width
font.letterSpacing: 0.2
selectByMouse: true
font.pointSize: 20
Rectangle {
y: parent.contentHeight
width: parent.width
height: 1.5
color: Material.accentColor
}
}
}
Button {
text: qsTr("取消")
x: parent.width*0.77
y: parent.height*0.2
width: parent.width*0.2
height: parent.height*0.3
onClicked: {
user_name.text = ""
user_password.text = ""
user_logging_method.text = ""
add_user.close()
}
}
Button {
text: qsTr("确定")
x: parent.width*0.77
y: parent.height*0.5
width: parent.width*0.2
height: parent.height*0.3
onClicked: {
user_manager.add_user(user_name.text,user_password.text,user_logging_method.text)
add_user.close()
}
}
}
Popup {
id: delete_user
x: (window.width-width)/2
y: (window.height-height)/2.6
width: window.width*0.8
height: window.height*0.2
Text {
text: qsTr("你确定?")
font.pointSize: 28
}
Button {
text: qsTr("确定")
font.pointSize: 29
Material.foreground: Material.Purple
Material.background: "#00000000"
x: parent.width*0.58
y: parent.height*0.25
width: parent.width*0.15
height: parent.height*0.7
onClicked: {
user_manager.delete_user(user_list.currentIndex)
delete_user.close()
}
}
Button {
text: qsTr("取消")
font.pointSize: 29
Material.foreground: Material.Purple
Material.background: "#00000000"
x: parent.width*0.8
y: parent.height*0.25
width: parent.width*0.15
height: parent.height*0.7
onClicked: delete_user.close()
}
}
StackView {
id: game_stackView
x: leftlist.width*1.006
y: toptoolbar.height
width: window.width-x
height: window.height-toptoolbar.height-bottomtoolbar.height
Component.onCompleted: push(game_list_page)
}
Component {
id: game_list_page
Rectangle {
color: "#00000000"
Button {
id: add_new_game_button
visible: game_list.count==0 ? true : false
Material.background: "#aaffffff"
y: -height*0.1
width: parent.width
height: parent.height*0.2
text: qsTr("还没有游戏,点击添加游戏")
font.pointSize: 18
onClicked: {
game_stackView.push(busy_page)
install_new_game.get_new_game_list()
}
}
Component.onCompleted: game_version_manager.fresh_game_version_list
ListView {
id: game_list
y: game_list.count==0 ? add_new_game_button.height*1.05 : 0
width: parent.width
height: parent.height
interactive: true
clip: true
model: game_version_manager.game_version_list
spacing: -10
delegate: Button {
id: each_game_version_button
width: game_list.width
height: 60
Material.background: highlighted? "#e0ffffff" : "#a0ffffff"
Text {
x: 20
y: 10
text: modelData
font.pointSize: 30
}
Button {
x: parent.width-parent.height
width: parent.height
height: parent.height
Material.background: "#00000000"
Image {
anchors.fill: parent
source: "/icon/setting_icon.svg"
}
}
onClicked: {
game_list.currentItem.highlighted = null
game_list.currentIndex = index
game_list.currentItem.highlighted = each_game_version_button
game_version_label.text = qsTr("当前游戏版本:") + game_version_manager.get_game_version_string(index)
}
}
}
}
}
Component {
id: busy_page
Rectangle {
anchors.fill: parent
color: "#00000000"
BusyIndicator {
id: busy1
x: (parent.width-width)/2
y: (parent.height-height)/2
width: parent.width*0.2
height: width
visible: true
Connections {
target: install_new_game
onGet_Completed: {
game_stackView.push(choose_install_game_version_page_root)
}
}
Connections {
target: install_new_game
onGet_Failed: {
game_stackView.push(get_failed_page)
}
}
Connections {
target: checker
onFresh_downloaded: game_stackView.pop(null)
}
}
}
}
Component {
id: get_failed_page
Rectangle {
color: "#00000000"
Button {
id: back_button_failed
Material.background: "#aaffffff"
y: -height*0.1
width: parent.width
height: parent.height*0.2
text: qsTr("返回")
font.pointSize: 18
onClicked: {
game_stackView.pop(null)
}
}
Rectangle {
y: back_button2.height
width: parent.width
height: parent.height*0.5
color: "#80ffffff"
Text {
x: (parent.width-width)/2
y: (parent.height-height)/2
text: qsTr("获取游戏版本列表失败")
horizontalAlignment: Text.AlignHCenter
font.pointSize: 25
}
}
}
}
Component {
id: choose_install_game_version_page_root
Rectangle {
color: "#00000000"
Column {
anchors.fill: parent
spacing: 10
Button {
id: snapshot_version_button
Material.background: "#88ffffff"
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
height: window.height/5
text: qsTr("快照版(有问题)")
font.pointSize: 15
onClicked: {
game_stackView.push(choose_install_game_version_page_snapshot)
index_a = 1
}
}
Button {
id: release_version_button
Material.background: "#88ffffff"
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
height: window.height/5
text: qsTr("正式版")
font.pointSize: 15
onClicked: {
game_stackView.push(choose_install_game_version_page_release)
index_a = 2
}
}
Button {
id: old_version_button
Material.background: "#88ffffff"
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
height: window.height/5
text: qsTr("旧版(有问题)")
font.pointSize: 15
onClicked: {
game_stackView.push(choose_install_game_version_page_old)
index_a = 3
}
}
}
}
}
Component {
id: choose_install_game_version_page_snapshot
Rectangle {
color: "#00000000"
ListView {
id: snapshot_list
width: parent.width
height: parent.height
spacing: -10
model: install_new_game.snapshot_version
interactive: true
clip: true
delegate: Button {
width: snapshot_list.width
height: 60
Material.background: "#a0ffffff"
Text {
x: 20
y: 10
text: modelData
font.pointSize: 20
}
onClicked: {
game_stackView.push(choose_install_options_page)
index_b = index
new_game_name = modelData
}
}
}
}
}
Component {
id: choose_install_game_version_page_release
Rectangle {
color: "#00000000"
ListView {
id: release_list
width: parent.width
height: parent.height
spacing: -10
model: install_new_game.release_version
clip: true
interactive: true
delegate: Button {
width: release_list.width
height: 60
Material.background: "#a0ffffff"
Text {
x: 20
y: 10
text: modelData
font.pointSize: 20
}
onClicked: {
game_stackView.push(choose_install_options_page)
index_b = index
new_game_name = modelData
}
}
}
}
}
Component {
id: choose_install_game_version_page_old
Rectangle {
color: "#00000000"
ListView {
id: old_list
width: parent.width
height: parent.height
spacing: -10
model: install_new_game.old_version
clip: true
delegate: Button {
width: old_list.width
height: 60
Material.background: "#a0ffffff"
Text {
x: 20
y: 10
text: modelData
font.pointSize: 20
}
onClicked: {
game_stackView.push(choose_install_options_page)
index_b = index
new_game_name = modelData
}
}
}
}
}
Component {
id: choose_install_options_page
Rectangle {
color: "#00000000"
Column {
anchors.fill: parent
spacing: 5
Button {
anchors.horizontalCenter: parent.horizontalCenter
height: parent.height/5.3
width: parent.width
enabled: false
text: qsTr("安装Optifine(未实现)")
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
height: parent.height/5.3
width: parent.width
enabled: false
text: qsTr("安装Forge(未实现)")
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
height: parent.height/5.3
width: parent.width
enabled: false
text: qsTr("安装Fabric(未实现)")
}
TextInput {
id: new_game_name_textinput
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
height: parent.height/6
text: new_game_name
horizontalAlignment: Text.AlignHCenter
selectByMouse: true
font.pointSize: 20
onTextChanged: {
for(var i = 0; i < game_version_manager.count_game_version_list(); ++i) if (game_version_manager.get_game_version_string(i) == text) install_button.enabled = false
else install_button.enabled = true
}
}
Button {
id: install_button
z: 0
x: width
anchors.horizontalCenter: parent.horizontalCenter
height: parent.height/5
width: parent.width/2
enabled: true
text: enabled? qsTr("安装") : qsTr("安装(游戏名已存在)")
font.pointSize: 18
onClicked: {
install_new_game.set_index(index_a,index_b)
install_new_game.set_new_game_name(new_game_name_textinput.text)
install_new_game.get_new_game_json()
game_stackView.push(busy_page)
}
}
}
}
}
/*InputPanel { //Qt virtualkeyboard,temporaryly ignore it
id: inputPanel
z: 99
x: 0
y: window.height
width: window.width
states: State {
name: "visible"
when: inputPanel.active
PropertyChanges {
target: inputPanel
y: window.height - inputPanel.height
}
}
transitions: Transition {
from: ""
to: "visible"
reversible: true
ParallelAnimation {
NumberAnimation {
properties: "y"
duration: 250
easing.type: Easing.InOutQuad
}
}
}
}
*/
}
/*##^##
Designer {
D{i:0;autoSize:true;formeditorZoom:0.1;height:480;width:640}
}
##^##*/