✨ 完成 UI
This commit is contained in:
@@ -891,6 +891,10 @@ Retry:
|
||||
''' </summary>
|
||||
Public PCLSetupVer As Boolean = True
|
||||
''' <summary>
|
||||
''' 整合包名称。仅在 Modrinth 有效。
|
||||
''' </summary>
|
||||
Public Name As String = ""
|
||||
''' <summary>
|
||||
''' 版本号。仅在 Modrinth 有效。
|
||||
''' </summary>
|
||||
Public VerID As String = ""
|
||||
@@ -900,6 +904,8 @@ Retry:
|
||||
Saves 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
|
||||
@@ -907,23 +913,35 @@ Retry:
|
||||
Me.Saves = Saves
|
||||
Me.PCLSetupGlobal = PCLSetupGlobal
|
||||
Me.PCLSetupVer = PCLSetupVer
|
||||
Me.Name = Name
|
||||
Me.VerID = VerID
|
||||
End Sub
|
||||
End Class
|
||||
''' <summary>
|
||||
''' 导出整合包。
|
||||
''' 导出整合包。不阻塞。
|
||||
''' </summary>
|
||||
Public Sub ModpackExport(Options As ExportOptions)
|
||||
Hint("正在导出……")
|
||||
RunInNewThread(Sub()
|
||||
If ModpackExportBlocking(Options) Then
|
||||
Hint("导出成功!", HintType.Finish)
|
||||
OpenExplorer($"""{GetPathFromFullPath(Options.Dest)}""")
|
||||
End If
|
||||
End Sub, "Modpack Export")
|
||||
End Sub
|
||||
Private Function ModpackExportBlocking(Options As ExportOptions) As Boolean
|
||||
Select Case Options.Type
|
||||
Case ModpackType.Modrinth
|
||||
ExportModrinth(Options.Version, Options.Dest, Options.Saves, Options.VerID)
|
||||
Return ExportModrinth(Options.Version, Options.Dest, Options.Saves, Options.Name, Options.VerID)
|
||||
Case ModpackType.Compressed
|
||||
ExportCompressed(Options.Version, Options.Dest, Options.Saves, Options.PCLSetupGlobal, Options.PCLSetupVer)
|
||||
Return ExportCompressed(Options.Version, Options.Dest, Options.Saves, Options.PCLSetupGlobal, Options.PCLSetupVer)
|
||||
Case Else
|
||||
Throw New ArgumentException($"未知的整合包类型:{Options.Type}")
|
||||
End Select
|
||||
End Sub
|
||||
End Function
|
||||
|
||||
#Region "冗余"
|
||||
Private VersionRedundant As String() = {"saves", "screenshots", "backups", "command_history\.txt", '个人文件
|
||||
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", '日志
|
||||
@@ -932,7 +950,7 @@ Retry:
|
||||
"\.replay_cache", "replay_recordings", "replay_videos", 'ReplayMod
|
||||
"irisUpdateInfo\.json", 'Iris
|
||||
".*\.BakaCoreInfo", 'BakaXL
|
||||
"PCL" '到时候会拷,别急
|
||||
"PCL", "saves" '到时候会拷,别急
|
||||
}
|
||||
Private Function IsVerRedundant(FileName As String) As Boolean
|
||||
For Each regex In VersionRedundant
|
||||
@@ -943,7 +961,7 @@ Retry:
|
||||
#End Region
|
||||
|
||||
#Region "不同类型整合包的导出方法"
|
||||
Private Sub ExportModrinth(Version As McVersion, DestPath As String, Saves As String(), VerID As String)
|
||||
Private Function ExportModrinth(Version As McVersion, DestPath As String, Saves As String(), Name As String, VerID As String)
|
||||
Try
|
||||
Log($"[Export] 导出整合包(Modrinth):{Version.Path} -> {DestPath},导出存档 {If(Saves Is Nothing OrElse Not Saves.Any, "不导出", Saves.Join(", "))}")
|
||||
Dim tempDir As String = $"{ExpTempDir}{GetUuid()}\"
|
||||
@@ -998,7 +1016,7 @@ Retry:
|
||||
{"game", "minecraft"},
|
||||
{"formatVersion", 1},
|
||||
{"versionId", VerID},
|
||||
{"name", Version.Name},
|
||||
{"name", If(String.IsNullOrEmpty(Name), Version.Name, Name)},
|
||||
{"summary", Version.Info},
|
||||
{"files", files},
|
||||
{"dependencies", depend}
|
||||
@@ -1013,6 +1031,7 @@ Retry:
|
||||
|
||||
'存档
|
||||
For Each s In Saves
|
||||
If String.IsNullOrWhiteSpace(s) Then Continue For '草了,传空字串进去会直接把 saves 整个文件夹拷过去
|
||||
Dim fromPath As String = $"{Version.Path}saves\{s}"
|
||||
If Directory.Exists(fromPath) Then CopyDirectory(fromPath, $"{tempDir}overrides\saves\{s}")
|
||||
Next
|
||||
@@ -1020,11 +1039,13 @@ Retry:
|
||||
If File.Exists(DestPath) Then File.Delete(DestPath) '选择文件的时候已经确认了要替换
|
||||
ZipFile.CreateFromDirectory(tempDir, DestPath)
|
||||
DeleteDirectory(tempDir)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Log(ex, "导出整合包失败", LogLevel.Msgbox)
|
||||
Return False
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub ExportCompressed(Version As McVersion, DestPath As String, Saves As String(), PCLSetupGlobal As Boolean, PCLSetupVer As Boolean)
|
||||
End Function
|
||||
Private Function ExportCompressed(Version As McVersion, DestPath As String, Saves As String(), PCLSetupGlobal As Boolean, PCLSetupVer As Boolean)
|
||||
Try
|
||||
Log($"[Export] 导出整合包(压缩包):{Version.Path} -> {DestPath},导出存档 {If(Saves Is Nothing OrElse Not Saves.Any, "不导出", Saves.Join(", "))},全局设置 {If(PCLSetupGlobal, "导出", "不导出")},版本设置 {If(PCLSetupVer, "导出", "不导出")}")
|
||||
Dim tempDir As String = $"{ExpTempDir}{GetUuid()}\"
|
||||
@@ -1079,10 +1100,12 @@ Retry:
|
||||
If File.Exists(DestPath) Then File.Delete(DestPath) '选择文件的时候已经确认了要替换
|
||||
ZipFile.CreateFromDirectory(tempDir, DestPath)
|
||||
DeleteDirectory(tempDir)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Log(ex, "导出整合包失败", LogLevel.Msgbox)
|
||||
Return False
|
||||
End Try
|
||||
End Sub
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#End Region
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
PanScroll="{Binding ElementName=PanBack}">
|
||||
<local:MyScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<StackPanel Margin="25,10">
|
||||
<local:MyCard Margin="0,0,0,15" Title="导出选项">
|
||||
<local:MyCard x:Name="CardExport" Margin="0,20,0,15" Title="导出选项">
|
||||
<StackPanel Margin="25,40,25,21">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -20,12 +20,46 @@
|
||||
<RowDefinition Height="9" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="9" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Text="整合包类型" VerticalAlignment="Center" />
|
||||
<local:MyComboBox x:Name="ComboExportType" Margin="10,0,0,0" Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="0">
|
||||
<local:MyComboBoxItem Content="压缩包" IsSelected="True" />
|
||||
<local:MyComboBoxItem Content="Modrinth" />
|
||||
</local:MyComboBox>
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Text="包含存档" VerticalAlignment="Center" />
|
||||
<local:MyTextBox x:Name="TbExportSave" HintText="不包含存档" ToolTip="填写存档的目录名,注意不是存档名。留空则不包含存档。" Margin="10,0,0,0" Grid.Column="1" Grid.Row="2" Tag="1" />
|
||||
</Grid>
|
||||
<Grid x:Name="GridCompressed">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Name" />
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="9" />
|
||||
</Grid.RowDefinitions>
|
||||
<local:MyCheckBox x:Name="CheckExportGlobal" Text="导出 PCL 全局设置" Grid.Column="0" Grid.Row="0" Checked="True" />
|
||||
<local:MyCheckBox x:Name="CheckExportVersion" Text="导出 PCL 版本设置" Grid.Column="2" Grid.Row="0" Checked="True" />
|
||||
</Grid>
|
||||
<Grid x:Name="GridModrinth" Visibility="Collapsed">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Name" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="9" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="9" />
|
||||
</Grid.RowDefinitions>
|
||||
<local:MyButton x:Name="BtnExportExport" Margin="0,0,0,0" Text="导出整合包" Grid.Column="0" Grid.Row="0" Width="150" />
|
||||
<TextBlock Text="整合包名称" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" />
|
||||
<local:MyTextBox x:Name="TbExportName" HintText="" Grid.Column="2" Grid.Row="0" Width="140" />
|
||||
<TextBlock Text="整合包版本" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" />
|
||||
<local:MyTextBox x:Name="TbExportVersion" HintText="1.0.0" Grid.Column="2" Grid.Row="2" Width="140" />
|
||||
</Grid>
|
||||
<local:MyButton x:Name="BtnExportExport" HorizontalAlignment="Left" Text="导出整合包" Height="35" Width="150" ColorType="Highlight" />
|
||||
</StackPanel>
|
||||
</local:MyCard>
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,15 +1,56 @@
|
||||
Public Class PageVersionExport
|
||||
Public Sub BtnExportExport_Click() Handles BtnExportExport.Click
|
||||
Dim Type As ModpackType = ModpackType.Modrinth
|
||||
|
||||
Private CurrentVersion As McVersion = PageVersionLeft.Version
|
||||
Private Type As ModpackType = ModpackType.Compressed
|
||||
Private SelectedSaves As New List(Of Integer)
|
||||
Private ReadOnly Property Saves As List(Of String)
|
||||
Get
|
||||
If Directory.Exists(CurrentVersion.Path & "saves\") Then
|
||||
Return Directory.EnumerateDirectories(CurrentVersion.Path & "saves\").ToList
|
||||
End If
|
||||
Return New List(Of String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private Sub PageVersionExport_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
||||
CurrentVersion = PageVersionLeft.Version '各个版本不同,每次都需要重新加载
|
||||
TbExportName.HintText = CurrentVersion.Name
|
||||
End Sub
|
||||
|
||||
#Region "控件事件"
|
||||
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)
|
||||
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
|
||||
End Select
|
||||
CardExport.TriggerForceResize()
|
||||
End Sub
|
||||
|
||||
Private Sub BtnExportExport_Click() Handles BtnExportExport.Click
|
||||
If Type = ModpackType.Compressed AndAlso Val(VersionBranchCode) <> 50 Then
|
||||
MyMsgBox("你当前的 PCL 不是正式版,且受到再次分发(制作压缩包)的限制。" & vbCrLf &
|
||||
If MyMsgBox("你当前的 PCL 不是正式版,且受到再次分发(制作压缩包)的限制。" & vbCrLf &
|
||||
"请使用正式版再次进行该操作再试!" & vbCrLf &
|
||||
"其他类型的整合包(例如 Modrinth 整合包)没有该限制。")
|
||||
"其他类型的整合包(例如 Modrinth 整合包)没有该限制。", Button1:="下载正式版", Button2:="取消") = 1 Then
|
||||
OpenWebsite("https://afdian.net/p/0164034c016c11ebafcb52540025c377")
|
||||
End If
|
||||
Exit Sub
|
||||
End If
|
||||
RunInNewThread(Sub()
|
||||
ModpackExport(New ExportOptions(McVersionCurrent, Path & "exportmr.zip", Type, {"新的世界", "雕塑"},
|
||||
PCLSetupGlobal:=False, PCLSetupVer:=True, VerID:="1.2.3"))
|
||||
End Sub, "Modpack Export")
|
||||
Dim savePath As String = SelectAs(
|
||||
"选择导出位置", $"整合包 - {If(String.IsNullOrWhiteSpace(TbExportName.Text), CurrentVersion.Name, TbExportName.Text)}" & If(Type = ModpackType.Modrinth, ".mrpack", ".zip"),
|
||||
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,
|
||||
VerID:=TbExportVersion.Text))
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<local:MyListItem x:Name="ItemModDisabled" IsScaleAnimationEnabled="False" Type="RadioBox" Tag="3" MinPaddingRight="35" Height="36" VerticalAlignment="Top" Title="Mod 管理"
|
||||
Logo="M789.504 912.896h-195.072a35.328 35.328 0 0 1-34.816-35.328v-77.312a39.936 39.936 0 0 0-40.448-39.936H481.28a40.448 40.448 0 0 0-40.448 39.936v77.312a34.816 34.816 0 0 1-34.816 35.328H204.8a41.984 41.984 0 0 1-40.448-42.496v-200.192a35.328 35.328 0 0 1 35.328-35.328h72.704a39.936 39.936 0 0 0 39.936-39.936v-37.888a39.936 39.936 0 0 0-39.936-40.448H199.68a35.328 35.328 0 0 1-35.328-35.328V287.744A41.984 41.984 0 0 1 204.8 245.76h176.64v-32.768a102.4 102.4 0 0 1 102.4-102.4h33.792a102.4 102.4 0 0 1 102.4 102.4v32.768h170.496a41.984 41.984 0 0 1 41.984 41.984V460.8h28.672a102.4 102.4 0 0 1 102.4 102.4v33.792a102.4 102.4 0 0 1-102.4 102.4h-28.672V870.4a41.984 41.984 0 0 1-43.008 42.496z m-159.744-70.144h131.584V665.6a34.304 34.304 0 0 1 34.816-34.816h64a31.744 31.744 0 0 0 31.744-31.744V563.2a31.744 31.744 0 0 0-31.744-31.744h-64a34.816 34.816 0 0 1-34.816-35.328V316.416h-177.152a35.328 35.328 0 0 1-35.328-35.328V212.992a31.744 31.744 0 0 0-31.744-31.744h-33.792a31.744 31.744 0 0 0-31.744 31.744v68.096a35.328 35.328 0 0 1-34.816 35.328H234.496v130.048h37.888a110.592 110.592 0 0 1 110.08 110.592v37.888a110.592 110.592 0 0 1-110.08 110.592h-37.888v137.216h136.192v-42.496a110.592 110.592 0 0 1 110.592-110.08h37.888a110.592 110.592 0 0 1 110.592 110.08z" />
|
||||
<local:MyListItem x:Name="ItemExport" IsScaleAnimationEnabled="False" Type="RadioBox" Tag="4" MinPaddingRight="35" Height="36" VerticalAlignment="Top" Title="导出整合包"
|
||||
Logo="M789.504 912.896h-195.072a35.328 35.328 0 0 1-34.816-35.328v-77.312a39.936 39.936 0 0 0-40.448-39.936H481.28a40.448 40.448 0 0 0-40.448 39.936v77.312a34.816 34.816 0 0 1-34.816 35.328H204.8a41.984 41.984 0 0 1-40.448-42.496v-200.192a35.328 35.328 0 0 1 35.328-35.328h72.704a39.936 39.936 0 0 0 39.936-39.936v-37.888a39.936 39.936 0 0 0-39.936-40.448H199.68a35.328 35.328 0 0 1-35.328-35.328V287.744A41.984 41.984 0 0 1 204.8 245.76h176.64v-32.768a102.4 102.4 0 0 1 102.4-102.4h33.792a102.4 102.4 0 0 1 102.4 102.4v32.768h170.496a41.984 41.984 0 0 1 41.984 41.984V460.8h28.672a102.4 102.4 0 0 1 102.4 102.4v33.792a102.4 102.4 0 0 1-102.4 102.4h-28.672V870.4a41.984 41.984 0 0 1-43.008 42.496z m-159.744-70.144h131.584V665.6a34.304 34.304 0 0 1 34.816-34.816h64a31.744 31.744 0 0 0 31.744-31.744V563.2a31.744 31.744 0 0 0-31.744-31.744h-64a34.816 34.816 0 0 1-34.816-35.328V316.416h-177.152a35.328 35.328 0 0 1-35.328-35.328V212.992a31.744 31.744 0 0 0-31.744-31.744h-33.792a31.744 31.744 0 0 0-31.744 31.744v68.096a35.328 35.328 0 0 1-34.816 35.328H234.496v130.048h37.888a110.592 110.592 0 0 1 110.08 110.592v37.888a110.592 110.592 0 0 1-110.08 110.592h-37.888v137.216h136.192v-42.496a110.592 110.592 0 0 1 110.592-110.08h37.888a110.592 110.592 0 0 1 110.592 110.08z" >
|
||||
Logo="M511.488 995.328a128.654222 128.654222 0 0 1-57.116444-13.112889L70.769778 791.808a126.833778 126.833778 0 0 1-70.769778-113.777778V311.608889a126.179556 126.179556 0 0 1 15.36-60.103111V248.604444c1.479111-2.901333 3.356444-5.603556 5.518222-8.021333a127.630222 127.630222 0 0 1 49.891556-42.325333L454.371556 13.368889a128.739556 128.739556 0 0 1 112.981333 0l383.601778 190.407111a126.862222 126.862222 0 0 1 72.049777 113.379556v360.874666a126.805333 126.805333 0 0 1-70.769777 115.939556L568.604444 984.32c-17.92 7.964444-37.461333 11.747556-57.116444 11.008z m42.638222-470.897778v370.204445l360.192-178.545778c14.449778-7.253333 23.552-21.987556 23.438222-38.087111v-335.928889L554.097778 524.430222zM85.248 330.666667v347.335111a42.268444 42.268444 0 0 0 23.438222 38.087111l360.192 178.545778V523.576889L85.248 330.666667zM135.537778 260.835556l375.950222 189.952 137.671111-65.564445L286.435556 188.074667 135.537778 260.864z m245.105778-118.471112l363.576888 197.973334 150.897778-71.480889-365.283555-180.224a42.922667 42.922667 0 0 0-37.518223 0l-111.672888 53.731555z" >
|
||||
</local:MyListItem>
|
||||
</StackPanel>
|
||||
</local:MyPageLeft>
|
||||
|
||||
Reference in New Issue
Block a user