PageVersionExport.xaml.vb 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. Private Sub BtnExportExport_Click() Handles BtnExportExport.Click
  37. If IncludePCL() AndAlso Val(VersionBranchCode) <> 50 Then
  38. If MyMsgBox("你当前的 PCL 不是正式版,有二次分发(制作压缩包)的限制。" & vbCrLf &
  39. "请使用正式版再次尝试该操作!" & vbCrLf &
  40. "其他类型的整合包(例如 Modrinth 整合包)没有该限制。", Button1:="下载正式版", Button2:="取消") = 1 Then
  41. OpenWebsite("https://afdian.net/p/0164034c016c11ebafcb52540025c377")
  42. End If
  43. Exit Sub
  44. End If
  45. Dim savePath As String = SelectAs(
  46. "选择导出位置", $"整合包 - {If(String.IsNullOrWhiteSpace(TbExportName.Text), CurrentVersion.Name, TbExportName.Text)}" & If(Type = ModpackType.Modrinth, ".mrpack", ".zip"),
  47. If(Type = ModpackType.Modrinth, "Modrinth 整合包(*.mrpack)|*.mrpack", "整合包文件(*.zip)|*.zip"))
  48. If String.IsNullOrEmpty(savePath) Then Exit Sub
  49. ModpackExport(New ExportOptions(CurrentVersion, savePath, Type, {TbExportSave.Text},
  50. PCLSetupGlobal:=CheckExportGlobal.Checked, Name:=TbExportName.Text,
  51. VerID:=TbExportVersion.Text))
  52. End Sub
  53. #End Region
  54. End Class