@@ -0,0 +1,121 @@
|
||||
<local:MyPageRight
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:PCL" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:System="clr-namespace:System;assembly=mscorlib"
|
||||
mc:Ignorable="d" x:Class="PageVersionExport"
|
||||
PanScroll="{Binding ElementName=PanBack}">
|
||||
<local:MyScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<StackPanel Margin="25,10">
|
||||
<local:MyHint Margin="0,10,0,0" IsWarn="False" Text="当前页面导出的整合包是 Modrinth 格式(.mrpack)。" />
|
||||
|
||||
<local:MyCard Margin="0,15" Title="导出预览">
|
||||
<StackPanel Margin="25,38,15,15">
|
||||
<Grid Margin="-10,-5,10,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="150" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Margin="10,7,10,7" Name="PanDisplayItem" Grid.Column="0" />
|
||||
<local:MyButton x:Name="BtnExportExport" Grid.Column="1" HorizontalAlignment="Right"
|
||||
Text="导出整合包" Width="150" Height="35" ColorType="Highlight" />
|
||||
</Grid>
|
||||
<Grid Margin="0,5,10,5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Name" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="60" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="9" />
|
||||
<RowDefinition Height="28" />
|
||||
<!--<RowDefinition Height="9" />
|
||||
<RowDefinition Height="28" />-->
|
||||
<RowDefinition Height="9" />
|
||||
<RowDefinition Height="28" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Text="整合包名称" Margin="0,0,25,0" />
|
||||
<local:MyTextBox Grid.Row="0" x:Name="TbExportName" Grid.ColumnSpan="2" Grid.Column="1" MaxLength="100" ShowValidateResult="True" />
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="整合包版本" Margin="0,0,25,0" />
|
||||
<local:MyTextBox Grid.Row="2" x:Name="TbExportVersion" HintText="1.0.0" Grid.ColumnSpan="2" Tag="VersionArgumentTitle" Grid.Column="1" MaxLength="100" />
|
||||
<!--<TextBlock Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Left" Text="图标" Margin="0,0,25,0" />
|
||||
<local:MyComboBox x:Name="ComboDisplayLogo" Grid.Row="4" Grid.ColumnSpan="2" Grid.Column="1">
|
||||
<local:MyComboBoxItem Content="自动" IsSelected="True" Tag="" />
|
||||
<local:MyComboBoxItem x:Name="ItemDisplayLogoCustom" Content="自定义..." />
|
||||
<local:MyComboBoxItem Content="圆石" Tag="pack://application:,,,/images/Blocks/CobbleStone.png" />
|
||||
<local:MyComboBoxItem Content="命令方块" Tag="pack://application:,,,/images/Blocks/CommandBlock.png" />
|
||||
<local:MyComboBoxItem Content="金块" Tag="pack://application:,,,/images/Blocks/GoldBlock.png" />
|
||||
<local:MyComboBoxItem Content="草方块" Tag="pack://application:,,,/images/Blocks/Grass.png" />
|
||||
<local:MyComboBoxItem Content="草径" Tag="pack://application:,,,/images/Blocks/GrassPath.png" />
|
||||
<local:MyComboBoxItem Content="铁砧" Tag="pack://application:,,,/images/Blocks/Anvil.png" />
|
||||
<local:MyComboBoxItem Content="红石块" Tag="pack://application:,,,/images/Blocks/RedstoneBlock.png" />
|
||||
<local:MyComboBoxItem Content="红石灯(开)" Tag="pack://application:,,,/images/Blocks/RedstoneLampOn.png" />
|
||||
<local:MyComboBoxItem Content="红石灯(关)" Tag="pack://application:,,,/images/Blocks/RedstoneLampOff.png" />
|
||||
<local:MyComboBoxItem Content="鸡蛋" Tag="pack://application:,,,/images/Blocks/Egg.png" />
|
||||
<local:MyComboBoxItem Content="布料(Fabric)" Tag="pack://application:,,,/images/Blocks/Fabric.png" />
|
||||
<local:MyComboBoxItem Content="狐狸(NeoForge)" Tag="pack://application:,,,/images/Blocks/NeoForge.png" />
|
||||
</local:MyComboBox>-->
|
||||
<TextBlock Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Left" Text="描述" Margin="0,0,25,0" />
|
||||
<local:MyTextBox Grid.Row="4" x:Name="TbExportDesc" Grid.ColumnSpan="2" Grid.Column="1" TextWrapping="Wrap" VerticalContentAlignment="Top" Padding="0,5" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</local:MyCard>
|
||||
|
||||
<local:MyCard x:Name="CardSwitch" Margin="0,0,0,15" Title="基础选项">
|
||||
<StackPanel Margin="25,38,15,15">
|
||||
<TextBlock x:Name="TbHint" Margin="0,1,0,1" Text="你可以在此勾选需要包含进整合包的文件或文件夹,其他文件或文件夹在高级选项添加。" TextWrapping="Wrap" />
|
||||
<!-- 注意:以上 TextBlock 的 Text 属性可能会在代码中被改动。 -->
|
||||
<Grid x:Name="PanCommonFiles">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="18" />
|
||||
<ColumnDefinition Width="1.7*" />
|
||||
<ColumnDefinition Width="1.9*" />
|
||||
<ColumnDefinition Width="1.4*" />
|
||||
<ColumnDefinition Width="1.0*" />
|
||||
<ColumnDefinition Width="1.0*" />
|
||||
<ColumnDefinition Width="1.0*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="游戏配置" VerticalAlignment="Center" Grid.Column="0" Grid.Row="1" />
|
||||
<local:MyCheckBox Height="22" VerticalAlignment="Center" Grid.Row="1" Grid.Column="2" Text="服务器列表"
|
||||
Tag="servers.dat" ToolTip="servers.dat 文件" />
|
||||
<local:MyCheckBox Height="22" VerticalAlignment="Center" Grid.Row="1" Grid.Column="3" Text="Mod 配置"
|
||||
Tag="config" ToolTip="config 文件夹" />
|
||||
<local:MyCheckBox Height="22" VerticalAlignment="Center" Grid.Row="1" Grid.Column="4" Text="游戏配置"
|
||||
Tag="options.txt" ToolTip="options.txt 文件" />
|
||||
<TextBlock Text="游戏文件" VerticalAlignment="Center" Grid.Column="0" Grid.Row="2" />
|
||||
<local:MyCheckBox Height="22" VerticalAlignment="Center" Grid.Row="2" Grid.Column="2" Text="存档"
|
||||
Tag="saves" ToolTip="saves 文件夹" />
|
||||
<local:MyCheckBox Height="22" VerticalAlignment="Center" Grid.Row="2" Grid.Column="3" Text="资源包"
|
||||
Tag="resourcepacks" ToolTip="resourcepacks 文件夹" />
|
||||
<local:MyCheckBox Height="22" VerticalAlignment="Center" Grid.Row="2" Grid.Column="4" Text="光影包"
|
||||
Tag="shaderpacks" ToolTip="shaderpacks 文件夹" />
|
||||
<TextBlock Text="PCL 配置" VerticalAlignment="Center" Grid.Column="0" Grid.Row="3" />
|
||||
<local:MyCheckBox x:Name="CheckIncludePCL" Height="22" VerticalAlignment="Center" Grid.Row="3" Grid.Column="2" Text="包含启动器"
|
||||
Tag="" ToolTip="将 PCL 程序包含在整合包内" />
|
||||
<local:MyCheckBox x:Name="CheckIncludeSetup" Height="22" VerticalAlignment="Center" Grid.Row="3" Grid.Column="3" Text="PCL 全局配置"
|
||||
Tag="" ToolTip="将 PCL 全局配置包含在整合包内" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
</local:MyCard>
|
||||
<local:MyCard x:Name="CardMore" Title="高级选项" Margin="0,0,0,15" CanSwap="True" IsSwaped="True">
|
||||
<StackPanel x:Name="PanFileList" Margin="25,40,23,15">
|
||||
<TextBlock Margin="0,1,0,10" Text="你可以在此勾选其他需要包含进整合包的内容。
请注意:部分必须包含在整合包中的内容(如 Mods 等),以及被排除的冗余文件(如游戏日志等),将不会在列表中展示。" TextWrapping="Wrap" />
|
||||
<local:MyListItem Type="CheckBox" Title="游戏存档" Height="35" Logo="M889.018182 418.909091H884.363636V316.509091a93.090909 93.090909 0 0 0-99.607272-89.832727h-302.545455l-93.090909-76.334546A46.545455 46.545455 0 0 0 358.865455 139.636364H146.152727A93.090909 93.090909 0 0 0 46.545455 229.469091V837.818182a46.545455 46.545455 0 0 0 46.545454 46.545454 46.545455 46.545455 0 0 0 16.756364-3.258181 109.381818 109.381818 0 0 0 25.134545 3.258181h586.472727a85.178182 85.178182 0 0 0 87.04-63.301818l163.374546-302.545454a46.545455 46.545455 0 0 0 5.585454-21.876364A82.385455 82.385455 0 0 0 889.018182 418.909091z m-744.727273-186.181818h198.283636l93.09091 76.334545a46.545455 46.545455 0 0 0 29.323636 10.705455h319.301818a12.101818 12.101818 0 0 1 6.516364 0V418.909091H302.545455a85.178182 85.178182 0 0 0-87.04 63.301818L139.636364 622.778182V232.727273a19.549091 19.549091 0 0 1 6.516363 0z m578.094546 552.029091a27.461818 27.461818 0 0 0-2.792728 6.516363H154.530909l147.083636-272.290909a27.461818 27.461818 0 0 0 2.792728-6.981818h565.061818z" />
|
||||
<local:MyListItem Type="CheckBox" Title="游戏存档" Height="35" Logo="M586.9 436h-74.7V62.4H177.1c-20.6 0-37.4 16.7-37.4 37.4v821.9c0 20.6 16.7 37.4 37.4 37.4h672.5c20.6 0 37.4-16.7 37.4-37.4V436H586.9z m0-74.7h297.8c-7.3-57.4-31.2-70.9-58.4-98.1l-66.5-66.5-0.1-0.1 0.1 0.1-0.9-0.9-22.8-22.8-0.9-0.9 0.1 0.1-0.1-0.1-66.5-66.5c-21.8-21.8-38.8-36.5-81.7-41.4l-0.1 297.1z" />
|
||||
<local:MyListItem Type="CheckBox" Title="游戏存档" Height="35" Logo="M757.792745 435.407215L419.597482 96.904967c-40.010393-40.010393-104.886579-40.010393-144.896972 0-40.010393 40.010393-40.010393 104.988908 0 144.9993L540.344959 507.855701 274.70051 773.807135c-40.010393 40.112721-40.010393 104.988908 0 144.9993 40.010393 40.010393 104.886579 40.010393 144.896972 0l338.092935-338.39992c40.112721-40.010393 40.112721-104.988908 0.102328-144.9993z" />
|
||||
</StackPanel>
|
||||
</local:MyCard>
|
||||
|
||||
</StackPanel>
|
||||
</local:MyScrollViewer>
|
||||
</local:MyPageRight>
|
||||
@@ -0,0 +1,346 @@
|
||||
Public Class PageVersionExport
|
||||
Private CurrentVer As String = ""
|
||||
Private Sub PageVersionExport_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
||||
Reload()
|
||||
End Sub
|
||||
|
||||
Public ItemVersion As MyListItem
|
||||
Public Sub Reload()
|
||||
AniControlEnabled += 1
|
||||
|
||||
If CurrentVer <> PageVersionLeft.Version.Path Then
|
||||
'说明切换到另一个版本了,所有的设置都要重置
|
||||
CurrentPath = ""
|
||||
Selected = New List(Of String)
|
||||
CurrentVer = PageVersionLeft.Version.Path
|
||||
|
||||
TbExportName.Text = ""
|
||||
TbExportVersion.Text = ""
|
||||
'ComboDisplayLogo.SelectedIndex = 0
|
||||
CustomLogoVal = Nothing
|
||||
TbExportDesc.Text = ""
|
||||
End If
|
||||
|
||||
TbExportName.ShowValidateResult = True
|
||||
TbExportName.ValidateRules = New ObjectModel.Collection(Of Validate) From {New ValidateFileName() With {.AllowNull = True}}
|
||||
TbExportName.Validate()
|
||||
|
||||
TbExportName.HintText = PageVersionLeft.Version.Name
|
||||
TbExportDesc.HintText = PageVersionLeft.Version.Info
|
||||
PanDisplayItem.Children.Clear()
|
||||
ItemVersion = PageSelectRight.McVersionListItem(PageVersionLeft.Version.Load())
|
||||
ItemVersion.IsHitTestVisible = False
|
||||
If Not String.IsNullOrEmpty(CustomLogo) Then ItemVersion.Logo = CustomLogo
|
||||
PanDisplayItem.Children.Add(ItemVersion)
|
||||
ItemVersion.Title = If(String.IsNullOrWhiteSpace(TbExportName.Text), PageVersionLeft.Version.Name, TbExportName.Text)
|
||||
ItemVersion.Info = If(String.IsNullOrWhiteSpace(TbExportDesc.Text), PageVersionLeft.Version.Info, TbExportDesc.Text)
|
||||
#If BETA Then
|
||||
CheckIncludePCL.IsEnabled = True
|
||||
#Else
|
||||
CheckIncludePCL.IsEnabled = False
|
||||
TbHint.Text = "你可以在此勾选需要包含进整合包的文件或文件夹,其他文件或文件夹在高级选项添加。" & vbCrLf & "你当前的 PCL 不是正式版,有二次分发的限制,因此整合包不能包含 PCL 程序。"
|
||||
#End If
|
||||
CheckIncludeSetup.IsEnabled = CheckIncludePCL.IsEnabled
|
||||
ReloadFileList(CurrentPath)
|
||||
|
||||
AniControlEnabled -= 1
|
||||
End Sub
|
||||
|
||||
#Region "文件列表"
|
||||
''' <summary>
|
||||
''' 当前所在的文件夹。注意是绝对路径!以 \ 结尾。
|
||||
''' </summary>
|
||||
Private CurrentPath As String = ""
|
||||
Private Sub ReloadFileList(Optional NewPath As String = "")
|
||||
If String.IsNullOrWhiteSpace(NewPath) OrElse NewPath = PathMcFolder Then NewPath = PageVersionLeft.Version.Path
|
||||
If Not NewPath.EndsWithF("\") Then NewPath &= "\"
|
||||
Dim tb As TextBlock = PanFileList.Children(0)
|
||||
PanFileList.Children.Clear()
|
||||
PanFileList.Children.Add(tb)
|
||||
|
||||
If NewPath <> PageVersionLeft.Version.Path Then
|
||||
Dim listItem As New MyListItem With {.Title = "返回上一级目录", .Tag = "..", .Height = 35, .Type = MyListItem.CheckType.Clickable}
|
||||
AddHandler listItem.Click, AddressOf ListItem_Click
|
||||
PanFileList.Children.Add(listItem)
|
||||
End If
|
||||
|
||||
Dim fileCount As Integer = 0
|
||||
Dim directories = Directory.EnumerateDirectories(NewPath)
|
||||
Dim files = Directory.EnumerateFiles(NewPath)
|
||||
If (NewPath = PageVersionLeft.Version.Path) AndAlso PageVersionLeft.Version.PathIndie = PathMcFolder Then
|
||||
'未开启版本隔离时 .minecraft 下的文件
|
||||
directories = directories.Concat(Directory.EnumerateDirectories(PathMcFolder))
|
||||
files = files.Concat(Directory.EnumerateFiles(PathMcFolder))
|
||||
End If
|
||||
|
||||
For Each d In directories
|
||||
If Directory.EnumerateFileSystemEntries(d).Count = 0 Then Continue For
|
||||
If IsVerRedundant(d, PageVersionLeft.Version.PathIndie) OrElse IsMustExport(d, PageVersionLeft.Version.PathIndie) Then Continue For
|
||||
Dim title As String = ""
|
||||
Dim listItem As New MyListItem
|
||||
If Titles.TryGetValue(GetFolderNameFromPath(d), title) Then 'title 作为引用类型传入
|
||||
listItem.Title = title
|
||||
Else
|
||||
listItem.Title = GetFolderNameFromPath(d)
|
||||
End If
|
||||
listItem.Info = d
|
||||
'图标按钮
|
||||
Dim btnSwap As New MyIconButton
|
||||
btnSwap.Logo = Logo.IconButtonRight
|
||||
btnSwap.LogoScale = 1.0
|
||||
btnSwap.Tag = d & "\"
|
||||
AddHandler btnSwap.Click, AddressOf BtnSwap_Click
|
||||
listItem.Buttons = {btnSwap}
|
||||
listItem.Type = MyListItem.CheckType.CheckBox
|
||||
listItem.Height = 35
|
||||
listItem.Logo = Logo.IconButtonOpen
|
||||
listItem.Tag = d & "\"
|
||||
Select Case IsSelected(d & "\")
|
||||
Case 1
|
||||
listItem.Half = True
|
||||
Case 2
|
||||
listItem.Checked = True
|
||||
End Select
|
||||
AddHandler listItem.Click, AddressOf ListItem_Click
|
||||
PanFileList.Children.Add(listItem)
|
||||
fileCount += 1
|
||||
Next
|
||||
|
||||
For Each f In files
|
||||
If IsVerRedundant(f, PageVersionLeft.Version.PathIndie) OrElse IsMustExport(f, PageVersionLeft.Version.PathIndie) Then Continue For
|
||||
Dim title As String = ""
|
||||
Dim listItem As New MyListItem
|
||||
If Titles.TryGetValue(f, title) Then 'title 作为引用类型传入
|
||||
listItem.Title = title
|
||||
Else
|
||||
listItem.Title = GetFileNameFromPath(f)
|
||||
End If
|
||||
listItem.Info = f
|
||||
listItem.Type = MyListItem.CheckType.CheckBox
|
||||
listItem.Height = 35
|
||||
listItem.Tag = f
|
||||
listItem.Checked = (IsSelected(f) = 2)
|
||||
AddHandler listItem.Click, AddressOf ListItem_Click
|
||||
PanFileList.Children.Add(listItem)
|
||||
fileCount += 1
|
||||
Next
|
||||
|
||||
CurrentPath = NewPath
|
||||
CardMore.Title = If(NewPath = PageVersionLeft.Version.Path, "高级选项", $"高级选项 ({NewPath.Replace(PageVersionLeft.Version.Path, "").TrimEnd("\")})")
|
||||
End Sub
|
||||
Private Titles As New Dictionary(Of String, String) From {
|
||||
{"saves", "存档"},
|
||||
{"resourcepacks", "资源包"},
|
||||
{"config", "Mod 配置"},
|
||||
{"shaderpacks", "光影包"},
|
||||
{"options.txt", "游戏配置"},
|
||||
{"servers.dat", "服务器列表"}
|
||||
}
|
||||
Private Sub BtnSwap_Click(sender As MyIconButton, e As Object)
|
||||
Dim actualPath As String = sender.Tag
|
||||
'Dim relative As String = actualPath.Replace(PageVersionLeft.Version.Path, "")
|
||||
|
||||
If Not Directory.Exists(actualPath) Then
|
||||
Hint($"找不到目录:{actualPath}", HintType.Critical)
|
||||
Exit Sub
|
||||
End If
|
||||
ReloadFileList(actualPath)
|
||||
End Sub
|
||||
''' <summary>
|
||||
''' 选中的文件列表,绝对路径。
|
||||
''' </summary>
|
||||
Private Selected As New List(Of String)
|
||||
Private Sub SelectedChange(IsAdd As Boolean, TargetPath As String)
|
||||
If File.Exists(TargetPath) Then
|
||||
If IsAdd Then Selected.Add(TargetPath) Else Selected.Remove(TargetPath)
|
||||
Exit Sub
|
||||
End If
|
||||
If Directory.Exists(TargetPath) Then
|
||||
For Each d In Directory.EnumerateDirectories(TargetPath)
|
||||
SelectedChange(IsAdd, d)
|
||||
Next
|
||||
For Each f In Directory.EnumerateFiles(TargetPath)
|
||||
If IsAdd Then Selected.Add(f) Else Selected.Remove(f)
|
||||
Next
|
||||
End If
|
||||
Selected = Selected.Distinct().ToList()
|
||||
End Sub
|
||||
''' <summary>
|
||||
''' 获取 TargetPath 是否选中。
|
||||
''' </summary>
|
||||
''' <returns>全部未选中为 0,部分选中为 1,全部选中为 2。</returns>
|
||||
Private Function IsSelected(TargetPath As String, Optional AllowEmpty As Boolean = False) As Integer
|
||||
If File.Exists(TargetPath) Then
|
||||
Return If(Selected.Contains(TargetPath), 2, 0)
|
||||
End If
|
||||
If Directory.Exists(TargetPath) Then
|
||||
Dim di As New DirectoryInfo(TargetPath)
|
||||
If di.GetDirectories.Length + di.GetFiles.Length = 0 Then Return If(AllowEmpty, 2, 0)
|
||||
'如果有一个文件不在列表,则 hasExclude = True
|
||||
Dim hasExclude As Boolean = False
|
||||
'如果有一个文件在列表,则 hasInclude = True
|
||||
Dim hasInclude As Boolean = False
|
||||
For Each d In Directory.EnumerateDirectories(TargetPath)
|
||||
If Directory.EnumerateFileSystemEntries(d).Count = 0 Then Continue For
|
||||
Select Case IsSelected(d, True)
|
||||
Case 0
|
||||
hasExclude = True
|
||||
Case 1
|
||||
Return 1
|
||||
Case 2
|
||||
hasInclude = True
|
||||
End Select
|
||||
If hasInclude AndAlso hasExclude Then Return 1 '如果有文件在、有文件不在列表中,可以断定部分选中
|
||||
Next
|
||||
For Each f In Directory.EnumerateFiles(TargetPath)
|
||||
If Selected.Contains(f) Then hasInclude = True Else hasExclude = True
|
||||
If hasInclude AndAlso hasExclude Then Return 1 '如果有文件在、有文件不在列表中,可以断定部分选中
|
||||
Next
|
||||
If hasExclude AndAlso Not hasInclude Then Return 0
|
||||
If hasInclude AndAlso Not hasExclude Then Return 2
|
||||
End If
|
||||
Return 0
|
||||
End Function
|
||||
Private Sub ListItem_Click(sender As MyListItem, e As Object)
|
||||
If sender.Tag = ".." Then '回到上一级目录
|
||||
ReloadFileList(GetPathFromFullPath(CurrentPath))
|
||||
Exit Sub
|
||||
End If
|
||||
SelectedChange(Not sender.Checked, '非常难绷的逻辑,很难描述清楚,自己打断点看 Checked 属性值吧……
|
||||
sender.Tag)
|
||||
End Sub
|
||||
|
||||
'Private ReadOnly Property Saves As List(Of String)
|
||||
' Get
|
||||
' If Directory.Exists(PageVersionLeft.Version.Path & "saves\") Then
|
||||
' Return Directory.EnumerateDirectories(PageVersionLeft.Version.Path & "saves\").ToList
|
||||
' End If
|
||||
' Return New List(Of String)
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
'复选框与高级选项同步
|
||||
Private Sub PanCommonFiles_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) Handles PanCommonFiles.MouseLeftButtonUp
|
||||
For Each c In PanCommonFiles.Children
|
||||
If String.IsNullOrEmpty(c.Tag) Then Continue For
|
||||
For Each l In PanFileList.Children
|
||||
If TypeOf l Is MyListItem Then
|
||||
If If(l.Tag.EndsWith("\"), GetFolderNameFromPath(l.Tag), GetFileNameFromPath(l.Tag)) = c.Tag Then
|
||||
l.Checked = c.Checked
|
||||
SelectedChange(c.Checked, PageVersionLeft.Version.Path & c.Tag)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
End Sub
|
||||
'高级选项与复选框同步
|
||||
Private Sub PanFileList_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) Handles PanFileList.MouseLeftButtonUp
|
||||
For Each c In PanCommonFiles.Children
|
||||
If TypeOf c Is MyCheckBox Then
|
||||
c.Checked = IsSelected(PageVersionLeft.Version.Path & c.Tag) = 2 OrElse IsSelected(PathMcFolder & c.Tag) = 2
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "整合包信息 & 预览栏"
|
||||
Private Sub TbExportName_TextChanged(sender As MyTextBox, e As TextChangedEventArgs) Handles TbExportName.TextChanged
|
||||
If String.IsNullOrEmpty(TbExportName.ValidateResult) Then
|
||||
ItemVersion.Title = If(String.IsNullOrWhiteSpace(sender.Text), PageVersionLeft.Version.Name, sender.Text)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub TbExportDesc_TextChanged(sender As MyTextBox, e As TextChangedEventArgs) Handles TbExportDesc.TextChanged
|
||||
ItemVersion.Info = If(String.IsNullOrWhiteSpace(sender.Text), PageVersionLeft.Version.Info, sender.Text)
|
||||
End Sub
|
||||
|
||||
Private CustomLogoVal As String
|
||||
''' <summary>
|
||||
''' 自定义 Logo 的路径。
|
||||
''' </summary>
|
||||
Public Property CustomLogo() As String
|
||||
Get
|
||||
Return CustomLogoVal
|
||||
End Get
|
||||
Set(value As String)
|
||||
If AniControlEnabled <> 0 Then Exit Property
|
||||
CustomLogoVal = value
|
||||
ItemVersion.Logo = value
|
||||
Reload()
|
||||
End Set
|
||||
End Property
|
||||
|
||||
'Private Sub ComboDisplayLogo_SelectionChanged(sender As MyComboBox, e As SelectionChangedEventArgs) Handles ComboDisplayLogo.SelectionChanged
|
||||
' If Not AniControlEnabled = 0 Then Exit Sub
|
||||
' '选择 自定义 时修改图片
|
||||
' If ComboDisplayLogo.SelectedItem Is ItemDisplayLogoCustom Then
|
||||
' Dim FileName As String = SelectFile("常用图片文件(*.png;*.jpg;*.gif)|*.png;*.jpg;*.gif", "选择图片")
|
||||
' If String.IsNullOrWhiteSpace(FileName) Then Exit Sub
|
||||
' CustomLogo = FileName
|
||||
' Else
|
||||
' CustomLogo = sender.SelectedItem.Tag
|
||||
' End If
|
||||
'End Sub
|
||||
#End Region
|
||||
|
||||
#Region "基本信息"
|
||||
Private Sub CheckIncludePCL_Change(sender As Object, user As Boolean) Handles CheckIncludePCL.Change
|
||||
CheckIncludeSetup.IsEnabled = CheckIncludePCL.IsEnabled
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "导出"
|
||||
'Private Sub ComboExportType_Change(sender As ComboBox, e As SelectionChangedEventArgs) Handles ComboExportType.SelectionChanged
|
||||
' If AniControlEnabled <> 0 Then Exit Sub
|
||||
' Type = sender.SelectedIndex
|
||||
' Select Case Type
|
||||
' Case ModpackType.Modrinth
|
||||
' 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
|
||||
Dim savePath As String = SelectAs(
|
||||
"选择导出位置", $"整合包 - {If(String.IsNullOrWhiteSpace(TbExportName.Text), PageVersionLeft.Version.Name, TbExportName.Text)}" & If(CheckIncludePCL.Checked, ".zip", ".mrpack"),
|
||||
If(CheckIncludePCL.Checked, "整合包文件(*.zip)|*.zip", "Modrinth 整合包(*.mrpack)|*.mrpack"))
|
||||
If String.IsNullOrEmpty(savePath) Then Exit Sub
|
||||
|
||||
'获取需要包含的文件
|
||||
Dim contains As List(Of String) = Selected
|
||||
For Each c In PanCommonFiles.Children
|
||||
If TypeOf c IsNot MyCheckBox Then Continue For
|
||||
If String.IsNullOrEmpty(c.Tag) Then Continue For
|
||||
If c.Checked Then contains.Add(PageVersionLeft.Version.Path & c.Tag)
|
||||
Next
|
||||
'重复任务检查
|
||||
For Each OngoingLoader In LoaderTaskbar
|
||||
If OngoingLoader.Name <> $"导出整合包 {PageVersionLeft.Version.Name}" Then Continue For
|
||||
Hint("正在处理中,请稍候!", HintType.Critical)
|
||||
Exit Sub
|
||||
Next
|
||||
'启动!
|
||||
Dim Loader As New LoaderTask(Of ExportOptions, Boolean)($"导出整合包 {PageVersionLeft.Version.Name}",
|
||||
Sub(Task As LoaderTask(Of ExportOptions, Boolean))
|
||||
Task.Output = ModpackExport(Task)
|
||||
Task.Progress = 1.0
|
||||
If Task.Output Then
|
||||
Hint($"{Task.Name} 成功!", HintType.Finish)
|
||||
OpenExplorer($"/select,""{Task.Input.Dest}""")
|
||||
End If
|
||||
End Sub)
|
||||
Dim Combo = New LoaderCombo(Of ExportOptions)($"导出整合包 {PageVersionLeft.Version.Name}", {Loader})
|
||||
Combo.Start(New ExportOptions(PageVersionLeft.Version, savePath, CheckIncludePCL.Checked, contains.Distinct.ToArray,
|
||||
PCLSetupGlobal:=CheckIncludeSetup.Checked, Name:=TbExportName.Text, Desc:=TbExportDesc.Text,
|
||||
VerID:=TbExportVersion.Text))
|
||||
LoaderTaskbarAdd(Combo)
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
@@ -23,5 +23,8 @@
|
||||
</local:MyListItem>
|
||||
<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="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>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
''' <summary>
|
||||
''' 勾选事件改变页面。
|
||||
''' </summary>
|
||||
Private Sub PageCheck(sender As MyListItem, e As RouteEventArgs) Handles ItemOverall.Check, ItemMod.Check, ItemModDisabled.Check, ItemSetup.Check
|
||||
Private Sub PageCheck(sender As MyListItem, e As RouteEventArgs) Handles ItemOverall.Check, ItemMod.Check, ItemModDisabled.Check, ItemSetup.Check, ItemExport.Check
|
||||
'尚未初始化控件属性时,sender.Tag 为 Nothing,会导致切换到页面 0
|
||||
'若使用 IsLoaded,则会导致模拟点击不被执行(模拟点击切换页面时,控件的 IsLoaded 为 False)
|
||||
If sender.Tag IsNot Nothing Then PageChange(Val(sender.Tag))
|
||||
@@ -46,6 +46,9 @@
|
||||
Case FormMain.PageSubType.VersionSetup
|
||||
If IsNothing(FrmVersionSetup) Then FrmVersionSetup = New PageVersionSetup
|
||||
Return FrmVersionSetup
|
||||
Case FormMain.PageSubType.VersionExport
|
||||
If FrmVersionExport Is Nothing Then FrmVersionExport = New PageVersionExport
|
||||
Return FrmVersionExport
|
||||
Case Else
|
||||
Throw New Exception("未知的版本设置子页面种类:" & ID)
|
||||
End Select
|
||||
|
||||
Reference in New Issue
Block a user