From 87e1fb0b1e229f54eca552b3456ff24ac556116d Mon Sep 17 00:00:00 2001 From: youzi-2333 Date: Wed, 10 Jul 2024 22:14:55 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E5=8C=85=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModModpack.vb | 59 ++++++++++++++----- .../PageVersion/PageVersionExport.xaml.vb | 7 ++- .../Plain Craft Launcher 2.vbproj | 4 -- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb index 3dd9730..02bfe5a 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb @@ -859,10 +859,6 @@ Retry: ''' 整合包类型。 ''' Public Enum ModpackType - CurseForge = 0 - HMCL = 1 - MMC = 2 - MCBBS = 3 Modrinth = 4 Compressed = 9 End Enum @@ -886,17 +882,39 @@ Retry: ''' 要保留到整合包的存档。 ''' Public Saves As String() + ''' + ''' 是否需要保留 PCL 全局设置。仅在压缩包中有效。 + ''' + Public PCLSetupGlobal As Boolean = True + ''' + ''' 是否需要保留 PCL 版本设置。仅在压缩包中有效。 + ''' + Public PCLSetupVer As Boolean = True + Public Sub New(Version As McVersion, + Dest As String, + Type As ModpackType, + Saves As String(), + Optional PCLSetupGlobal As Boolean = True, + Optional PCLSetupVer As Boolean = True) + Me.Version = Version + Me.Dest = Dest + Me.Type = Type + Me.Saves = Saves + Me.PCLSetupGlobal = PCLSetupGlobal + Me.PCLSetupVer = PCLSetupVer + End Sub End Class ''' ''' 导出整合包。 ''' - ''' 是否成功。 - Public Function ModpackExport(Options As ExportOptions) + Public Sub ModpackExport(Options As ExportOptions) Select Case Options.Type + Case ModpackType.Modrinth + ExportModrinth(Options.Version, Options.Dest, Options.Saves) Case ModpackType.Compressed - ExportCompressed(Options.Version, Options.Dest) + ExportCompressed(Options.Version, Options.Dest, Options.Saves, Options.PCLSetupGlobal, Options.PCLSetupVer) End Select - End Function + End Sub #Region "冗余" Private VersionRedundant As String() = {"saves", "screenshots", "backups", "command_history\.txt", '个人文件 @@ -907,7 +925,8 @@ Retry: "\$\{quickPlayPath\}", '服务器 "\.replay_cache", "replay_recordings", "replay_videos", 'ReplayMod "irisUpdateInfo\.json", 'Iris - ".*\.BakaCoreInfo" 'BakaXL + ".*\.BakaCoreInfo", 'BakaXL + "PCL" '到时候会拷,别急 } Private Function IsVerRedundant(FileName As String) As Boolean For Each regex In VersionRedundant @@ -918,7 +937,10 @@ Retry: #End Region #Region "不同类型整合包的导出方法" - Private Sub ExportCompressed(Version As McVersion, DestPath As String, Optional Saves As String() = Nothing, Optional PCLSetup As Boolean = True) + Private Sub ExportModrinth(Version As McVersion, DestPath As String, Saves As String()) + + End Sub + Private Sub ExportCompressed(Version As McVersion, DestPath As String, Saves As String(), PCLSetupGlobal As Boolean, PCLSetupVer As Boolean) Try Dim tempDir As String = $"{ExpTempDir}{GetUuid()}\" Directory.CreateDirectory(tempDir) @@ -928,25 +950,34 @@ Retry: If Not IsVerRedundant(GetFileNameFromPath(f)) Then CopyFile(f, tempVerPath & GetFileNameFromPath(f)) Next For Each d In Directory.EnumerateDirectories(Version.Path) - If Not IsVerRedundant(GetFolderNameFromPath(d)) Then CopyDirectory(d, tempVerPath & GetFileNameFromPath(d)) + If Not IsVerRedundant(GetFolderNameFromPath(d)) Then CopyDirectory(d, $"{tempVerPath}{GetFolderNameFromPath(d)}\") Next If Saves IsNot Nothing Then For Each s In Saves - Dim saveFullPath As String = Version.Path & "saves" & s + Dim saveFullPath As String = $"{Version.Path}saves\{s}" If Not Directory.Exists(saveFullPath) Then Continue For CopyDirectory(saveFullPath, $"{tempVerPath}saves\{s}") Next End If - If PCLSetup Then + If PCLSetupGlobal Then If File.Exists(Path & "PCL\Setup.ini") Then CopyFile("PCL\Setup.ini", tempDir & "PCL\Setup.ini") If File.Exists(Path & "PCL\Custom.xaml") Then CopyFile("PCL\Custom.xaml", tempDir & "PCL\Custom.xaml") If Directory.Exists(Path & "PCL\Pictures") Then CopyDirectory(Path & "PCL\Pictures", tempDir & "PCL\Pictures") If Directory.Exists(Path & "PCL\Musics") Then CopyDirectory(Path & "PCL\Musics", tempDir & "PCL\Musics") End If - CopyFile(PathWithName, tempDir & GetFileNameFromPath(PathWithName)) + If PCLSetupVer Then + 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 缺失造成补全文件失败 + CopyDirectory($"{Version.PathIndie}libraries\optifine", + $"{tempDir}{GetFolderNameFromPath(Version.PathIndie)}libraries\optifine") + End If + + CopyFile(PathWithName, tempDir & GetFileNameFromPath(PathWithName)) 'PCL 本体 If File.Exists(DestPath) Then File.Delete(DestPath) '选择文件的时候已经确认了要替换 ZipFile.CreateFromDirectory(tempDir, DestPath) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml.vb index 03316cb..c8188ac 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml.vb @@ -1,5 +1,10 @@ Public Class PageVersionExport Public Sub BtnExportExport_Click() Handles BtnExportExport.Click - ModpackExport(New ExportOptions With {.Version = McVersionCurrent, .Type = ModpackType.Compressed, .Dest = Path & "export.zip"}) + ModpackExport(New ExportOptions(McVersionCurrent, + Path & "export.zip", + ModpackType.Compressed, + {"新的世界", "雕塑"}, + PCLSetupGlobal:=False, + PCLSetupVer:=True)) End Sub End Class diff --git a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj index ab8011b..ffd61a8 100644 --- a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj +++ b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj @@ -677,10 +677,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile -