PageVersionExport.xaml.vb 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Public Class PageVersionExport
  2. Private CurrentVersion As McVersion = PageVersionLeft.Version
  3. Private Type As ModpackType = ModpackType.Modrinth
  4. Private SelectedSaves As New List(Of Integer)
  5. Private ReadOnly Property Saves As List(Of String)
  6. Get
  7. If Directory.Exists(CurrentVersion.Path & "saves\") Then
  8. Return Directory.EnumerateDirectories(CurrentVersion.Path & "saves\").ToList
  9. End If
  10. Return New List(Of String)
  11. End Get
  12. End Property
  13. Private Sub PageVersionExport_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
  14. CurrentVersion = PageVersionLeft.Version '各个版本不同,每次都需要重新加载
  15. TbExportName.HintText = CurrentVersion.Name
  16. End Sub
  17. #Region "控件事件"
  18. Private Function IncludePCL() As Boolean
  19. Return True
  20. End Function
  21. Private Sub ComboExportType_Change(sender As ComboBox, e As SelectionChangedEventArgs) Handles ComboExportType.SelectionChanged
  22. If AniControlEnabled <> 0 Then Exit Sub
  23. Type = sender.SelectedIndex
  24. Select Case Type
  25. Case ModpackType.Modrinth
  26. If IncludePCL() Then 'TODO:修改这里的条件
  27. If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Visible
  28. If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Collapsed
  29. Else
  30. If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Collapsed
  31. If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Visible
  32. End If
  33. End Select
  34. CardExport.TriggerForceResize()
  35. End Sub
  36. If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Visible
  37. Private Sub BtnExportExport_Click() Handles BtnExportExport.Click
  38. If IncludePCL() AndAlso Val(VersionBranchCode) <> 50 Then
  39. If MyMsgBox("你当前的 PCL 不是正式版,有二次分发(制作压缩包)的限制。" & vbCrLf &
  40. "请使用正式版再次尝试该操作!" & vbCrLf &
  41. "其他类型的整合包(例如 Modrinth 整合包)没有该限制。", Button1:="下载正式版", Button2:="取消") = 1 Then
  42. OpenWebsite("https://afdian.net/p/0164034c016c11ebafcb52540025c377")
  43. End If
  44. Exit Sub
  45. End If
  46. Dim savePath As String = SelectAs(
  47. "选择导出位置", $"整合包 - {If(String.IsNullOrWhiteSpace(TbExportName.Text), CurrentVersion.Name, TbExportName.Text)}" & If(Type = ModpackType.Modrinth, ".mrpack", ".zip"),
  48. If(Type = ModpackType.Modrinth, "Modrinth 整合包(*.mrpack)|*.mrpack", "整合包文件(*.zip)|*.zip"))
  49. If String.IsNullOrEmpty(savePath) Then Exit Sub
  50. ModpackExport(New ExportOptions(CurrentVersion, savePath, Type, {TbExportSave.Text},
  51. PCLSetupGlobal:=CheckExportGlobal.Checked, Name:=TbExportName.Text,
  52. VerID:=TbExportVersion.Text))
  53. End Sub
  54. ModpackExport(New ExportOptions(CurrentVersion, savePath, Type, {TbExportSave.Text},
  55. PCLSetupGlobal:=CheckExportGlobal.Checked,
  56. PCLSetupVer:=CheckExportVersion.Checked, Name:=TbExportName.Text,
  57. VerID:=TbExportVersion.Text))
  58. End Sub
  59. #End Region
  60. End Class