2.12.8.0
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:PCL;assembly="
|
||||
x:Name="PanBack" Height="44"
|
||||
RenderTransformOrigin="0.5,0.5" Background="{StaticResource ColorBrushSemiTransparent}" SnapsToDevicePixels="True">
|
||||
RenderTransformOrigin="0.5,0.5" Background="{StaticResource ColorBrushSemiTransparent}" SnapsToDevicePixels="True" Cursor="Hand">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="6" />
|
||||
<ColumnDefinition Width="34" />
|
||||
|
||||
@@ -61,11 +61,11 @@ Public Class MyLocalModItem
|
||||
End Property
|
||||
|
||||
'相关联的 Mod
|
||||
Public Property Entry As ResourceFile
|
||||
Public Property Entry As LocalResourceFile
|
||||
Get
|
||||
Return Tag
|
||||
End Get
|
||||
Set(value As ResourceFile)
|
||||
Set(value As LocalResourceFile)
|
||||
Tag = value
|
||||
End Set
|
||||
End Property
|
||||
@@ -80,7 +80,7 @@ Public Class MyLocalModItem
|
||||
If IsMouseDown Then
|
||||
RaiseEvent Click(sender, e)
|
||||
If e.Handled Then Return
|
||||
Log("[Control] 按下本地 Mod 列表项:" & LabTitle.Text)
|
||||
Logger.Info($"按下本地 Mod 列表项:{LabTitle.Text}")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -203,7 +203,7 @@ Public Class MyLocalModItem
|
||||
AniStop("MyLocalModItem Checked " & Uuid)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Log(ex, "设置 Checked 失败")
|
||||
Logger.Warn(ex, "设置 Checked 失败")
|
||||
End Try
|
||||
End Set
|
||||
End Property
|
||||
@@ -335,9 +335,9 @@ Public Class MyLocalModItem
|
||||
BtnUpdate.Visibility = Visibility.Collapsed
|
||||
End If
|
||||
'标题与描述
|
||||
Dim DescFileName As String = Path.GetFileNameWithoutExtension(Entry.File.FullName)
|
||||
Dim DescFileName As String = Entry.File.Name.BeforeLast(".")
|
||||
Dim NewDescription As String
|
||||
If Settings.Get("ToolModLocalNameStyle") = 1 Then
|
||||
If Settings.Get(Of Integer)("ToolModLocalNameStyle") = 1 Then
|
||||
'标题显示文件名,详情显示译名
|
||||
'标题
|
||||
Title = DescFileName
|
||||
|
||||
@@ -25,7 +25,7 @@ Public Class PageInstanceExport
|
||||
AniControlEnabled -= 1
|
||||
End Sub
|
||||
Public Sub RefreshAll() Implements IRefreshable.Refresh
|
||||
Log($"[Export] 刷新导出页面")
|
||||
Logger.Info($"刷新导出页面")
|
||||
HintOptiFine.Visibility = If(PageInstanceLeft.Instance.Version.HasOptiFine, Visibility.Visible, Visibility.Collapsed)
|
||||
CurrentInstance = PageInstanceLeft.Instance.PathVersion
|
||||
TextExportName.Text = ""
|
||||
@@ -56,7 +56,7 @@ Public Class PageInstanceExport
|
||||
Private Sub ReloadSubOptions(Panel As StackPanel, AcceptCompressedFile As Boolean, AcceptFolder As Boolean, ParamArray Folders As String())
|
||||
Panel.Children.Clear()
|
||||
For Each Folder In Folders
|
||||
Dim TargetFolder As New DirectoryInfo(PageInstanceLeft.Instance.PathIndie & Folder)
|
||||
Dim TargetFolder = DirectoryUtils.GetInfo(PageInstanceLeft.Instance.PathIndie & Folder)
|
||||
If Not TargetFolder.Exists() Then Continue For
|
||||
'查找文件夹下的对应项
|
||||
If AcceptCompressedFile Then
|
||||
@@ -98,14 +98,14 @@ Public Class PageInstanceExport
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Dim PathInfo As New DirectoryInfo(PageInstanceLeft.Instance.PathIndie)
|
||||
Dim PathInfo = DirectoryUtils.GetInfo(PageInstanceLeft.Instance.PathIndie)
|
||||
AllEntries.AddRange(PathInfo.EnumerateFiles().Select(Function(f) f.Name))
|
||||
For Each SubFolder In PathInfo.EnumerateDirectories().Where(IsValidDirectory)
|
||||
AllEntries.Add($"{SubFolder.Name}\")
|
||||
AllEntries.AddRange(SubFolder.EnumerateFiles().Select(Function(f) $"{SubFolder.Name}\{f.Name}"))
|
||||
AllEntries.AddRange(SubFolder.EnumerateDirectories().Where(IsValidDirectory).Select(Function(d) $"{SubFolder.Name}\{d.Name}\"))
|
||||
Next
|
||||
Log($"[Export] 共发现 {AllEntries.Count} 个可行的二级文件/文件夹")
|
||||
Logger.Info($"共发现 {AllEntries.Count} 个可行的二级文件/文件夹")
|
||||
'确认选项是否应该被显示
|
||||
Dim IsVisible =
|
||||
Function(TargetOption As ExportOption) As Boolean
|
||||
@@ -121,16 +121,16 @@ Public Class PageInstanceExport
|
||||
Try
|
||||
If AllEntries.Any(Function(Entry) Entry Like Rule) Then Return True
|
||||
Catch ex As Exception
|
||||
Log(ex, $"错误的规则:{Rule}", NotifyLevel.AllUsers)
|
||||
Logger.Error(ex, $"错误的规则:{Rule}", LogBehavior.Toast)
|
||||
Return False
|
||||
End Try
|
||||
'粗略检查所有级
|
||||
Rule = Rule.Trim("*?".ToCharArray)
|
||||
If Rule.Split({"\"c}, StringSplitOptions.RemoveEmptyEntries).Count >= 3 Then
|
||||
If Rule.Split("\"c, True).Count >= 3 Then
|
||||
If Rule.EndsWithF("\") Then
|
||||
Return IsValidDirectory(New DirectoryInfo(PageInstanceLeft.Instance.PathIndie & Rule)) '文件夹有效
|
||||
Return IsValidDirectory(DirectoryUtils.GetInfo(PageInstanceLeft.Instance.PathIndie & Rule)) '文件夹有效
|
||||
Else
|
||||
Return File.Exists(PageInstanceLeft.Instance.PathIndie & Rule) '文件有效
|
||||
Return FileUtils.Exists(PageInstanceLeft.Instance.PathIndie & Rule) '文件有效
|
||||
End If
|
||||
Else
|
||||
Return False
|
||||
@@ -303,8 +303,8 @@ Public Class PageInstanceExport
|
||||
'保存配置文件
|
||||
Private Sub ExportConfig() Handles BtnAdvancedExport.Click
|
||||
Try
|
||||
Dim ConfigPath As String = SelectSaveFile("选择文件位置", "export_config.txt", "整合包导出配置(*.txt)|*.txt", Settings.Get("CacheExportConfig"))
|
||||
If String.IsNullOrEmpty(ConfigPath) Then Return
|
||||
Dim ConfigPath As String = Dialogs.SaveFile("选择文件位置", "export_config.txt", Settings.Get(Of String)("CacheExportConfig"), {("txt", "整合包导出配置")})
|
||||
If ConfigPath Is Nothing Then Return
|
||||
Settings.Set("CacheExportConfig", ConfigPath)
|
||||
Dim ConfigLines As New List(Of String)
|
||||
'ini 段
|
||||
@@ -343,19 +343,19 @@ Public Class PageInstanceExport
|
||||
Hint("已保存配置文件:" & ConfigPath, HintType.Green)
|
||||
OpenExplorer(ConfigPath)
|
||||
Catch ex As Exception
|
||||
Log(ex, "保存配置失败", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, "保存配置失败", LogBehavior.Alert)
|
||||
End Try
|
||||
End Sub
|
||||
'读取配置文件
|
||||
Private Sub ImportConfig() Handles BtnAdvancedImport.Click
|
||||
Try
|
||||
Dim ConfigPath As String = SelectFile("整合包导出配置(*.txt)|*.txt", "选择配置文件", Settings.Get("CacheExportConfig"))
|
||||
Dim ConfigPath As String = Dialogs.SelectFile("选择配置文件", False, Settings.Get(Of String)("CacheExportConfig"), {({"txt"}, "整合包导出配置")}).FirstOrDefault()
|
||||
If String.IsNullOrEmpty(ConfigPath) Then Return
|
||||
Settings.Set("CacheExportConfig", ConfigPath)
|
||||
Dim Segments As String() = ReadFile(ConfigPath).Split(Sperator)
|
||||
Dim Segments As String() = FileUtils.ReadAsString(ConfigPath).Split(Sperator)
|
||||
'ini 段
|
||||
Dim Ini As New Dictionary(Of String, String)
|
||||
For Each Line In Segments(0).Split(vbCrLf.ToCharArray())
|
||||
For Each Line In Segments(0).SplitLines(True)
|
||||
Line = Line.Trim
|
||||
If Line = "" OrElse Line.StartsWithF("#") OrElse Line.StartsWithF("=") Then Continue For
|
||||
Dim Index As Integer = Line.IndexOfF(":")
|
||||
@@ -369,17 +369,17 @@ Public Class PageInstanceExport
|
||||
If Not CheckAdvancedInclude.Checked Then CheckAdvancedModrinth.Checked = Ini.GetOrDefault("ModrinthUploadMode", False) '#7979,加个特判
|
||||
ConfigPackPath = Ini.GetOrDefault("PackPath", Nothing)
|
||||
'导出内容段
|
||||
RulesOverrides = Segments(1).ReplaceLineEndings(vbLf, mergeMultiple:=True).Split(vbLf).ToList
|
||||
RulesOverrides = Segments(1).SplitLines(True).ToList
|
||||
'追加内容段
|
||||
If Segments.Length > 2 Then
|
||||
ExtraFiles = Segments(2).ReplaceLineEndings(vbLf, mergeMultiple:=True).Split(vbLf).ToList
|
||||
ExtraFiles = Segments(2).SplitLines(True).ToList
|
||||
Else
|
||||
ExtraFiles = Nothing
|
||||
End If
|
||||
'结束
|
||||
Hint("已读取配置文件:" & ConfigPath, HintType.Green)
|
||||
Catch ex As Exception
|
||||
Log(ex, "读取配置失败", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, "读取配置失败", LogBehavior.Alert)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -412,23 +412,23 @@ Public Class PageInstanceExport
|
||||
If Not String.IsNullOrWhiteSpace(ConfigPackPath) AndAlso
|
||||
(Not ConfigPackPath.EndsWithF("\") AndAlso Not ConfigPackPath.EndsWithF("/")) Then
|
||||
Try
|
||||
DirectoryUtils.Create(ConfigPackPath, isFilePath:=True)
|
||||
DirectoryUtils.Create(PathUtils.RemoveLastPart(ConfigPackPath))
|
||||
PackPath = ConfigPackPath
|
||||
Log($"[Export] 使用配置文件中指定的导出路径:{ConfigPackPath}")
|
||||
Logger.Info($"使用配置文件中指定的导出路径:{ConfigPackPath}")
|
||||
Catch ex As Exception
|
||||
Log(ex, $"无法使用配置文件中指定的导出路径({ConfigPackPath})", NotifyLevel.DebugModeOnly)
|
||||
If MyMsgBox($"指定的路径:{ConfigPackPath}{vbCrLf}{vbCrLf}{ex.GetDetail}", "无法使用配置文件中指定的导出路径", "确定", "取消") = 2 Then Return
|
||||
Logger.Warn(ex, $"无法使用配置文件中指定的导出路径({ConfigPackPath})")
|
||||
If MyMsgBox($"指定的路径:{ConfigPackPath}{vbCrLf}{vbCrLf}{ex.GetDisplay(True)}", "无法使用配置文件中指定的导出路径", "确定", "取消") = 2 Then Return
|
||||
End Try
|
||||
End If
|
||||
If PackPath Is Nothing Then
|
||||
Dim Extensions As New List(Of String)
|
||||
Extensions.Add("压缩文件(*.zip)|*.zip")
|
||||
If Not CheckOptionsPcl.Checked Then Extensions.Add("Modrinth 整合包文件(*.mrpack)|*.mrpack")
|
||||
PackPath = SelectSaveFile("选择导出位置",
|
||||
PackName & If(String.IsNullOrEmpty(TextExportVersion.Text), "", " " & TextExportVersion.Text), Extensions.Join("|"))
|
||||
Log($"[Export] 手动指定的导出路径:{PackPath}")
|
||||
Dim Extensions As New List(Of (Extension As String, Display As String))
|
||||
Extensions.Add(("zip", "压缩文件"))
|
||||
If Not CheckOptionsPcl.Checked Then Extensions.Add(("mrpack", "Modrinth 整合包文件"))
|
||||
PackPath = Dialogs.SaveFile("选择导出位置",
|
||||
PackName & If(String.IsNullOrEmpty(TextExportVersion.Text), "", " " & TextExportVersion.Text), filter:=Extensions)
|
||||
Logger.Info($"手动指定的导出路径:{PackPath}")
|
||||
End If
|
||||
If String.IsNullOrEmpty(PackPath) Then Return
|
||||
If PackPath Is Nothing Then Return
|
||||
|
||||
'缓存所需参数
|
||||
Dim CacheFolder = RequestTaskTempFolder()
|
||||
@@ -441,7 +441,7 @@ Public Class PageInstanceExport
|
||||
Dim IncludePCLCustom As Boolean = IncludePCL AndAlso CheckOptionsPclCustom.Checked
|
||||
Dim AllRules = StandardizeLines(GetAllRules(), True).ToList()
|
||||
Dim AllExtraFiles = StandardizeLines(GetExtraFileLines(), False).ToList()
|
||||
Log($"[Export] 准备导出整合包,共有 {AllRules.Count} 条规则,{AllExtraFiles.Count} 条追加内容行")
|
||||
Logger.Info($"准备导出整合包,共有 {AllRules.Count} 条规则,{AllExtraFiles.Count} 条追加内容行")
|
||||
|
||||
'构造步骤加载器
|
||||
Dim Loaders As New List(Of LoaderBase)
|
||||
@@ -452,7 +452,7 @@ Public Class PageInstanceExport
|
||||
Loaders.Add(New LoaderTask(Of Integer, Integer)("下载 PCL 正式版",
|
||||
Sub(Loader As LoaderTask(Of Integer, Integer))
|
||||
DownloadLatestPCL(Loader)
|
||||
CopyFile(PathTemp & "Latest.exe", CacheFolder & "Plain Craft Launcher.exe")
|
||||
FileUtils.Copy(PathTemp & "Latest.exe", CacheFolder & "Plain Craft Launcher.exe")
|
||||
End Sub) With {.ProgressWeight = 0.5, .Block = False})
|
||||
End If
|
||||
|
||||
@@ -460,9 +460,9 @@ Public Class PageInstanceExport
|
||||
|
||||
#Region "复制文件"
|
||||
|
||||
Loaders.Add(New LoaderTask(Of Integer, List(Of ResourceFile))("复制导出内容",
|
||||
Sub(Loader As LoaderTask(Of Integer, List(Of ResourceFile)))
|
||||
Loader.Output = New List(Of ResourceFile)
|
||||
Loaders.Add(New LoaderTask(Of Integer, List(Of LocalResourceFile))("复制导出内容",
|
||||
Sub(Loader As LoaderTask(Of Integer, List(Of LocalResourceFile)))
|
||||
Loader.Output = New List(Of LocalResourceFile)
|
||||
'复制版本文件
|
||||
Dim Progress As Integer = 0
|
||||
Dim SearchFolder As Action(Of DirectoryInfo)
|
||||
@@ -471,7 +471,7 @@ Public Class PageInstanceExport
|
||||
'文件夹:进一步搜索
|
||||
For Each SubFolder In Folder.EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
|
||||
'跳过部分又没用文件又多的文件夹,加快搜索
|
||||
If Folder.FullName = PathIndie AndAlso {"assets", "versions", "libraries"}.Contains(SubFolder.Name) Then Continue For
|
||||
If {"assets", "versions", "libraries"}.Contains(SubFolder.Name) AndAlso PathIndie = PathUtils.RemoveExtendedPrefix(Folder.FullName) Then Continue For
|
||||
If {"structureCacheV1", ".fabric", ".git", "avatar-cache", "cosmetic-cache"}.Contains(SubFolder.Name) Then Continue For
|
||||
SearchFolder(SubFolder)
|
||||
Next
|
||||
@@ -486,12 +486,12 @@ Public Class PageInstanceExport
|
||||
Next
|
||||
If Not ShouldKeep Then Continue For
|
||||
Dim TargetPath As String = OverridesFolder & RelativePath
|
||||
CopyFile(Entry.FullName, TargetPath)
|
||||
FileUtils.Copy(Entry.FullName, TargetPath)
|
||||
'若为压缩包,考虑联网获取路径
|
||||
If CheckHostedAssets AndAlso
|
||||
{".zip", ".rar", ".jar", ".disabled", ".old"}.Contains(Entry.Extension.Lower) AndAlso
|
||||
{"mods", "packs", "openloader", "resource"}.Any(Function(s) RelativePath.Contains(s)) Then
|
||||
Dim ModFile As New ResourceFile(TargetPath)
|
||||
Dim ModFile As New LocalResourceFile(TargetPath)
|
||||
Dim Unused = ModFile.ModrinthHash '提前计算 Hash
|
||||
Unused = ModFile.CurseForgeHash
|
||||
Loader.Output.Add(ModFile)
|
||||
@@ -504,21 +504,21 @@ Public Class PageInstanceExport
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
SearchFolder(New DirectoryInfo(PathIndie))
|
||||
Log($"[Export] 复制 overrides 文件完成,有 {Loader.Output.Count} 个文件需要联网检查")
|
||||
SearchFolder(DirectoryUtils.GetInfo(PathIndie))
|
||||
Logger.Info($"复制 overrides 文件完成,有 {Loader.Output.Count} 个文件需要联网检查")
|
||||
Loader.Progress = 0.95
|
||||
'复制追加内容到根目录
|
||||
Dim BaseFolder As String = If(IncludePCL, CacheFolder, CacheFolder & "modpack\")
|
||||
For Each Line In AllExtraFiles
|
||||
If Line.EndsWithF("\") OrElse Line.EndsWithF("/") Then
|
||||
If Directory.Exists(Line) Then
|
||||
CopyDirectory(Line, BaseFolder & GetFolderNameFromPath(Line) & "\")
|
||||
If DirectoryUtils.Exists(Line) Then
|
||||
DirectoryUtils.Copy(Line, BaseFolder & PathUtils.GetLastPart(Line) & "\")
|
||||
Else
|
||||
Hint($"未找到配置文件中指定的文件夹:{Line}", HintType.Red)
|
||||
End If
|
||||
Else
|
||||
If File.Exists(Line) Then
|
||||
CopyFile(Line, BaseFolder & GetFileNameFromPath(Line))
|
||||
If FileUtils.Exists(Line) Then
|
||||
FileUtils.Copy(Line, BaseFolder & PathUtils.GetLastPart(Line))
|
||||
Else
|
||||
Hint($"未找到配置文件中指定的单个文件:{Line}", HintType.Red)
|
||||
End If
|
||||
@@ -526,19 +526,19 @@ Public Class PageInstanceExport
|
||||
Next
|
||||
Loader.Progress = 0.97
|
||||
'复制 PCL 版本设置
|
||||
CopyDirectory(McVersion.PathVersion & "PCL\", OverridesFolder & "PCL\")
|
||||
If DirectoryUtils.Exists(McVersion.PathVersion & "PCL\") Then DirectoryUtils.Copy(McVersion.PathVersion & "PCL\", OverridesFolder & "PCL\")
|
||||
WriteIni(OverridesFolder & "PCL\Setup.ini", "IsStar", False)
|
||||
'复制 PCL 本体(正式版)
|
||||
If BuildType = BuildTypes.Release AndAlso IncludePCL Then CopyFile(PathExe, CacheFolder & "Plain Craft Launcher.exe")
|
||||
If BuildType = BuildTypes.Release AndAlso IncludePCL Then FileUtils.Copy(PathExe, CacheFolder & "Plain Craft Launcher.exe")
|
||||
'复制 PCL 个性化内容
|
||||
If IncludePCLCustom Then
|
||||
If Directory.Exists(PathExeFolder & "PCL\Pictures\") Then CopyDirectory(PathExeFolder & "PCL\Pictures\", CacheFolder & "PCL\Pictures\")
|
||||
If Directory.Exists(PathExeFolder & "PCL\Musics\") Then CopyDirectory(PathExeFolder & "PCL\Musics\", CacheFolder & "PCL\Musics\")
|
||||
If Directory.Exists(PathExeFolder & "PCL\Help\") Then CopyDirectory(PathExeFolder & "PCL\Help\", CacheFolder & "PCL\Help\")
|
||||
If File.Exists(PathExeFolder & "PCL\Custom.xaml") Then CopyFile(PathExeFolder & "PCL\Custom.xaml", CacheFolder & "PCL\Custom.xaml")
|
||||
If File.Exists(PathExeFolder & "PCL\Setup.ini") Then CopyFile(PathExeFolder & "PCL\Setup.ini", CacheFolder & "PCL\Setup.ini")
|
||||
If File.Exists(PathExeFolder & "PCL\hints.txt") Then CopyFile(PathExeFolder & "PCL\hints.txt", CacheFolder & "PCL\hints.txt")
|
||||
If File.Exists(PathExeFolder & "PCL\Logo.png") Then CopyFile(PathExeFolder & "PCL\Logo.png", CacheFolder & "PCL\Logo.png")
|
||||
If DirectoryUtils.Exists(PathExeFolder & "PCL\Pictures\") Then DirectoryUtils.Copy(PathExeFolder & "PCL\Pictures\", CacheFolder & "PCL\Pictures\")
|
||||
If DirectoryUtils.Exists(PathExeFolder & "PCL\Musics\") Then DirectoryUtils.Copy(PathExeFolder & "PCL\Musics\", CacheFolder & "PCL\Musics\")
|
||||
If DirectoryUtils.Exists(PathExeFolder & "PCL\Help\") Then DirectoryUtils.Copy(PathExeFolder & "PCL\Help\", CacheFolder & "PCL\Help\")
|
||||
If FileUtils.Exists(PathExeFolder & "PCL\Custom.xaml") Then FileUtils.Copy(PathExeFolder & "PCL\Custom.xaml", CacheFolder & "PCL\Custom.xaml")
|
||||
If FileUtils.Exists(PathExeFolder & "PCL\Setup.ini") Then FileUtils.Copy(PathExeFolder & "PCL\Setup.ini", CacheFolder & "PCL\Setup.ini")
|
||||
If FileUtils.Exists(PathExeFolder & "PCL\hints.txt") Then FileUtils.Copy(PathExeFolder & "PCL\hints.txt", CacheFolder & "PCL\hints.txt")
|
||||
If FileUtils.Exists(PathExeFolder & "PCL\Logo.png") Then FileUtils.Copy(PathExeFolder & "PCL\Logo.png", CacheFolder & "PCL\Logo.png")
|
||||
End If
|
||||
End Sub) With {.ProgressWeight = 5})
|
||||
|
||||
@@ -546,11 +546,11 @@ Public Class PageInstanceExport
|
||||
|
||||
#Region "联网检查"
|
||||
|
||||
Loaders.Add(New LoaderTask(Of List(Of ResourceFile), Dictionary(Of ResourceFile, List(Of String)))("联网获取文件信息",
|
||||
Sub(Loader As LoaderTask(Of List(Of ResourceFile), Dictionary(Of ResourceFile, List(Of String))))
|
||||
Loader.Output = New Dictionary(Of ResourceFile, List(Of String))
|
||||
If Not CheckHostedAssets Then Log($"[Export] 要求跳过联网获取步骤") : Return
|
||||
If Not Loader.Input.Any Then Log($"[Export] 没有需要联网检查的文件,跳过联网获取步骤") : Return
|
||||
Loaders.Add(New LoaderTask(Of List(Of LocalResourceFile), Dictionary(Of LocalResourceFile, List(Of String)))("联网获取文件信息",
|
||||
Sub(Loader As LoaderTask(Of List(Of LocalResourceFile), Dictionary(Of LocalResourceFile, List(Of String))))
|
||||
Loader.Output = New Dictionary(Of LocalResourceFile, List(Of String))
|
||||
If Not CheckHostedAssets Then Logger.Info($"要求跳过联网获取步骤") : Return
|
||||
If Not Loader.Input.Any Then Logger.Info($"没有需要联网检查的文件,跳过联网获取步骤") : Return
|
||||
|
||||
'分平台获取下载地址
|
||||
Dim EndedThreadCount As Integer = 0, FailedExceptions As New List(Of Exception)
|
||||
@@ -569,9 +569,9 @@ Public Class PageInstanceExport
|
||||
'写入下载地址
|
||||
Loader.Output.AddIntoValueCollection(ModFile, ModrinthRaw(ModFile.ModrinthHash)("files")(0)("url"))
|
||||
Next
|
||||
Log($"[Export] 从 Modrinth 获取到 {ModrinthRaw.Count} 个本地资源项的对应信息")
|
||||
Logger.Info($"从 Modrinth 获取到 {ModrinthRaw.Count} 个本地资源项的对应信息")
|
||||
Catch ex As Exception
|
||||
Log(ex, "从 Modrinth 获取本地 Mod 信息失败")
|
||||
Logger.Warn(ex, "从 Modrinth 获取本地 Mod 信息失败")
|
||||
FailedExceptions.Add(ex)
|
||||
Finally
|
||||
EndedThreadCount += 1
|
||||
@@ -592,16 +592,16 @@ Public Class PageInstanceExport
|
||||
Dim File As JObject = ResultJson("file")
|
||||
If String.IsNullOrEmpty(File("downloadUrl")) Then Continue For
|
||||
'查找对应的文件
|
||||
Dim ModFile As ResourceFile = Loader.Input.FirstOrDefault(Function(m) m.CurseForgeHash = File("fileFingerprint").ToObject(Of UInteger))
|
||||
Dim ModFile As LocalResourceFile = Loader.Input.FirstOrDefault(Function(m) m.CurseForgeHash = File("fileFingerprint").ToObject(Of UInteger))
|
||||
If ModFile Is Nothing Then Continue For
|
||||
'写入下载地址
|
||||
For Each Address In ResourceVersion.ParseCurseForgeDownloadUrls(File("downloadUrl").ToString)
|
||||
Loader.Output.AddIntoValueCollection(ModFile, Address)
|
||||
Next
|
||||
Next
|
||||
Log($"[Export] 从 CurseForge 获取到 {CurseForgeRaw.Count} 个本地资源项的对应信息")
|
||||
Logger.Info($"从 CurseForge 获取到 {CurseForgeRaw.Count} 个本地资源项的对应信息")
|
||||
Catch ex As Exception
|
||||
Log(ex, "从 CurseForge 获取本地 Mod 信息失败")
|
||||
Logger.Warn(ex, "从 CurseForge 获取本地 Mod 信息失败")
|
||||
FailedExceptions.Add(ex)
|
||||
Finally
|
||||
EndedThreadCount += 1
|
||||
@@ -633,17 +633,17 @@ Public Class PageInstanceExport
|
||||
|
||||
#Region "生成压缩包"
|
||||
|
||||
Loaders.Add(New LoaderTask(Of Dictionary(Of ResourceFile, List(Of String)), Integer)("生成压缩包",
|
||||
Sub(Loader As LoaderTask(Of Dictionary(Of ResourceFile, List(Of String)), Integer))
|
||||
Loaders.Add(New LoaderTask(Of Dictionary(Of LocalResourceFile, List(Of String)), Integer)("生成压缩包",
|
||||
Sub(Loader As LoaderTask(Of Dictionary(Of LocalResourceFile, List(Of String)), Integer))
|
||||
'整理文件列表
|
||||
Dim Files As New JArray
|
||||
For Each Pair In Loader.Input
|
||||
Dim ModFile As ResourceFile = Pair.Key
|
||||
Dim ModFile As LocalResourceFile = Pair.Key
|
||||
Files.Add(New JObject From {
|
||||
{"path", ModFile.File.FullName.AfterFirst(OverridesFolder).Replace("\", "/")},
|
||||
{"hashes", New JObject From {{"sha1", ModFile.ModrinthHash}, {"sha512", GetFileSHA512(ModFile.File.FullName)}}},
|
||||
{"path", PathUtils.RemoveExtendedPrefix(ModFile.File.FullName).AfterFirst(OverridesFolder).Replace("\", "/")},
|
||||
{"hashes", New JObject From {{"sha1", ModFile.ModrinthHash}, {"sha512", HashUtils.ComputeFromFile(ModFile.File.FullName, HashUtils.HashMethod.Sha512)}}},
|
||||
{"downloads", New JArray(Pair.Value.OrderBy(Function(u) u.Contains("modrinth.com")))}, '不优先选择 Modrinth
|
||||
{"fileSize", New FileInfo(ModFile.File.FullName).Length}
|
||||
{"fileSize", ModFile.File.Length}
|
||||
})
|
||||
ModFile.File.Delete()
|
||||
Next
|
||||
@@ -662,25 +662,22 @@ Public Class PageInstanceExport
|
||||
{"files", Files},
|
||||
{"dependencies", Dependencies}
|
||||
}
|
||||
File.WriteAllText(CacheFolder & "modpack\modrinth.index.json", ResultJson.ToString(Newtonsoft.Json.Formatting.Indented))
|
||||
FileUtils.Write(CacheFolder & "modpack\modrinth.index.json", ResultJson.ToString(Newtonsoft.Json.Formatting.Indented))
|
||||
'打包
|
||||
DirectoryUtils.Create(PackPath, isFilePath:=True)
|
||||
If File.Exists(PackPath) Then File.Delete(PackPath)
|
||||
If IncludePCL Then
|
||||
'首次压缩整合包
|
||||
ZipFile.CreateFromDirectory(CacheFolder & "modpack\", CacheFolder & "modpack.mrpack")
|
||||
FileUtils.CreateZipFromDirectory(CacheFolder & "modpack.mrpack", CacheFolder & "modpack\")
|
||||
Loader.Progress = 0.5
|
||||
DeleteDirectory(CacheFolder & "modpack\")
|
||||
DirectoryUtils.Delete(CacheFolder & "modpack\")
|
||||
Loader.Progress = 0.6
|
||||
'二次压缩整合包
|
||||
ZipFile.CreateFromDirectory(CacheFolder, PackPath)
|
||||
FileUtils.CreateZipFromDirectory(PackPath, CacheFolder)
|
||||
Loader.Progress = 0.9
|
||||
Else
|
||||
'直接压缩整合包
|
||||
ZipFile.CreateFromDirectory(CacheFolder & "modpack\", PackPath)
|
||||
FileUtils.CreateZipFromDirectory(PackPath, CacheFolder & "modpack\")
|
||||
Loader.Progress = 0.8
|
||||
End If
|
||||
DeleteDirectory(CacheFolder, True)
|
||||
OpenExplorer(PackPath)
|
||||
End Sub) With {.ProgressWeight = 6})
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
PageChangeRun(PageGet(ID))
|
||||
PageID = ID
|
||||
Catch ex As Exception
|
||||
Log(ex, "切换分页面失败(ID " & ID & ")", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, $"切换分页面失败(ID {ID})")
|
||||
Finally
|
||||
AniControlEnabled -= 1
|
||||
End Try
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
''' </summary>
|
||||
Public Sub ReloadModList(Optional ForceReload As Boolean = False)
|
||||
If Not LoaderRun(If(ForceReload, LoaderFolderRunType.ForceRun, LoaderFolderRunType.RunOnUpdated)) Then Return
|
||||
Log("[System] 已刷新 Mod 列表")
|
||||
Logger.Info("已刷新 Mod 列表")
|
||||
Filter = FilterType.All
|
||||
PanBack.ScrollToHome()
|
||||
SearchBox.Text = ""
|
||||
@@ -42,10 +42,10 @@
|
||||
Try
|
||||
ResourceProject.Cache.Clear()
|
||||
ResourceVersion.ProjectFilesCache.Clear()
|
||||
File.Delete(PathTemp & "Cache\LocalMod.json")
|
||||
Log("[Mod] 由于点击刷新按钮,清理本地 Mod 信息缓存")
|
||||
FileUtils.Delete(PathTemp & "Cache\LocalMod.json")
|
||||
Logger.Info("由于点击刷新按钮,清理本地 Mod 信息缓存")
|
||||
Catch ex As Exception
|
||||
Log(ex, "强制刷新时清理本地 Mod 信息缓存失败")
|
||||
Logger.Warn(ex, "强制刷新时清理本地 Mod 信息缓存失败")
|
||||
End Try
|
||||
If FrmInstanceMod IsNot Nothing Then FrmInstanceMod.ReloadModList(True) '无需 Else,还没加载刷个鬼的新
|
||||
FrmInstanceLeft.ItemMod.Checked = True
|
||||
@@ -53,15 +53,13 @@
|
||||
End Sub
|
||||
|
||||
Private Sub LoaderInit() Handles Me.Initialized
|
||||
PageLoaderInit(Load, PanLoad, PanAllBack, Nothing, McModLoader, AddressOf LoadUIFromLoaderOutput, AutoRun:=False)
|
||||
PageLoaderInit(Load, PanLoad, PanAllBack, Nothing, LocalResourceLoader, AddressOf LoadUIFromLoaderOutput, AutoRun:=False)
|
||||
End Sub
|
||||
Private Sub Load_Click(sender As Object, e As MouseButtonEventArgs) Handles Load.Click
|
||||
If McModLoader.State = LoadState.Failed Then
|
||||
LoaderRun(LoaderFolderRunType.ForceRun)
|
||||
End If
|
||||
If LocalResourceLoader.State = LoadState.Failed Then LoaderRun(LoaderFolderRunType.ForceRun)
|
||||
End Sub
|
||||
Public Function LoaderRun(Type As LoaderFolderRunType) As Boolean
|
||||
Return LoaderFolderRun(McModLoader, PageInstanceLeft.Instance.PathIndie & "mods\", Type)
|
||||
Return LoaderFolderRun(LocalResourceLoader, PageInstanceLeft.Instance.PathIndie & "mods\", Type)
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
@@ -78,7 +76,7 @@
|
||||
Private Sub LoadUIFromLoaderOutput()
|
||||
Try
|
||||
'判断应该显示哪一个页面
|
||||
If McModLoader.Output.Any() Then
|
||||
If LocalResourceLoader.Output.Any() Then
|
||||
PanBack.Visibility = Visibility.Visible
|
||||
PanEmpty.Visibility = Visibility.Collapsed
|
||||
Else
|
||||
@@ -88,7 +86,7 @@
|
||||
End If
|
||||
'修改缓存
|
||||
ModItems.Clear()
|
||||
For Each ModEntity As ResourceFile In McModLoader.Output
|
||||
For Each ModEntity As LocalResourceFile In LocalResourceLoader.Output
|
||||
ModItems(ModEntity.EnabledName) = McModListItem(ModEntity)
|
||||
Next
|
||||
'显示结果
|
||||
@@ -96,10 +94,10 @@
|
||||
SearchBox.Text = "" '这会触发结果刷新,所以需要在 ModItems 更新之后,详见 #3124 的视频
|
||||
RefreshUI()
|
||||
Catch ex As Exception
|
||||
Log(ex, "加载 Mod 列表 UI 失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, "加载 Mod 列表 UI 失败")
|
||||
End Try
|
||||
End Sub
|
||||
Private Function McModListItem(Entry As ResourceFile) As MyLocalModItem
|
||||
Private Function McModListItem(Entry As LocalResourceFile) As MyLocalModItem
|
||||
AniControlEnabled += 1
|
||||
Dim NewItem As New MyLocalModItem With {.SnapsToDevicePixels = True, .Entry = Entry,
|
||||
.ButtonHandler = AddressOf McModContent, .Checked = SelectedMods.Contains(Entry.EnabledName)}
|
||||
@@ -145,7 +143,7 @@
|
||||
''' </summary>
|
||||
Public Sub RefreshUI()
|
||||
If PanList Is Nothing Then Return
|
||||
Dim ShowingMods = If(IsSearching, SearchResult, If(McModLoader.Output, New List(Of ResourceFile))).Where(Function(m) CanPassFilter(m)).ToList
|
||||
Dim ShowingMods = If(IsSearching, SearchResult, If(LocalResourceLoader.Output, New List(Of LocalResourceFile))).Where(Function(m) CanPassFilter(m)).ToList
|
||||
'重新列出列表
|
||||
AniControlEnabled += 1
|
||||
If ShowingMods.Any() Then
|
||||
@@ -178,7 +176,7 @@
|
||||
Dim AnyCount As Integer = 0
|
||||
Dim EnabledCount As Integer = 0
|
||||
Dim UpdateCount As Integer = 0
|
||||
For Each ModItem In If(IsSearching, SearchResult, If(McModLoader.Output, New List(Of ResourceFile)))
|
||||
For Each ModItem In If(IsSearching, SearchResult, If(LocalResourceLoader.Output, New List(Of LocalResourceFile)))
|
||||
AnyCount += 1
|
||||
If ModItem.HasUpdate Then UpdateCount += 1
|
||||
If ModItem.IsEnabled Then EnabledCount += 1
|
||||
@@ -206,7 +204,7 @@
|
||||
Dim HasUpdate As Boolean = False
|
||||
Dim HasEnabled As Boolean = False
|
||||
Dim HasDisabled As Boolean = False
|
||||
For Each ModEntity In McModLoader.Output
|
||||
For Each ModEntity In LocalResourceLoader.Output
|
||||
If Not SelectedMods.Contains(ModEntity.EnabledName) Then Continue For
|
||||
If ModEntity.HasUpdate Then HasUpdate = True
|
||||
If ModEntity.IsEnabled Then HasEnabled = True
|
||||
@@ -274,7 +272,7 @@
|
||||
DirectoryUtils.Create(PageInstanceLeft.Instance.PathIndie & "mods\")
|
||||
OpenExplorer(PageInstanceLeft.Instance.PathIndie & "mods\")
|
||||
Catch ex As Exception
|
||||
Log(ex, "打开 Mods 文件夹失败", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, "打开 Mods 文件夹失败", LogBehavior.Alert)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -289,7 +287,7 @@
|
||||
''' 安装 Mod。
|
||||
''' </summary>
|
||||
Private Sub BtnManageInstall_Click(sender As Object, e As MouseButtonEventArgs) Handles BtnManageInstall.Click, BtnHintInstall.Click
|
||||
Dim FileList = SelectFiles("Mod 文件(*.jar;*.litemod;*.disabled;*.old)|*.jar;*.litemod;*.disabled;*.old", "选择要安装的 Mod")
|
||||
Dim FileList = Dialogs.SelectFile("选择要安装的 Mod", True, filter:={({"jar", "litemod", "disabled", "old"}, "Mod 文件")})
|
||||
If Not FileList.Any Then Return
|
||||
InstallMods(FileList)
|
||||
End Sub
|
||||
@@ -301,7 +299,7 @@
|
||||
Dim Extension As String = FilePathList.First.AfterLast(".").Lower
|
||||
'检查文件扩展名
|
||||
If Not {"jar", "litemod", "disabled", "old"}.Any(Function(t) t = Extension) Then Return False
|
||||
Log("[System] 文件为 jar/litemod 格式,尝试作为 Mod 安装")
|
||||
Logger.Info("文件为 jar/litemod 格式,尝试作为 Mod 安装")
|
||||
'检查回收站:回收站中的文件有错误的文件名
|
||||
If FilePathList.First.Contains(":\$RECYCLE.BIN\") Then
|
||||
Hint("请先将文件从回收站还原,再尝试安装!", HintType.Red)
|
||||
@@ -321,21 +319,21 @@
|
||||
Install:
|
||||
Try
|
||||
For Each ModFile In FilePathList
|
||||
Dim NewFileName = GetFileNameFromPath(ModFile).Replace(".disabled", "").Replace(".old", "")
|
||||
Dim NewFileName = PathUtils.GetLastPart(ModFile).Replace(".disabled", "").Replace(".old", "")
|
||||
If Not NewFileName.Contains(".") Then NewFileName += ".jar" '#4227
|
||||
CopyFile(ModFile, Instance.PathIndie & "mods\" & NewFileName)
|
||||
FileUtils.Copy(ModFile, Instance.PathIndie & "mods\" & NewFileName)
|
||||
Next
|
||||
If FilePathList.IsSingle Then
|
||||
Hint($"已安装 {GetFileNameFromPath(FilePathList.First).Replace(".disabled", "").Replace(".old", "")}!", HintType.Green)
|
||||
Hint($"已安装 {PathUtils.GetLastPart(FilePathList.First).Replace(".disabled", "").Replace(".old", "")}!", HintType.Green)
|
||||
Else
|
||||
Hint($"已安装 {FilePathList.Count} 个 Mod!", HintType.Green)
|
||||
End If
|
||||
'刷新列表
|
||||
If FrmMain.PageCurrent = FormMain.PageType.InstanceSetup AndAlso FrmMain.PageCurrentSub = FormMain.PageSubType.InstanceMod Then
|
||||
LoaderFolderRun(McModLoader, Instance.PathIndie & "mods\", LoaderFolderRunType.ForceRun)
|
||||
LoaderFolderRun(LocalResourceLoader, Instance.PathIndie & "mods\", LoaderFolderRunType.ForceRun)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Log(ex, "复制 Mod 文件失败", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, "复制 Mod 文件失败", LogBehavior.Alert)
|
||||
End Try
|
||||
End If
|
||||
Return True
|
||||
@@ -435,7 +433,7 @@ Install:
|
||||
''' <summary>
|
||||
''' 检查该 Mod 项是否符合当前筛选的类别。
|
||||
''' </summary>
|
||||
Private Function CanPassFilter(CheckingMod As ResourceFile) As Boolean
|
||||
Private Function CanPassFilter(CheckingMod As LocalResourceFile) As Boolean
|
||||
Select Case Filter
|
||||
Case FilterType.All
|
||||
Return True
|
||||
@@ -462,18 +460,18 @@ Install:
|
||||
|
||||
'启用 / 禁用
|
||||
Private Sub BtnSelectED_Click(sender As MyIconTextButton, e As RouteEventArgs) Handles BtnSelectEnable.Click, BtnSelectDisable.Click
|
||||
EDMods(McModLoader.Output.Where(Function(m) SelectedMods.Contains(m.EnabledName)),
|
||||
EDMods(LocalResourceLoader.Output.Where(Function(m) SelectedMods.Contains(m.EnabledName)),
|
||||
Not sender.Equals(BtnSelectDisable))
|
||||
ChangeAllSelected(False)
|
||||
End Sub
|
||||
Private Sub EDMods(ModList As IEnumerable(Of ResourceFile), IsEnable As Boolean)
|
||||
Private Sub EDMods(ModList As IEnumerable(Of LocalResourceFile), IsEnable As Boolean)
|
||||
Dim IsSuccessful As Boolean = True
|
||||
For Each ModE In ModList.ToList
|
||||
Dim ModEntity = ModE '仅用于去除迭代变量无法修改的限制
|
||||
Dim NewPath As String = Nothing
|
||||
If ModEntity.IsEnabled AndAlso Not IsEnable Then
|
||||
'禁用
|
||||
NewPath = ModEntity.File.FullName & If(File.Exists(ModEntity.File.FullName & ".old"), ".old", ".disabled")
|
||||
NewPath = PathUtils.RemoveExtendedPrefix(ModEntity.File.FullName) & If(FileUtils.Exists(ModEntity.File.FullName & ".old"), ".old", ".disabled")
|
||||
ElseIf Not ModEntity.IsEnabled AndAlso IsEnable Then
|
||||
'启用
|
||||
NewPath = ModEntity.EnabledFullName
|
||||
@@ -482,36 +480,36 @@ Install:
|
||||
End If
|
||||
'重命名
|
||||
Try
|
||||
If File.Exists(NewPath) Then
|
||||
If File.Exists(ModEntity.File.FullName) Then
|
||||
If FileUtils.Exists(NewPath) Then
|
||||
If FileUtils.Exists(ModEntity.File.FullName) Then
|
||||
'同时存在两个名称的 Mod
|
||||
If GetFileMD5(ModEntity.File.FullName) <> GetFileMD5(NewPath) Then
|
||||
MyMsgBox($"目前同时存在启用和禁用的两个 Mod 文件:{vbCrLf} - {NewPath}{vbCrLf} - {ModEntity.File.FullName}{vbCrLf}{vbCrLf}注意,这两个文件的内容并不相同。{vbCrLf}在手动删除或重命名其中一个文件后,才能继续操作。", "存在文件冲突")
|
||||
If HashUtils.ComputeFromFile(ModEntity.File.FullName, HashUtils.HashMethod.Md5) <> HashUtils.ComputeFromFile(NewPath, HashUtils.HashMethod.Md5) Then
|
||||
MyMsgBox($"目前同时存在启用和禁用的两个 Mod 文件:{vbCrLf} - {PathUtils.GetLastPart(NewPath)}{vbCrLf} - {ModEntity.File.Name}{vbCrLf}{vbCrLf}注意,这两个文件的内容并不相同。{vbCrLf}在手动删除或重命名其中一个文件后,才能继续操作。", "存在文件冲突")
|
||||
Continue For
|
||||
End If
|
||||
Else
|
||||
'已经重命名过了
|
||||
Log("[Mod] Mod 的状态已被切换", NotifyLevel.DebugModeOnly)
|
||||
Logger.Warn("Mod 的状态已被切换")
|
||||
Continue For
|
||||
End If
|
||||
End If
|
||||
File.Delete(NewPath)
|
||||
File.Move(ModEntity.File.FullName, NewPath)
|
||||
FileUtils.Delete(NewPath)
|
||||
FileUtils.Move(ModEntity.File.FullName, NewPath)
|
||||
Catch ex As FileNotFoundException
|
||||
Log(ex, $"未找到需要重命名的 Mod({If(ModEntity.File.FullName, "null")})", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, $"未找到需要重命名的 Mod({If(ModEntity.File.FullName, "null")})")
|
||||
ReloadModList(True)
|
||||
Return
|
||||
Catch ex As Exception
|
||||
Log(ex, $"重命名 Mod 失败({If(ModEntity.File.FullName, "null")})")
|
||||
Logger.Warn(ex, $"重命名 Mod 失败({If(ModEntity.File.FullName, "null")})")
|
||||
IsSuccessful = False
|
||||
End Try
|
||||
'更改 Loader 中的列表
|
||||
Dim NewModEntity As New ResourceFile(NewPath)
|
||||
Dim NewModEntity As New LocalResourceFile(NewPath)
|
||||
NewModEntity.FromJson(ModEntity.ToJson)
|
||||
If McModLoader.Output.Contains(ModEntity) Then
|
||||
Dim IndexOfLoader As Integer = McModLoader.Output.IndexOf(ModEntity)
|
||||
McModLoader.Output.RemoveAt(IndexOfLoader)
|
||||
McModLoader.Output.Insert(IndexOfLoader, NewModEntity)
|
||||
If LocalResourceLoader.Output.Contains(ModEntity) Then
|
||||
Dim IndexOfLoader As Integer = LocalResourceLoader.Output.IndexOf(ModEntity)
|
||||
LocalResourceLoader.Output.RemoveAt(IndexOfLoader)
|
||||
LocalResourceLoader.Output.Insert(IndexOfLoader, NewModEntity)
|
||||
End If
|
||||
If SearchResult IsNot Nothing AndAlso SearchResult.Contains(ModEntity) Then '#4862
|
||||
Dim IndexOfResult As Integer = SearchResult.IndexOf(ModEntity)
|
||||
@@ -538,7 +536,7 @@ Install:
|
||||
|
||||
'更新
|
||||
Private Sub BtnSelectUpdate_Click() Handles BtnSelectUpdate.Click
|
||||
Dim UpdateList As List(Of ResourceFile) = McModLoader.Output.Where(Function(m) SelectedMods.Contains(m.EnabledName) AndAlso m.HasUpdate).ToList()
|
||||
Dim UpdateList As List(Of LocalResourceFile) = LocalResourceLoader.Output.Where(Function(m) SelectedMods.Contains(m.EnabledName) AndAlso m.HasUpdate).ToList()
|
||||
If Not UpdateList.Any() Then Return
|
||||
UpdateMods(UpdateList)
|
||||
ChangeAllSelected(False)
|
||||
@@ -547,9 +545,9 @@ Install:
|
||||
''' 记录正在进行 Mod 更新的 mods 文件夹路径。
|
||||
''' </summary>
|
||||
Public Shared UpdatingInstanceModFolders As New List(Of String)
|
||||
Public Sub UpdateMods(ModList As IEnumerable(Of ResourceFile))
|
||||
Public Sub UpdateMods(ModList As IEnumerable(Of LocalResourceFile))
|
||||
'更新前警告
|
||||
If Not Settings.Get("HintUpdateMod") OrElse ModList.Count >= 15 Then
|
||||
If Not Settings.Get(Of Boolean)("HintUpdateMod") OrElse ModList.Count >= 15 Then
|
||||
If MyMsgBox($"新版本 Mod 可能不兼容旧存档或者其他 Mod,这可能导致游戏崩溃,甚至永久损坏存档!{vbCrLf}如果你在游玩整合包,请千万不要自行更新 Mod!{vbCrLf}{vbCrLf}在更新前,请先备份存档,并检查 Mod 的更新日志。{vbCrLf}如果更新后出现问题,你也可以在回收站找回更新前的 Mod。", "Mod 更新警告", "我已了解风险,继续更新", "取消", IsWarn:=True) = 1 Then
|
||||
Settings.Set("HintUpdateMod", True)
|
||||
Else
|
||||
@@ -561,7 +559,7 @@ Install:
|
||||
ModList = ModList.ToList() '防止刷新影响迭代器
|
||||
Dim FileList As New List(Of NetFile)
|
||||
Dim FileCopyList As New Dictionary(Of String, String)
|
||||
For Each Entry As ResourceFile In ModList
|
||||
For Each Entry As LocalResourceFile In ModList
|
||||
Dim File As ResourceVersion = Entry.UpdateFile
|
||||
If Not File.DownloadAvailable Then Continue For
|
||||
'确认更新后的文件名
|
||||
@@ -590,8 +588,8 @@ Install:
|
||||
End If
|
||||
'添加到下载列表
|
||||
Dim TempAddress As String = PathTemp & "mods\" & Entry.File.Name.Replace(CurrentReplaceName, NewestReplaceName) '需要下载到 mods 文件夹,以便重复文件检查时识别
|
||||
Dim RealAddress As String = GetPathFromFullPath(Entry.File.FullName) & Entry.File.Name.Replace(CurrentReplaceName, NewestReplaceName)
|
||||
FileList.Add(File.ToNetFile(TempAddress))
|
||||
Dim RealAddress As String = Path.Combine(PathUtils.RemoveLastPart(Entry.File.FullName), Entry.File.Name.Replace(CurrentReplaceName, NewestReplaceName))
|
||||
FileList.Add(File.ToNetFile(TempAddress, ResourceVersion.DownloadReason.Update, PageInstanceLeft.Instance.Version.VanillaName, PageInstanceLeft.Instance.Version.ModLoaders))
|
||||
FileCopyList(TempAddress) = RealAddress
|
||||
Next
|
||||
'构造加载器
|
||||
@@ -601,31 +599,31 @@ Install:
|
||||
InstallLoaders.Add(New LoaderTask(Of Integer, Integer)("替换旧版 Mod 文件",
|
||||
Sub()
|
||||
Try
|
||||
For Each Entry As ResourceFile In ModList
|
||||
If File.Exists(Entry.File.FullName) Then
|
||||
My.Computer.FileSystem.DeleteFile(Entry.File.FullName, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin)
|
||||
For Each Entry As LocalResourceFile In ModList
|
||||
If FileUtils.Exists(Entry.File.FullName) Then
|
||||
FileUtils.Delete(Entry.File.FullName, True)
|
||||
Else
|
||||
Log($"[Mod] 未找到更新前的 Mod 文件,跳过对它的删除:{Entry.File.FullName}", NotifyLevel.DebugModeOnly)
|
||||
Logger.Warn($"未找到更新前的 Mod 文件,跳过对它的删除:{Entry.File.FullName}")
|
||||
End If
|
||||
Next
|
||||
For Each Entry As KeyValuePair(Of String, String) In FileCopyList
|
||||
If File.Exists(Entry.Value) Then
|
||||
My.Computer.FileSystem.DeleteFile(Entry.Value, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin)
|
||||
Log($"[Mod] 更新后的 Mod 文件已存在,将会把它放入回收站:{Entry.Value}", NotifyLevel.DebugModeOnly)
|
||||
If FileUtils.Exists(Entry.Value) Then
|
||||
FileUtils.Delete(Entry.Value, True)
|
||||
Logger.Warn($"更新后的 Mod 文件已存在,将会把它放入回收站:{Entry.Value}")
|
||||
End If
|
||||
If Directory.Exists(GetPathFromFullPath(Entry.Value)) Then
|
||||
File.Move(Entry.Key, Entry.Value)
|
||||
FinishedFileNames.Add(GetFileNameFromPath(Entry.Value))
|
||||
If DirectoryUtils.Exists(PathUtils.RemoveLastPart(Entry.Value)) Then
|
||||
FileUtils.Move(Entry.Key, Entry.Value)
|
||||
FinishedFileNames.Add(PathUtils.GetLastPart(Entry.Value))
|
||||
Else
|
||||
Log($"[Mod] 更新后的目标文件夹已被删除:{Entry.Value}", NotifyLevel.DebugModeOnly)
|
||||
Logger.Warn($"更新后的目标文件夹已被删除:{Entry.Value}")
|
||||
End If
|
||||
Next
|
||||
Catch ex As OperationCanceledException
|
||||
Log(ex, "替换旧版 Mod 文件时被主动取消")
|
||||
Logger.Warn(ex, "替换旧版 Mod 文件时被主动取消")
|
||||
End Try
|
||||
End Sub))
|
||||
'结束处理
|
||||
Dim Loader As New LoaderCombo(Of IEnumerable(Of ResourceFile))("Mod 更新:" & PageInstanceLeft.Instance.Name, InstallLoaders)
|
||||
Dim Loader As New LoaderCombo(Of IEnumerable(Of LocalResourceFile))("Mod 更新:" & PageInstanceLeft.Instance.Name, InstallLoaders)
|
||||
Dim PathMods As String = PageInstanceLeft.Instance.PathIndie & "mods\"
|
||||
Loader.OnStateChanged =
|
||||
Sub()
|
||||
@@ -634,35 +632,35 @@ Install:
|
||||
Case LoadState.Finished
|
||||
Select Case FinishedFileNames.Count
|
||||
Case 0 '一般是由于 Mod 文件被占用,然后玩家主动取消
|
||||
Log($"[Mod] 没有 Mod 被成功更新")
|
||||
Logger.Info($"没有 Mod 被成功更新")
|
||||
Case 1
|
||||
Hint($"已成功更新 {FinishedFileNames.Single}!", HintType.Green)
|
||||
Case Else
|
||||
Hint($"已成功更新 {FinishedFileNames.Count} 个 Mod!", HintType.Green)
|
||||
End Select
|
||||
Case LoadState.Failed
|
||||
Hint("Mod 更新失败:" & Loader.Error.GetBrief(), HintType.Red)
|
||||
Hint("Mod 更新失败:" & Loader.Error.GetDisplay(False), HintType.Red)
|
||||
Case LoadState.Interrupted
|
||||
Hint("Mod 更新已中止!", HintType.Blue)
|
||||
Case Else
|
||||
Return
|
||||
End Select
|
||||
Log($"[Mod] 已从正在进行 Mod 更新的文件夹列表移除:{PathMods}")
|
||||
Logger.Info($"已从正在进行 Mod 更新的文件夹列表移除:{PathMods}")
|
||||
UpdatingInstanceModFolders.Remove(PathMods)
|
||||
'清理缓存
|
||||
RunInNewThread(
|
||||
Sub()
|
||||
Try
|
||||
For Each TempFile In FileCopyList.Keys
|
||||
If File.Exists(TempFile) Then File.Delete(TempFile)
|
||||
FileUtils.Delete(TempFile)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Log(ex, "清理 Mod 更新缓存失败")
|
||||
Logger.Warn(ex, "清理 Mod 更新缓存失败")
|
||||
End Try
|
||||
End Sub, "Clean Mod Update Cache", ThreadPriority.BelowNormal)
|
||||
End Sub
|
||||
'启动加载器
|
||||
Log($"[Mod] 开始更新 {ModList.Count} 个 Mod:{PathMods}")
|
||||
Logger.Info($"开始更新 {ModList.Count} 个 Mod:{PathMods}")
|
||||
UpdatingInstanceModFolders.Add(PathMods)
|
||||
Loader.Start()
|
||||
LoaderTaskbarAdd(Loader)
|
||||
@@ -670,49 +668,45 @@ Install:
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
ReloadModList(True)
|
||||
Catch ex As Exception
|
||||
Log(ex, "初始化 Mod 更新失败")
|
||||
Logger.Warn(ex, "初始化 Mod 更新失败")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'删除
|
||||
Private Sub BtnSelectDelete_Click() Handles BtnSelectDelete.Click
|
||||
DeleteMods(McModLoader.Output.Where(Function(m) SelectedMods.Contains(m.EnabledName)))
|
||||
DeleteMods(LocalResourceLoader.Output.Where(Function(m) SelectedMods.Contains(m.EnabledName)))
|
||||
ChangeAllSelected(False)
|
||||
End Sub
|
||||
Private Sub DeleteMods(ModList As IEnumerable(Of ResourceFile))
|
||||
Private Sub DeleteMods(ModsToDelete As IEnumerable(Of LocalResourceFile))
|
||||
Try
|
||||
Dim IsSuccessful As Boolean = True
|
||||
Dim IsShiftPressed As Boolean = My.Computer.Keyboard.ShiftKeyDown
|
||||
'确认需要删除的文件
|
||||
ModList = ModList.SelectMany(
|
||||
Function(Target As ResourceFile)
|
||||
Dim ModList = ModsToDelete.SelectMany(
|
||||
Function(Target As LocalResourceFile)
|
||||
If Target.IsEnabled Then
|
||||
Return {Target.File.FullName, Target.File.FullName & If(File.Exists(Target.File.FullName & ".old"), ".old", ".disabled")}
|
||||
Return {Target.File.FullName, Target.File.FullName & If(FileUtils.Exists(Target.File.FullName & ".old"), ".old", ".disabled")}
|
||||
Else
|
||||
Return {Target.File.FullName, Target.EnabledFullName}
|
||||
End If
|
||||
End Function).Distinct.Where(Function(m) File.Exists(m)).Select(Function(m) New ResourceFile(m)).ToList()
|
||||
End Function).Distinct.Where(Function(m) FileUtils.Exists(m)).Select(Function(m) New LocalResourceFile(m)).ToList()
|
||||
'实际删除文件
|
||||
For Each ModEntity In ModList
|
||||
'删除
|
||||
Try
|
||||
If IsShiftPressed Then
|
||||
ModEntity.File.Delete()
|
||||
Else
|
||||
My.Computer.FileSystem.DeleteFile(ModEntity.File.FullName, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin)
|
||||
End If
|
||||
FileUtils.Delete(ModEntity.File.FullName, Not IsShiftPressed)
|
||||
Catch ex As OperationCanceledException
|
||||
Log(ex, "删除 Mod 被主动取消")
|
||||
Logger.Warn(ex, "删除 Mod 被主动取消")
|
||||
ReloadModList(True)
|
||||
Return
|
||||
Catch ex As Exception
|
||||
Log(ex, $"删除 Mod 失败({ModEntity.File.FullName})", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, $"删除 Mod 失败({ModEntity.File.FullName})", LogBehavior.Alert)
|
||||
IsSuccessful = False
|
||||
End Try
|
||||
'取消选中
|
||||
SelectedMods.Remove(ModEntity.EnabledName)
|
||||
'更改 Loader 和 UI 中的列表
|
||||
McModLoader.Output.Remove(ModEntity)
|
||||
LocalResourceLoader.Output.Remove(ModEntity)
|
||||
SearchResult?.Remove(ModEntity)
|
||||
ModItems.Remove(ModEntity.EnabledName)
|
||||
Dim IndexOfUi As Integer = PanList.Children.IndexOf(PanList.Children.OfType(Of MyLocalModItem).FirstOrDefault(Function(i) i.Entry.Equals(ModEntity)))
|
||||
@@ -743,10 +737,10 @@ Install:
|
||||
End If
|
||||
End If
|
||||
Catch ex As OperationCanceledException
|
||||
Log(ex, "删除 Mod 被主动取消")
|
||||
Logger.Warn(ex, "删除 Mod 被主动取消")
|
||||
ReloadModList(True)
|
||||
Catch ex As Exception
|
||||
Log(ex, "删除 Mod 出现未知错误", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, "删除 Mod 出现未知错误")
|
||||
ReloadModList(True)
|
||||
End Try
|
||||
LoaderRun(LoaderFolderRunType.UpdateOnly)
|
||||
@@ -765,16 +759,12 @@ Install:
|
||||
Public Sub Info_Click(sender As Object, e As EventArgs)
|
||||
Try
|
||||
|
||||
Dim ModEntry As ResourceFile = CType(If(TypeOf sender Is MyIconButton, sender.Tag, sender), MyLocalModItem).Entry
|
||||
Dim ModEntry As LocalResourceFile = CType(If(TypeOf sender Is MyIconButton, sender.Tag, sender), MyLocalModItem).Entry
|
||||
'加载失败信息
|
||||
If ModEntry.Project IsNot Nothing Then
|
||||
'跳转到 Mod 下载页面
|
||||
FrmMain.PageChange(New FormMain.PageStackData With {.Page = FormMain.PageType.ResourceDetail,
|
||||
.Additional = {ModEntry.Project, New List(Of String), PageInstanceLeft.Instance.Version.VanillaName,
|
||||
If(PageInstanceLeft.Instance.Version.HasForge, ModLoaderTypes.Forge,
|
||||
If(PageInstanceLeft.Instance.Version.HasNeoForge, ModLoaderTypes.NeoForge,
|
||||
If(PageInstanceLeft.Instance.Version.HasFabric, ModLoaderTypes.Fabric, ModLoaderTypes.Any))),
|
||||
ResourceTypes.Mod}})
|
||||
.Additional = {ModEntry.Project, New List(Of String), PageInstanceLeft.Instance.Version.VanillaName, PageInstanceLeft.Instance.Version.ModLoaders, ResourceTypes.Mod}})
|
||||
Else
|
||||
'获取信息
|
||||
Dim ContentLines As New List(Of String)
|
||||
@@ -805,7 +795,7 @@ Install:
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Log(ex, "获取 Mod 详情失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, "获取 Mod 详情失败")
|
||||
End Try
|
||||
End Sub
|
||||
'打开文件所在的位置
|
||||
@@ -814,7 +804,7 @@ Install:
|
||||
Dim ListItem As MyLocalModItem = sender.Tag
|
||||
OpenExplorer(ListItem.Entry.File.FullName)
|
||||
Catch ex As Exception
|
||||
Log(ex, "打开 Mod 文件位置失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, "打开 Mod 文件位置失败")
|
||||
End Try
|
||||
End Sub
|
||||
'删除
|
||||
@@ -837,12 +827,12 @@ Install:
|
||||
Return Not String.IsNullOrWhiteSpace(SearchBox.Text)
|
||||
End Get
|
||||
End Property
|
||||
Private SearchResult As List(Of ResourceFile)
|
||||
Private SearchResult As List(Of LocalResourceFile)
|
||||
Public Sub SearchRun() Handles SearchBox.TextChanged
|
||||
If IsSearching Then
|
||||
'构造请求
|
||||
Dim QueryList As New List(Of SearchEntry(Of ResourceFile))
|
||||
For Each Entry As ResourceFile In McModLoader.Output
|
||||
Dim QueryList As New List(Of SearchEntry(Of LocalResourceFile))
|
||||
For Each Entry As LocalResourceFile In LocalResourceLoader.Output
|
||||
Dim SearchSources As New List(Of SearchSource)
|
||||
SearchSources.Add(New SearchSource(Entry.Display, 1))
|
||||
SearchSources.Add(New SearchSource(Entry.File.Name, 1))
|
||||
@@ -858,7 +848,7 @@ Install:
|
||||
If Entry.Project.Description <> Entry.Description Then SearchSources.Add(New SearchSource(Entry.Project.Description, 0.4))
|
||||
SearchSources.Add(New SearchSource(String.Join("", Entry.Project.Tags), 0.2))
|
||||
End If
|
||||
QueryList.Add(New SearchEntry(Of ResourceFile) With {.Item = Entry, .SearchSource = SearchSources})
|
||||
QueryList.Add(New SearchEntry(Of LocalResourceFile) With {.Item = Entry, .SearchSource = SearchSources})
|
||||
Next
|
||||
'进行搜索
|
||||
SearchResult = Search(QueryList, SearchBox.Text, MaxBlurCount:=6, MinBlurSimilarity:=0.35).Select(Function(r) r.Item).ToList
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
End Sub
|
||||
|
||||
Public Sub BtnDownload_Loaded() Handles BtnDownload.Loaded
|
||||
Dim NewVisibility = If((Settings.Get("UiHiddenPageDownload") AndAlso Not PageSetupUI.HiddenForceShow) OrElse If(FrmSelectRight Is Nothing, False, FrmSelectRight.ShowHidden), Visibility.Collapsed, Visibility.Visible)
|
||||
Dim NewVisibility = If((Settings.Get(Of Boolean)("UiHiddenPageDownload") AndAlso Not PageSetupUI.HiddenForceShow) OrElse If(FrmSelectRight Is Nothing, False, FrmSelectRight.ShowHidden), Visibility.Collapsed, Visibility.Visible)
|
||||
If BtnDownload.Visibility <> NewVisibility Then
|
||||
BtnDownload.Visibility = NewVisibility
|
||||
PanMain.TriggerForceResize()
|
||||
|
||||
@@ -65,13 +65,13 @@
|
||||
WriteIni(McFolderSelected & "PCL.ini", "InstanceCache", "") '要求刷新缓存
|
||||
LoaderFolderRun(McInstanceListLoader, McFolderSelected, LoaderFolderRunType.ForceRun, MaxDepth:=1, ExtraPath:="versions\")
|
||||
Catch ex As Exception
|
||||
Log(ex, "修改版本分类失败(" & PageInstanceLeft.Instance.Name & ")", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, $"修改版本分类失败({PageInstanceLeft.Instance.Name})")
|
||||
End Try
|
||||
Reload() '更新 “打开 Mod 文件夹” 按钮
|
||||
Else
|
||||
'改为隐藏
|
||||
Try
|
||||
If Not Settings.Get("HintHide") Then
|
||||
If Not Settings.Get(Of Boolean)("HintHide") Then
|
||||
If MyMsgBox("确认要从版本列表中隐藏该版本吗?隐藏该版本后,它将不再出现于 PCL 显示的版本列表中。" & vbCrLf & "此后,在版本列表页面按下 F11 才可以查看被隐藏的版本。", "隐藏版本提示",, "取消") <> 1 Then
|
||||
ComboDisplayType.SelectedIndex = 0
|
||||
Return
|
||||
@@ -82,7 +82,7 @@
|
||||
WriteIni(McFolderSelected & "PCL.ini", "InstanceCache", "") '要求刷新缓存
|
||||
LoaderFolderRun(McInstanceListLoader, McFolderSelected, LoaderFolderRunType.ForceRun, MaxDepth:=1, ExtraPath:="versions\")
|
||||
Catch ex As Exception
|
||||
Log(ex, "隐藏版本 " & PageInstanceLeft.Instance.Name & " 失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, $"隐藏版本 {PageInstanceLeft.Instance.Name} 失败")
|
||||
End Try
|
||||
End If
|
||||
End Sub
|
||||
@@ -97,7 +97,7 @@
|
||||
Reload()
|
||||
LoaderFolderRun(McInstanceListLoader, McFolderSelected, LoaderFolderRunType.ForceRun, MaxDepth:=1, ExtraPath:="versions\")
|
||||
Catch ex As Exception
|
||||
Log(ex, "版本 " & PageInstanceLeft.Instance.Name & " 描述更改失败", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, $"版本 {PageInstanceLeft.Instance.Name} 描述更改失败", LogBehavior.Alert)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -109,51 +109,29 @@
|
||||
Dim OldPath As String = PageInstanceLeft.Instance.PathVersion
|
||||
'修改此部分的同时修改快速安装的版本名检测*
|
||||
Dim NewName As String = MyMsgBoxInput("重命名版本", "", OldName, New ObjectModel.Collection(Of Validate) From {
|
||||
New ValidateFolderName(McFolderSelected & "versions", IgnoreCase:=False), New ValidateExceptSame(OldName & "_temp", "不能使用该名称!")})
|
||||
New ValidateFolderName(McFolderSelected & "versions", IgnoreCase:=False)})
|
||||
If String.IsNullOrWhiteSpace(NewName) Then Return
|
||||
Dim NewPath As String = McFolderSelected & "versions\" & NewName & "\"
|
||||
'获取临时中间名,以防止仅修改大小写的重命名失败
|
||||
Dim TempName As String = NewName & "_temp"
|
||||
Dim TempPath As String = McFolderSelected & "versions\" & TempName & "\"
|
||||
Dim OnlyChangedCase As Boolean = NewName.Lower = OldName.Lower
|
||||
'重新读取版本 JSON 信息,避免 JsonObject 中已被合并的项被重新存储
|
||||
Dim JsonObject As JObject
|
||||
Dim OldJsonPath As String = PageInstanceLeft.Instance.GetJsonPath()
|
||||
Try
|
||||
JsonObject = GetJson(ReadFile(OldJsonPath))
|
||||
JsonObject = GetJson(FileUtils.ReadAsString(OldJsonPath))
|
||||
Catch ex As Exception
|
||||
Log(ex, "在重命名读取 json 时失败")
|
||||
Logger.Warn(ex, "在重命名读取 json 时失败")
|
||||
JsonObject = PageInstanceLeft.Instance.JsonObject
|
||||
End Try
|
||||
'重命名主文件夹
|
||||
Directory.Move(OldPath, TempPath)
|
||||
Directory.Move(TempPath, NewPath)
|
||||
DirectoryUtils.Move(OldPath, NewPath)
|
||||
'清理 ini 缓存
|
||||
IniClearCache(PageInstanceLeft.Instance.PathIndie & "options.txt")
|
||||
IniClearCache(PageInstanceLeft.Instance.PathVersion & "PCL\Setup.ini")
|
||||
PageInstanceLeft.Instance.ResetIniCache()
|
||||
'重命名 jar 文件与 natives 文件夹
|
||||
'不能进行遍历重命名,否则在版本名很短的时候容易误伤其他文件(#6443)
|
||||
If Directory.Exists($"{NewPath}{OldName}-natives") Then
|
||||
If OnlyChangedCase Then
|
||||
Directory.Move($"{NewPath}{OldName}-natives", $"{NewPath}{OldName}natives_temp")
|
||||
Directory.Move($"{NewPath}{OldName}-natives_temp", $"{NewPath}{NewName}-natives")
|
||||
Else
|
||||
DeleteDirectory($"{NewPath}{NewName}-natives")
|
||||
Directory.Move($"{NewPath}{OldName}-natives", $"{NewPath}{NewName}-natives")
|
||||
End If
|
||||
End If
|
||||
If File.Exists($"{NewPath}{OldName}.jar") Then
|
||||
If OnlyChangedCase Then
|
||||
File.Move($"{NewPath}{OldName}.jar", $"{NewPath}{OldName}_temp.jar")
|
||||
File.Move($"{NewPath}{OldName}_temp.jar", $"{NewPath}{NewName}.jar")
|
||||
Else
|
||||
File.Delete($"{NewPath}{NewName}.jar")
|
||||
File.Move($"{NewPath}{OldName}.jar", $"{NewPath}{NewName}.jar")
|
||||
End If
|
||||
End If
|
||||
If DirectoryUtils.Exists($"{NewPath}{OldName}-natives") Then DirectoryUtils.Move($"{NewPath}{OldName}-natives", $"{NewPath}{NewName}-natives")
|
||||
If FileUtils.Exists($"{NewPath}{OldName}.jar") Then FileUtils.Move($"{NewPath}{OldName}.jar", $"{NewPath}{NewName}.jar")
|
||||
'替换版本设置文件中的路径
|
||||
If File.Exists(NewPath & "PCL\Setup.ini") Then
|
||||
FileUtils.Write(NewPath & "PCL\Setup.ini", ReadFile(NewPath & "PCL\Setup.ini").Replace(OldPath, NewPath))
|
||||
If FileUtils.Exists(NewPath & "PCL\Setup.ini") Then
|
||||
FileUtils.Write(NewPath & "PCL\Setup.ini", FileUtils.ReadAsString(NewPath & "PCL\Setup.ini").Replace(OldPath, NewPath))
|
||||
End If
|
||||
'更改已选中的版本
|
||||
If ReadIni(McFolderSelected & "PCL.ini", "Version") = OldName Then
|
||||
@@ -162,10 +140,10 @@
|
||||
'更新版本 Json
|
||||
Try
|
||||
JsonObject("id") = NewName
|
||||
FileUtils.Delete(NewPath & PathUtils.GetLastPart(OldJsonPath))
|
||||
FileUtils.Write(NewPath & NewName & ".json", JsonObject.ToString)
|
||||
File.Delete(NewPath & GetFileNameFromPath(OldJsonPath))
|
||||
Catch ex As Exception
|
||||
Log(ex, "重命名版本 json 失败")
|
||||
Logger.Warn(ex, "重命名版本 json 失败")
|
||||
End Try
|
||||
'刷新与提示
|
||||
Hint("重命名成功!", HintType.Green)
|
||||
@@ -174,7 +152,7 @@
|
||||
Reload()
|
||||
LoaderFolderRun(McInstanceListLoader, McFolderSelected, LoaderFolderRunType.ForceRun, MaxDepth:=1, ExtraPath:="versions\")
|
||||
Catch ex As Exception
|
||||
Log(ex, "重命名版本失败", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, "重命名版本失败", LogBehavior.Alert)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -184,17 +162,17 @@
|
||||
'选择 自定义 时修改图片
|
||||
Try
|
||||
If ComboDisplayLogo.SelectedItem Is ItemDisplayLogoCustom Then
|
||||
Dim FileName As String = SelectFile("常用图片文件(*.png;*.jpeg;*.jpg;*.gif;*.webp)|*.png;*.jpeg;*.jpg;*.gif;*.webp", "选择图片")
|
||||
If FileName = "" Then
|
||||
Dim FileName As String = Dialogs.SelectFile("选择图片", False, filter:={({"png", "jpeg", "jpg", "gif", "webp"}, "常用图片文件")}).FirstOrDefault()
|
||||
If String.IsNullOrEmpty(FileName) Then
|
||||
Reload() '还原选项
|
||||
Return
|
||||
End If
|
||||
CopyFile(FileName, PageInstanceLeft.Instance.PathVersion & "PCL\Logo.png")
|
||||
FileUtils.Copy(FileName, PageInstanceLeft.Instance.PathVersion & "PCL\Logo.png")
|
||||
Else
|
||||
File.Delete(PageInstanceLeft.Instance.PathVersion & "PCL\Logo.png")
|
||||
FileUtils.Delete(PageInstanceLeft.Instance.PathVersion & "PCL\Logo.png")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Log(ex, "更改自定义版本图标失败(" & PageInstanceLeft.Instance.Name & ")", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, $"更改自定义版本图标失败({PageInstanceLeft.Instance.Name})")
|
||||
End Try
|
||||
'进行更改
|
||||
Try
|
||||
@@ -207,7 +185,7 @@
|
||||
Reload()
|
||||
LoaderFolderRun(McInstanceListLoader, McFolderSelected, LoaderFolderRunType.ForceRun, MaxDepth:=1, ExtraPath:="versions\")
|
||||
Catch ex As Exception
|
||||
Log(ex, "更改版本图标失败(" & PageInstanceLeft.Instance.Name & ")", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, $"更改版本图标失败({PageInstanceLeft.Instance.Name})")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -220,7 +198,7 @@
|
||||
McInstanceListForceRefresh = True
|
||||
LoaderFolderRun(McInstanceListLoader, McFolderSelected, LoaderFolderRunType.ForceRun, MaxDepth:=1, ExtraPath:="versions\")
|
||||
Catch ex As Exception
|
||||
Log(ex, "版本 " & PageInstanceLeft.Instance.Name & " 收藏状态更改失败", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, $"版本 {PageInstanceLeft.Instance.Name} 收藏状态更改失败", LogBehavior.Alert)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -258,8 +236,8 @@
|
||||
Private Sub BtnManageScript_Click() Handles BtnManageScript.Click
|
||||
Try
|
||||
'弹窗要求指定脚本的保存位置
|
||||
Dim SavePath As String = SelectSaveFile("选择脚本保存位置", "启动 " & PageInstanceLeft.Instance.Name & ".bat", "批处理文件(*.bat)|*.bat")
|
||||
If SavePath = "" Then Return
|
||||
Dim SavePath As String = Dialogs.SaveFile("选择脚本保存位置", "启动 " & PageInstanceLeft.Instance.Name & ".bat", filter:={("bat", "批处理文件")})
|
||||
If SavePath Is Nothing Then Return
|
||||
'检查中断(等玩家选完弹窗指不定任务就结束了呢……)
|
||||
If McLaunchLoader.State = LoadState.Loading Then
|
||||
Hint("请在当前启动任务结束后再试!", HintType.Red)
|
||||
@@ -267,14 +245,14 @@
|
||||
End If
|
||||
'生成脚本
|
||||
If McLaunchStart(New McLaunchOptions With {.SaveBatch = SavePath, .Instance = PageInstanceLeft.Instance}) Then
|
||||
If Settings.Get("LoginType") = McLoginType.Legacy Then
|
||||
If Settings.Get(Of McLoginType)("LoginType") = McLoginType.Legacy Then
|
||||
Hint("正在导出启动脚本……")
|
||||
Else
|
||||
Hint("正在导出启动脚本……(注意,使用脚本启动可能会导致登录失效!)")
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Log(ex, "导出启动脚本失败(" & PageInstanceLeft.Instance.Name & ")", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, $"导出启动脚本失败({PageInstanceLeft.Instance.Name})", LogBehavior.Alert)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -300,7 +278,7 @@
|
||||
Case LoadState.Finished
|
||||
Hint(Loader.Name & "成功!", HintType.Green)
|
||||
Case LoadState.Failed
|
||||
Hint(Loader.Name & "失败:" & Loader.Error.GetBrief(), HintType.Red)
|
||||
Hint(Loader.Name & "失败:" & Loader.Error.GetDisplay(False), HintType.Red)
|
||||
Case LoadState.Interrupted
|
||||
Hint(Loader.Name & "已取消!", HintType.Blue)
|
||||
End Select
|
||||
@@ -310,7 +288,7 @@
|
||||
FrmMain.BtnExtraDownload.ShowRefresh()
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
Catch ex As Exception
|
||||
Log(ex, "尝试补全文件失败(" & PageInstanceLeft.Instance.Name & ")", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, $"尝试补全文件失败({PageInstanceLeft.Instance.Name})", LogBehavior.Alert)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -324,13 +302,8 @@
|
||||
If(IsHintIndie, vbCrLf & "由于该版本开启了版本隔离,删除版本时该版本对应的存档、资源包、Mod 等文件也将被一并删除!", ""),
|
||||
"版本删除确认", , "取消",, IsHintIndie OrElse IsShiftPressed)
|
||||
Case 1
|
||||
IniClearCache(PageInstanceLeft.Instance.PathIndie & "options.txt")
|
||||
IniClearCache(PageInstanceLeft.Instance.PathVersion & "PCL\Setup.ini")
|
||||
If IsShiftPressed Then
|
||||
DeleteDirectory(PageInstanceLeft.Instance.PathVersion)
|
||||
Else
|
||||
FileIO.FileSystem.DeleteDirectory(PageInstanceLeft.Instance.PathVersion, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin)
|
||||
End If
|
||||
PageInstanceLeft.Instance.ResetIniCache()
|
||||
DirectoryUtils.Delete(PageInstanceLeft.Instance.PathVersion, Not IsShiftPressed)
|
||||
Hint("已删除版本 " & PageInstanceLeft.Instance.Name & "!", HintType.Green)
|
||||
Case 2
|
||||
Return
|
||||
@@ -338,9 +311,9 @@
|
||||
LoaderFolderRun(McInstanceListLoader, McFolderSelected, LoaderFolderRunType.ForceRun, MaxDepth:=1, ExtraPath:="versions\")
|
||||
FrmMain.PageBack()
|
||||
Catch ex As OperationCanceledException
|
||||
Log(ex, "删除版本 " & PageInstanceLeft.Instance.Name & " 被主动取消")
|
||||
Logger.Warn(ex, $"删除版本 {PageInstanceLeft.Instance.Name} 被主动取消")
|
||||
Catch ex As Exception
|
||||
Log(ex, "删除版本 " & PageInstanceLeft.Instance.Name & " 失败", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, $"删除版本 {PageInstanceLeft.Instance.Name} 失败", LogBehavior.Alert)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="游戏窗口标题" Margin="0,0,25,0" />
|
||||
<local:MyTextBox x:Name="TextArgumentTitle" Grid.Row="2" Grid.ColumnSpan="2" local:SettingService.Key="VersionArgumentTitle" Grid.Column="1" ToolTip="自定义游戏窗口的标题,若留空则跟随全局设置的值。
你可以用替换标记来动态改变其内容,在 更多 → 帮助 中搜索 “替换标记” 以了解用法。" HintText="跟随全局设置" MaxLength="100" />
|
||||
<TextBlock Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Left" Text="自定义信息" Margin="0,0,25,0" />
|
||||
<local:MyTextBox x:Name="TextArgumentInfo" Grid.Row="4" Grid.ColumnSpan="2" local:SettingService.Key="VersionArgumentInfo" Grid.Column="1" HintText="跟随全局设置" ToolTip="该信息会显示在游戏主界面的左下角,与 F3 调试页面的左上角。
若留空,则跟随全局设置的值。

你可以用替换标记来动态改变其内容,在 更多 → 帮助 中搜索 “替换标记” 以了解用法。">
|
||||
<local:MyTextBox x:Name="TextArgumentInfo" Grid.Row="4" Grid.ColumnSpan="2" local:SettingService.Key="VersionArgumentInfo" Grid.Column="1" HintText="跟随全局设置" ToolTip="注意:Mojang 于 Minecraft 26.1 移除了该设置,因此该设置在新版本中无效。

该信息会显示在游戏主界面的左下角,与 F3 调试页面的左上角。
若留空,则跟随全局设置的值。

你可以用替换标记来动态改变其内容,在 更多 → 帮助 中搜索 “替换标记” 以了解用法。">
|
||||
<local:MyTextBox.ValidateRules>
|
||||
<local:ValidateExcept>
|
||||
<local:ValidateExcept.Excepts>
|
||||
@@ -250,7 +250,7 @@
|
||||
ToolTip="是否使用 Java Launch Wrapper 修复 Java 18- 在中文路径下可能无法正常启动的问题。
详见:https://github.com/00ll00/java_launch_wrapper" />
|
||||
<local:MyCheckBox Height="28" Text="禁用 LWJGL Unsafe Agent" local:SettingService.Key="VersionAdvanceDisableLUA"
|
||||
ToolTipService.Placement="Right"
|
||||
ToolTip="是否使用 LWJGL Unsafe Agent 修复 Java 25+ 的一个性能问题。
详见:https://github.com/HMCL-dev/lwjgl-unsafe-agent" />
|
||||
ToolTip="是否使用 LWJGL Unsafe Agent 修复 LWJGL 3.4.1 的一个性能问题。
详见:https://github.com/HMCL-dev/lwjgl-unsafe-agent" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</local:MyCard>
|
||||
|
||||
@@ -28,17 +28,17 @@
|
||||
|
||||
'启动参数
|
||||
Dim _unused = PageInstanceLeft.Instance.PathIndie '触发自动判定
|
||||
ComboArgumentIndieV2.SelectedIndex = If(Settings.Get("VersionArgumentIndieV2", Instance:=PageInstanceLeft.Instance), 0, 1)
|
||||
ComboArgumentIndieV2.SelectedIndex = If(Settings.Get(Of Boolean)("VersionArgumentIndieV2", Instance:=PageInstanceLeft.Instance), 0, 1)
|
||||
RefreshJavaComboBox()
|
||||
|
||||
'服务器
|
||||
ComboServerLogin.SelectedIndex = Settings.Get("VersionServerLogin", Instance:=PageInstanceLeft.Instance)
|
||||
ComboServerLogin.SelectedIndex = Settings.Get(Of Integer)("VersionServerLogin", Instance:=PageInstanceLeft.Instance)
|
||||
ComboServerLoginLast = ComboServerLogin.SelectedIndex
|
||||
UpdateServerLoginUI()
|
||||
|
||||
'高级设置
|
||||
If Settings.Get("VersionAdvanceAssets", Instance:=PageInstanceLeft.Instance) = 2 Then
|
||||
Log("[Setup] 已迁移老版本的关闭文件校验设置")
|
||||
If Settings.Get(Of Integer)("VersionAdvanceAssets", Instance:=PageInstanceLeft.Instance) = 2 Then
|
||||
Logger.Info("已迁移老版本的关闭文件校验设置")
|
||||
Settings.Reset("VersionAdvanceAssets", Instance:=PageInstanceLeft.Instance)
|
||||
Settings.Set("VersionAdvanceAssetsV2", True, Instance:=PageInstanceLeft.Instance)
|
||||
End If
|
||||
@@ -46,10 +46,10 @@
|
||||
SettingService.RefreshSettings(Me)
|
||||
|
||||
'游戏内存
|
||||
OnVersionRamTypeChanged(Settings.Get("VersionRamType", Instance:=PageInstanceLeft.Instance))
|
||||
OnVersionRamTypeChanged(Settings.Get(Of Integer)("VersionRamType", Instance:=PageInstanceLeft.Instance))
|
||||
|
||||
Catch ex As Exception
|
||||
Log(ex, "重载版本独立设置时出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, "重载版本独立设置时出错")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -65,10 +65,10 @@
|
||||
Settings.Reset("VersionArgumentJavaSelect", Instance:=PageInstanceLeft.Instance)
|
||||
JavaSearchLoader.Start(IsForceRestart:=True)
|
||||
|
||||
Log("[Setup] 已初始化版本独立设置")
|
||||
Logger.Info("已初始化版本独立设置")
|
||||
Hint("已初始化版本独立设置!", HintType.Green, False)
|
||||
Catch ex As Exception
|
||||
Log(ex, "初始化版本独立设置失败", NotifyLevel.MsgBox)
|
||||
Logger.Error(ex, "初始化版本独立设置失败", LogBehavior.Alert)
|
||||
End Try
|
||||
|
||||
Reload()
|
||||
@@ -219,7 +219,7 @@
|
||||
''' </summary>
|
||||
Public Shared Function GetRam(Instance As McInstance, Optional Is32BitJava As Boolean? = Nothing) As Double
|
||||
'跟随全局设置
|
||||
If Settings.Get("VersionRamType", Instance:=Instance) = 2 Then
|
||||
If Settings.Get(Of Integer)("VersionRamType", Instance:=Instance) = 2 Then
|
||||
Return PageSetupLaunch.GetRam(Instance, True, Is32BitJava)
|
||||
End If
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
|
||||
'使用当前版本的设置
|
||||
Dim RamGive As Double
|
||||
If Settings.Get("VersionRamType", Instance:=Instance) = 0 Then
|
||||
If Settings.Get(Of Integer)("VersionRamType", Instance:=Instance) = 0 Then
|
||||
'自动配置
|
||||
Dim RamAvailable As Double = Math.Round(My.Computer.Info.AvailablePhysicalMemory / 1024 / 1024 / 1024 * 10) / 10
|
||||
'确定需求的内存值
|
||||
@@ -240,7 +240,7 @@
|
||||
If Instance IsNot Nothing AndAlso Not Instance.IsLoaded Then Instance.Load()
|
||||
If Instance IsNot Nothing AndAlso Instance.Modable Then
|
||||
'可安装 Mod 的版本
|
||||
Dim ModDir As New DirectoryInfo(Instance.PathIndie & "mods\")
|
||||
Dim ModDir = DirectoryUtils.GetInfo(Instance.PathIndie & "mods\")
|
||||
Dim ModCount As Integer = If(ModDir.Exists, ModDir.GetFiles.Count(Function(f) {".jar", ".zip", ".litemod"}.Contains(f.Extension.Lower)), 0)
|
||||
RamMininum = 0.5 + ModCount / 150
|
||||
RamTarget1 = 1.5 + ModCount / 90
|
||||
@@ -285,7 +285,7 @@ PreFin:
|
||||
RamGive = Math.Round(Math.Max(RamGive, RamMininum), 1)
|
||||
Else
|
||||
'手动配置
|
||||
Dim Value As Integer = Settings.Get("VersionRamCustom", Instance:=Instance)
|
||||
Dim Value As Integer = Settings.Get(Of Integer)("VersionRamCustom", Instance:=Instance)
|
||||
If Value <= 12 Then
|
||||
RamGive = Value * 0.1 + 0.3
|
||||
ElseIf Value <= 25 Then
|
||||
@@ -374,10 +374,10 @@ PreFin:
|
||||
'初始化列表
|
||||
ComboArgumentJava.Items.Clear()
|
||||
ComboArgumentJava.Items.Add(New MyComboBoxItem With {.Content = "跟随全局设置", .Tag = "使用全局设置"})
|
||||
ComboArgumentJava.Items.Add(New MyComboBoxItem With {.Content = "自动选择合适的 Java", .Tag = "自动选择"})
|
||||
ComboArgumentJava.Items.Add(New MyComboBoxItem With {.Content = "自动选择(推荐)", .Tag = "自动选择"})
|
||||
'更新列表
|
||||
Dim SelectedItem As MyComboBoxItem = Nothing
|
||||
Dim SelectedBySetup As String = Settings.Get("VersionArgumentJavaSelect", Instance:=PageInstanceLeft.Instance)
|
||||
Dim SelectedBySetup As String = Settings.Get(Of String)("VersionArgumentJavaSelect", Instance:=PageInstanceLeft.Instance)
|
||||
Try
|
||||
For Each Java In JavaList.ToList().OrderByDescending(Function(v) v.MajorVersion)
|
||||
Dim ListItem = New MyComboBoxItem With {.Content = Java.ToString, .ToolTip = Java.PathFolder, .Tag = Java}
|
||||
@@ -389,7 +389,7 @@ PreFin:
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Settings.Set("VersionArgumentJavaSelect", "使用全局设置", Instance:=PageInstanceLeft.Instance)
|
||||
Log(ex, "更新版本设置 Java 下拉框失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
Logger.Error(ex, "更新版本设置 Java 下拉框失败")
|
||||
End Try
|
||||
'更新选择项
|
||||
If SelectedItem Is Nothing AndAlso JavaList.Any Then
|
||||
@@ -424,15 +424,15 @@ PreFin:
|
||||
If "使用全局设置".Equals(SelectedJava) Then
|
||||
'选择 “自动”
|
||||
Settings.Set("VersionArgumentJavaSelect", "使用全局设置", Instance:=PageInstanceLeft.Instance)
|
||||
Log("[Java] 修改版本 Java 选择设置:跟随全局设置")
|
||||
Logger.Info("修改版本 Java 选择设置:跟随全局设置")
|
||||
ElseIf "自动选择".Equals(SelectedJava) Then
|
||||
'选择 “自动”
|
||||
Settings.Set("VersionArgumentJavaSelect", "", Instance:=PageInstanceLeft.Instance)
|
||||
Log("[Java] 修改版本 Java 选择设置:自动选择")
|
||||
Logger.Info("修改版本 Java 选择设置:自动选择")
|
||||
Else
|
||||
'选择指定项
|
||||
Settings.Set("VersionArgumentJavaSelect", CType(SelectedJava.ToJson(), JObject).ToString(Newtonsoft.Json.Formatting.None), Instance:=PageInstanceLeft.Instance)
|
||||
Log("[Java] 修改版本 Java 选择设置:" & SelectedJava.ToString)
|
||||
Logger.Info($"修改版本 Java 选择设置:{SelectedJava}")
|
||||
End If
|
||||
RefreshRam(True)
|
||||
End Sub
|
||||
|
||||
Reference in New Issue
Block a user