🚧 修改一些龙猫的审查

This commit is contained in:
youzi-2333
2024-07-12 21:42:07 +08:00
parent ae4f1b8672
commit ca07edc707
3 changed files with 46 additions and 47 deletions
@@ -859,8 +859,7 @@ Retry:
''' 整合包类型。 ''' 整合包类型。
''' </summary> ''' </summary>
Public Enum ModpackType Public Enum ModpackType
Modrinth = 4 Modrinth
Compressed = 9
End Enum End Enum
''' <summary> ''' <summary>
''' 导出整合包的选项。 ''' 导出整合包的选项。
@@ -875,22 +874,22 @@ Retry:
''' </summary> ''' </summary>
Public Dest As String Public Dest As String
''' <summary> ''' <summary>
''' 是否包括 PCL 文件。
''' </summary>
Public IncludePCL As Boolean
''' <summary>
''' 整合包类型。 ''' 整合包类型。
''' </summary> ''' </summary>
Public Type As ModpackType Public Type As ModpackType
''' <summary> ''' <summary>
''' 要保留到整合包的存档。 ''' 要保留到整合包的文件。
''' </summary> ''' </summary>
Public Saves As String() Public Remain As String()
''' <summary> ''' <summary>
''' 是否需要保留 PCL 全局设置。仅在压缩包中有效。 ''' 是否需要保留 PCL 全局设置。仅在压缩包中有效。
''' </summary> ''' </summary>
Public PCLSetupGlobal As Boolean = True Public PCLSetupGlobal As Boolean = True
''' <summary> ''' <summary>
''' 是否需要保留 PCL 版本设置。仅在压缩包中有效。
''' </summary>
Public PCLSetupVer As Boolean = True
''' <summary>
''' 整合包名称。仅在 Modrinth 有效。 ''' 整合包名称。仅在 Modrinth 有效。
''' </summary> ''' </summary>
Public Name As String = "" Public Name As String = ""
@@ -900,19 +899,17 @@ Retry:
Public VerID As String = "" Public VerID As String = ""
Public Sub New(Version As McVersion, Public Sub New(Version As McVersion,
Dest As String, Dest As String,
Type As ModpackType, IncludePCL As Boolean,
Saves As String(), Remain As String(),
Optional PCLSetupGlobal As Boolean = True, Optional PCLSetupGlobal As Boolean = True,
Optional PCLSetupVer As Boolean = True,
Optional Name As String = "", Optional Name As String = "",
Optional Author As String = "", Optional Author As String = "",
Optional VerID As String = "") Optional VerID As String = "")
Me.Version = Version Me.Version = Version
Me.Dest = Dest Me.Dest = Dest
Me.Type = Type Me.IncludePCL = IncludePCL
Me.Saves = Saves Me.Remain = Remain
Me.PCLSetupGlobal = PCLSetupGlobal Me.PCLSetupGlobal = PCLSetupGlobal
Me.PCLSetupVer = PCLSetupVer
Me.Name = Name Me.Name = Name
Me.VerID = VerID Me.VerID = VerID
End Sub End Sub
@@ -930,32 +927,34 @@ Retry:
End Sub, "Modpack Export") End Sub, "Modpack Export")
End Sub End Sub
Private Function ModpackExportBlocking(Options As ExportOptions) As Boolean Private Function ModpackExportBlocking(Options As ExportOptions) As Boolean
Select Case Options.Type If Options.IncludePCL Then
Case ModpackType.Modrinth Return ExportCompressed(Options.Version, Options.Dest, Options.Remain, Options.PCLSetupGlobal)
Return ExportModrinth(Options.Version, Options.Dest, Options.Saves, Options.Name, Options.VerID) End If
Case ModpackType.Compressed Return ExportModrinth(Options.Version, Options.Dest, Options.Remain, Options.Name, Options.VerID)
Return ExportCompressed(Options.Version, Options.Dest, Options.Saves, Options.PCLSetupGlobal, Options.PCLSetupVer)
Case Else
Throw New ArgumentException($"未知的整合包类型:{Options.Type}")
End Select
End Function End Function
#Region "冗余" #Region "冗余"
Private VersionRedundant As String() = {"screenshots", "backups", "command_history\.txt", '个人文件 Private VersionRedundant As String() = {"screenshots", "backups", "command_history\.txt", '个人文件
".*-natives", "server-resource-packs", "user.*cache\.json", "\.optifine", "\.fabric", '缓存 ".*-natives", "server-resource-packs", "user.*cache\.json", "\.optifine", "\.fabric", "\.mixin\.out", '缓存
".*\.jar", "downloads", "realms_persistence.json", "\$\{natives_directory\}", '可联网更新 ".*\.jar", "downloads", "realms_persistence.json", "\$\{natives_directory\}", "essential", '可联网更新
"logs", "crash-reports", ".*\.log", '日志 "logs", "crash-reports", ".*\.log", "debug", '日志
".*\.dat_old", ".*\.old", '备份 ".*\.dat_old", ".*\.old", '备份
"\$\{quickPlayPath\}", '服务器 "\$\{quickPlayPath\}", '服务器
"\.replay_cache", "replay_recordings", "replay_videos", 'ReplayMod "\.replay_cache", "replay_recordings", "replay_videos", 'ReplayMod
"irisUpdateInfo\.json", 'Iris "irisUpdateInfo\.json", 'Iris
"modernfix", 'ModernFix 模组
"modtranslations", 'Mod 翻译
"schematics", 'schematics 模组
".*\.BakaCoreInfo", 'BakaXL 配置 ".*\.BakaCoreInfo", 'BakaXL 配置
"hmclversion\.cfg", "log4j2\.xml", 'HMCL 配置 "hmclversion\.cfg", "log4j2\.xml" 'HMCL 配置
"PCL", "saves" '到时候会拷,别急
} }
Private Function IsVerRedundant(FileName As String) As Boolean Private Function IsVerRedundant(FilePath As String) As Boolean
For Each regex In VersionRedundant 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 Next
Return False Return False
End Function End Function
@@ -972,7 +971,7 @@ Retry:
'步骤 1:从 Modrinth 获取 Mod 工程信息,得到 URL '步骤 1:从 Modrinth 获取 Mod 工程信息,得到 URL
Dim Mods As New List(Of McMod) Dim Mods As New List(Of McMod)
For Each m In Directory.EnumerateFiles(Version.Path & "mods\") 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 Next
'从 Modrinth 获取信息 '从 Modrinth 获取信息
@@ -1046,9 +1045,9 @@ Retry:
Return False Return False
End Try End Try
End Function 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 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()}\" Dim tempDir As String = $"{ExpTempDir}{GetUuid()}\"
Log($"[Export] 缓存文件夹:{tempDir}") Log($"[Export] 缓存文件夹:{tempDir}")
Directory.CreateDirectory(tempDir) Directory.CreateDirectory(tempDir)
@@ -1084,11 +1083,6 @@ Retry:
If Directory.Exists(Path & "PCL\Musics") Then CopyDirectory(Path & "PCL\Musics", tempDir & "PCL\Musics") If Directory.Exists(Path & "PCL\Musics") Then CopyDirectory(Path & "PCL\Musics", tempDir & "PCL\Musics")
End If 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 缺失造成补全文件失败 If Directory.Exists($"{Version.PathIndie}libraries\optifine") Then '#114 OptiFine Libraries 缺失造成补全文件失败
Log($"[Export] 正在复制 OptiFine Libraries") Log($"[Export] 正在复制 OptiFine Libraries")
CopyDirectory($"{Version.PathIndie}libraries\optifine", CopyDirectory($"{Version.PathIndie}libraries\optifine",
@@ -61,6 +61,7 @@
<local:MyTextBox x:Name="TbExportVersion" HintText="1.0.0" Grid.Column="2" Grid.Row="2" /> <local:MyTextBox x:Name="TbExportVersion" HintText="1.0.0" Grid.Column="2" Grid.Row="2" />
</Grid> </Grid>
<local:MyButton x:Name="BtnExportExport" HorizontalAlignment="Left" Text="导出整合包" Height="35" Width="150" ColorType="Highlight" /> <local:MyButton x:Name="BtnExportExport" HorizontalAlignment="Left" Text="导出整合包" Height="35" Width="150" ColorType="Highlight" />
<local:MyListItem Title="游戏存档" />
</StackPanel> </StackPanel>
</local:MyCard> </local:MyCard>
</StackPanel> </StackPanel>
@@ -1,7 +1,7 @@
Public Class PageVersionExport Public Class PageVersionExport
Private CurrentVersion As McVersion = PageVersionLeft.Version 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 SelectedSaves As New List(Of Integer)
Private ReadOnly Property Saves As List(Of String) Private ReadOnly Property Saves As List(Of String)
Get Get
@@ -18,22 +18,27 @@
End Sub End Sub
#Region "控件事件" #Region "控件事件"
Private Function IncludePCL() As Boolean
Return True
End Function
Private Sub ComboExportType_Change(sender As ComboBox, e As SelectionChangedEventArgs) Handles ComboExportType.SelectionChanged Private Sub ComboExportType_Change(sender As ComboBox, e As SelectionChangedEventArgs) Handles ComboExportType.SelectionChanged
If AniControlEnabled <> 0 Then Exit Sub If AniControlEnabled <> 0 Then Exit Sub
Type = If(sender.SelectedIndex = 0, ModpackType.Compressed, ModpackType.Modrinth) Type = sender.SelectedIndex
Select Case Type Select Case Type
Case ModpackType.Modrinth Case ModpackType.Modrinth
If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Collapsed If IncludePCL() Then 'TODO:修改这里的条件
If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Visible If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Visible
Case ModpackType.Compressed If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Collapsed
If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Visible Else
If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Collapsed If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Collapsed
If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Visible
End If
End Select End Select
CardExport.TriggerForceResize() CardExport.TriggerForceResize()
End Sub End Sub
Private Sub BtnExportExport_Click() Handles BtnExportExport.Click 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 & If MyMsgBox("你当前的 PCL 不是正式版,有二次分发(制作压缩包)的限制。" & vbCrLf &
"请使用正式版再次尝试该操作!" & vbCrLf & "请使用正式版再次尝试该操作!" & vbCrLf &
"其他类型的整合包(例如 Modrinth 整合包)没有该限制。", Button1:="下载正式版", Button2:="取消") = 1 Then "其他类型的整合包(例如 Modrinth 整合包)没有该限制。", Button1:="下载正式版", Button2:="取消") = 1 Then
@@ -46,8 +51,7 @@
If(Type = ModpackType.Modrinth, "Modrinth 整合包(*.mrpack)|*.mrpack", "整合包文件(*.zip)|*.zip")) If(Type = ModpackType.Modrinth, "Modrinth 整合包(*.mrpack)|*.mrpack", "整合包文件(*.zip)|*.zip"))
If String.IsNullOrEmpty(savePath) Then Exit Sub If String.IsNullOrEmpty(savePath) Then Exit Sub
ModpackExport(New ExportOptions(CurrentVersion, savePath, Type, {TbExportSave.Text}, ModpackExport(New ExportOptions(CurrentVersion, savePath, Type, {TbExportSave.Text},
PCLSetupGlobal:=CheckExportGlobal.Checked, PCLSetupGlobal:=CheckExportGlobal.Checked, Name:=TbExportName.Text,
PCLSetupVer:=CheckExportVersion.Checked, Name:=TbExportName.Text,
VerID:=TbExportVersion.Text)) VerID:=TbExportVersion.Text))
End Sub End Sub