PageVersionExport.xaml.vb 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Public Class PageVersionExport
  2. Private CurrentVersion As McVersion = PageVersionLeft.Version
  3. Private Type As ModpackType = ModpackType.Compressed
  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 Sub ComboExportType_Change(sender As ComboBox, e As SelectionChangedEventArgs) Handles ComboExportType.SelectionChanged
  19. If AniControlEnabled <> 0 Then Exit Sub
  20. Type = If(sender.SelectedIndex = 0, ModpackType.Compressed, ModpackType.Modrinth)
  21. Select Case Type
  22. Case ModpackType.Modrinth
  23. If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Collapsed
  24. If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Visible
  25. Case ModpackType.Compressed
  26. If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Visible
  27. If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Collapsed
  28. End Select
  29. CardExport.TriggerForceResize()
  30. End Sub
  31. Private Sub BtnExportExport_Click() Handles BtnExportExport.Click
  32. If Type = ModpackType.Compressed AndAlso Val(VersionBranchCode) <> 50 Then
  33. If MyMsgBox("你当前的 PCL 不是正式版,有二次分发(制作压缩包)的限制。" & vbCrLf &
  34. "请使用正式版再次进行该操作再试!" & vbCrLf &
  35. "其他类型的整合包(例如 Modrinth 整合包)没有该限制。", Button1:="下载正式版", Button2:="取消") = 1 Then
  36. OpenWebsite("https://afdian.net/p/0164034c016c11ebafcb52540025c377")
  37. End If
  38. Exit Sub
  39. End If
  40. Dim savePath As String = SelectAs(
  41. "选择导出位置", $"整合包 - {If(String.IsNullOrWhiteSpace(TbExportName.Text), CurrentVersion.Name, TbExportName.Text)}" & If(Type = ModpackType.Modrinth, ".mrpack", ".zip"),
  42. If(Type = ModpackType.Modrinth, "Modrinth 整合包(*.mrpack)|*.mrpack", "整合包文件(*.zip)|*.zip"))
  43. If String.IsNullOrEmpty(savePath) Then Exit Sub
  44. ModpackExport(New ExportOptions(CurrentVersion, savePath, Type, {TbExportSave.Text},
  45. PCLSetupGlobal:=CheckExportGlobal.Checked,
  46. PCLSetupVer:=CheckExportVersion.Checked, Name:=TbExportName.Text,
  47. VerID:=TbExportVersion.Text))
  48. End Sub
  49. #End Region
  50. End Class