From d9326785e90f489a9076bee62be28c74606794a4 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 16:00:50 +0800 Subject: [PATCH 01/34] =?UTF-8?q?feat:=20=E6=88=AA=E5=9B=BE=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E7=AE=A1=E7=90=86=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/FormMain.xaml.vb | 1 + Plain Craft Launcher 2/Modules/ModMain.vb | 1 + .../Pages/PageVersion/PageVersionLeft.xaml | 8 + .../Pages/PageVersion/PageVersionLeft.xaml.vb | 24 ++- .../PageVersion/PageVersionScreenshot.xaml | 25 +++ .../PageVersion/PageVersionScreenshot.xaml.vb | 144 ++++++++++++++++++ .../Plain Craft Launcher 2.vbproj | 7 + 7 files changed, 203 insertions(+), 7 deletions(-) create mode 100644 Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml create mode 100644 Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb diff --git a/Plain Craft Launcher 2/FormMain.xaml.vb b/Plain Craft Launcher 2/FormMain.xaml.vb index e57bc968..fc42acca 100644 --- a/Plain Craft Launcher 2/FormMain.xaml.vb +++ b/Plain Craft Launcher 2/FormMain.xaml.vb @@ -1106,6 +1106,7 @@ Install: VersionSetup = 1 VersionMod = 2 VersionModDisabled = 3 + VersionScreenshot = 4 End Enum ''' ''' 获取次级页面的名称。若并非次级页面则返回空字符串,故可以以此判断是否为次级页面。 diff --git a/Plain Craft Launcher 2/Modules/ModMain.vb b/Plain Craft Launcher 2/Modules/ModMain.vb index 21362135..dbbe9669 100644 --- a/Plain Craft Launcher 2/Modules/ModMain.vb +++ b/Plain Craft Launcher 2/Modules/ModMain.vb @@ -426,6 +426,7 @@ EndHint: Public FrmVersionOverall As PageVersionOverall Public FrmVersionMod As PageVersionMod Public FrmVersionModDisabled As PageVersionModDisabled + Public FrmVersionScreenshot As PageVersionScreenshot Public FrmVersionSetup As PageVersionSetup '资源信息分页声明 diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml index 32d8fdee..21bcddb6 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml @@ -23,5 +23,13 @@ + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb index 99e211fa..31799a79 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb @@ -25,7 +25,7 @@ ''' ''' 勾选事件改变页面。 ''' - 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, ItemScreenshot.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.VersionScreenshot + If FrmVersionScreenshot Is Nothing Then FrmVersionScreenshot = New PageVersionScreenshot + Return FrmVersionScreenshot Case Else Throw New Exception("未知的版本设置子页面种类:" & ID) End Select @@ -90,14 +93,21 @@ Public Sub Refresh(sender As Object, e As EventArgs) '由边栏按钮匿名调用 '强制刷新 Try - CompProjectCache.Clear() - File.Delete(PathTemp & "Cache\LocalMod.json") - Log("[Mod] 由于点击刷新按钮,清理本地 Mod 信息缓存") + Select Case Val(sender.Tag) + Case FormMain.PageSubType.VersionMod + CompProjectCache.Clear() + File.Delete(PathTemp & "Cache\LocalMod.json") + Log("[Mod] 由于点击刷新按钮,清理本地 Mod 信息缓存") + If FrmVersionMod IsNot Nothing Then FrmVersionMod.ReloadModList(True) '无需 Else,还没加载刷个鬼的新 + ItemMod.Checked = True + Case FormMain.PageSubType.VersionScreenshot + FrmVersionScreenshot = New PageVersionScreenshot + If FrmVersionScreenshot IsNot Nothing Then FrmVersionScreenshot.Reload() + ItemScreenshot.Checked = True + End Select Catch ex As Exception - Log(ex, "强制刷新时清理本地 Mod 信息缓存失败") + Log(ex, "强制刷新出错") End Try - If FrmVersionMod IsNot Nothing Then FrmVersionMod.ReloadModList(True) '无需 Else,还没加载刷个鬼的新 - ItemMod.Checked = True Hint("正在刷新……", Log:=False) End Sub diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml new file mode 100644 index 00000000..dd81360e --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml @@ -0,0 +1,25 @@ + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb new file mode 100644 index 00000000..e1b46551 --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -0,0 +1,144 @@ +Imports System.Security.Principal + +Public Class PageVersionScreenshot + + Private IsLoad As Boolean = False + Private Sub PageSetupLaunch_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + + '重复加载部分 + PanBack.ScrollToHome() + + Reload() + + '非重复加载部分 + If IsLoad Then Exit Sub + IsLoad = True + + End Sub + + Dim FileList As List(Of String) = New List(Of String) + Dim ScreenshotPath As String = PageVersionLeft.Version.Path + "screenshots" + + ''' + ''' 确保当前页面上的信息已正确显示。 + ''' + Public Sub Reload() + AniControlEnabled += 1 + PanBack.ScrollToHome() + LoadFileList() + AniControlEnabled -= 1 + End Sub + + Private Sub LoadFileList() + Log("[Screenshot] 刷新截图文件") + FileList.Clear() + If Directory.Exists(ScreenshotPath) Then FileList = Directory.EnumerateFiles(ScreenshotPath, "*.png", SearchOption.AllDirectories).ToList() + PanList.Children.Clear() + If ModeDebug Then Log("[Screenshot] 共发现 " & FileList.Count & " 个截图文件", LogLevel.Debug) + For Each i In FileList + Dim myCard As New MyCard With { + .Height = Double.NaN, ' 允许高度自适应 + .Width = Double.NaN, ' 允许宽度自适应 + .MinWidth = 230, + .Margin = New Thickness(7), + .Tag = i + } + Dim grid As New Grid + grid.Margin = New Thickness(4) + myCard.Children.Add(grid) + + grid.RowDefinitions.Add(New RowDefinition With {.Height = New GridLength(120)}) + grid.RowDefinitions.Add(New RowDefinition) + + '图片 + Dim image As New Image + Dim bitmapImage As New BitmapImage() + bitmapImage.BeginInit() + bitmapImage.UriSource = New Uri(i) ' 直接使用文件路径加载图片 + bitmapImage.CacheOption = BitmapCacheOption.OnLoad ' 立即加载并释放文件流 + bitmapImage.EndInit() + bitmapImage.Freeze() ' 冻结图像以提高性能 + image.Source = bitmapImage + image.Stretch = Stretch.Uniform ' 使图片自适应控件大小 + Grid.SetRow(image, 0) + grid.Children.Add(image) + + '按钮 + Dim stackPanel As New StackPanel + stackPanel.Orientation = Orientation.Horizontal + stackPanel.Margin = New Thickness(3,5,3,2) + Grid.SetRow(stackPanel, 1) + grid.Children.Add(stackPanel) + + Dim btnOpen As New MyIconTextButton With { + .Name = "BtnOpen", + .Text = "打开", + .LogoScale = 0.8, + .Logo = Logo.IconButtonOpen + } + AddHandler btnOpen.Click, AddressOf btnOpen_Click + stackPanel.Children.Add(btnOpen) + Dim btnDelete As New MyIconTextButton With { + .Name = "BtnDelete", + .Text = "删除", + .LogoScale = 0.8, + .Logo = Logo.IconButtonDelete + } + AddHandler btnDelete.Click, AddressOf btnDelete_Click + stackPanel.Children.Add(btnDelete) + Dim btnCopy As New MyIconTextButton With { + .Name = "BtnCopy", + .Text = "复制", + .LogoScale = 0.8, + .Logo = Logo.IconButtonInfo + } + AddHandler btnCopy.Click, AddressOf btnCopy_Click + stackPanel.Children.Add(btnCopy) + + PanList.Children.Add(myCard) + Next + End Sub + + Private Sub RemoveItem(Path As String) + For Each i In PanList.Children + If CType(i, MyCard).Tag.Equals(Path) Then + PanList.Children.Remove(i) + Exit For + End If + Next + End Sub + + Private Function GetPathFromSender(sender As MyIconTextButton) As String + Return CType(CType(CType(sender.Parent, StackPanel).Parent, Grid).Parent, MyCard).Tag + End Function + + Private Sub btnOpen_Click(sender As MyIconTextButton, e As EventArgs) + OpenExplorer("""" & GetPathFromSender(sender) & """") + End Sub + Private Sub btnDelete_Click(sender As MyIconTextButton, e As EventArgs) + Dim IsShiftPressed As Boolean = My.Computer.Keyboard.ShiftKeyDown + Path = GetPathFromSender(sender) + RemoveItem(Path) + Try + If IsShiftPressed Then + File.Delete(Path) + Hint("已永久删除截图!") + Else + My.Computer.FileSystem.DeleteFile(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + Hint("已将截图移至回收站!") + End If + Catch ex As Exception + Log(ex, "删除截图失败!", LogLevel.Hint) + End Try + End Sub + Private Sub btnCopy_Click(sender As MyIconTextButton, e As EventArgs) + Dim imagePath As String = GetPathFromSender(sender) + If File.Exists(imagePath) Then + Dim bitmap As BitmapImage = New BitmapImage(New Uri(imagePath)) + Clipboard.SetImage(bitmap) + Hint("已复制截图到剪贴板!") + Else + Hint("截图文件不存在!") + End If + 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 bc74b16e..38bcb94d 100644 --- a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj +++ b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj @@ -293,6 +293,9 @@ PageVersionModDisabled.xaml + + PageVersionScreenshot.xaml + PageVersionOverall.xaml @@ -554,6 +557,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + Designer MSBuild:Compile From 2aba4a96ff7e257985d80d0b673f62adf6ad8f9e Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 16:28:45 +0800 Subject: [PATCH 02/34] =?UTF-8?q?fix:=20=E6=88=AA=E5=9B=BE=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=8F=90=E7=A4=BA=20&=20=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PageVersion/PageVersionScreenshot.xaml | 28 +++++++++++++++++-- .../PageVersion/PageVersionScreenshot.xaml.vb | 14 ++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml index dd81360e..03bf2ac7 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml @@ -6,8 +6,29 @@ mc:Ignorable="d" x:Class="PageVersionScreenshot" PanScroll="{Binding ElementName=PanBack}" Grid.IsSharedSizeScope="True"> - - - + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index e1b46551..08f37198 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -7,7 +7,7 @@ Public Class PageVersionScreenshot '重复加载部分 PanBack.ScrollToHome() - + ScreenshotPath = PageVersionLeft.Version.Path + "screenshots" Reload() '非重复加载部分 @@ -17,7 +17,7 @@ Public Class PageVersionScreenshot End Sub Dim FileList As List(Of String) = New List(Of String) - Dim ScreenshotPath As String = PageVersionLeft.Version.Path + "screenshots" + Dim ScreenshotPath As String ''' ''' 确保当前页面上的信息已正确显示。 @@ -26,6 +26,11 @@ Public Class PageVersionScreenshot AniControlEnabled += 1 PanBack.ScrollToHome() LoadFileList() + If FileList.Count.Equals(0) Then + PanNoPic.Visibility = Visibility.Visible + Else + PanNoPic.Visibility = Visibility.Collapsed + End If AniControlEnabled -= 1 End Sub @@ -141,4 +146,9 @@ Public Class PageVersionScreenshot Hint("截图文件不存在!") End If End Sub + + Private Sub BtnOpenFolder_Click(sender As Object, e As MouseButtonEventArgs) + If Not Directory.Exists(ScreenshotPath) Then Directory.CreateDirectory(ScreenshotPath) + OpenExplorer("""" & ScreenshotPath & """") + End Sub End Class From 832d0ec24619ea1d4a3f1f146a6ce6468f84f531 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 16:33:58 +0800 Subject: [PATCH 03/34] =?UTF-8?q?fix:=20=E5=A4=8D=E5=88=B6=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=80=8C=E4=B8=8D=E6=98=AF=E6=96=87=E4=BB=B6=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 08f37198..533137ec 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -139,8 +139,7 @@ Public Class PageVersionScreenshot Private Sub btnCopy_Click(sender As MyIconTextButton, e As EventArgs) Dim imagePath As String = GetPathFromSender(sender) If File.Exists(imagePath) Then - Dim bitmap As BitmapImage = New BitmapImage(New Uri(imagePath)) - Clipboard.SetImage(bitmap) + Clipboard.SetFileDropList(New Specialized.StringCollection() From {imagePath}) Hint("已复制截图到剪贴板!") Else Hint("截图文件不存在!") From 4b62cb1e9b7258f23ec62b6155bd92eacfda1933 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 17:23:28 +0800 Subject: [PATCH 04/34] =?UTF-8?q?feat:=20=E5=AD=98=E6=A1=A3=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/FormMain.xaml.vb | 3 +- Plain Craft Launcher 2/Modules/ModMain.vb | 1 + .../Pages/PageVersion/PageVersionLeft.xaml | 12 +++- .../Pages/PageVersion/PageVersionLeft.xaml.vb | 9 ++- .../PageVersion/PageVersionScreenshot.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionWorld.xaml | 37 ++++++++++++ .../PageVersion/PageVersionWorld.xaml.vb | 60 +++++++++++++++++++ .../Plain Craft Launcher 2.vbproj | 7 +++ 8 files changed, 125 insertions(+), 6 deletions(-) create mode 100644 Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml create mode 100644 Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb diff --git a/Plain Craft Launcher 2/FormMain.xaml.vb b/Plain Craft Launcher 2/FormMain.xaml.vb index fc42acca..fc60542c 100644 --- a/Plain Craft Launcher 2/FormMain.xaml.vb +++ b/Plain Craft Launcher 2/FormMain.xaml.vb @@ -1106,7 +1106,8 @@ Install: VersionSetup = 1 VersionMod = 2 VersionModDisabled = 3 - VersionScreenshot = 4 + VersionWorld = 4 + VersionScreenshot = 5 End Enum ''' ''' 获取次级页面的名称。若并非次级页面则返回空字符串,故可以以此判断是否为次级页面。 diff --git a/Plain Craft Launcher 2/Modules/ModMain.vb b/Plain Craft Launcher 2/Modules/ModMain.vb index dbbe9669..3da12cb9 100644 --- a/Plain Craft Launcher 2/Modules/ModMain.vb +++ b/Plain Craft Launcher 2/Modules/ModMain.vb @@ -427,6 +427,7 @@ EndHint: Public FrmVersionMod As PageVersionMod Public FrmVersionModDisabled As PageVersionModDisabled Public FrmVersionScreenshot As PageVersionScreenshot + Public FrmVersionWorld As PageVersionWorld Public FrmVersionSetup As PageVersionSetup '资源信息分页声明 diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml index 21bcddb6..bf8af0f0 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml @@ -23,13 +23,21 @@ - + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb index 31799a79..01006d5d 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb @@ -25,7 +25,7 @@ ''' ''' 勾选事件改变页面。 ''' - Private Sub PageCheck(sender As MyListItem, e As RouteEventArgs) Handles ItemOverall.Check, ItemMod.Check, ItemModDisabled.Check, ItemSetup.Check, ItemScreenshot.Check + Private Sub PageCheck(sender As MyListItem, e As RouteEventArgs) Handles ItemOverall.Check, ItemMod.Check, ItemModDisabled.Check, ItemSetup.Check, ItemScreenshot.Check, ItemWorld.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.VersionWorld + If FrmVersionWorld Is Nothing Then FrmVersionWorld = New PageVersionWorld + Return FrmVersionWorld Case FormMain.PageSubType.VersionScreenshot If FrmVersionScreenshot Is Nothing Then FrmVersionScreenshot = New PageVersionScreenshot Return FrmVersionScreenshot @@ -101,9 +104,11 @@ If FrmVersionMod IsNot Nothing Then FrmVersionMod.ReloadModList(True) '无需 Else,还没加载刷个鬼的新 ItemMod.Checked = True Case FormMain.PageSubType.VersionScreenshot - FrmVersionScreenshot = New PageVersionScreenshot If FrmVersionScreenshot IsNot Nothing Then FrmVersionScreenshot.Reload() ItemScreenshot.Checked = True + Case FormMain.PageSubType.VersionWorld + If FrmVersionWorld IsNot Nothing Then FrmVersionWorld.Reload() + ItemWorld.Checked = True End Select Catch ex As Exception Log(ex, "强制刷新出错") diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 533137ec..351ec2b4 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -7,7 +7,7 @@ Public Class PageVersionScreenshot '重复加载部分 PanBack.ScrollToHome() - ScreenshotPath = PageVersionLeft.Version.Path + "screenshots" + ScreenshotPath = PageVersionLeft.Version.PathIndie + "screenshots" Reload() '非重复加载部分 diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml new file mode 100644 index 00000000..eec76f3a --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb new file mode 100644 index 00000000..f7e07f1e --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -0,0 +1,60 @@ +Imports System.Security.Principal + +Public Class PageVersionWorld + + Private IsLoad As Boolean = False + Private Sub PageSetupLaunch_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + + '重复加载部分 + PanBack.ScrollToHome() + WorldPath = PageVersionLeft.Version.PathIndie + "saves" + Reload() + + '非重复加载部分 + If IsLoad Then Exit Sub + IsLoad = True + + End Sub + + Dim FileList As List(Of String) = New List(Of String) + Dim WorldPath As String + + ''' + ''' 确保当前页面上的信息已正确显示。 + ''' + Public Sub Reload() + AniControlEnabled += 1 + PanBack.ScrollToHome() + LoadFileList() + If FileList.Count.Equals(0) Then + PanNoWorld.Visibility = Visibility.Visible + PanContent.Visibility = Visibility.Collapsed + Else + PanNoWorld.Visibility = Visibility.Collapsed + PanContent.Visibility = Visibility.Visible + End If + AniControlEnabled -= 1 + End Sub + + Private Sub LoadFileList() + Log("[World] 刷新存档文件") + FileList.Clear() + FileList = Directory.EnumerateDirectories(WorldPath).ToList() + If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个存档文件夹", LogLevel.Debug) + PanList.Children.Clear() + PanCard.Title = $"存档列表 ({FileList.Count})" + For Each i In FileList + Dim worldItem As MyListItem = New MyListItem With { + .Logo = i + "\icon.png", + .Title = GetFileNameFromPath(i), + .Info = $"创建时间:{ Directory.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")},最后修改时间:{Directory.GetLastWriteTime(i).ToString("yyyy'/'MM'/'dd")}" + } + PanList.Children.Add(worldItem) + Next + End Sub + + Private Sub BtnOpenFolder_Click(sender As Object, e As MouseButtonEventArgs) + If Not Directory.Exists(WorldPath) Then Directory.CreateDirectory(WorldPath) + OpenExplorer("""" & WorldPath & """") + 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 38bcb94d..254c7e6a 100644 --- a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj +++ b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj @@ -293,6 +293,9 @@ PageVersionModDisabled.xaml + + PageVersionWorld.xaml + PageVersionScreenshot.xaml @@ -557,6 +560,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer From 6d915e2ededab954d648a08f354cc7716b0c96f1 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 17:27:29 +0800 Subject: [PATCH 05/34] =?UTF-8?q?feat:=20=E5=A4=8D=E5=88=B6=E5=9B=BE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Modules/Base/ModBase.vb | 4 ++++ .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Plain Craft Launcher 2/Modules/Base/ModBase.vb b/Plain Craft Launcher 2/Modules/Base/ModBase.vb index 994dfaa9..513c19f7 100644 --- a/Plain Craft Launcher 2/Modules/Base/ModBase.vb +++ b/Plain Craft Launcher 2/Modules/Base/ModBase.vb @@ -174,6 +174,10 @@ Public Module ModBase ''' Public Const IconButtonOffline As String = "M533.293176 788.841412a60.235294 60.235294 0 1 1 85.202824 85.202823l-42.616471 42.586353c-129.355294 129.385412-339.124706 129.385412-468.510117 0-129.385412-129.385412-129.385412-339.124706 0-468.510117l42.586353-42.616471a60.235294 60.235294 0 1 1 85.202823 85.202824l-42.61647 42.586352a210.823529 210.823529 0 1 0 298.164706 298.164706l42.586352-42.61647z m255.548236-255.548236l42.61647-42.586352a210.823529 210.823529 0 1 0-298.164706-298.164706l-42.586352 42.61647a60.235294 60.235294 0 1 1-85.202824-85.202823l42.616471-42.586353c129.355294-129.385412 339.124706-129.385412 468.510117 0 129.385412 129.385412 129.385412 339.124706 0 468.510117l-42.586353 42.616471a60.235294 60.235294 0 1 1-85.202823-85.202824zM192.542118 192.542118a60.235294 60.235294 0 0 1 85.202823 0l553.712941 553.712941a60.235294 60.235294 0 0 1-85.202823 85.202823L192.542118 277.744941a60.235294 60.235294 0 0 1 0-85.202823z" ''' + ''' 图标按钮,复制 + ''' + Public Const IconButtonCopy As String = "M394.666667 106.666667h448a74.666667 74.666667 0 0 1 74.666666 74.666666v448a74.666667 74.666667 0 0 1-74.666666 74.666667H394.666667a74.666667 74.666667 0 0 1-74.666667-74.666667V181.333333a74.666667 74.666667 0 0 1 74.666667-74.666666z m0 64a10.666667 10.666667 0 0 0-10.666667 10.666666v448a10.666667 10.666667 0 0 0 10.666667 10.666667h448a10.666667 10.666667 0 0 0 10.666666-10.666667V181.333333a10.666667 10.666667 0 0 0-10.666666-10.666666H394.666667z m245.333333 597.333333a32 32 0 0 1 64 0v74.666667a74.666667 74.666667 0 0 1-74.666667 74.666666H181.333333a74.666667 74.666667 0 0 1-74.666666-74.666666V394.666667a74.666667 74.666667 0 0 1 74.666666-74.666667h74.666667a32 32 0 0 1 0 64h-74.666667a10.666667 10.666667 0 0 0-10.666666 10.666667v448a10.666667 10.666667 0 0 0 10.666666 10.666666h448a10.666667 10.666667 0 0 0 10.666667-10.666666v-74.666667z" + ''' ''' 图标,音符,1x ''' Public Const IconMusic As String = "M348.293565 716.53287V254.797913c0-41.672348 28.004174-78.358261 68.919652-90.37913L815.994435 40.826435c62.775652-18.610087 125.907478 26.579478 125.907478 89.933913v539.158261c8.013913 42.25113-8.94887 89.177043-47.014956 127.109565a232.848696 232.848696 0 0 1-170.785392 65.758609c-61.885217-2.938435-111.081739-33.435826-129.113043-80.050087-18.031304-46.614261-2.137043-102.177391 41.672348-145.853218a232.848696 232.848696 0 0 1 170.785391-65.80313c21.014261 1.024 40.514783 5.164522 57.878261 12.065391V233.338435c0-12.109913-10.551652-20.034783-20.569044-20.034783a24.620522 24.620522 0 0 0-5.787826 0.934957L439.785739 338.18713a19.545043 19.545043 0 0 0-14.825739 19.144348v438.984348H423.846957c11.53113 43.987478-5.164522 94.208-45.412174 134.322087a232.848696 232.848696 0 0 1-170.785392 65.758609c-61.885217-2.938435-111.081739-33.435826-129.113043-80.050087-18.031304-46.614261-2.137043-102.177391 41.672348-145.853218a232.848696 232.848696 0 0 1 170.785391-65.80313c20.791652 1.024 40.069565 5.075478 57.299478 11.842783z" diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 351ec2b4..388a3dac 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -95,7 +95,7 @@ Public Class PageVersionScreenshot .Name = "BtnCopy", .Text = "复制", .LogoScale = 0.8, - .Logo = Logo.IconButtonInfo + .Logo = Logo.IconButtonCopy } AddHandler btnCopy.Click, AddressOf btnCopy_Click stackPanel.Children.Add(btnCopy) From 26939ccab6abf2d5d58fef41d44d662033cf7e15 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 20:16:28 +0800 Subject: [PATCH 06/34] =?UTF-8?q?feat:=20=E5=AD=98=E6=A1=A3=E8=AF=A6?= =?UTF-8?q?=E7=BB=86=E4=BF=A1=E6=81=AF=E6=9F=A5=E7=9C=8B=20&=20=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PageVersion/PageVersionScreenshot.xaml.vb | 10 +-- .../PageVersion/PageVersionWorld.xaml.vb | 74 ++++++++++++++++++- 2 files changed, 73 insertions(+), 11 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 388a3dac..70fe1add 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -121,17 +121,11 @@ Public Class PageVersionScreenshot OpenExplorer("""" & GetPathFromSender(sender) & """") End Sub Private Sub btnDelete_Click(sender As MyIconTextButton, e As EventArgs) - Dim IsShiftPressed As Boolean = My.Computer.Keyboard.ShiftKeyDown Path = GetPathFromSender(sender) RemoveItem(Path) Try - If IsShiftPressed Then - File.Delete(Path) - Hint("已永久删除截图!") - Else - My.Computer.FileSystem.DeleteFile(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) - Hint("已将截图移至回收站!") - End If + My.Computer.FileSystem.DeleteFile(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + Hint("已将截图移至回收站!") Catch ex As Exception Log(ex, "删除截图失败!", LogLevel.Hint) End Try diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb index f7e07f1e..b8426608 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -26,6 +26,11 @@ Public Class PageVersionWorld AniControlEnabled += 1 PanBack.ScrollToHome() LoadFileList() + AniControlEnabled -= 1 + End Sub + + Private Sub RefreshUI() + PanCard.Title = $"存档列表 ({FileList.Count})" If FileList.Count.Equals(0) Then PanNoWorld.Visibility = Visibility.Visible PanContent.Visibility = Visibility.Collapsed @@ -33,7 +38,6 @@ Public Class PageVersionWorld PanNoWorld.Visibility = Visibility.Collapsed PanContent.Visibility = Visibility.Visible End If - AniControlEnabled -= 1 End Sub Private Sub LoadFileList() @@ -42,17 +46,81 @@ Public Class PageVersionWorld FileList = Directory.EnumerateDirectories(WorldPath).ToList() If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个存档文件夹", LogLevel.Debug) PanList.Children.Clear() - PanCard.Title = $"存档列表 ({FileList.Count})" For Each i In FileList Dim worldItem As MyListItem = New MyListItem With { .Logo = i + "\icon.png", .Title = GetFileNameFromPath(i), - .Info = $"创建时间:{ Directory.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")},最后修改时间:{Directory.GetLastWriteTime(i).ToString("yyyy'/'MM'/'dd")}" + .Info = $"创建时间:{ Directory.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")},最后修改时间:{Directory.GetLastWriteTime(i).ToString("yyyy'/'MM'/'dd")}", + .Tag = i + } + Dim BtnDelete As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonDelete, + .ToolTip = "删除", + .Tag = i + } + AddHandler BtnDelete.Click, AddressOf BtnDelete_Click + Dim BtnCopy As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonCopy, + .ToolTip = "复制", + .Tag = i + } + AddHandler BtnCopy.Click, AddressOf BtnCopy_Click + Dim BtnInfo As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonInfo, + .ToolTip = "详情", + .Tag = i } + AddHandler BtnInfo.Click, AddressOf BtnInfo_Click + worldItem.Buttons = {BtnDelete, BtnCopy, BtnInfo} PanList.Children.Add(worldItem) Next + RefreshUI() End Sub + Private Function GetPathFromSender(sender As Object) As String + Return CType(sender, MyIconButton).Tag + End Function + + Private Sub RemoveItem(Path As String) + For Each i In PanList.Children + If CType(i, MyListItem).Tag.Equals(Path) Then + PanList.Children.Remove(CType(i, MyListItem)) + FileList.Remove(Path) + Exit For + End If + Next + RefreshUI() + End Sub + + Private Sub BtnDelete_Click(sender As Object, e As MouseButtonEventArgs) + Path = GetPathFromSender(sender) + RemoveItem(Path) + Try + My.Computer.FileSystem.DeleteDirectory(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + Hint("已将存档移至回收站!") + Catch ex As Exception + Log(ex, "删除存档失败!", LogLevel.Hint) + End Try + End Sub + Private Sub BtnCopy_Click(sender As Object, e As MouseButtonEventArgs) + Dim Path As String = GetPathFromSender(sender) + If Directory.Exists(Path) Then + Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) + Hint("已复制存档文件夹到剪贴板!") + Else + Hint("存档文件夹不存在!") + End If + End Sub + Private Sub BtnInfo_Click(sender As Object, e As MouseButtonEventArgs) + Dim Path As String = GetPathFromSender(sender) + Dim infos As List(Of String) = New List(Of String) + infos.Add("名称:" & GetFileNameFromPath(Path)) + infos.Add("创建日期:" & Directory.GetCreationTime(Path).ToString("yyyy'/'MM'/'dd")) + infos.Add("最后一次修改日期:" & Directory.GetLastWriteTime(Path).ToString("yyyy'/'MM'/'dd")) + infos.Add("玩家数量:" & Directory.GetFiles(Path & "\playerdata", "*.dat", SearchOption.TopDirectoryOnly).Count()) + infos.Add("数据包数量:" & (Directory.GetDirectories(Path + "\datapacks").Count() + Directory.GetFiles(Path + "\datapacks").Count()).ToString()) + MyMsgBox(infos.Join(vbCrLf), "存档详细信息") + End Sub Private Sub BtnOpenFolder_Click(sender As Object, e As MouseButtonEventArgs) If Not Directory.Exists(WorldPath) Then Directory.CreateDirectory(WorldPath) OpenExplorer("""" & WorldPath & """") From a7469e26801d5dcf62a374445b6a9a0943244b73 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 21:02:22 +0800 Subject: [PATCH 07/34] =?UTF-8?q?feat:=20=E5=85=89=E5=BD=B1=20&=20?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=8C=85=20=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/FormMain.xaml.vb | 2 + Plain Craft Launcher 2/Modules/ModMain.vb | 2 + .../Pages/PageVersion/PageVersionLeft.xaml | 24 +++- .../Pages/PageVersion/PageVersionLeft.xaml.vb | 8 +- .../PageVersion/PageVersionResourcePack.xaml | 37 ++++++ .../PageVersionResourcePack.xaml.vb | 113 ++++++++++++++++++ .../PageVersion/PageVersionScreenshot.xaml.vb | 2 + .../Pages/PageVersion/PageVersionShader.xaml | 37 ++++++ .../PageVersion/PageVersionShader.xaml.vb | 113 ++++++++++++++++++ .../PageVersion/PageVersionWorld.xaml.vb | 1 + .../Plain Craft Launcher 2.vbproj | 14 +++ 11 files changed, 348 insertions(+), 5 deletions(-) create mode 100644 Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml create mode 100644 Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb create mode 100644 Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml create mode 100644 Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb diff --git a/Plain Craft Launcher 2/FormMain.xaml.vb b/Plain Craft Launcher 2/FormMain.xaml.vb index fc60542c..65dc7a73 100644 --- a/Plain Craft Launcher 2/FormMain.xaml.vb +++ b/Plain Craft Launcher 2/FormMain.xaml.vb @@ -1108,6 +1108,8 @@ Install: VersionModDisabled = 3 VersionWorld = 4 VersionScreenshot = 5 + VersionResourcePack = 6 + VersionShader = 7 End Enum ''' ''' 获取次级页面的名称。若并非次级页面则返回空字符串,故可以以此判断是否为次级页面。 diff --git a/Plain Craft Launcher 2/Modules/ModMain.vb b/Plain Craft Launcher 2/Modules/ModMain.vb index 3da12cb9..0f280bf6 100644 --- a/Plain Craft Launcher 2/Modules/ModMain.vb +++ b/Plain Craft Launcher 2/Modules/ModMain.vb @@ -428,6 +428,8 @@ EndHint: Public FrmVersionModDisabled As PageVersionModDisabled Public FrmVersionScreenshot As PageVersionScreenshot Public FrmVersionWorld As PageVersionWorld + Public FrmVersionShader As PageVersionShader + Public FrmVersionResourcePack As PageVersionResourcePack Public FrmVersionSetup As PageVersionSetup '资源信息分页声明 diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml index bf8af0f0..383eb3a8 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml @@ -13,7 +13,7 @@ - @@ -21,10 +21,10 @@ - + Logo="M819.392 0L1024 202.752v652.16a168.96 168.96 0 0 1-168.832 168.768h-104.192a47.296 47.296 0 0 1-10.752 0H283.776a47.232 47.232 0 0 1-10.752 0H168.832A168.96 168.96 0 0 1 0 854.912V168.768A168.96 168.96 0 0 1 168.832 0h650.56z m110.208 854.912V242.112l-149.12-147.776H168.896c-41.088 0-74.432 33.408-74.432 74.432v686.144c0 41.024 33.344 74.432 74.432 74.432h62.4v-190.528c0-33.408 27.136-60.544 60.544-60.544h440.448c33.408 0 60.544 27.136 60.544 60.544v190.528h62.4c41.088 0 74.432-33.408 74.432-74.432z m-604.032 74.432h372.864v-156.736H325.568v156.736z m403.52-596.48a47.168 47.168 0 1 1 0 94.336H287.872a47.168 47.168 0 1 1 0-94.336h441.216z m0-153.728a47.168 47.168 0 1 1 0 94.4H287.872a47.168 47.168 0 1 1 0-94.4h441.216z"> @@ -32,12 +32,28 @@ + Logo="M791.272727 837.818182v139.636363h-93.090909v-139.636363H232.727273a93.090909 93.090909 0 0 1-93.090909-93.090909V279.272727H0V186.181818h139.636364V46.545455h93.090909v139.636363h465.454545a93.090909 93.090909 0 0 1 93.090909 93.090909v465.454546h139.636364v93.090909h-139.636364z m-93.090909-232.727273V279.272727H232.727273v465.454546h465.454545v-139.636364z"> + + + + + + + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb index 01006d5d..09af293c 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb @@ -25,7 +25,7 @@ ''' ''' 勾选事件改变页面。 ''' - Private Sub PageCheck(sender As MyListItem, e As RouteEventArgs) Handles ItemOverall.Check, ItemMod.Check, ItemModDisabled.Check, ItemSetup.Check, ItemScreenshot.Check, ItemWorld.Check + Private Sub PageCheck(sender As MyListItem, e As RouteEventArgs) Handles ItemOverall.Check, ItemMod.Check, ItemModDisabled.Check, ItemSetup.Check, ItemScreenshot.Check, ItemWorld.Check, ItemResourcePack.Check, ItemShader.Check '尚未初始化控件属性时,sender.Tag 为 Nothing,会导致切换到页面 0 '若使用 IsLoaded,则会导致模拟点击不被执行(模拟点击切换页面时,控件的 IsLoaded 为 False) If sender.Tag IsNot Nothing Then PageChange(Val(sender.Tag)) @@ -52,6 +52,12 @@ Case FormMain.PageSubType.VersionScreenshot If FrmVersionScreenshot Is Nothing Then FrmVersionScreenshot = New PageVersionScreenshot Return FrmVersionScreenshot + Case FormMain.PageSubType.VersionResourcePack + If FrmVersionResourcePack Is Nothing Then FrmVersionResourcePack = New PageVersionResourcePack + Return FrmVersionResourcePack + Case FormMain.PageSubType.VersionShader + If FrmVersionShader Is Nothing Then FrmVersionShader = New PageVersionShader + Return FrmVersionShader Case Else Throw New Exception("未知的版本设置子页面种类:" & ID) End Select diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml new file mode 100644 index 00000000..3f1b862a --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb new file mode 100644 index 00000000..8c34a8bf --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -0,0 +1,113 @@ +Imports System.Security.Principal + +Public Class PageVersionResourcePack + + Private IsLoad As Boolean = False + Private Sub PageSetupLaunch_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + + '重复加载部分 + PanBack.ScrollToHome() + ResourcepacksPath = PageVersionLeft.Version.PathIndie + "resourcepacks" + If Not Directory.Exists(ResourcepacksPath) Then Directory.CreateDirectory(ResourcepacksPath) + Reload() + + '非重复加载部分 + If IsLoad Then Exit Sub + IsLoad = True + + End Sub + + Dim FileList As List(Of String) = New List(Of String) + Dim ResourcepacksPath As String + + ''' + ''' 确保当前页面上的信息已正确显示。 + ''' + Public Sub Reload() + AniControlEnabled += 1 + PanBack.ScrollToHome() + LoadFileList() + AniControlEnabled -= 1 + End Sub + + Private Sub RefreshUI() + PanCard.Title = $"资源包列表 ({FileList.Count})" + If FileList.Count.Equals(0) Then + PanNoWorld.Visibility = Visibility.Visible + PanContent.Visibility = Visibility.Collapsed + Else + PanNoWorld.Visibility = Visibility.Collapsed + PanContent.Visibility = Visibility.Visible + End If + End Sub + + Private Sub LoadFileList() + Log("[World] 刷新资源包文件") + FileList.Clear() + FileList = Directory.EnumerateFiles(ResourcepacksPath, "*.zip").ToList() + If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个资源包文件", LogLevel.Debug) + PanList.Children.Clear() + For Each i In FileList + Dim worldItem As MyListItem = New MyListItem With { + .Title = GetFileNameWithoutExtentionFromPath(i), + .Info = $"引入时间:{ File.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")}", + .Tag = i + } + Dim BtnDelete As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonDelete, + .ToolTip = "删除", + .Tag = i + } + AddHandler BtnDelete.Click, AddressOf BtnDelete_Click + Dim BtnCopy As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonCopy, + .ToolTip = "复制", + .Tag = i + } + AddHandler BtnCopy.Click, AddressOf BtnCopy_Click + worldItem.Buttons = {BtnDelete, BtnCopy} + PanList.Children.Add(worldItem) + Next + RefreshUI() + End Sub + + Private Function GetPathFromSender(sender As Object) As String + Return CType(sender, MyIconButton).Tag + End Function + + Private Sub RemoveItem(Path As String) + For Each i In PanList.Children + If CType(i, MyListItem).Tag.Equals(Path) Then + PanList.Children.Remove(CType(i, MyListItem)) + FileList.Remove(Path) + Exit For + End If + Next + RefreshUI() + End Sub + + Private Sub BtnDelete_Click(sender As Object, e As MouseButtonEventArgs) + Path = GetPathFromSender(sender) + RemoveItem(Path) + Try + My.Computer.FileSystem.DeleteDirectory(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + Hint("已将资源包移至回收站!") + Catch ex As Exception + Log(ex, "删除资源包失败!", LogLevel.Hint) + End Try + End Sub + Private Sub BtnCopy_Click(sender As Object, e As MouseButtonEventArgs) + Dim Path As String = GetPathFromSender(sender) + If File.Exists(Path) Then + Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) + Hint("已复制资源包文件到剪贴板!") + Else + Hint("资源包不存在!") + End If + End Sub + + Private Sub BtnOpenFolder_Click(sender As Object, e As MouseButtonEventArgs) + If Not Directory.Exists(ResourcepacksPath) Then Directory.CreateDirectory(ResourcepacksPath) + OpenExplorer("""" & ResourcepacksPath & """") + End Sub +End Class diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 70fe1add..77a9af71 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -8,8 +8,10 @@ Public Class PageVersionScreenshot '重复加载部分 PanBack.ScrollToHome() ScreenshotPath = PageVersionLeft.Version.PathIndie + "screenshots" + If Not Directory.Exists(ScreenshotPath) Then Directory.CreateDirectory(ScreenshotPath) Reload() + '非重复加载部分 If IsLoad Then Exit Sub IsLoad = True diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml new file mode 100644 index 00000000..89ba3f62 --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb new file mode 100644 index 00000000..60b7d848 --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb @@ -0,0 +1,113 @@ +Imports System.Security.Principal + +Public Class PageVersionShader + + Private IsLoad As Boolean = False + Private Sub PageSetupLaunch_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + + '重复加载部分 + PanBack.ScrollToHome() + ShaderPath = PageVersionLeft.Version.PathIndie + "shaderpacks" + If Not Directory.Exists(ShaderPath) Then Directory.CreateDirectory(ShaderPath) + Reload() + + '非重复加载部分 + If IsLoad Then Exit Sub + IsLoad = True + + End Sub + + Dim FileList As List(Of String) = New List(Of String) + Dim ShaderPath As String + + ''' + ''' 确保当前页面上的信息已正确显示。 + ''' + Public Sub Reload() + AniControlEnabled += 1 + PanBack.ScrollToHome() + LoadFileList() + AniControlEnabled -= 1 + End Sub + + Private Sub RefreshUI() + PanCard.Title = $"光影包列表 ({FileList.Count})" + If FileList.Count.Equals(0) Then + PanNoWorld.Visibility = Visibility.Visible + PanContent.Visibility = Visibility.Collapsed + Else + PanNoWorld.Visibility = Visibility.Collapsed + PanContent.Visibility = Visibility.Visible + End If + End Sub + + Private Sub LoadFileList() + Log("[World] 刷新光影包文件") + FileList.Clear() + FileList = Directory.EnumerateFiles(ShaderPath, "*.zip").ToList() + If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个光影包文件", LogLevel.Debug) + PanList.Children.Clear() + For Each i In FileList + Dim worldItem As MyListItem = New MyListItem With { + .Title = GetFileNameWithoutExtentionFromPath(i), + .Info = $"引入时间:{ File.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")}", + .Tag = i + } + Dim BtnDelete As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonDelete, + .ToolTip = "删除", + .Tag = i + } + AddHandler BtnDelete.Click, AddressOf BtnDelete_Click + Dim BtnCopy As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonCopy, + .ToolTip = "复制", + .Tag = i + } + AddHandler BtnCopy.Click, AddressOf BtnCopy_Click + worldItem.Buttons = {BtnDelete, BtnCopy} + PanList.Children.Add(worldItem) + Next + RefreshUI() + End Sub + + Private Function GetPathFromSender(sender As Object) As String + Return CType(sender, MyIconButton).Tag + End Function + + Private Sub RemoveItem(Path As String) + For Each i In PanList.Children + If CType(i, MyListItem).Tag.Equals(Path) Then + PanList.Children.Remove(CType(i, MyListItem)) + FileList.Remove(Path) + Exit For + End If + Next + RefreshUI() + End Sub + + Private Sub BtnDelete_Click(sender As Object, e As MouseButtonEventArgs) + Path = GetPathFromSender(sender) + RemoveItem(Path) + Try + My.Computer.FileSystem.DeleteDirectory(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + Hint("已将光影包移至回收站!") + Catch ex As Exception + Log(ex, "删除光影包失败!", LogLevel.Hint) + End Try + End Sub + Private Sub BtnCopy_Click(sender As Object, e As MouseButtonEventArgs) + Dim Path As String = GetPathFromSender(sender) + If File.Exists(Path) Then + Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) + Hint("已复制光影包文件到剪贴板!") + Else + Hint("光影包不存在!") + End If + End Sub + + Private Sub BtnOpenFolder_Click(sender As Object, e As MouseButtonEventArgs) + If Not Directory.Exists(ShaderPath) Then Directory.CreateDirectory(ShaderPath) + OpenExplorer("""" & ShaderPath & """") + End Sub +End Class \ No newline at end of file diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb index b8426608..670bc9b5 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -8,6 +8,7 @@ Public Class PageVersionWorld '重复加载部分 PanBack.ScrollToHome() WorldPath = PageVersionLeft.Version.PathIndie + "saves" + If Not Directory.Exists(WorldPath) Then Directory.CreateDirectory(WorldPath) Reload() '非重复加载部分 diff --git a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj index 254c7e6a..857872f1 100644 --- a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj +++ b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj @@ -293,6 +293,12 @@ PageVersionModDisabled.xaml + + PageVersionShader.xaml + + + PageVersionResourcePack.xaml + PageVersionWorld.xaml @@ -560,6 +566,14 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + MSBuild:Compile Designer From ce1f45cc5683caeacdc2b1446248d12d26a1964d Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 21:06:56 +0800 Subject: [PATCH 08/34] =?UTF-8?q?feat:=20=E6=89=93=E5=BC=80=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PageVersion/PageVersionResourcePack.xaml.vb | 11 ++++++++++- .../Pages/PageVersion/PageVersionShader.xaml.vb | 12 +++++++++++- .../Pages/PageVersion/PageVersionWorld.xaml.vb | 11 ++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index 8c34a8bf..2b69ff1d 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -53,6 +53,12 @@ Public Class PageVersionResourcePack .Info = $"引入时间:{ File.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")}", .Tag = i } + Dim BtnOpen As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonOpen, + .ToolTip = "打开", + .Tag = i + } + AddHandler BtnOpen.Click, AddressOf BtnOpen_Click Dim BtnDelete As MyIconButton = New MyIconButton With { .Logo = Logo.IconButtonDelete, .ToolTip = "删除", @@ -65,7 +71,7 @@ Public Class PageVersionResourcePack .Tag = i } AddHandler BtnCopy.Click, AddressOf BtnCopy_Click - worldItem.Buttons = {BtnDelete, BtnCopy} + worldItem.Buttons = {BtnOpen, BtnDelete, BtnCopy} PanList.Children.Add(worldItem) Next RefreshUI() @@ -110,4 +116,7 @@ Public Class PageVersionResourcePack If Not Directory.Exists(ResourcepacksPath) Then Directory.CreateDirectory(ResourcepacksPath) OpenExplorer("""" & ResourcepacksPath & """") End Sub + Private Sub BtnOpen_Click(sender As Object, e As MouseButtonEventArgs) + OpenExplorer("""" & sender.Tag & """") + End Sub End Class diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb index 60b7d848..e05456de 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb @@ -53,6 +53,12 @@ Public Class PageVersionShader .Info = $"引入时间:{ File.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")}", .Tag = i } + Dim BtnOpen As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonOpen, + .ToolTip = "打开", + .Tag = i + } + AddHandler BtnOpen.Click, AddressOf BtnOpen_Click Dim BtnDelete As MyIconButton = New MyIconButton With { .Logo = Logo.IconButtonDelete, .ToolTip = "删除", @@ -65,7 +71,7 @@ Public Class PageVersionShader .Tag = i } AddHandler BtnCopy.Click, AddressOf BtnCopy_Click - worldItem.Buttons = {BtnDelete, BtnCopy} + worldItem.Buttons = {BtnOpen, BtnDelete, BtnCopy} PanList.Children.Add(worldItem) Next RefreshUI() @@ -110,4 +116,8 @@ Public Class PageVersionShader If Not Directory.Exists(ShaderPath) Then Directory.CreateDirectory(ShaderPath) OpenExplorer("""" & ShaderPath & """") End Sub + + Private Sub BtnOpen_Click(sender As Object, e As MouseButtonEventArgs) + OpenExplorer("""" & sender.Tag & """") + End Sub End Class \ No newline at end of file diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb index 670bc9b5..482398e2 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -54,6 +54,12 @@ Public Class PageVersionWorld .Info = $"创建时间:{ Directory.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")},最后修改时间:{Directory.GetLastWriteTime(i).ToString("yyyy'/'MM'/'dd")}", .Tag = i } + Dim BtnOpen As MyIconButton = New MyIconButton With { + .Logo = Logo.IconButtonOpen, + .ToolTip = "打开", + .Tag = i + } + AddHandler BtnOpen.Click, AddressOf BtnOpen_Click Dim BtnDelete As MyIconButton = New MyIconButton With { .Logo = Logo.IconButtonDelete, .ToolTip = "删除", @@ -72,7 +78,7 @@ Public Class PageVersionWorld .Tag = i } AddHandler BtnInfo.Click, AddressOf BtnInfo_Click - worldItem.Buttons = {BtnDelete, BtnCopy, BtnInfo} + worldItem.Buttons = {BtnOpen, BtnDelete, BtnCopy, BtnInfo} PanList.Children.Add(worldItem) Next RefreshUI() @@ -126,4 +132,7 @@ Public Class PageVersionWorld If Not Directory.Exists(WorldPath) Then Directory.CreateDirectory(WorldPath) OpenExplorer("""" & WorldPath & """") End Sub + Private Sub BtnOpen_Click(sender As Object, e As MouseButtonEventArgs) + OpenExplorer("""" & sender.Tag & """") + End Sub End Class From e800b5adbce07d070dab4453e9983cb2f14ac82d Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 21:08:01 +0800 Subject: [PATCH 09/34] =?UTF-8?q?feat:=20=E6=88=AA=E5=9B=BE=E5=9B=BE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml index 383eb3a8..6f26e2b6 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml @@ -32,7 +32,7 @@ + Logo="M791.3,837.8v117.7c0,12.1-9.8,22-22,22h-49.1c-12.1,0-22-9.8-22-22V837.8H232.7c-51.4,0-93.1-41.7-93.1-93.1V279.3H22 c-12.1,0-22-9.8-22-22v-49.1c0-12.1,9.8-22,22-22h117.7V68.5c0-12.1,9.8-22,22-22h49.1c12.1,0,22,9.8,22,22v117.7h465.5 c51.4,0,93.1,41.7,93.1,93.1v465.5h117.7c12.1,0,22,9.8,22,22v49.1c0,12.1-9.8,22-22,22L791.3,837.8L791.3,837.8z M698.2,605.1 V279.3H232.7v465.5h465.5L698.2,605.1L698.2,605.1z"> From fc81f94953648c28ee34105cf32c7da5d641dcce Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 21:13:20 +0800 Subject: [PATCH 10/34] =?UTF-8?q?feat:=20=E6=88=AA=E5=9B=BE=E5=9B=BE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml index 6f26e2b6..e24e3717 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml @@ -32,7 +32,7 @@ + Logo="M853.333333 42.666667H170.666667C99.978667 42.666667 42.666667 99.978667 42.666667 170.666667v682.666666c0 70.688 57.312 128 128 128h682.666666c70.688 0 128-57.312 128-128V170.666667c0-70.688-57.312-128-128-128z m42.666667 810.666666c0 23.573333-19.093333 42.666667-42.666667 42.666667H316.341333L682.666667 529.674667l213.333333 213.322666V853.333333z m0-230.997333l-213.333333-213.333333L195.658667 896H170.666667c-23.573333 0-42.666667-19.093333-42.666667-42.666667V170.666667c0-23.573333 19.093333-42.666667 42.666667-42.666667h682.666666c23.573333 0 42.666667 19.093333 42.666667 42.666667v451.669333zM341.333333 213.333333c-70.688 0-128 57.312-128 128s57.312 128 128 128 128-57.312 128-128-57.312-128-128-128z m0 170.666667a42.666667 42.666667 0 1 1 0-85.333333 42.666667 42.666667 0 0 1 0 85.333333z"> From 5eb2bf4b4d38af3d1aee031a5db69f9ef4c62a6c Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 21:18:02 +0800 Subject: [PATCH 11/34] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/FormMain.xaml.vb | 8 ++++---- .../Pages/PageVersion/PageVersionLeft.xaml | 20 +++++++++---------- .../Pages/PageVersion/PageVersionLeft.xaml.vb | 6 ++++++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Plain Craft Launcher 2/FormMain.xaml.vb b/Plain Craft Launcher 2/FormMain.xaml.vb index 65dc7a73..c0e390b5 100644 --- a/Plain Craft Launcher 2/FormMain.xaml.vb +++ b/Plain Craft Launcher 2/FormMain.xaml.vb @@ -1104,10 +1104,10 @@ Install: OtherTest = 2 VersionOverall = 0 VersionSetup = 1 - VersionMod = 2 - VersionModDisabled = 3 - VersionWorld = 4 - VersionScreenshot = 5 + VersionWorld = 2 + VersionScreenshot = 3 + VersionMod = 4 + VersionModDisabled = 5 VersionResourcePack = 6 VersionShader = 7 End Enum diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml index e24e3717..11f7418f 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml @@ -13,32 +13,32 @@ - + - - + - + - + - + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb index 09af293c..37f5c053 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb @@ -115,6 +115,12 @@ Case FormMain.PageSubType.VersionWorld If FrmVersionWorld IsNot Nothing Then FrmVersionWorld.Reload() ItemWorld.Checked = True + Case FormMain.PageSubType.VersionResourcePack + If FrmVersionWorld IsNot Nothing Then FrmVersionResourcePack.Reload() + ItemResourcePack.Checked = True + Case FormMain.PageSubType.VersionShader + If FrmVersionWorld IsNot Nothing Then FrmVersionShader.Reload() + ItemShader.Checked = True End Select Catch ex As Exception Log(ex, "强制刷新出错") From 6c7fbcd34afeaa129bbd909e3ab1a74402cff943 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 21:30:23 +0800 Subject: [PATCH 12/34] =?UTF-8?q?feat:=20=E6=8C=89=E9=92=AE=E5=B1=85?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 77a9af71..4cc7c211 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -73,6 +73,7 @@ Public Class PageVersionScreenshot '按钮 Dim stackPanel As New StackPanel stackPanel.Orientation = Orientation.Horizontal + stackPanel.HorizontalAlignment = HorizontalAlignment.Center stackPanel.Margin = New Thickness(3,5,3,2) Grid.SetRow(stackPanel, 1) grid.Children.Add(stackPanel) From 62805dc16f31d9d1db1f053404de07eb4aa07261 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 22:04:53 +0800 Subject: [PATCH 13/34] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 资源包显示图标 部分图标修改 部分文案修改 --- .../Pages/PageVersion/PageVersionLeft.xaml | 6 +++--- .../Pages/PageVersion/PageVersionResourcePack.xaml.vb | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml index 11f7418f..956bf5e5 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml @@ -40,15 +40,15 @@ + Logo="M913.066667 264.533333l-371.2-209.066666c-25.6-12.8-59.733333-12.8-85.333334 0L89.6 264.533333C34.133333 298.666667 34.133333 379.733333 89.6 413.866667l371.2 209.066666c25.6 12.8 59.733333 12.8 85.333333 0l371.2-209.066666c55.466667-34.133333 55.466667-119.466667-4.266666-149.333334z m-413.866667 281.6L132.266667 337.066667 499.2 128l371.2 209.066667-371.2 209.066666z M46.933333 516.266667c12.8-21.333333 38.4-25.6 59.733334-17.066667l384 221.866667c12.8 8.533333 29.866667 8.533333 42.666666 0l388.266667-217.6c21.333333-12.8 46.933333-4.266667 59.733333 17.066666 12.8 21.333333 4.266667 46.933333-17.066666 59.733334l-388.266667 217.6c-38.4 21.333333-89.6 21.333333-128 0l-384-221.866667c-21.333333-12.8-25.6-38.4-17.066667-59.733333z M106.666667 669.866667c-21.333333-12.8-46.933333-4.266667-59.733334 17.066666-12.8 21.333333-4.266667 46.933333 17.066667 59.733334l388.266667 217.6c38.4 21.333333 85.333333 21.333333 128 0l379.733333-217.6c21.333333-12.8 25.6-38.4 17.066667-59.733334-12.8-21.333333-38.4-25.6-59.733334-17.066666l-379.733333 217.6c-12.8 8.533333-29.866667 8.533333-42.666667 0l-388.266666-217.6z"> - + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index 2b69ff1d..a063a9e0 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -1,4 +1,5 @@ -Imports System.Security.Principal +Imports System.IO.Compression +Imports System.Security.Principal Public Class PageVersionResourcePack @@ -47,9 +48,15 @@ Public Class PageVersionResourcePack FileList = Directory.EnumerateFiles(ResourcepacksPath, "*.zip").ToList() If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个资源包文件", LogLevel.Debug) PanList.Children.Clear() + Directory.Delete(PageVersionLeft.Version.PathIndie & "PCL\Resourcepacks\", True) + Directory.CreateDirectory(PageVersionLeft.Version.PathIndie & "PCL\Resourcepacks\") For Each i In FileList + Dim Archive = New ZipArchive(New FileStream(i, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + Dim ResTempFile = PageVersionLeft.Version.PathIndie & "PCL\Resourcepacks\" & GetHash(i) & ".png" + Archive.GetEntry("pack.png").ExtractToFile(ResTempFile) Dim worldItem As MyListItem = New MyListItem With { .Title = GetFileNameWithoutExtentionFromPath(i), + .Logo = ResTempFile, .Info = $"引入时间:{ File.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")}", .Tag = i } From 8000b3e41863246ef367b403295f49ee1febad38 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 22:17:22 +0800 Subject: [PATCH 14/34] =?UTF-8?q?fix:=20=E7=BC=93=E5=AD=98=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=88=9B=E5=BB=BA=E4=B8=8E=E5=88=A0=E9=99=A4=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionResourcePack.xaml.vb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index a063a9e0..0dfe28f7 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -9,7 +9,7 @@ Public Class PageVersionResourcePack '重复加载部分 PanBack.ScrollToHome() ResourcepacksPath = PageVersionLeft.Version.PathIndie + "resourcepacks" - If Not Directory.Exists(ResourcepacksPath) Then Directory.CreateDirectory(ResourcepacksPath) + Directory.CreateDirectory(ResourcepacksPath) Reload() '非重复加载部分 @@ -48,7 +48,8 @@ Public Class PageVersionResourcePack FileList = Directory.EnumerateFiles(ResourcepacksPath, "*.zip").ToList() If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个资源包文件", LogLevel.Debug) PanList.Children.Clear() - Directory.Delete(PageVersionLeft.Version.PathIndie & "PCL\Resourcepacks\", True) + Dim ResCachaPath = PageVersionLeft.Version.PathIndie & "PCL\Resourcepacks\" + If Directory.Exists(ResCachaPath) Then Directory.Delete(ResCachaPath, True) Directory.CreateDirectory(PageVersionLeft.Version.PathIndie & "PCL\Resourcepacks\") For Each i In FileList Dim Archive = New ZipArchive(New FileStream(i, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) From ad46cc16661eca9a6e0905d4f53dc877a3867890 Mon Sep 17 00:00:00 2001 From: tangge233 <50769997+tangge233@users.noreply.github.com> Date: Sat, 21 Sep 2024 22:20:01 +0800 Subject: [PATCH 15/34] Update Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com> --- .../Pages/PageVersion/PageVersionScreenshot.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml index 03bf2ac7..e3cb0d41 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml @@ -23,7 +23,7 @@ - + From 668c83ffd51a4ef49706fe3a0a331e37a9c30bca Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 22:50:25 +0800 Subject: [PATCH 16/34] =?UTF-8?q?fix:=20=E5=8F=AF=E8=83=BD=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E7=9A=84=E5=A4=8D=E5=88=B6=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PageVersion/PageVersionScreenshot.xaml.vb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 4cc7c211..4633d4f2 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -136,10 +136,22 @@ Public Class PageVersionScreenshot Private Sub btnCopy_Click(sender As MyIconTextButton, e As EventArgs) Dim imagePath As String = GetPathFromSender(sender) If File.Exists(imagePath) Then - Clipboard.SetFileDropList(New Specialized.StringCollection() From {imagePath}) - Hint("已复制截图到剪贴板!") + Dim TryTime = 0 + While TryTime <= 5 + Try + Log("[Screenshot] 尝试复制" & imagePath & "到剪切板") + Clipboard.Clear() + Clipboard.SetImage(New BitmapImage(New Uri(imagePath))) + Hint("已复制截图到剪贴板!") + TryTime = 6 + Exit Sub + Catch ex As Exception + TryTime += 1 + End Try + End While + Hint("截图复制失败!", HintType.Critical) Else - Hint("截图文件不存在!") + Hint("截图文件不存在!") End If End Sub From a55e8cfcab0a9e7f4dd53b6c40728d54bb63653e Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 21 Sep 2024 23:46:50 +0800 Subject: [PATCH 17/34] =?UTF-8?q?fix:=20=E4=B8=8D=E5=90=88=E7=90=86?= =?UTF-8?q?=E7=9A=84=E5=89=AA=E5=88=87=E6=9D=BF=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 1 - 1 file changed, 1 deletion(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 4633d4f2..d6017605 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -140,7 +140,6 @@ Public Class PageVersionScreenshot While TryTime <= 5 Try Log("[Screenshot] 尝试复制" & imagePath & "到剪切板") - Clipboard.Clear() Clipboard.SetImage(New BitmapImage(New Uri(imagePath))) Hint("已复制截图到剪贴板!") TryTime = 6 From 0665e813bab1c4efc8433cf7d0b15755445df182 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sun, 22 Sep 2024 13:03:31 +0800 Subject: [PATCH 18/34] =?UTF-8?q?feat:=20=E7=B2=98=E8=B4=B4=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PageVersion/PageVersionResourcePack.xaml | 11 ++++ .../PageVersionResourcePack.xaml.vb | 57 ++++++++++++++++--- .../PageVersion/PageVersionScreenshot.xaml | 41 ++++++++----- .../PageVersion/PageVersionScreenshot.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionShader.xaml | 11 ++++ .../PageVersion/PageVersionShader.xaml.vb | 38 +++++++++++-- .../Pages/PageVersion/PageVersionWorld.xaml | 12 ++++ .../PageVersion/PageVersionWorld.xaml.vb | 31 +++++++++- 8 files changed, 171 insertions(+), 32 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml index 3f1b862a..77937d3b 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml @@ -25,9 +25,20 @@ + + + + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index 0dfe28f7..924f08e0 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -8,7 +8,7 @@ Public Class PageVersionResourcePack '重复加载部分 PanBack.ScrollToHome() - ResourcepacksPath = PageVersionLeft.Version.PathIndie + "resourcepacks" + ResourcepacksPath = PageVersionLeft.Version.PathIndie + "resourcepacks\" Directory.CreateDirectory(ResourcepacksPath) Reload() @@ -43,18 +43,28 @@ Public Class PageVersionResourcePack End Sub Private Sub LoadFileList() - Log("[World] 刷新资源包文件") + Log("[Resourcepack] 刷新资源包文件") FileList.Clear() FileList = Directory.EnumerateFiles(ResourcepacksPath, "*.zip").ToList() - If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个资源包文件", LogLevel.Debug) + If ModeDebug Then Log("[Resourcepack] 共发现 " & FileList.Count & " 个资源包文件", LogLevel.Debug) PanList.Children.Clear() - Dim ResCachaPath = PageVersionLeft.Version.PathIndie & "PCL\Resourcepacks\" + Dim ResCachaPath = PageVersionLeft.Version.PathIndie & "PCL\Cache\resourcepacks\" If Directory.Exists(ResCachaPath) Then Directory.Delete(ResCachaPath, True) - Directory.CreateDirectory(PageVersionLeft.Version.PathIndie & "PCL\Resourcepacks\") + Directory.CreateDirectory(ResCachaPath) For Each i In FileList - Dim Archive = New ZipArchive(New FileStream(i, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - Dim ResTempFile = PageVersionLeft.Version.PathIndie & "PCL\Resourcepacks\" & GetHash(i) & ".png" - Archive.GetEntry("pack.png").ExtractToFile(ResTempFile) + Dim ResTempFile = ResCachaPath & GetHash(i) & ".png" + Try + Dim Archive = New ZipArchive(New FileStream(i, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + Dim pack = Archive.GetEntry("pack.png") + If pack Is Nothing Then + ResTempFile = PathImage & "Icons/NoIcon.png" + Else + pack.ExtractToFile(ResTempFile) + End If + Catch ex As Exception + Log(ex, "[Resourcepack] 提取整合包图片失败!") + ResTempFile = PathImage & "Icons/NoIcon.png" + End Try Dim worldItem As MyListItem = New MyListItem With { .Title = GetFileNameWithoutExtentionFromPath(i), .Logo = ResTempFile, @@ -104,7 +114,7 @@ Public Class PageVersionResourcePack Path = GetPathFromSender(sender) RemoveItem(Path) Try - My.Computer.FileSystem.DeleteDirectory(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + My.Computer.FileSystem.DeleteFile(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) Hint("已将资源包移至回收站!") Catch ex As Exception Log(ex, "删除资源包失败!", LogLevel.Hint) @@ -127,4 +137,33 @@ Public Class PageVersionResourcePack Private Sub BtnOpen_Click(sender As Object, e As MouseButtonEventArgs) OpenExplorer("""" & sender.Tag & """") End Sub + Private Sub BtnPaste_Click(sender As Object, e As MouseButtonEventArgs) + Try + Dim files As Specialized.StringCollection = Clipboard.GetFileDropList() + If files.Count.Equals(0) Then + Hint("剪切板内无文件可粘贴") + Exit Sub + End If + Dim CopiedFiles = 0 + For Each i In files + If File.Exists(i) Then + Try + If File.Exists(ResourcepacksPath & GetFileNameFromPath(i)) Then + Hint("已存在同名文件:" & GetFileNameWithoutExtentionFromPath(i)) + Else + File.Copy(i, ResourcepacksPath & GetFileNameFromPath(i)) + CopiedFiles += 1 + End If + Catch ex As Exception + Log(ex, "[Shader] 复制文件时出错") + Continue For + End Try + End If + Next + Hint("已复制 " & CopiedFiles & "个文件") + LoadFileList() + Catch ex As Exception + Log(ex, "粘贴存档文件夹失败", LogLevel.Hint) + End Try + End Sub End Class diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml index e3cb0d41..87455109 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml @@ -27,21 +27,32 @@ - - - + + + + + + + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index d6017605..09633fea 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -7,7 +7,7 @@ Public Class PageVersionScreenshot '重复加载部分 PanBack.ScrollToHome() - ScreenshotPath = PageVersionLeft.Version.PathIndie + "screenshots" + ScreenshotPath = PageVersionLeft.Version.PathIndie + "screenshots\" If Not Directory.Exists(ScreenshotPath) Then Directory.CreateDirectory(ScreenshotPath) Reload() diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml index 89ba3f62..d51b7d19 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml @@ -25,9 +25,20 @@ + + + + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb index e05456de..db4f0a39 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb @@ -7,7 +7,7 @@ Public Class PageVersionShader '重复加载部分 PanBack.ScrollToHome() - ShaderPath = PageVersionLeft.Version.PathIndie + "shaderpacks" + ShaderPath = PageVersionLeft.Version.PathIndie + "shaderpacks\" If Not Directory.Exists(ShaderPath) Then Directory.CreateDirectory(ShaderPath) Reload() @@ -42,10 +42,10 @@ Public Class PageVersionShader End Sub Private Sub LoadFileList() - Log("[World] 刷新光影包文件") + Log("[Shader] 刷新光影包文件") FileList.Clear() FileList = Directory.EnumerateFiles(ShaderPath, "*.zip").ToList() - If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个光影包文件", LogLevel.Debug) + If ModeDebug Then Log("[Shader] 共发现 " & FileList.Count & " 个光影包文件", LogLevel.Debug) PanList.Children.Clear() For Each i In FileList Dim worldItem As MyListItem = New MyListItem With { @@ -96,7 +96,7 @@ Public Class PageVersionShader Path = GetPathFromSender(sender) RemoveItem(Path) Try - My.Computer.FileSystem.DeleteDirectory(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + My.Computer.FileSystem.DeleteFile(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) Hint("已将光影包移至回收站!") Catch ex As Exception Log(ex, "删除光影包失败!", LogLevel.Hint) @@ -120,4 +120,34 @@ Public Class PageVersionShader Private Sub BtnOpen_Click(sender As Object, e As MouseButtonEventArgs) OpenExplorer("""" & sender.Tag & """") End Sub + + Private Sub BtnPaste_Click(sender As Object, e As MouseButtonEventArgs) + Try + Dim files As Specialized.StringCollection = Clipboard.GetFileDropList() + If files.Count.Equals(0) Then + Hint("剪切板内无文件可粘贴") + Exit Sub + End If + Dim CopiedFiles = 0 + For Each i In files + If File.Exists(i) Then + Try + If File.Exists(ShaderPath & GetFileNameFromPath(i)) Then + Hint("已存在同名文件:" & GetFileNameWithoutExtentionFromPath(i)) + Else + File.Copy(i, ShaderPath & GetFileNameFromPath(i)) + CopiedFiles += 1 + End If + Catch ex As Exception + Log(ex, "[Shader] 复制文件时出错") + Continue For + End Try + End If + Next + Hint("已复制 " & CopiedFiles & "个文件") + LoadFileList() + Catch ex As Exception + Log(ex, "粘贴存档文件夹失败", LogLevel.Hint) + End Try + End Sub End Class \ No newline at end of file diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml index eec76f3a..36582eba 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml @@ -25,9 +25,21 @@ + + + + + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb index 482398e2..602d3181 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -7,7 +7,7 @@ Public Class PageVersionWorld '重复加载部分 PanBack.ScrollToHome() - WorldPath = PageVersionLeft.Version.PathIndie + "saves" + WorldPath = PageVersionLeft.Version.PathIndie + "saves\" If Not Directory.Exists(WorldPath) Then Directory.CreateDirectory(WorldPath) Reload() @@ -48,9 +48,11 @@ Public Class PageVersionWorld If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个存档文件夹", LogLevel.Debug) PanList.Children.Clear() For Each i In FileList + Dim SaveLogo = i + "\icon.png" + If Not File.Exists(SaveLogo) Then SaveLogo = PathImage & "Icons/NoIcon.png" Dim worldItem As MyListItem = New MyListItem With { - .Logo = i + "\icon.png", - .Title = GetFileNameFromPath(i), + .Logo = SaveLogo, + .Title = GetFolderNameFromPath(i), .Info = $"创建时间:{ Directory.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")},最后修改时间:{Directory.GetLastWriteTime(i).ToString("yyyy'/'MM'/'dd")}", .Tag = i } @@ -135,4 +137,27 @@ Public Class PageVersionWorld Private Sub BtnOpen_Click(sender As Object, e As MouseButtonEventArgs) OpenExplorer("""" & sender.Tag & """") End Sub + Private Sub BtnPaste_Click(sender As Object, e As MouseButtonEventArgs) + Dim files As Specialized.StringCollection = Clipboard.GetFileDropList() + Dim Copied = 0 + For Each i In files + Try + If Directory.Exists(i) Then + If (Directory.Exists(WorldPath & GetFolderNameFromPath(i))) Then + Hint("发现同名文件夹,无法粘贴:" & GetFolderNameFromPath(i)) + Else + CopyDirectory(i, WorldPath & GetFolderNameFromPath(i)) + Copied += 1 + End If + Else + Hint("源文件夹不存在或源目标不是文件夹") + End If + Catch ex As Exception + Log(ex, "粘贴存档文件夹失败", LogLevel.Hint) + Continue For + End Try + Next + Hint("已复制 " & Copied & " 个文件夹") + LoadFileList() + End Sub End Class From f8bebb5ac0ff9612bdc242e6e548379b3a9a1bb4 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sun, 22 Sep 2024 13:09:39 +0800 Subject: [PATCH 19/34] =?UTF-8?q?fix:=20=E6=96=87=E6=9C=AC=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionResourcePack.xaml | 4 ++-- .../Pages/PageVersion/PageVersionResourcePack.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionShader.xaml | 4 ++-- .../Pages/PageVersion/PageVersionShader.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionWorld.xaml | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml index 77937d3b..08571ebe 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml @@ -25,7 +25,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index 924f08e0..444c5c44 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -141,7 +141,7 @@ Public Class PageVersionResourcePack Try Dim files As Specialized.StringCollection = Clipboard.GetFileDropList() If files.Count.Equals(0) Then - Hint("剪切板内无文件可粘贴") + Hint("剪贴板内无文件可粘贴") Exit Sub End If Dim CopiedFiles = 0 diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 09633fea..1e6e9b41 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -139,7 +139,7 @@ Public Class PageVersionScreenshot Dim TryTime = 0 While TryTime <= 5 Try - Log("[Screenshot] 尝试复制" & imagePath & "到剪切板") + Log("[Screenshot] 尝试复制" & imagePath & "到剪贴板") Clipboard.SetImage(New BitmapImage(New Uri(imagePath))) Hint("已复制截图到剪贴板!") TryTime = 6 diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml index d51b7d19..e323cc28 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml @@ -25,7 +25,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb index db4f0a39..8d81a95f 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb @@ -125,7 +125,7 @@ Public Class PageVersionShader Try Dim files As Specialized.StringCollection = Clipboard.GetFileDropList() If files.Count.Equals(0) Then - Hint("剪切板内无文件可粘贴") + Hint("剪贴板内无文件可粘贴") Exit Sub End If Dim CopiedFiles = 0 diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml index 36582eba..d0b5c6de 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml @@ -25,7 +25,7 @@ - + @@ -37,7 +37,7 @@ - + From 688c8847ca43c5c6462b12d6d2b5d6db5de542cb Mon Sep 17 00:00:00 2001 From: tangge233 <50769997+tangge233@users.noreply.github.com> Date: Sun, 22 Sep 2024 13:17:50 +0800 Subject: [PATCH 20/34] Apply suggestions from code review Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com> --- .../Pages/PageVersion/PageVersionResourcePack.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionShader.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionWorld.xaml.vb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index 444c5c44..dfb6add4 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -160,7 +160,7 @@ Public Class PageVersionResourcePack End Try End If Next - Hint("已复制 " & CopiedFiles & "个文件") + Hint("已粘贴 " & CopiedFiles & " 个文件") LoadFileList() Catch ex As Exception Log(ex, "粘贴存档文件夹失败", LogLevel.Hint) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb index 8d81a95f..9881602a 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb @@ -144,7 +144,7 @@ Public Class PageVersionShader End Try End If Next - Hint("已复制 " & CopiedFiles & "个文件") + Hint("已粘贴 " & CopiedFiles & " 个文件") LoadFileList() Catch ex As Exception Log(ex, "粘贴存档文件夹失败", LogLevel.Hint) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb index 602d3181..74f4be18 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -157,7 +157,7 @@ Public Class PageVersionWorld Continue For End Try Next - Hint("已复制 " & Copied & " 个文件夹") + Hint("已粘贴 " & Copied & " 个文件夹") LoadFileList() End Sub End Class From 2c3f87cb21f893b3d556004fa994524b9ef0ae2d Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sun, 22 Sep 2024 13:48:57 +0800 Subject: [PATCH 21/34] =?UTF-8?q?fix:=20UI=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 1e6e9b41..609c26f5 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -28,12 +28,17 @@ Public Class PageVersionScreenshot AniControlEnabled += 1 PanBack.ScrollToHome() LoadFileList() + AniControlEnabled -= 1 + End Sub + + Private Sub RefreshUI() If FileList.Count.Equals(0) Then PanNoPic.Visibility = Visibility.Visible + PanContent.Visibility = Visibility.Collapsed Else PanNoPic.Visibility = Visibility.Collapsed + PanContent.Visibility = Visibility.Visible End If - AniControlEnabled -= 1 End Sub Private Sub LoadFileList() @@ -48,7 +53,8 @@ Public Class PageVersionScreenshot .Width = Double.NaN, ' 允许宽度自适应 .MinWidth = 230, .Margin = New Thickness(7), - .Tag = i + .Tag = i, + .ToolTip = i.Replace(ScreenshotPath, "") } Dim grid As New Grid grid.Margin = New Thickness(4) @@ -74,7 +80,7 @@ Public Class PageVersionScreenshot Dim stackPanel As New StackPanel stackPanel.Orientation = Orientation.Horizontal stackPanel.HorizontalAlignment = HorizontalAlignment.Center - stackPanel.Margin = New Thickness(3,5,3,2) + stackPanel.Margin = New Thickness(3, 5, 3, 2) Grid.SetRow(stackPanel, 1) grid.Children.Add(stackPanel) @@ -105,6 +111,7 @@ Public Class PageVersionScreenshot PanList.Children.Add(myCard) Next + RefreshUI() End Sub Private Sub RemoveItem(Path As String) From dfa2663fde4148f3d00c6eb709ecbc2e1e2ac657 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sun, 22 Sep 2024 16:46:05 +0800 Subject: [PATCH 22/34] =?UTF-8?q?feat:=20=E6=88=AA=E5=9B=BE=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 609c26f5..c124bcbe 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -51,15 +51,13 @@ Public Class PageVersionScreenshot Dim myCard As New MyCard With { .Height = Double.NaN, ' 允许高度自适应 .Width = Double.NaN, ' 允许宽度自适应 - .MinWidth = 230, .Margin = New Thickness(7), - .Tag = i, - .ToolTip = i.Replace(ScreenshotPath, "") + .Tag = i } Dim grid As New Grid - grid.Margin = New Thickness(4) myCard.Children.Add(grid) + grid.RowDefinitions.Add(New RowDefinition With {.Height = New GridLength(7)}) grid.RowDefinitions.Add(New RowDefinition With {.Height = New GridLength(120)}) grid.RowDefinitions.Add(New RowDefinition) @@ -73,15 +71,15 @@ Public Class PageVersionScreenshot bitmapImage.Freeze() ' 冻结图像以提高性能 image.Source = bitmapImage image.Stretch = Stretch.Uniform ' 使图片自适应控件大小 - Grid.SetRow(image, 0) + Grid.SetRow(image, 1) grid.Children.Add(image) '按钮 Dim stackPanel As New StackPanel stackPanel.Orientation = Orientation.Horizontal stackPanel.HorizontalAlignment = HorizontalAlignment.Center - stackPanel.Margin = New Thickness(3, 5, 3, 2) - Grid.SetRow(stackPanel, 1) + stackPanel.Margin = New Thickness(3, 5, 3, 5) + Grid.SetRow(stackPanel, 2) grid.Children.Add(stackPanel) Dim btnOpen As New MyIconTextButton With { From 8902ffdda67ed38b33a9a6400048f852a5891321 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sun, 22 Sep 2024 21:03:40 +0800 Subject: [PATCH 23/34] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index c124bcbe..da3e2b95 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -52,12 +52,13 @@ Public Class PageVersionScreenshot .Height = Double.NaN, ' 允许高度自适应 .Width = Double.NaN, ' 允许宽度自适应 .Margin = New Thickness(7), - .Tag = i + .Tag = i, + .ToolTip = i.Replace(ScreenshotPath, "") '适配高清截图模组 } Dim grid As New Grid myCard.Children.Add(grid) - grid.RowDefinitions.Add(New RowDefinition With {.Height = New GridLength(7)}) + grid.RowDefinitions.Add(New RowDefinition With {.Height = New GridLength(9)}) grid.RowDefinitions.Add(New RowDefinition With {.Height = New GridLength(120)}) grid.RowDefinitions.Add(New RowDefinition) From eb52f3eeec555ea169771029a309b13cb65b1e9b Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sun, 22 Sep 2024 21:08:18 +0800 Subject: [PATCH 24/34] =?UTF-8?q?fix:=20=E7=A9=BA=E5=80=BC=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=AF=B9=E8=B1=A1=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionLeft.xaml.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb index 37f5c053..a1ba52f6 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionLeft.xaml.vb @@ -116,10 +116,10 @@ If FrmVersionWorld IsNot Nothing Then FrmVersionWorld.Reload() ItemWorld.Checked = True Case FormMain.PageSubType.VersionResourcePack - If FrmVersionWorld IsNot Nothing Then FrmVersionResourcePack.Reload() + If FrmVersionResourcePack IsNot Nothing Then FrmVersionResourcePack.Reload() ItemResourcePack.Checked = True Case FormMain.PageSubType.VersionShader - If FrmVersionWorld IsNot Nothing Then FrmVersionShader.Reload() + If FrmVersionShader IsNot Nothing Then FrmVersionShader.Reload() ItemShader.Checked = True End Select Catch ex As Exception From ca6c7861e55aea852a7ff529862ce072d26bfaec Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sun, 22 Sep 2024 21:19:48 +0800 Subject: [PATCH 25/34] =?UTF-8?q?fix:=20=E7=95=8C=E9=9D=A2=E5=85=83?= =?UTF-8?q?=E7=B4=A0=E6=9C=89=E6=97=B6=E7=9C=8B=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionResourcePack.xaml.vb | 2 ++ .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 2 ++ .../Pages/PageVersion/PageVersionShader.xaml.vb | 2 ++ .../Pages/PageVersion/PageVersionWorld.xaml.vb | 2 ++ 4 files changed, 8 insertions(+) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index dfb6add4..7fc86976 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -36,9 +36,11 @@ Public Class PageVersionResourcePack If FileList.Count.Equals(0) Then PanNoWorld.Visibility = Visibility.Visible PanContent.Visibility = Visibility.Collapsed + PanNoWorld.UpdateLayout() Else PanNoWorld.Visibility = Visibility.Collapsed PanContent.Visibility = Visibility.Visible + PanContent.UpdateLayout() End If End Sub diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index da3e2b95..d36cdca7 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -35,9 +35,11 @@ Public Class PageVersionScreenshot If FileList.Count.Equals(0) Then PanNoPic.Visibility = Visibility.Visible PanContent.Visibility = Visibility.Collapsed + PanNoPic.UpdateLayout() Else PanNoPic.Visibility = Visibility.Collapsed PanContent.Visibility = Visibility.Visible + PanContent.UpdateLayout() End If End Sub diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb index 9881602a..3d7732ac 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb @@ -35,9 +35,11 @@ Public Class PageVersionShader If FileList.Count.Equals(0) Then PanNoWorld.Visibility = Visibility.Visible PanContent.Visibility = Visibility.Collapsed + PanNoWorld.UpdateLayout() Else PanNoWorld.Visibility = Visibility.Collapsed PanContent.Visibility = Visibility.Visible + PanContent.UpdateLayout() End If End Sub diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb index 74f4be18..8b6e9a14 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -35,9 +35,11 @@ Public Class PageVersionWorld If FileList.Count.Equals(0) Then PanNoWorld.Visibility = Visibility.Visible PanContent.Visibility = Visibility.Collapsed + PanNoWorld.UpdateLayout() Else PanNoWorld.Visibility = Visibility.Collapsed PanContent.Visibility = Visibility.Visible + PanContent.UpdateLayout() End If End Sub From 62be47d961bddb2005ea2a88f520da7287c08bf5 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Mon, 23 Sep 2024 17:07:32 +0800 Subject: [PATCH 26/34] =?UTF-8?q?feat:=20=E8=B5=84=E6=BA=90=E5=8C=85?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E6=94=AF=E6=8C=81=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PageVersionResourcePack.xaml.vb | 61 ++++++++++++++----- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index 7fc86976..d6414b2e 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -18,6 +18,9 @@ Public Class PageVersionResourcePack End Sub + ''' + ''' 文件和文件夹列表 + ''' Dim FileList As List(Of String) = New List(Of String) Dim ResourcepacksPath As String @@ -47,31 +50,40 @@ Public Class PageVersionResourcePack Private Sub LoadFileList() Log("[Resourcepack] 刷新资源包文件") FileList.Clear() - FileList = Directory.EnumerateFiles(ResourcepacksPath, "*.zip").ToList() - If ModeDebug Then Log("[Resourcepack] 共发现 " & FileList.Count & " 个资源包文件", LogLevel.Debug) + Dim fileRes = Directory.EnumerateFiles(ResourcepacksPath, "*.zip").ToList() + FileList.AddRange(fileRes) + Dim FolderRes = Directory.EnumerateDirectories(ResourcepacksPath).ToList() + FileList.AddRange(FolderRes) + If ModeDebug Then Log($"[Resourcepack] 共发现 {FileList.Count} 个资源包文件({fileRes.Count} 个文件,{FolderRes.Count} 个文件夹)", LogLevel.Debug) PanList.Children.Clear() Dim ResCachaPath = PageVersionLeft.Version.PathIndie & "PCL\Cache\resourcepacks\" If Directory.Exists(ResCachaPath) Then Directory.Delete(ResCachaPath, True) Directory.CreateDirectory(ResCachaPath) For Each i In FileList Dim ResTempFile = ResCachaPath & GetHash(i) & ".png" + Dim isFile = File.Exists(i) Try - Dim Archive = New ZipArchive(New FileStream(i, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - Dim pack = Archive.GetEntry("pack.png") - If pack Is Nothing Then - ResTempFile = PathImage & "Icons/NoIcon.png" - Else - pack.ExtractToFile(ResTempFile) + If isFile Then '文件类型的资源包 + Dim Archive = New ZipArchive(New FileStream(i, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + Dim pack = Archive.GetEntry("pack.png") + If pack Is Nothing Then + ResTempFile = PathImage & "Icons/NoIcon.png" + Else + pack.ExtractToFile(ResTempFile) + End If + Else '文件夹型资源包 + ResTempFile = i + "\pack.png" End If Catch ex As Exception Log(ex, "[Resourcepack] 提取整合包图片失败!") ResTempFile = PathImage & "Icons/NoIcon.png" End Try + If Not File.Exists(ResTempFile) Then ResTempFile = PathImage & "Icons/NoIcon.png" '防止未考虑到的错误 Dim worldItem As MyListItem = New MyListItem With { - .Title = GetFileNameWithoutExtentionFromPath(i), - .Logo = ResTempFile, - .Info = $"引入时间:{ File.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")}", - .Tag = i + .Title = If(isFile, GetFileNameWithoutExtentionFromPath(i), GetFolderNameFromPath(i)), + .Logo = ResTempFile, + .Info = $"引入时间:{ If(isFile, File.GetCreationTime(i), Directory.GetCreationTime(i)).ToString("yyyy'/'MM'/'dd")}", + .Tag = i } Dim BtnOpen As MyIconButton = New MyIconButton With { .Logo = Logo.IconButtonOpen, @@ -116,7 +128,11 @@ Public Class PageVersionResourcePack Path = GetPathFromSender(sender) RemoveItem(Path) Try - My.Computer.FileSystem.DeleteFile(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + If File.Exists(Path) Then + My.Computer.FileSystem.DeleteFile(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + Else + My.Computer.FileSystem.DeleteDirectory(Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) + End If Hint("已将资源包移至回收站!") Catch ex As Exception Log(ex, "删除资源包失败!", LogLevel.Hint) @@ -124,7 +140,7 @@ Public Class PageVersionResourcePack End Sub Private Sub BtnCopy_Click(sender As Object, e As MouseButtonEventArgs) Dim Path As String = GetPathFromSender(sender) - If File.Exists(Path) Then + If File.Exists(Path) Or Directory.Exists(Path) Then Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) Hint("已复制资源包文件到剪贴板!") Else @@ -147,6 +163,7 @@ Public Class PageVersionResourcePack Exit Sub End If Dim CopiedFiles = 0 + Dim CopiedFolders = 0 For Each i In files If File.Exists(i) Then Try @@ -157,12 +174,24 @@ Public Class PageVersionResourcePack CopiedFiles += 1 End If Catch ex As Exception - Log(ex, "[Shader] 复制文件时出错") + Log(ex, "[Reourcepack] 复制文件时出错") + Continue For + End Try + Else + Try + If Directory.Exists(ResourcepacksPath & GetFolderNameFromPath(i)) Then + Hint("已存在同名文件夹:" & GetFolderNameFromPath(i)) + Else + CopyDirectory(i, ResourcepacksPath & GetFolderNameFromPath(i)) + CopiedFolders += 1 + End If + Catch ex As Exception + Log(ex, "[Resourcepack] 复制文件时出错") Continue For End Try End If Next - Hint("已粘贴 " & CopiedFiles & " 个文件") + Hint("已粘贴 " & CopiedFiles & " 个文件和 " & CopiedFolders & " 个文件夹") LoadFileList() Catch ex As Exception Log(ex, "粘贴存档文件夹失败", LogLevel.Hint) From 7123f890b125b0a9907a7e27a1678b50cb73cd57 Mon Sep 17 00:00:00 2001 From: tangge233 <50769997+tangge233@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:32:38 +0800 Subject: [PATCH 27/34] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 《我不希望我的日志拿起来就被别人看懂》 Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com> --- .../Pages/PageVersion/PageVersionResourcePack.xaml.vb | 4 ++-- .../Pages/PageVersion/PageVersionShader.xaml.vb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index d6414b2e..edf50fb7 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -75,7 +75,7 @@ Public Class PageVersionResourcePack ResTempFile = i + "\pack.png" End If Catch ex As Exception - Log(ex, "[Resourcepack] 提取整合包图片失败!") + Log(ex, "[Resourcepack] 提取资源包图片失败!") ResTempFile = PathImage & "Icons/NoIcon.png" End Try If Not File.Exists(ResTempFile) Then ResTempFile = PathImage & "Icons/NoIcon.png" '防止未考虑到的错误 @@ -194,7 +194,7 @@ Public Class PageVersionResourcePack Hint("已粘贴 " & CopiedFiles & " 个文件和 " & CopiedFolders & " 个文件夹") LoadFileList() Catch ex As Exception - Log(ex, "粘贴存档文件夹失败", LogLevel.Hint) + Log(ex, "粘贴资源包文件失败", LogLevel.Hint) End Try End Sub End Class diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb index 3d7732ac..fbcbc3a2 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb @@ -149,7 +149,7 @@ Public Class PageVersionShader Hint("已粘贴 " & CopiedFiles & " 个文件") LoadFileList() Catch ex As Exception - Log(ex, "粘贴存档文件夹失败", LogLevel.Hint) + Log(ex, "粘贴光影包文件失败", LogLevel.Hint) End Try End Sub End Class \ No newline at end of file From b5d721ee87dc141f888b38cc85f2f26c060d2edb Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 28 Sep 2024 13:13:54 +0800 Subject: [PATCH 28/34] =?UTF-8?q?fix:=20=E7=9B=AE=E5=BD=95=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PageVersion/PageVersionWorld.xaml.vb | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb index 8b6e9a14..b3008616 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -123,17 +123,22 @@ Public Class PageVersionWorld End If End Sub Private Sub BtnInfo_Click(sender As Object, e As MouseButtonEventArgs) - Dim Path As String = GetPathFromSender(sender) - Dim infos As List(Of String) = New List(Of String) - infos.Add("名称:" & GetFileNameFromPath(Path)) - infos.Add("创建日期:" & Directory.GetCreationTime(Path).ToString("yyyy'/'MM'/'dd")) - infos.Add("最后一次修改日期:" & Directory.GetLastWriteTime(Path).ToString("yyyy'/'MM'/'dd")) - infos.Add("玩家数量:" & Directory.GetFiles(Path & "\playerdata", "*.dat", SearchOption.TopDirectoryOnly).Count()) - infos.Add("数据包数量:" & (Directory.GetDirectories(Path + "\datapacks").Count() + Directory.GetFiles(Path + "\datapacks").Count()).ToString()) - MyMsgBox(infos.Join(vbCrLf), "存档详细信息") + Try + Dim Path As String = GetPathFromSender(sender) + Dim infos As List(Of String) = New List(Of String) + infos.Add("名称:" & GetFileNameFromPath(Path)) + infos.Add("创建日期:" & Directory.GetCreationTime(Path).ToString("yyyy'/'MM'/'dd")) + infos.Add("最后一次修改日期:" & Directory.GetLastWriteTime(Path).ToString("yyyy'/'MM'/'dd")) + Directory.CreateDirectory(Path & "\playerdata") + infos.Add("玩家数量:" & Directory.GetFiles(Path & "\playerdata", "*.dat", SearchOption.TopDirectoryOnly).Count()) + Directory.CreateDirectory(Path + "\datapacks") + infos.Add("数据包数量:" & (Directory.GetDirectories(Path + "\datapacks").Count() + Directory.GetFiles(Path + "\datapacks").Count()).ToString()) + MyMsgBox(infos.Join(vbCrLf), "存档详细信息") + Catch ex As Exception + Log(ex, "获取存档详细信息失败……", LogLevel.Hint) + End Try End Sub Private Sub BtnOpenFolder_Click(sender As Object, e As MouseButtonEventArgs) - If Not Directory.Exists(WorldPath) Then Directory.CreateDirectory(WorldPath) OpenExplorer("""" & WorldPath & """") End Sub Private Sub BtnOpen_Click(sender As Object, e As MouseButtonEventArgs) From 3accfe038a3af94689726ac24f9c5014289b41cd Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 28 Sep 2024 13:39:21 +0800 Subject: [PATCH 29/34] =?UTF-8?q?chore:=20=E8=B5=84=E6=BA=90=E5=8C=85?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=86=85=E9=83=A8=E8=87=AA=E5=B8=A6=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PageVersionResourcePack.xaml.vb | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index edf50fb7..970bbfbc 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -60,29 +60,44 @@ Public Class PageVersionResourcePack If Directory.Exists(ResCachaPath) Then Directory.Delete(ResCachaPath, True) Directory.CreateDirectory(ResCachaPath) For Each i In FileList - Dim ResTempFile = ResCachaPath & GetHash(i) & ".png" + Dim ResTempIconFile = ResCachaPath & GetHash(i) & ".png" + Dim ResTempDescFile = ResCachaPath & GetHash(i) & ".json" + Dim ResDesc As String = "" Dim isFile = File.Exists(i) + + '提取资源 Try If isFile Then '文件类型的资源包 Dim Archive = New ZipArchive(New FileStream(i, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) Dim pack = Archive.GetEntry("pack.png") + Dim desc = Archive.GetEntry("pack.mcmeta") If pack Is Nothing Then - ResTempFile = PathImage & "Icons/NoIcon.png" + ResTempIconFile = PathImage & "Icons/NoIcon.png" Else - pack.ExtractToFile(ResTempFile) + pack.ExtractToFile(ResTempIconFile) + End If + If desc IsNot Nothing Then + desc.ExtractToFile(ResTempDescFile) + ResDesc = GetJson(File.ReadAllText(ResTempDescFile, Encoding.UTF8))?("pack")?("description") End If Else '文件夹型资源包 - ResTempFile = i + "\pack.png" + ResTempIconFile = i + "\pack.png" + ResDesc = GetJson(File.ReadAllText(i & "\pack.mcmeta", Encoding.UTF8))?("pack")?("description") End If Catch ex As Exception - Log(ex, "[Resourcepack] 提取资源包图片失败!") - ResTempFile = PathImage & "Icons/NoIcon.png" + Log(ex, "[Resourcepack] 提取资源包信息失败!") + ResTempIconFile = PathImage & "Icons/NoIcon.png" + ResDesc = $"引入时间:{ If(isFile, File.GetCreationTime(i), Directory.GetCreationTime(i)).ToString("yyyy'/'MM'/'dd")}" End Try - If Not File.Exists(ResTempFile) Then ResTempFile = PathImage & "Icons/NoIcon.png" '防止未考虑到的错误 + + '防止错误 + If String.IsNullOrEmpty(ResDesc) Then ResDesc = $"引入时间:{ If(isFile, File.GetCreationTime(i), Directory.GetCreationTime(i)).ToString("yyyy'/'MM'/'dd")}" + If Not File.Exists(ResTempIconFile) Then ResTempIconFile = PathImage & "Icons/NoIcon.png" + Dim worldItem As MyListItem = New MyListItem With { .Title = If(isFile, GetFileNameWithoutExtentionFromPath(i), GetFolderNameFromPath(i)), - .Logo = ResTempFile, - .Info = $"引入时间:{ If(isFile, File.GetCreationTime(i), Directory.GetCreationTime(i)).ToString("yyyy'/'MM'/'dd")}", + .Logo = ResTempIconFile, + .Info = ResDesc, .Tag = i } Dim BtnOpen As MyIconButton = New MyIconButton With { From 3f0ed3ab96bf48f1e136f16a3e05b60803e37dda Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 28 Sep 2024 13:47:44 +0800 Subject: [PATCH 30/34] =?UTF-8?q?chore:=20=E5=8A=A0=E5=85=A5=20Try=20Catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PageVersionResourcePack.xaml.vb | 36 +++++++++++-------- .../PageVersion/PageVersionScreenshot.xaml.vb | 17 +++++---- .../PageVersion/PageVersionShader.xaml.vb | 34 +++++++++++------- .../PageVersion/PageVersionWorld.xaml.vb | 34 +++++++++++------- 4 files changed, 75 insertions(+), 46 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index 970bbfbc..8d399930 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -129,13 +129,17 @@ Public Class PageVersionResourcePack End Function Private Sub RemoveItem(Path As String) - For Each i In PanList.Children - If CType(i, MyListItem).Tag.Equals(Path) Then - PanList.Children.Remove(CType(i, MyListItem)) - FileList.Remove(Path) - Exit For - End If - Next + Try + For Each i In PanList.Children + If CType(i, MyListItem).Tag.Equals(Path) Then + PanList.Children.Remove(CType(i, MyListItem)) + FileList.Remove(Path) + Exit For + End If + Next + Catch ex As Exception + Log(ex, "未能找到对应 UI") + End Try RefreshUI() End Sub @@ -154,13 +158,17 @@ Public Class PageVersionResourcePack End Try End Sub Private Sub BtnCopy_Click(sender As Object, e As MouseButtonEventArgs) - Dim Path As String = GetPathFromSender(sender) - If File.Exists(Path) Or Directory.Exists(Path) Then - Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) - Hint("已复制资源包文件到剪贴板!") - Else - Hint("资源包不存在!") - End If + Try + Dim Path As String = GetPathFromSender(sender) + If File.Exists(Path) Or Directory.Exists(Path) Then + Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) + Hint("已复制资源包文件到剪贴板!") + Else + Hint("资源包不存在!") + End If + Catch ex As Exception + Log(ex, "复制失败……", LogLevel.Hint) + End Try End Sub Private Sub BtnOpenFolder_Click(sender As Object, e As MouseButtonEventArgs) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index d36cdca7..04983852 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -116,12 +116,16 @@ Public Class PageVersionScreenshot End Sub Private Sub RemoveItem(Path As String) - For Each i In PanList.Children - If CType(i, MyCard).Tag.Equals(Path) Then - PanList.Children.Remove(i) - Exit For - End If - Next + Try + For Each i In PanList.Children + If CType(i, MyCard).Tag.Equals(Path) Then + PanList.Children.Remove(i) + Exit For + End If + Next + Catch ex As Exception + Log(ex, "未能找到对应 UI") + End Try End Sub Private Function GetPathFromSender(sender As MyIconTextButton) As String @@ -154,6 +158,7 @@ Public Class PageVersionScreenshot Exit Sub Catch ex As Exception TryTime += 1 + Log(ex, $"[Screenshot]第 {TryTime} 次复制尝试失败") End Try End While Hint("截图复制失败!", HintType.Critical) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb index fbcbc3a2..34adf371 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb @@ -84,13 +84,17 @@ Public Class PageVersionShader End Function Private Sub RemoveItem(Path As String) - For Each i In PanList.Children - If CType(i, MyListItem).Tag.Equals(Path) Then - PanList.Children.Remove(CType(i, MyListItem)) - FileList.Remove(Path) - Exit For - End If - Next + Try + For Each i In PanList.Children + If CType(i, MyListItem).Tag.Equals(Path) Then + PanList.Children.Remove(CType(i, MyListItem)) + FileList.Remove(Path) + Exit For + End If + Next + Catch ex As Exception + Log(ex, "未能找到对应 UI") + End Try RefreshUI() End Sub @@ -106,12 +110,16 @@ Public Class PageVersionShader End Sub Private Sub BtnCopy_Click(sender As Object, e As MouseButtonEventArgs) Dim Path As String = GetPathFromSender(sender) - If File.Exists(Path) Then - Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) - Hint("已复制光影包文件到剪贴板!") - Else - Hint("光影包不存在!") - End If + Try + If File.Exists(Path) Then + Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) + Hint("已复制光影包文件到剪贴板!") + Else + Hint("光影包不存在!") + End If + Catch ex As Exception + Log(ex, "复制失败……", LogLevel.Hint) + End Try End Sub Private Sub BtnOpenFolder_Click(sender As Object, e As MouseButtonEventArgs) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb index b3008616..c208bb1e 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -93,13 +93,17 @@ Public Class PageVersionWorld End Function Private Sub RemoveItem(Path As String) - For Each i In PanList.Children - If CType(i, MyListItem).Tag.Equals(Path) Then - PanList.Children.Remove(CType(i, MyListItem)) - FileList.Remove(Path) - Exit For - End If - Next + Try + For Each i In PanList.Children + If CType(i, MyListItem).Tag.Equals(Path) Then + PanList.Children.Remove(CType(i, MyListItem)) + FileList.Remove(Path) + Exit For + End If + Next + Catch ex As Exception + Log(ex, "未能找到对应 UI") + End Try RefreshUI() End Sub @@ -115,12 +119,16 @@ Public Class PageVersionWorld End Sub Private Sub BtnCopy_Click(sender As Object, e As MouseButtonEventArgs) Dim Path As String = GetPathFromSender(sender) - If Directory.Exists(Path) Then - Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) - Hint("已复制存档文件夹到剪贴板!") - Else - Hint("存档文件夹不存在!") - End If + Try + If Directory.Exists(Path) Then + Clipboard.SetFileDropList(New Specialized.StringCollection() From {Path}) + Hint("已复制存档文件夹到剪贴板!") + Else + Hint("存档文件夹不存在!") + End If + Catch ex As Exception + Log(ex, "复制失败……", LogLevel.Hint) + End Try End Sub Private Sub BtnInfo_Click(sender As Object, e As MouseButtonEventArgs) Try From e49f038ecc1f6b3ed3d7a520840810a1739b3fd7 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sat, 28 Sep 2024 13:50:49 +0800 Subject: [PATCH 31/34] =?UTF-8?q?fix:=20=E4=B8=8D=E5=90=88=E7=90=86?= =?UTF-8?q?=E7=9A=84=E8=B7=AF=E5=BE=84=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageVersion/PageVersionResourcePack.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionScreenshot.xaml.vb | 11 +++++++---- .../Pages/PageVersion/PageVersionShader.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionWorld.xaml.vb | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb index 8d399930..6eae3d8a 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionResourcePack.xaml.vb @@ -125,7 +125,7 @@ Public Class PageVersionResourcePack End Sub Private Function GetPathFromSender(sender As Object) As String - Return CType(sender, MyIconButton).Tag + Return sender.Tag End Function Private Sub RemoveItem(Path As String) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb index 04983852..142d5e0b 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml.vb @@ -89,7 +89,8 @@ Public Class PageVersionScreenshot .Name = "BtnOpen", .Text = "打开", .LogoScale = 0.8, - .Logo = Logo.IconButtonOpen + .Logo = Logo.IconButtonOpen, + .Tag = i } AddHandler btnOpen.Click, AddressOf btnOpen_Click stackPanel.Children.Add(btnOpen) @@ -97,7 +98,8 @@ Public Class PageVersionScreenshot .Name = "BtnDelete", .Text = "删除", .LogoScale = 0.8, - .Logo = Logo.IconButtonDelete + .Logo = Logo.IconButtonDelete, + .Tag = i } AddHandler btnDelete.Click, AddressOf btnDelete_Click stackPanel.Children.Add(btnDelete) @@ -105,7 +107,8 @@ Public Class PageVersionScreenshot .Name = "BtnCopy", .Text = "复制", .LogoScale = 0.8, - .Logo = Logo.IconButtonCopy + .Logo = Logo.IconButtonCopy, + .Tag = i } AddHandler btnCopy.Click, AddressOf btnCopy_Click stackPanel.Children.Add(btnCopy) @@ -129,7 +132,7 @@ Public Class PageVersionScreenshot End Sub Private Function GetPathFromSender(sender As MyIconTextButton) As String - Return CType(CType(CType(sender.Parent, StackPanel).Parent, Grid).Parent, MyCard).Tag + Return sender.Tag End Function Private Sub btnOpen_Click(sender As MyIconTextButton, e As EventArgs) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb index 34adf371..79ac5d03 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb @@ -80,7 +80,7 @@ Public Class PageVersionShader End Sub Private Function GetPathFromSender(sender As Object) As String - Return CType(sender, MyIconButton).Tag + Return sender.Tag End Function Private Sub RemoveItem(Path As String) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb index c208bb1e..d9b87c76 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb @@ -89,7 +89,7 @@ Public Class PageVersionWorld End Sub Private Function GetPathFromSender(sender As Object) As String - Return CType(sender, MyIconButton).Tag + Return sender.Tag End Function Private Sub RemoveItem(Path As String) From cf56f948e8c6b28019d83cf162930110cc15f000 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Sun, 29 Sep 2024 19:59:39 +0800 Subject: [PATCH 32/34] chore: that's better --- .../Pages/PageVersion/PageVersionScreenshot.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml index 87455109..b36bfb54 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionScreenshot.xaml @@ -37,7 +37,7 @@ - +