PageVersionExport.xaml.vb 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Public Class PageVersionExport
  2. Private Sub PageVersionExport_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
  3. Reload()
  4. End Sub
  5. Public ItemVersion As MyListItem
  6. Public Sub Reload()
  7. AniControlEnabled += 1
  8. TbExportName.HintText = PageVersionLeft.Version.Name
  9. TbExportDesc.HintText = PageVersionLeft.Version.Info
  10. PanDisplayItem.Children.Clear()
  11. ItemVersion = PageSelectRight.McVersionListItem(PageVersionLeft.Version.Load())
  12. ItemVersion.IsHitTestVisible = False
  13. If Not String.IsNullOrEmpty(CustomLogo) Then ItemVersion.Logo = CustomLogo
  14. PanDisplayItem.Children.Add(ItemVersion)
  15. ItemVersion.Title = If(String.IsNullOrWhiteSpace(TbExportName.Text), PageVersionLeft.Version.Name, TbExportName.Text)
  16. ItemVersion.Info = If(String.IsNullOrWhiteSpace(TbExportDesc.Text), PageVersionLeft.Version.Info, TbExportDesc.Text)
  17. AniControlEnabled -= 1
  18. End Sub
  19. Private Type As ModpackType = ModpackType.Modrinth
  20. Private SelectedSaves As New List(Of Integer)
  21. Private ReadOnly Property Saves As List(Of String)
  22. Get
  23. If Directory.Exists(PageVersionLeft.Version.Path & "saves\") Then
  24. Return Directory.EnumerateDirectories(PageVersionLeft.Version.Path & "saves\").ToList
  25. End If
  26. Return New List(Of String)
  27. End Get
  28. End Property
  29. #Region "整合包信息 & 预览栏"
  30. Private Sub TbExportName_TextChanged(sender As MyTextBox, e As TextChangedEventArgs) Handles TbExportName.TextChanged
  31. ItemVersion.Title = If(String.IsNullOrWhiteSpace(sender.Text), PageVersionLeft.Version.Name, sender.Text)
  32. End Sub
  33. Private Sub TbExportDesc_TextChanged(sender As MyTextBox, e As TextChangedEventArgs) Handles TbExportDesc.TextChanged
  34. ItemVersion.Info = If(String.IsNullOrWhiteSpace(sender.Text), PageVersionLeft.Version.Info, sender.Text)
  35. End Sub
  36. Private CustomLogoVal As String
  37. ''' <summary>
  38. ''' 自定义 Logo 的路径。
  39. ''' </summary>
  40. Public Property CustomLogo() As String
  41. Get
  42. Return CustomLogoVal
  43. End Get
  44. Set(value As String)
  45. If AniControlEnabled <> 0 Then Exit Property
  46. CustomLogoVal = value
  47. ItemVersion.Logo = value
  48. Reload()
  49. End Set
  50. End Property
  51. Private Sub ComboDisplayLogo_SelectionChanged(sender As MyComboBox, e As SelectionChangedEventArgs) Handles ComboDisplayLogo.SelectionChanged
  52. If Not AniControlEnabled = 0 Then Exit Sub
  53. '选择 自定义 时修改图片
  54. If ComboDisplayLogo.SelectedItem Is ItemDisplayLogoCustom Then
  55. Dim FileName As String = SelectFile("常用图片文件(*.png;*.jpg;*.gif)|*.png;*.jpg;*.gif", "选择图片")
  56. If String.IsNullOrWhiteSpace(FileName) Then Exit Sub
  57. CustomLogo = FileName
  58. Else
  59. CustomLogo = sender.SelectedItem.Tag
  60. End If
  61. End Sub
  62. #End Region
  63. #Region "导出"
  64. Private Function IncludePCL() As Boolean
  65. Return True
  66. End Function
  67. 'Private Sub ComboExportType_Change(sender As ComboBox, e As SelectionChangedEventArgs) Handles ComboExportType.SelectionChanged
  68. ' If AniControlEnabled <> 0 Then Exit Sub
  69. ' Type = sender.SelectedIndex
  70. ' Select Case Type
  71. ' Case ModpackType.Modrinth
  72. ' If IncludePCL() Then 'TODO:修改这里的条件
  73. ' If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Visible
  74. ' If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Collapsed
  75. ' Else
  76. ' If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Collapsed
  77. ' If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Visible
  78. ' End If
  79. ' End Select
  80. ' CardExport.TriggerForceResize()
  81. 'End Sub
  82. Private Sub BtnExportExport_Click() Handles BtnExportExport.Click
  83. If IncludePCL() AndAlso Val(VersionBranchCode) <> 50 Then
  84. If MyMsgBox("你当前的 PCL 不是正式版,有二次分发(制作压缩包)的限制。" & vbCrLf &
  85. "请使用正式版再次尝试该操作!" & vbCrLf &
  86. "其他类型的整合包(例如 Modrinth 整合包)没有该限制。", Button1:="下载正式版", Button2:="取消") = 1 Then
  87. OpenWebsite("https://afdian.net/p/0164034c016c11ebafcb52540025c377")
  88. End If
  89. Exit Sub
  90. End If
  91. Dim savePath As String = SelectAs(
  92. "选择导出位置", $"整合包 - {If(String.IsNullOrWhiteSpace(TbExportName.Text), PageVersionLeft.Version.Name, TbExportName.Text)}" & If(Type = ModpackType.Modrinth, ".mrpack", ".zip"),
  93. If(Type = ModpackType.Modrinth, "Modrinth 整合包(*.mrpack)|*.mrpack", "整合包文件(*.zip)|*.zip"))
  94. If String.IsNullOrEmpty(savePath) Then Exit Sub
  95. ModpackExport(New ExportOptions(PageVersionLeft.Version, savePath, Type, {}, 'TODO:改成要保留的文件列表
  96. Name:=TbExportName.Text, VerID:=TbExportVersion.Text))
  97. End Sub
  98. #End Region
  99. End Class