-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfrmYuzuInstaller.frm
1212 lines (1168 loc) · 45.1 KB
/
frmYuzuInstaller.frm
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
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form frmYuzuInstaller
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
Caption = "安装 Yuzu"
ClientHeight = 5085
ClientLeft = 5625
ClientTop = 4485
ClientWidth = 8760
BeginProperty Font
Name = "微软雅黑 Light"
Size = 12
Charset = 134
Weight = 290
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmYuzuInstaller.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5085
ScaleWidth = 8760
Begin VB.ComboBox ComboVersion
BeginProperty Font
Name = "微软雅黑 Light"
Size = 10.5
Charset = 134
Weight = 290
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 4080
TabIndex = 20
Text = "Combo1"
Top = 2520
Width = 1695
End
Begin VB.CommandButton btnShortcut
Caption = "创建桌面快捷方式"
Height = 555
Left = 240
TabIndex = 18
Top = 4320
Width = 2775
End
Begin VB.CommandButton btnDelNo
Caption = "否"
Height = 555
Left = 7080
TabIndex = 17
Top = 4320
Width = 1455
End
Begin VB.CommandButton btnDelYes
Caption = "是"
Height = 555
Left = 5280
TabIndex = 16
Top = 4320
Width = 1455
End
Begin InetCtlsObjects.Inet Inet1
Left = 840
Top = 4320
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
End
Begin NSEmuHelper.ucDownload ucDownload1
Height = 255
Left = 0
TabIndex = 15
Top = 4800
Width = 615
_ExtentX = 1085
_ExtentY = 450
End
Begin VB.ComboBox cbFirmware
BeginProperty Font
Name = "微软雅黑 Light"
Size = 10.5
Charset = 134
Weight = 290
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 3120
TabIndex = 12
Text = "Combo1"
Top = 3120
Width = 4095
End
Begin VB.OptionButton opFirmware
BackColor = &H80000005&
Caption = "在线下载"
Height = 375
Index = 1
Left = 1320
TabIndex = 11
Top = 3120
Width = 1455
End
Begin VB.OptionButton opFirmware
BackColor = &H80000005&
Caption = "本地选择"
Height = 375
Index = 0
Left = 1320
TabIndex = 10
Top = 2520
Value = -1 'True
Width = 1455
End
Begin VB.TextBox txtFirmware
BeginProperty Font
Name = "微软雅黑 Light"
Size = 10.5
Charset = 134
Weight = 290
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
IMEMode = 3 'DISABLE
Left = 3120
TabIndex = 9
Text = "<请点击“浏览”,之后在下方选择版本号>"
Top = 2520
Width = 4095
End
Begin VB.TextBox txtKey
BeginProperty Font
Name = "微软雅黑 Light"
Size = 10.5
Charset = 134
Weight = 290
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
IMEMode = 3 'DISABLE
Left = 1560
TabIndex = 8
Text = "<请点击“浏览”>"
Top = 2520
Width = 5655
End
Begin VB.CommandButton btnBrowse
Caption = "浏览"
Height = 420
Left = 7560
TabIndex = 7
Top = 2520
Width = 975
End
Begin VB.CommandButton btnNextStep
Caption = "下一步"
Height = 555
Left = 7080
TabIndex = 6
Top = 4320
Width = 1455
End
Begin VB.TextBox txtVersion
BeginProperty Font
Name = "微软雅黑 Light"
Size = 10.5
Charset = 134
Weight = 290
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
IMEMode = 3 'DISABLE
Left = 4080
TabIndex = 5
Text = "加载中 ..."
Top = 2520
Width = 1695
End
Begin MSComctlLib.ImageList ImageList2
Left = 6120
Top = 3840
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 256
ImageHeight = 256
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 2
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmYuzuInstaller.frx":54AA
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmYuzuInstaller.frx":6FAE
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.ImageList ImageList1
Left = 7320
Top = 1320
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 2
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmYuzuInstaller.frx":B911
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmYuzuInstaller.frx":10DCB
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.ImageCombo ImageCombo1
Height = 435
Left = 1560
TabIndex = 0
Top = 2520
Width = 2295
_ExtentX = 4048
_ExtentY = 767
_Version = 393216
ForeColor = -2147483640
BackColor = -2147483643
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "微软雅黑 Light"
Size = 10.5
Charset = 134
Weight = 290
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Text = "ImageCombo1"
ImageList = "ImageList1"
End
Begin VB.Label lblProgBar
BackStyle = 0 'Transparent
Height = 375
Left = 120
TabIndex = 19
Top = 3120
Width = 8535
End
Begin VB.Label Labels
BackStyle = 0 'Transparent
Caption = "indicator2"
Height = 495
Index = 5
Left = 120
TabIndex = 14
Top = 2520
Width = 8415
End
Begin VB.Label Labels
BackStyle = 0 'Transparent
Caption = "indicator1"
Height = 495
Index = 4
Left = 120
TabIndex = 13
Top = 2040
Width = 8415
End
Begin VB.Label Labels
BackStyle = 0 'Transparent
Caption = "模拟器版本:"
Height = 495
Index = 3
Left = 120
TabIndex = 4
Top = 2520
Width = 2175
End
Begin VB.Label Labels
BackStyle = 0 'Transparent
Caption = "Steps"
Height = 975
Index = 2
Left = 120
TabIndex = 3
Top = 1200
Width = 6615
End
Begin VB.Image Image1
Height = 1215
Left = 7320
Stretch = -1 'True
Top = 240
Width = 1215
End
Begin VB.Label Labels
BackStyle = 0 'Transparent
Caption = "Steps"
BeginProperty Font
Name = "微软雅黑 Light"
Size = 15.75
Charset = 134
Weight = 290
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 1
Left = 120
TabIndex = 2
Top = 600
Width = 6975
End
Begin VB.Label Labels
BackStyle = 0 'Transparent
Caption = "安装 Yuzu"
Height = 495
Index = 0
Left = 120
TabIndex = 1
Top = 120
Width = 3735
End
End
Attribute VB_Name = "frmYuzuInstaller"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public DownloadCompleted As Boolean, TitlePrefix As String
Attribute DownloadCompleted.VB_VarHelpID = -1
Attribute TitlePrefix.VB_VarUserMemId = 1073938432
Attribute TitlePrefix.VB_VarHelpID = -1
'1:纯净安装
'2:更新模拟器
'3:固件
Public iIsEarlyAccess As Boolean, iVersion As String, iKeyPath As String, iFirmwareOnline As Boolean, iFirmwarePath As String, iFirmwareVersion As String
Attribute iIsEarlyAccess.VB_VarUserMemId = 1073938434
Attribute iVersion.VB_VarUserMemId = 1073938434
Attribute iKeyPath.VB_VarUserMemId = 1073938434
Attribute iFirmwareOnline.VB_VarUserMemId = 1073938434
Attribute iFirmwarePath.VB_VarUserMemId = 1073938434
Attribute iFirmwareVersion.VB_VarUserMemId = 1073938434
'1:分支 True EA False Mainline
'2:版本号
Public CurrentStep As Integer, YuzuVersionName As String
Private Sub btnBrowse_Click()
Debug.Print CurrentStep
'浏览
Select Case CurrentStep
Case 2
txtKey.Text = ChooseFile("选择密钥文件 (prod.keys)", "NS 密钥文件", "*.keys", frmYuzuInstaller.hwnd)
Case 3
If opFirmware(0).Value Then
txtFirmware.Text = ChooseFile("选择固件包 (zip 压缩文件)", "NS 固件包", "*.zip", frmYuzuInstaller.hwnd)
If txtFirmware.Text <> "" Then
Dim TmpName As String
TmpName = Split(txtFirmware.Text, "\")(UBound(Split(txtFirmware.Text, "\")))
If InStr(TmpName, "Firmware ") <> 0 Then
cbFirmware.Text = Replace(Replace(TmpName, ".zip", ""), "Firmware ", "")
ElseIf InStr(TmpName, "Firmware_") <> 0 Then
cbFirmware.Text = Replace(Replace(TmpName, ".zip", ""), "Firmware_", "")
ElseIf InStr(TmpName, "registered-") <> 0 Then
cbFirmware.Text = Replace(Replace(TmpName, ".zip", ""), "registered-", "")
End If
End If
End If
Case Else
Exit Sub
End Select
End Sub
Private Sub btnNextStep_Click()
'下一步
If InstallMode = 1 Then
Select Case CurrentStep
Case 1
Step2
Case 2
Step3
Case 3
Step4
Case Else
Exit Sub
End Select
ElseIf InstallMode = 2 Then
Step4
ElseIf InstallMode = 3 Then
Step4
End If
End Sub
Private Sub btnShortcut_Click()
Dim nPath As String, sh, ShortCut
On Error Resume Next
Set sh = CreateObject("wscript.shell") '
nPath = sh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop") '获取当前用户的桌面目录
If Right(nPath, 1) <> "" Then nPath = nPath & "\"
ShortF = nPath & "Yuzu.lnk"
Set ShortCut = sh.CreateShortcut(ShortF) '开始创建快捷方式对象
ShortCut.TargetPath = YuzuInstallFolder & "\yuzu.exe" '快捷方式指向的目标文件,写完整路径
ShortCut.Save
MsgBox "快捷方式创建成功!", vbOKOnly, "提示"
End Sub
Private Sub Form_Activate()
'加载
If InstallMode = 1 Then
If YuzuInstallFolder = "D:\Yuzu" Then
If MsgBox("当前模拟器安装目录为默认的 D:\Yuzu,请确认是否安装到此文件夹?" & vbCrLf & "点“否”以回到主界面,点击左下角的设置更改模拟器文件夹。" & vbCrLf & "你也可以把模拟器文件夹设为你已经装好的模拟器位置,程序会自动识别。", vbQuestion + vbYesNo, "确认吗?") = 7 Then
frmMain.Show
Unload Me
Exit Sub
End If
End If
TitlePrefix = "安装 Yuzu"
Labels(0).Caption = TitlePrefix
DoEvents
CurrentStep = 1
Step1
ElseIf InstallMode = 2 Then
TitlePrefix = "更新 Yuzu"
Labels(0).Caption = TitlePrefix
DoEvents
CurrentStep = 1
Step1
ElseIf InstallMode = 3 Then
TitlePrefix = "更新固件"
Labels(0).Caption = TitlePrefix
DoEvents
CurrentStep = 3
Step3
End If
If InstallMode <> 1 Then RemoveTemps
End Sub
Private Sub Step1()
On Error Resume Next
'第一步
'界面
btnShortcut.Visible = False
btnDelYes.Visible = False
btnDelNo.Visible = False
Labels(4).Visible = False
Labels(5).Visible = False
cbFirmware.Visible = False
opFirmware(0).Visible = False
opFirmware(1).Visible = False
btnBrowse.Visible = False
txtFirmware.Visible = False
txtKey.Visible = False
txtVersion.Visible = True
ComboVersion.Visible = True
Image1.Picture = ImageList2.ListImages(1).Picture
If InstallMode = 1 Then
Me.Caption = "NS模拟器助手 " & App.Major & "." & App.Minor & "." & App.Revision & " - " & TitlePrefix & " - Step 1"
Labels(1).Caption = "Step 1 - 选择模拟器版本"
Labels(2).Caption = "在安装模拟器之前,你需要先进行几步选择。" & vbCrLf & "如果追求最新功能,就使用预先测试版,如果追求稳定,就使用主线版。"
Else
Me.Caption = "NS模拟器助手 " & App.Major & "." & App.Minor & "." & App.Revision & " - " & TitlePrefix
Labels(1).Caption = "选择模拟器版本"
Labels(2).Caption = "请选择要更换到的模拟器版本。" & vbCrLf & "如果追求最新功能,就使用预先测试版,如果追求稳定,就使用主线版。"
End If
Labels(3).Caption = "模拟器版本:"
ImageCombo1.ComboItems.Clear
ImageCombo1.ComboItems.Add 1, "EA", "预先测试版", 1
ImageCombo1.ComboItems.Add 2, "Mainline", "主线版", 2
ImageCombo1.ComboItems(1).Selected = True
ImageCombo1.Enabled = False
If DownloadSource = "GitHub" Then
txtVersion.Visible = True
ComboVersion.Visible = False
txtVersion.Text = GetYuzuVersion
txtVersion.SetFocus
Else
txtVersion.Visible = False
ComboVersion.Visible = True
Dim YuzuVersion() As String
ComboVersion.Clear
ComboVersion.Text = "加载中 ..."
YuzuVersion = Split(GetYuzuVersionAli, vbCrLf)
Dim i As Integer
For i = 0 To (UBound(YuzuVersion) - LBound(YuzuVersion))
ComboVersion.AddItem YuzuVersion(i)
ComboVersion.Text = YuzuVersion(i)
ComboVersion.SetFocus
Next
End If
'确保文件夹存在
MkDirs YuzuInstallFolder
ImageCombo1.Enabled = True '加载完毕,列表框可以点击
End Sub
Private Sub Step2()
On Error GoTo Step2Error
If DownloadSource = "GitHub" Then
If txtVersion.Text = "加载中 ..." Then Exit Sub
iVersion = txtVersion.Text
Else
If ComboVersion.Text = "加载中 ..." Then Exit Sub
iVersion = ComboVersion.Text
End If
CurrentStep = 2
'第二步
'设置第一步结果
If ImageCombo1.SelectedItem.index = 1 Then
iIsEarlyAccess = True
YuzuVersionName = "yuzu-windows-msvc-early-access"
ElseIf ImageCombo1.SelectedItem.index = 2 Then
iIsEarlyAccess = False
YuzuVersionName = "yuzu-windows-msvc"
Else
Exit Sub
End If
'界面
ImageCombo1.Visible = False
txtVersion.Visible = False
ComboVersion.Visible = False
btnBrowse.Visible = True
txtKey.Visible = True
Me.Caption = "NS模拟器助手 " & App.Major & "." & App.Minor & "." & App.Revision & " - " & TitlePrefix & " - Step 2"
Labels(1).Caption = "Step 2 - 选择密钥文件"
Labels(2).Caption = "NS 模拟器需要密钥 (Keys) 文件才能玩游戏。" & vbCrLf & "你可以在相关的群中找到它 (prod.keys),并在这里打开。"
Labels(3).Caption = "密钥文件:"
Exit Sub
Step2Error:
ImageCombo1.ComboItems(1).Selected = True
Exit Sub
End Sub
Private Sub Step3()
If InstallMode = 1 Then
If txtKey.Text = "<请点击“浏览”>" Or txtKey.Text = "" Then Exit Sub
CurrentStep = 3
'第三步
'设置第二步结果
iKeyPath = txtKey.Text
'界面
End If
ComboVersion.Visible = False
txtVersion.Visible = False
ImageCombo1.Visible = False
btnShortcut.Visible = False
btnDelYes.Visible = False
btnDelNo.Visible = False
Labels(4).Visible = False
Labels(5).Visible = False
cbFirmware.Visible = True
btnBrowse.Visible = True
cbFirmware.Visible = True
txtKey.Visible = False
txtFirmware.Visible = True
opFirmware(0).Visible = True
opFirmware(0).Enabled = False
opFirmware(1).Visible = True
If InstallMode = 1 Then
Me.Caption = "NS模拟器助手 " & App.Major & "." & App.Minor & "." & App.Revision & " - " & TitlePrefix & " - Step 3"
Labels(1).Caption = "Step 3 - 选择固件"
Labels(2).Caption = "Yuzu 需要固件才能使大部分游戏正常运行。" & vbCrLf & "你可以在相关的群中找到固件包,或使用“在线下载”。" & vbCrLf & "固件版本需要小于等于密钥版本。"
ElseIf InstallMode = 3 Then
If Left(YuzuBranch, 5) = "预先测试版" Then
Image1.Picture = ImageList2.ListImages(1).Picture
Else
Image1.Picture = ImageList2.ListImages(2).Picture
End If
Me.Caption = "NS模拟器助手 " & App.Major & "." & App.Minor & "." & App.Revision & " - " & TitlePrefix & " - 选择固件"
Labels(1).Caption = "更新固件版本"
Labels(2).Caption = "你可以在此更新或更换固件的版本。" & vbCrLf & "你可以在相关的群中找到固件包,或使用“在线下载”。" & vbCrLf & "固件版本需要小于等于密钥版本。"
End If
Labels(3).Caption = "固件包:"
'----
cbFirmware.Clear
cbFirmware.Text = "加载中 ..."
Dim FirmwareVersionArr() As String
FirmwareVersionArr = Split(Replace(Replace(Join(Filter(Split(Replace(Replace(GetData(CloudflareReverseProxyUrl & "/https://archive.org/download/nintendo-switch-global-firmwares/nintendo-switch-global-firmwares_files.xml"), Chr(34), ""), " ", ""), vbLf), ".zip"), vbCrLf), "<filename=Firmware", ""), ".zipsource=original>", ""), vbCrLf)
Dim i As Integer
For i = 0 To (UBound(FirmwareVersionArr) - LBound(FirmwareVersionArr))
cbFirmware.AddItem FirmwareVersionArr(i)
Next
cbFirmware.Text = "选择固件版本"
End Sub
Private Sub Step4()
Dim ReDownloadCount As Integer
ReDownloadCount = 0
Dim fso As Object, folder As Object
Set fso = New FileSystemObject '创建FSO对象
'dependencies
On Error Resume Next
'第四步(开始安装)
If InstallMode = 1 Or InstallMode = 3 Then
'上一步结果
If cbFirmware.Text = "选择固件版本" Then Exit Sub
If opFirmware(0).Value Then
If txtFirmware.Text = "<请点击“浏览”,之后在下方选择版本号>" Or txtFirmware.Text = "" Then Exit Sub
iFirmwareOnline = False
iFirmwareVersion = cbFirmware.Text
iFirmwarePath = txtFirmware.Text
Else
iFirmwareOnline = True
iFirmwareVersion = cbFirmware.Text
If DownloadSource = "GitHub" Then
iFirmwarePath = CloudflareReverseProxyUrl & "/https://archive.org/download/nintendo-switch-global-firmwares/Firmware " & cbFirmware.Text & ".zip"
Else
iFirmwarePath = AliyundriveDomain & "/NSFirmwareMirror/Firmware_" & cbFirmware.Text & ".zip"
End If
'Legacy reverse proxy for testing purpose, uncomment it when new reverse proxy is not work
'iFirmwarePath = "https://download.sydzy.workers.dev/api/download?url=https://archive.org/download/nintendo-switch-global-firmwares/Firmware " & cbFirmware.Text & ".zip"
End If
ElseIf InstallMode = 2 Then
If DownloadSource = "GitHub" Then
If txtVersion.Text = "加载中 ..." Then Exit Sub
iVersion = txtVersion.Text
Else
If ComboVersion.Text = "加载中 ..." Then Exit Sub
iVersion = ComboVersion.Text
End If
'设置第一步结果
If ImageCombo1.SelectedItem.index = 1 Then
iIsEarlyAccess = True
YuzuVersionName = "yuzu-windows-msvc-early-access"
ElseIf ImageCombo1.SelectedItem.index = 2 Then
iIsEarlyAccess = False
YuzuVersionName = "yuzu-windows-msvc"
Else
Exit Sub
End If
End If
CurrentStep = 4
'界面
ImageCombo1.Visible = False
txtVersion.Visible = False
ComboVersion.Visible = False
cbFirmware.Visible = False
txtFirmware.Visible = False
opFirmware(0).Visible = False
opFirmware(1).Visible = False
Labels(3).Visible = False
btnNextStep.Visible = False
btnBrowse.Visible = False
Labels(4).Visible = True
Labels(5).Visible = True
Labels(2).Caption = "这可能需要十几分钟,你可以坐下来喝杯茶。" & vbCrLf & "根据网络状况和电脑性能,安装速度会有所不同。"
If InstallMode = 1 Then
Me.Caption = "NS模拟器助手 " & App.Major & "." & App.Minor & "." & App.Revision & " - " & TitlePrefix & " - 正在安装"
If iIsEarlyAccess Then
Labels(1).Caption = "正在安装 Yuzu 预先测试版 " & iVersion & " ..."
Else
Labels(1).Caption = "正在安装 Yuzu 主线版 " & iVersion & " ..."
End If
ElseIf InstallMode = 2 Then
Me.Caption = "NS模拟器助手 " & App.Major & "." & App.Minor & "." & App.Revision & " - 正在安装模拟器"
If iIsEarlyAccess Then
Labels(1).Caption = "正在更新 Yuzu 到预先测试版 " & iVersion & " ..."
Else
Labels(1).Caption = "正在更新 Yuzu 到主线版 " & iVersion & " ..."
End If
ElseIf InstallMode = 3 Then
Me.Caption = "NS模拟器助手 " & App.Major & "." & App.Minor & "." & App.Revision & " - 正在安装固件"
Labels(1).Caption = "正在安装固件 ..."
GoTo FirmwareInstallation
End If
'生成模拟器下载链接
DoEvents
Labels(4).Caption = "准备安装 ..."
Labels(5).Caption = ""
iVersion = CStr(CInt(iVersion))
Dim YuzuUrl As String
If DownloadSource = "GitHub" Then
If iIsEarlyAccess Then
YuzuUrl = "https://github.com/PineappleEA/pineapple-src/releases/download/EA-" & iVersion & "/Windows-Yuzu-EA-" & iVersion & ".7z"
Else
'主线
Dim TmpArr() As String
TmpArr = Split(Replace(GetData(CloudflareReverseProxyUrl & "/https://api.github.com/repos/yuzu-emu/yuzu-mainline/releases"), Chr(34), ""), ",")
If Err.Number = 9 Then
MsgBox "运行时错误 (9): 下标越界,可能是你的网络对 Cloudflare 的通信有问题。"
End
End If
Dim i As Integer, j As Integer
For i = LBound(TmpArr) To UBound(TmpArr)
If TmpArr(i) = "tag_name:mainline-0-" & iVersion Then Exit For
Next
j = i
For i = j To UBound(TmpArr)
If InStr(TmpArr(i), ".7z") <> 0 Then
Exit For
End If
Next
YuzuUrl = "https://github.com/yuzu-emu/yuzu-mainline/releases/download/mainline-0-" & iVersion & "/" & Replace(TmpArr(i), "name:", "")
End If
Else
'阿里
If iIsEarlyAccess Then
YuzuUrl = AliyundriveDomain & "/YuzuEAMirror/Windows-Yuzu-EA-" & iVersion & ".7z"
Else
YuzuUrl = AliyundriveDomain & "/YuzuMainlineMirror/yuzu-windows-msvc-" & iVersion & ".7z"
End If
End If
If CheckFileExists(YuzuInstallFolder & "\Yuzu.7z") = False Then
If DownloadSource = "GitHub" Then
If AlwaysUseCloudflare = False Then
DoEvents
'github连通性测试
Labels(4).Caption = "正在测试 GitHub 连通性 ..."
Labels(5).Caption = "如果 GitHub 不能连通,就使用 Cloudflare Workers。"
Dim Tmp As String
Tmp = "timeout"
Inet1.Cancel
Inet1.Protocol = icHTTPS
Inet1.Url = "https://github.com/opensearch.xml"
Inet1.RequestTimeout = 10
Tmp = Inet1.OpenURL
If Err.Number = 35761 Then
Labels(4).Caption = "正在下载模拟器,使用 Cloudflare Workers ..."
YuzuUrl = CloudflareReverseProxyUrl & "\" & YuzuUrl
Else
If InStr(Tmp, "OpenSearchDescription") = 2 Then
Labels(4).Caption = "正在下载模拟器,使用 GitHub ..."
Else
Labels(4).Caption = "正在下载模拟器,使用 Cloudflare Workers ..."
YuzuUrl = CloudflareReverseProxyUrl & "\" & YuzuUrl
End If
End If
Labels(5).Caption = "准备下载 ..."
Else
YuzuUrl = CloudflareReverseProxyUrl & "\" & YuzuUrl
End If
Else
Labels(4).Caption = "正在下载模拟器 ..."
End If
End If
DoEvents
'下载模拟器
If CheckFileExists(YuzuInstallFolder & "\Yuzu.7z") = False Then
ReDownload:
PBarLoad 1, Me.hwnd, lblProgBar.Left \ Screen.TwipsPerPixelX, lblProgBar.Top \ Screen.TwipsPerPixelY, lblProgBar.Width \ Screen.TwipsPerPixelX, lblProgBar.Height \ Screen.TwipsPerPixelY
PBarSetRange 1, 0, 100
PBarSetPos 1, 0
Debug.Print YuzuUrl
AsyncReads(0) = YuzuUrl
AsyncReads(1) = YuzuInstallFolder & "\Yuzu.7z"
ucDownload1.DownloadFile AsyncReads(0), AsyncReads(1)
DoEvents
DownloadCompleted = False
Do Until DownloadCompleted
Sleep 100
DoEvents
Loop
Sleep 2000
DoEvents
PBarUnload 1
If CheckFileExists(YuzuInstallFolder & "\Yuzu.7z") = False Then '文件不存在就火速()重下
ReDownloadCount = ReDownloadCount + 1
If ReDownloadCount < 5 Then
Sleep 1000
Sleep 1000
Sleep 1000
Sleep 1000
Sleep 1000
GoTo ReDownload
Else
MsgBox "下载失败!请检查您的互联网连接和 DNS。", vbCritical
End
End If
End If
End If
FirmwareInstallation:
ReDownloadCount = 0
If InstallMode = 1 Or InstallMode = 3 Then
'下载固件
DoEvents
If CheckFileExists(YuzuInstallFolder & "\Firmware.zip") = False Then
If iFirmwareOnline Then
ReDownload2:
Labels(4).Caption = "正在下载固件,请耐心等待 ..."
Labels(5).Caption = "准备下载 ..."
PBarLoad 1, Me.hwnd, lblProgBar.Left \ Screen.TwipsPerPixelX, lblProgBar.Top \ Screen.TwipsPerPixelY, lblProgBar.Width \ Screen.TwipsPerPixelX, lblProgBar.Height \ Screen.TwipsPerPixelY
PBarSetRange 1, 0, 100
PBarSetPos 1, 0
DoEvents
Debug.Print iFirmwarePath
AsyncReads(0) = iFirmwarePath
AsyncReads(1) = YuzuInstallFolder & "\Firmware.zip"
ucDownload1.DownloadFile AsyncReads(0), AsyncReads(1)
DoEvents
DownloadCompleted = False
Do Until DownloadCompleted
Sleep 100
DoEvents
Loop
Sleep 2000
DoEvents
PBarUnload 1
DoEvents
If CheckFileExists(YuzuInstallFolder & "\Firmware.zip") = False Then
ReDownloadCount = ReDownloadCount + 1
If ReDownloadCount < 5 Then
Sleep 1000
Sleep 1000
Sleep 1000
Sleep 1000
Sleep 1000
GoTo ReDownload2
Else
MsgBox "下载失败!请检查您的互联网连接和 DNS。", vbCritical
End
End If
End If
Else
Labels(4).Caption = "正在加载 ..."
Labels(5).Caption = ""
PBarUnload 1
DoEvents
End If
End If
End If
If InstallMode = 1 Then
DoEvents
'下载 Sysdata (shared fonts)
If CheckFileExists(YuzuInstallFolder & "\Sysdata.zip") = False Then
Labels(4).Caption = "正在下载 Shared fonts ..."
PBarLoad 1, Me.hwnd, lblProgBar.Left \ Screen.TwipsPerPixelX, lblProgBar.Top \ Screen.TwipsPerPixelY, lblProgBar.Width \ Screen.TwipsPerPixelX, lblProgBar.Height \ Screen.TwipsPerPixelY
PBarSetRange 1, 0, 100
PBarSetPos 1, 0
AsyncReads(0) = AliyundriveDomain & "/sysdata.zip"
AsyncReads(1) = YuzuInstallFolder & "\Sysdata.zip"
Debug.Print AsyncReads(0)
ucDownload1.DownloadFile AsyncReads(0), AsyncReads(1)
DoEvents
DownloadCompleted = False
Do Until DownloadCompleted
Sleep 100
DoEvents
Loop
Sleep 2000
PBarUnload 1
DoEvents
End If
End If
ReInstall:
If InstallMode = 1 Or InstallMode = 2 Then
'删除旧版本
If InstallMode = 2 Then
Labels(4).Caption = "正在删除之前的模拟器 ..."
Labels(5).Caption = ""
DoEvents
fso.DeleteFolder YuzuInstallFolder & "\plugins"
fso.DeleteFile YuzuInstallFolder & "\*.tar.xz"
DoEvents
fso.DeleteFile YuzuInstallFolder & "\*.dll"
fso.DeleteFile YuzuInstallFolder & "\*.pak"
fso.DeleteFile YuzuInstallFolder & "\*.conf"
fso.DeleteFile YuzuInstallFolder & "\*.dat"
fso.DeleteFile YuzuInstallFolder & "\*.exe"
DoEvents
End If
'安装模拟器 解压
Labels(4).Caption = "正在解压缩并安装模拟器 ..."
Labels(5).Caption = ""
PBarLoad 1, Me.hwnd, lblProgBar.Left \ Screen.TwipsPerPixelX, lblProgBar.Top \ Screen.TwipsPerPixelY, lblProgBar.Width \ Screen.TwipsPerPixelX, lblProgBar.Height \ Screen.TwipsPerPixelY
PBarSetRange 1, 0, 100
PBarSetPos 1, 100
DoEvents
Unzip YuzuInstallFolder & "\Yuzu.7z", YuzuInstallFolder
PBarUnload 1
DoEvents
'复制文件
Set folder = fso.GetFolder(YuzuInstallFolder & "\" & YuzuVersionName & "\plugins")
folder.Move YuzuInstallFolder & "\plugins"
'XCopy YuzuInstallFolder & "\" & YuzuVersionName & "\plugins", YuzuInstallFolder & "\plugins"
fso.CopyFile YuzuInstallFolder & "\" & YuzuVersionName & "\*.*", YuzuInstallFolder & "\", True
DoEvents
fso.DeleteFolder YuzuInstallFolder & "\" & YuzuVersionName
DoEvents
fso.DeleteFile YuzuInstallFolder & "\*.tar.xz"
DoEvents
End If
Sleep 1000
If CheckFileExists(YuzuInstallFolder & "\yuzu.exe") = False Then
Labels(5).Caption = "解压失败,正在重新解压 ..."
GoTo ReInstall
End If
If InstallMode = 1 Then
'安装密钥
Labels(4).Caption = "正在安装密钥 ..."
DoEvents
MkDirs YuzuInstallFolder & "\user\keys"
FileCopy iKeyPath, YuzuInstallFolder & "\user\keys\prod.keys"
End If
If InstallMode = 1 Or InstallMode = 3 Then
If InstallMode = 3 Then
Labels(4).Caption = "正在删除旧固件 ..."
DoEvents
Shell "cmd /c rd /s /q " & Chr(34) & YuzuInstallFolder & "\user\nand\system\Contents" & Chr(34), vbMinimizedNoFocus
Sleep 10000
End If
'安装固件
'文件夹
Labels(4).Caption = "正在解压缩并安装固件包 ..."
DoEvents
MkDirs YuzuInstallFolder & "\user\nand\system\Contents\registered"
DoEvents
'解压
PBarLoad 1, Me.hwnd, lblProgBar.Left \ Screen.TwipsPerPixelX, lblProgBar.Top \ Screen.TwipsPerPixelY, lblProgBar.Width \ Screen.TwipsPerPixelX, lblProgBar.Height \ Screen.TwipsPerPixelY
PBarSetRange 1, 0, 100
PBarSetPos 1, 0
DoEvents
If iFirmwareOnline Then
Unzip YuzuInstallFolder & "\Firmware.zip", YuzuInstallFolder & "\user\nand\system\Contents\registered"
Else
Unzip iFirmwarePath, YuzuInstallFolder & "\user\nand\system\Contents\registered"
End If
PBarUnload 1
DoEvents
End If
If InstallMode = 1 Then
'sysdata
Labels(4).Caption = "正在解压缩并安装 Shared fonts ..."
MkDirs YuzuInstallFolder & "\user\sysdata"
PBarLoad 1, Me.hwnd, lblProgBar.Left \ Screen.TwipsPerPixelX, lblProgBar.Top \ Screen.TwipsPerPixelY, lblProgBar.Width \ Screen.TwipsPerPixelX, lblProgBar.Height \ Screen.TwipsPerPixelY
PBarSetRange 1, 0, 100
PBarSetPos 1, 0
DoEvents
Unzip YuzuInstallFolder & "\Sysdata.zip", YuzuInstallFolder & "\user\sysdata"
PBarUnload 1
DoEvents
DoEvents
'MSVC
If CheckFileExists("C:\Windows\System32\MSVCP140_ATOMIC_WAIT.DLL") = False And CheckFileExists("C:\Windows\System32\msvcp140_atomic_wait.dll") = False Then
Labels(4).Caption = "系统中缺少MSVC2019运行库,正在安装 ..."
If CheckFileExists(YuzuInstallFolder & "\VC2019.exe") = False Then
Labels(5).Caption = "正在下载 MSVC 运行库 ..."
PBarLoad 1, Me.hwnd, lblProgBar.Left \ Screen.TwipsPerPixelX, lblProgBar.Top \ Screen.TwipsPerPixelY, lblProgBar.Width \ Screen.TwipsPerPixelX, lblProgBar.Height \ Screen.TwipsPerPixelY
PBarSetRange 1, 0, 100
PBarSetPos 1, 0
DoEvents
ucDownload1.DownloadFile "https://aka.ms/vs/17/release/vc_redist.x64.exe", YuzuInstallFolder & "\VC2019.exe"
DoEvents
DownloadCompleted = False
Do Until DownloadCompleted
Sleep 100
DoEvents
Loop
Sleep 1000
PBarUnload 1
DoEvents
End If
Labels(5).Caption = "正在安装 MSVC 运行库 ..."
Shell YuzuInstallFolder & "\VC2019.exe /quiet"
Labels(5).Caption = ""
DoEvents
End If
End If
'生成 ini 和配置
If InstallMode = 1 Then
YuzuVersion = iVersion
If iIsEarlyAccess Then
YuzuBranch = "预先测试版"
Else
YuzuBranch = "主线版"