diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb index 3125453..cfa67aa 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb @@ -859,8 +859,7 @@ Retry: ''' 整合包类型。 ''' Public Enum ModpackType - Modrinth = 4 - Compressed = 9 + Modrinth End Enum ''' ''' 导出整合包的选项。 @@ -875,22 +874,22 @@ Retry: ''' Public Dest As String ''' + ''' 是否包括 PCL 文件。 + ''' + Public IncludePCL As Boolean + ''' ''' 整合包类型。 ''' Public Type As ModpackType ''' - ''' 要保留到整合包的存档。 + ''' 要保留到整合包的文件。 ''' - Public Saves As String() + Public Remain As String() ''' ''' 是否需要保留 PCL 全局设置。仅在压缩包中有效。 ''' Public PCLSetupGlobal As Boolean = True ''' - ''' 是否需要保留 PCL 版本设置。仅在压缩包中有效。 - ''' - Public PCLSetupVer As Boolean = True - ''' ''' 整合包名称。仅在 Modrinth 有效。 ''' Public Name As String = "" @@ -900,19 +899,17 @@ Retry: Public VerID As String = "" Public Sub New(Version As McVersion, Dest As String, - Type As ModpackType, - Saves As String(), + IncludePCL As Boolean, + Remain As String(), Optional PCLSetupGlobal As Boolean = True, - Optional PCLSetupVer As Boolean = True, Optional Name As String = "", Optional Author As String = "", Optional VerID As String = "") Me.Version = Version Me.Dest = Dest - Me.Type = Type - Me.Saves = Saves + Me.IncludePCL = IncludePCL + Me.Remain = Remain Me.PCLSetupGlobal = PCLSetupGlobal - Me.PCLSetupVer = PCLSetupVer Me.Name = Name Me.VerID = VerID End Sub @@ -930,32 +927,34 @@ Retry: End Sub, "Modpack Export") End Sub Private Function ModpackExportBlocking(Options As ExportOptions) As Boolean - Select Case Options.Type - Case ModpackType.Modrinth - Return ExportModrinth(Options.Version, Options.Dest, Options.Saves, Options.Name, Options.VerID) - Case ModpackType.Compressed - Return ExportCompressed(Options.Version, Options.Dest, Options.Saves, Options.PCLSetupGlobal, Options.PCLSetupVer) - Case Else - Throw New ArgumentException($"未知的整合包类型:{Options.Type}") - End Select + If Options.IncludePCL Then + Return ExportCompressed(Options.Version, Options.Dest, Options.Remain, Options.PCLSetupGlobal) + End If + Return ExportModrinth(Options.Version, Options.Dest, Options.Remain, Options.Name, Options.VerID) End Function #Region "冗余" Private VersionRedundant As String() = {"screenshots", "backups", "command_history\.txt", '个人文件 - ".*-natives", "server-resource-packs", "user.*cache\.json", "\.optifine", "\.fabric", '缓存 - ".*\.jar", "downloads", "realms_persistence.json", "\$\{natives_directory\}", '可联网更新 - "logs", "crash-reports", ".*\.log", '日志 + ".*-natives", "server-resource-packs", "user.*cache\.json", "\.optifine", "\.fabric", "\.mixin\.out", '缓存 + ".*\.jar", "downloads", "realms_persistence.json", "\$\{natives_directory\}", "essential", '可联网更新 + "logs", "crash-reports", ".*\.log", "debug", '日志 ".*\.dat_old", ".*\.old", '备份 "\$\{quickPlayPath\}", '服务器 "\.replay_cache", "replay_recordings", "replay_videos", 'ReplayMod "irisUpdateInfo\.json", 'Iris + "modernfix", 'ModernFix 模组 + "modtranslations", 'Mod 翻译 + "schematics", 'schematics 模组 ".*\.BakaCoreInfo", 'BakaXL 配置 - "hmclversion\.cfg", "log4j2\.xml", 'HMCL 配置 - "PCL", "saves" '到时候会拷,别急 + "hmclversion\.cfg", "log4j2\.xml" 'HMCL 配置 } - Private Function IsVerRedundant(FileName As String) As Boolean + Private Function IsVerRedundant(FilePath As String) As Boolean For Each regex In VersionRedundant - If RegexCheck(FileName, regex) Then Return True + If RegexCheck(GetFileNameFromPath(FilePath).ToLower(), regex) Then Return True + If FilePath.Replace("/", "\").EndsWithF("\journeymap\data\") OrElse + FilePath.Replace("/", "\").EndsWithF("\journeymap\data") Then + Return True + End If Next Return False End Function @@ -972,7 +971,7 @@ Retry: '步骤 1:从 Modrinth 获取 Mod 工程信息,得到 URL Dim Mods As New List(Of McMod) For Each m In Directory.EnumerateFiles(Version.Path & "mods\") - Mods.Add(New McMod(m)) + If m.EndsWithF(".jar") Then Mods.Add(New McMod(m)) Next '从 Modrinth 获取信息 @@ -1046,9 +1045,9 @@ Retry: Return False End Try End Function - Private Function ExportCompressed(Version As McVersion, DestPath As String, Saves As String(), PCLSetupGlobal As Boolean, PCLSetupVer As Boolean) + Private Function ExportCompressed(Version As McVersion, DestPath As String, Saves As String(), PCLSetupGlobal As Boolean) Try - Log($"[Export] 导出整合包(压缩包):{Version.Path} -> {DestPath},导出存档 {If(Saves Is Nothing OrElse Not Saves.Any, "不导出", Saves.Join(", "))},全局设置 {If(PCLSetupGlobal, "导出", "不导出")},版本设置 {If(PCLSetupVer, "导出", "不导出")}") + Log($"[Export] 导出整合包(压缩包):{Version.Path} -> {DestPath},导出存档 {If(Saves Is Nothing OrElse Not Saves.Any, "不导出", Saves.Join(", "))},全局设置 {If(PCLSetupGlobal, "导出", "不导出")}") Dim tempDir As String = $"{ExpTempDir}{GetUuid()}\" Log($"[Export] 缓存文件夹:{tempDir}") Directory.CreateDirectory(tempDir) @@ -1084,11 +1083,6 @@ Retry: If Directory.Exists(Path & "PCL\Musics") Then CopyDirectory(Path & "PCL\Musics", tempDir & "PCL\Musics") End If - If PCLSetupVer Then - Log($"[Export] 正在复制 PCL 版本设置") - If Directory.Exists(Version.Path & "PCL\") Then CopyDirectory(Version.Path & "PCL\", tempVerPath & "PCL\") - End If - If Directory.Exists($"{Version.PathIndie}libraries\optifine") Then '#114 OptiFine Libraries 缺失造成补全文件失败 Log($"[Export] 正在复制 OptiFine Libraries") CopyDirectory($"{Version.PathIndie}libraries\optifine", diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml index dc77126..e9690ad 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml @@ -61,6 +61,7 @@ + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml.vb index 15c81c7..2b26139 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml.vb @@ -1,7 +1,7 @@ Public Class PageVersionExport Private CurrentVersion As McVersion = PageVersionLeft.Version - Private Type As ModpackType = ModpackType.Compressed + Private Type As ModpackType = ModpackType.Modrinth Private SelectedSaves As New List(Of Integer) Private ReadOnly Property Saves As List(Of String) Get @@ -18,22 +18,27 @@ End Sub #Region "控件事件" + Private Function IncludePCL() As Boolean + Return True + End Function Private Sub ComboExportType_Change(sender As ComboBox, e As SelectionChangedEventArgs) Handles ComboExportType.SelectionChanged If AniControlEnabled <> 0 Then Exit Sub - Type = If(sender.SelectedIndex = 0, ModpackType.Compressed, ModpackType.Modrinth) + Type = sender.SelectedIndex Select Case Type Case ModpackType.Modrinth - If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Collapsed - If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Visible - Case ModpackType.Compressed - If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Visible - If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Collapsed + If IncludePCL() Then 'TODO:修改这里的条件 + If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Visible + If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Collapsed + Else + If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Collapsed + If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Visible + End If End Select CardExport.TriggerForceResize() End Sub Private Sub BtnExportExport_Click() Handles BtnExportExport.Click - If Type = ModpackType.Compressed AndAlso Val(VersionBranchCode) <> 50 Then + If IncludePCL() AndAlso Val(VersionBranchCode) <> 50 Then If MyMsgBox("你当前的 PCL 不是正式版,有二次分发(制作压缩包)的限制。" & vbCrLf & "请使用正式版再次尝试该操作!" & vbCrLf & "其他类型的整合包(例如 Modrinth 整合包)没有该限制。", Button1:="下载正式版", Button2:="取消") = 1 Then @@ -46,8 +51,7 @@ If(Type = ModpackType.Modrinth, "Modrinth 整合包(*.mrpack)|*.mrpack", "整合包文件(*.zip)|*.zip")) If String.IsNullOrEmpty(savePath) Then Exit Sub ModpackExport(New ExportOptions(CurrentVersion, savePath, Type, {TbExportSave.Text}, - PCLSetupGlobal:=CheckExportGlobal.Checked, - PCLSetupVer:=CheckExportVersion.Checked, Name:=TbExportName.Text, + PCLSetupGlobal:=CheckExportGlobal.Checked, Name:=TbExportName.Text, VerID:=TbExportVersion.Text)) End Sub