2.7.0
This commit is contained in:
@@ -120,49 +120,49 @@ Public Module ModDownloadLib
|
||||
'下载版本 Json 文件
|
||||
If JsonUrl Is Nothing Then
|
||||
Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("获取原版 json 文件下载地址",
|
||||
Sub(Task As LoaderTask(Of String, List(Of NetFile)))
|
||||
Dim JsonAddress As String = DlClientListGet(Id)
|
||||
Task.Output = New List(Of NetFile) From {New NetFile(DlSourceLauncherOrMetaGet(JsonAddress), VersionFolder & VersionName & ".json")}
|
||||
End Sub) With {.ProgressWeight = 2, .Show = False})
|
||||
Sub(Task As LoaderTask(Of String, List(Of NetFile)))
|
||||
Dim JsonAddress As String = DlClientListGet(Id)
|
||||
Task.Output = New List(Of NetFile) From {New NetFile(DlSourceLauncherOrMetaGet(JsonAddress), VersionFolder & VersionName & ".json")}
|
||||
End Sub) With {.ProgressWeight = 2, .Show = False})
|
||||
End If
|
||||
Loaders.Add(New LoaderDownload(McDownloadClientJsonName, New List(Of NetFile) From {
|
||||
New NetFile(DlSourceLauncherOrMetaGet(If(JsonUrl, "")), VersionFolder & VersionName & ".json", New FileChecker(CanUseExistsFile:=False, IsJson:=True))
|
||||
}) With {.ProgressWeight = 3})
|
||||
New NetFile(DlSourceLauncherOrMetaGet(If(JsonUrl, "")), VersionFolder & VersionName & ".json", New FileChecker(CanUseExistsFile:=False, IsJson:=True))
|
||||
}) With {.ProgressWeight = 3})
|
||||
|
||||
'下载支持库文件
|
||||
Dim LoadersLib As New List(Of LoaderBase)
|
||||
LoadersLib.Add(New LoaderTask(Of String, List(Of NetFile))("分析原版支持库文件(副加载器)",
|
||||
Sub(Task As LoaderTask(Of String, List(Of NetFile)))
|
||||
Log("[Download] 开始分析原版支持库文件:" & VersionFolder)
|
||||
Task.Output = McLibFix(New McVersion(VersionFolder))
|
||||
End Sub) With {.ProgressWeight = 1, .Show = False})
|
||||
Sub(Task As LoaderTask(Of String, List(Of NetFile)))
|
||||
Log("[Download] 开始分析原版支持库文件:" & VersionFolder)
|
||||
Task.Output = McLibFix(New McVersion(VersionFolder))
|
||||
End Sub) With {.ProgressWeight = 1, .Show = False})
|
||||
LoadersLib.Add(New LoaderDownload("下载原版支持库文件(副加载器)", New List(Of NetFile)) With {.ProgressWeight = 13, .Show = False})
|
||||
Loaders.Add(New LoaderCombo(Of String)(McDownloadClientLibName, LoadersLib) With {.Block = False, .ProgressWeight = 14})
|
||||
|
||||
'下载资源文件
|
||||
Dim LoadersAssets As New List(Of LoaderBase)
|
||||
LoadersAssets.Add(New LoaderTask(Of String, List(Of NetFile))("分析资源文件索引地址(副加载器)",
|
||||
Sub(Task As LoaderTask(Of String, List(Of NetFile)))
|
||||
Try
|
||||
Dim Version As New McVersion(VersionFolder)
|
||||
Task.Output = New List(Of NetFile) From {DlClientAssetIndexGet(Version)}
|
||||
Catch ex As Exception
|
||||
Throw New Exception("分析资源文件索引地址失败", ex)
|
||||
End Try
|
||||
'顺手添加 Json 项目
|
||||
Try
|
||||
Dim VersionJson As JObject = GetJson(ReadFile(VersionFolder & VersionName & ".json"))
|
||||
VersionJson.Add("clientVersion", Id)
|
||||
WriteFile(VersionFolder & VersionName & ".json", VersionJson.ToString)
|
||||
Catch ex As Exception
|
||||
Throw New Exception("添加客户端版本失败", ex)
|
||||
End Try
|
||||
End Sub) With {.ProgressWeight = 1, .Show = False})
|
||||
Sub(Task As LoaderTask(Of String, List(Of NetFile)))
|
||||
Try
|
||||
Dim Version As New McVersion(VersionFolder)
|
||||
Task.Output = New List(Of NetFile) From {DlClientAssetIndexGet(Version)}
|
||||
Catch ex As Exception
|
||||
Throw New Exception("分析资源文件索引地址失败", ex)
|
||||
End Try
|
||||
'顺手添加 Json 项目
|
||||
Try
|
||||
Dim VersionJson As JObject = GetJson(ReadFile(VersionFolder & VersionName & ".json"))
|
||||
VersionJson.Add("clientVersion", Id)
|
||||
WriteFile(VersionFolder & VersionName & ".json", VersionJson.ToString)
|
||||
Catch ex As Exception
|
||||
Throw New Exception("添加客户端版本失败", ex)
|
||||
End Try
|
||||
End Sub) With {.ProgressWeight = 1, .Show = False})
|
||||
LoadersAssets.Add(New LoaderDownload("下载资源文件索引(副加载器)", New List(Of NetFile)) With {.ProgressWeight = 3, .Show = False})
|
||||
LoadersAssets.Add(New LoaderTask(Of String, List(Of NetFile))("分析所需资源文件(副加载器)",
|
||||
Sub(Task As LoaderTask(Of String, List(Of NetFile)))
|
||||
Task.Output = McAssetsFixList(McAssetsGetIndexName(New McVersion(VersionFolder)), True, Task)
|
||||
End Sub) With {.ProgressWeight = 3, .Show = False})
|
||||
Sub(Task As LoaderTask(Of String, List(Of NetFile)))
|
||||
Task.Output = McAssetsFixList(McAssetsGetIndexName(New McVersion(VersionFolder)), True, Task)
|
||||
End Sub) With {.ProgressWeight = 3, .Show = False})
|
||||
LoadersAssets.Add(New LoaderDownload("下载资源文件(副加载器)", New List(Of NetFile)) With {.ProgressWeight = 14, .Show = False})
|
||||
Loaders.Add(New LoaderCombo(Of String)("下载原版资源文件", LoadersAssets) With {.Block = False, .ProgressWeight = 21})
|
||||
|
||||
@@ -283,7 +283,7 @@ Public Module ModDownloadLib
|
||||
WikiName = "Java版Combat_Test_8c"
|
||||
ElseIf Id = "1.0.0-rc2-2" Then
|
||||
WikiName = "Java版RC2"
|
||||
ElseIf Id.StartsWith("1.19_deep_dark_experimental_snapshot-") OrElse Id.StartsWith("1_19_deep_dark_experimental_snapshot-") Then
|
||||
ElseIf Id.StartsWithF("1.19_deep_dark_experimental_snapshot-") OrElse Id.StartsWithF("1_19_deep_dark_experimental_snapshot-") Then
|
||||
WikiName = Id.Replace("1_19", "1.19").Replace("1.19_deep_dark_experimental_snapshot-", "Java版Deep_Dark_Experimental_Snapshot_")
|
||||
ElseIf Id = "b1.9-pre6" Then
|
||||
WikiName = "Java版Beta_1.9_Prerelease_6"
|
||||
@@ -291,19 +291,19 @@ Public Module ModDownloadLib
|
||||
WikiName = "Java版Beta_1.9_Prerelease"
|
||||
ElseIf VersionJson("type") = "release" OrElse VersionJson("type") = "snapshot" OrElse VersionJson("type") = "special" Then
|
||||
WikiName = If(Id.Contains("w"), "", "Java版") & Id.Replace(" Pre-Release ", "-pre")
|
||||
ElseIf Id.StartsWith("b") Then
|
||||
ElseIf Id.StartsWithF("b") Then
|
||||
WikiName = "Java版" & Id.TrimEnd("a", "b", "c", "d", "e").Replace("b", "Beta_")
|
||||
ElseIf Id.StartsWith("a") Then
|
||||
ElseIf Id.StartsWithF("a") Then
|
||||
WikiName = "Java版" & Id.TrimEnd("a", "b", "c", "d", "e").Replace("a", "Alpha_v")
|
||||
ElseIf Id = "inf-20100618" Then
|
||||
WikiName = "Java版Infdev_20100618"
|
||||
ElseIf Id = "c0.30_01c" OrElse Id = "c0.30_survival" OrElse Id.Contains("生存测试") Then
|
||||
WikiName = "Java版Classic_0.30(生存模式)"
|
||||
ElseIf Id.StartsWith("c0.31") Then
|
||||
ElseIf Id.StartsWithF("c0.31") Then
|
||||
WikiName = "Java版Indev_0.31_20100130"
|
||||
ElseIf Id.StartsWith("c") Then
|
||||
ElseIf Id.StartsWithF("c") Then
|
||||
WikiName = "Java版" & Id.Replace("c", "Classic_")
|
||||
ElseIf Id.StartsWith("rd-") Then
|
||||
ElseIf Id.StartsWithF("rd-") Then
|
||||
WikiName = "Java版Pre-classic_" & Id
|
||||
Else
|
||||
Log("[Error] 未知的版本格式:" & Id & "。", LogLevel.Feedback)
|
||||
@@ -428,52 +428,54 @@ Public Module ModDownloadLib
|
||||
Dim LastResult As String = ""
|
||||
Using outputWaitHandle As New AutoResetEvent(False)
|
||||
Using errorWaitHandle As New AutoResetEvent(False)
|
||||
AddHandler process.OutputDataReceived, Function(sender, e)
|
||||
Try
|
||||
If e.Data Is Nothing Then
|
||||
outputWaitHandle.[Set]()
|
||||
Else
|
||||
LastResult = e.Data
|
||||
If ModeDebug Then Log("[Installer] " & LastResult)
|
||||
TotalLength += 1
|
||||
Task.Progress += 0.9 / 7000
|
||||
End If
|
||||
Catch ex As ObjectDisposedException
|
||||
Catch ex As Exception
|
||||
Log(ex, "读取 OptiFine 安装器信息失败")
|
||||
End Try
|
||||
Try
|
||||
If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then
|
||||
Log("[Installer] 由于任务取消,已中止 OptiFine 安装")
|
||||
process.Kill()
|
||||
End If
|
||||
Catch
|
||||
End Try
|
||||
Return Nothing
|
||||
End Function
|
||||
AddHandler process.ErrorDataReceived, Function(sender, e)
|
||||
Try
|
||||
If e.Data Is Nothing Then
|
||||
errorWaitHandle.[Set]()
|
||||
Else
|
||||
LastResult = e.Data
|
||||
If ModeDebug Then Log("[Installer] " & LastResult)
|
||||
TotalLength += 1
|
||||
Task.Progress += 0.9 / 7000
|
||||
End If
|
||||
Catch ex As ObjectDisposedException
|
||||
Catch ex As Exception
|
||||
Log(ex, "读取 OptiFine 安装器错误信息失败")
|
||||
End Try
|
||||
Try
|
||||
If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then
|
||||
Log("[Installer] 由于任务取消,已中止 OptiFine 安装")
|
||||
process.Kill()
|
||||
End If
|
||||
Catch
|
||||
End Try
|
||||
Return Nothing
|
||||
End Function
|
||||
AddHandler process.OutputDataReceived,
|
||||
Function(sender, e)
|
||||
Try
|
||||
If e.Data Is Nothing Then
|
||||
outputWaitHandle.[Set]()
|
||||
Else
|
||||
LastResult = e.Data
|
||||
If ModeDebug Then Log("[Installer] " & LastResult)
|
||||
TotalLength += 1
|
||||
Task.Progress += 0.9 / 7000
|
||||
End If
|
||||
Catch ex As ObjectDisposedException
|
||||
Catch ex As Exception
|
||||
Log(ex, "读取 OptiFine 安装器信息失败")
|
||||
End Try
|
||||
Try
|
||||
If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then
|
||||
Log("[Installer] 由于任务取消,已中止 OptiFine 安装")
|
||||
process.Kill()
|
||||
End If
|
||||
Catch
|
||||
End Try
|
||||
Return Nothing
|
||||
End Function
|
||||
AddHandler process.ErrorDataReceived,
|
||||
Function(sender, e)
|
||||
Try
|
||||
If e.Data Is Nothing Then
|
||||
errorWaitHandle.[Set]()
|
||||
Else
|
||||
LastResult = e.Data
|
||||
If ModeDebug Then Log("[Installer] " & LastResult)
|
||||
TotalLength += 1
|
||||
Task.Progress += 0.9 / 7000
|
||||
End If
|
||||
Catch ex As ObjectDisposedException
|
||||
Catch ex As Exception
|
||||
Log(ex, "读取 OptiFine 安装器错误信息失败")
|
||||
End Try
|
||||
Try
|
||||
If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then
|
||||
Log("[Installer] 由于任务取消,已中止 OptiFine 安装")
|
||||
process.Kill()
|
||||
End If
|
||||
Catch
|
||||
End Try
|
||||
Return Nothing
|
||||
End Function
|
||||
process.Start()
|
||||
process.BeginOutputReadLine()
|
||||
process.BeginErrorReadLine()
|
||||
@@ -1010,7 +1012,7 @@ Retry:
|
||||
End If
|
||||
Exit Sub
|
||||
End If
|
||||
If DownloadInfo.Category = "universal" OrElse DownloadInfo.Inherit.StartsWith("1.5") Then '对该版本自动安装的支持将在之后加入
|
||||
If DownloadInfo.Category = "universal" OrElse DownloadInfo.Inherit.StartsWithF("1.5") Then '对该版本自动安装的支持将在之后加入
|
||||
If MyMsgBox("该 Forge 版本过于古老,PCL 暂不支持该版本的自动安装。" & vbCrLf &
|
||||
"若你仍然希望继续,PCL 将把安装程序下载到你指定的位置,但不会进行安装。",
|
||||
"版本过老", "继续", "取消") = 1 Then
|
||||
@@ -1214,9 +1216,9 @@ Retry:
|
||||
End SyncLock
|
||||
End Sub
|
||||
Private Sub ForgeInjectorLine(Content As String, Task As LoaderTask(Of Boolean, Boolean))
|
||||
If Content.StartsWith(" Data") OrElse Content.StartsWith(" Slim") Then
|
||||
If Content.StartsWithF(" Data") OrElse Content.StartsWithF(" Slim") Then
|
||||
If ModeDebug Then Log("[Installer] " & Content)
|
||||
ElseIf Content.StartsWith(" Reading patch ") Then
|
||||
ElseIf Content.StartsWithF(" Reading patch ") Then
|
||||
If ModeDebug Then Log("[Installer] " & Content)
|
||||
Task.Progress = 0.86
|
||||
Else
|
||||
@@ -1265,7 +1267,7 @@ Retry:
|
||||
|
||||
'参数初始化
|
||||
McFolder = If(McFolder, PathMcFolder)
|
||||
If Version.StartsWith("1.") AndAlso Version.Contains("-") Then
|
||||
If Version.StartsWithF("1.") AndAlso Version.Contains("-") Then
|
||||
'类似 1.19.3-41.2.8 格式,优先使用 Version 中要求的版本而非 Inherit(例如 1.19.3 却使用了 1.19 的 Forge)
|
||||
Inherit = Version.Split("-").First
|
||||
Version = Version.Split("-").Last
|
||||
@@ -1345,8 +1347,8 @@ Retry:
|
||||
Task.Progress = 0.8
|
||||
'去除其中的原始 Forge 项
|
||||
For i = 0 To Libs.Count - 1
|
||||
If Libs(i).LocalPath.EndsWith("forge-" & Inherit & "-" & Version & ".jar") OrElse
|
||||
Libs(i).LocalPath.EndsWith("forge-" & Inherit & "-" & Version & "-client.jar") Then
|
||||
If Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & ".jar") OrElse
|
||||
Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & "-client.jar") Then
|
||||
Log("[Download] 已从待下载 Forge 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug)
|
||||
Libs.RemoveAt(i)
|
||||
Exit For
|
||||
@@ -1644,7 +1646,7 @@ Retry:
|
||||
For Each Version As JObject In ResultJson
|
||||
If Version("name") Is Nothing OrElse Version("build") Is Nothing Then Continue For
|
||||
Dim Name As String = Version("name")
|
||||
If Not Name.EndsWith("-recommended") Then Continue For
|
||||
If Not Name.EndsWithF("-recommended") Then Continue For
|
||||
'内容为:"1.15.2":"31.2.0"
|
||||
RecommendedList.Add("""" & Name.Replace("-recommended", """:""" & Version("build")("version").ToString & """"))
|
||||
Next
|
||||
@@ -1974,9 +1976,9 @@ Retry:
|
||||
Request.OptiFineEntry = New DlOptiFineListEntry With {
|
||||
.NameDisplay = Request.MinecraftName & " " & Request.OptiFineVersion.Replace("HD_U_", "").Replace("_", "").Replace("pre", " pre"),
|
||||
.Inherit = Request.MinecraftName,
|
||||
.IsPreview = Request.OptiFineVersion.ToLower.Contains("pre"),
|
||||
.IsPreview = Request.OptiFineVersion.ContainsF("pre", True),
|
||||
.NameVersion = Request.MinecraftName & "-OptiFine_" & Request.OptiFineVersion,
|
||||
.NameFile = If(Request.OptiFineVersion.ToLower.Contains("pre"), "preview_", "") &
|
||||
.NameFile = If(Request.OptiFineVersion.ContainsF("pre", True), "preview_", "") &
|
||||
"OptiFine_" & Request.MinecraftName & "_" & Request.OptiFineVersion & ".jar"
|
||||
}
|
||||
End If
|
||||
@@ -2012,7 +2014,7 @@ Retry:
|
||||
|
||||
Dim LoaderList As New List(Of LoaderBase)
|
||||
'添加忽略标识
|
||||
LoaderList.Add(New LoaderTask(Of Integer, Integer)("添加忽略标识", Sub() WriteFile(OutputFolder & ".pclignore", "该文件会使得该文件夹不在 PCL 的版本列表中显示")) With {.Show = False, .Block = False})
|
||||
LoaderList.Add(New LoaderTask(Of Integer, Integer)("添加忽略标识", Sub() WriteFile(OutputFolder & ".pclignore", "用于临时地 PCL 的版本列表中屏蔽此版本。")) With {.Show = False, .Block = False})
|
||||
'Fabric API
|
||||
If Request.FabricApi IsNot Nothing Then
|
||||
LoaderList.Add(New LoaderDownload("下载 Fabric API", New List(Of NetFile) From {Request.FabricApi.ToNetFile(New McVersion(OutputFolder).GetPathIndie(True) & "mods\")}) With {.ProgressWeight = 3, .Block = False})
|
||||
@@ -2083,36 +2085,36 @@ Retry:
|
||||
Dim OutputJsonPath As String, MinecraftJsonPath As String, OptiFineJsonPath As String = Nothing, ForgeJsonPath As String = Nothing, LiteLoaderJsonPath As String = Nothing, FabricJsonPath As String = Nothing
|
||||
Dim OutputJar As String, MinecraftJar As String
|
||||
#Region "初始化路径信息"
|
||||
If Not OutputFolder.EndsWith("\") Then OutputFolder += "\"
|
||||
If Not OutputFolder.EndsWithF("\") Then OutputFolder += "\"
|
||||
OutputName = GetFolderNameFromPath(OutputFolder)
|
||||
OutputJsonPath = OutputFolder & OutputName & ".json"
|
||||
OutputJar = OutputFolder & OutputName & ".jar"
|
||||
|
||||
If Not MinecraftFolder.EndsWith("\") Then MinecraftFolder += "\"
|
||||
If Not MinecraftFolder.EndsWithF("\") Then MinecraftFolder += "\"
|
||||
MinecraftName = GetFolderNameFromPath(MinecraftFolder)
|
||||
MinecraftJsonPath = MinecraftFolder & MinecraftName & ".json"
|
||||
MinecraftJar = MinecraftFolder & MinecraftName & ".jar"
|
||||
|
||||
If HasOptiFine Then
|
||||
If Not OptiFineFolder.EndsWith("\") Then OptiFineFolder += "\"
|
||||
If Not OptiFineFolder.EndsWithF("\") Then OptiFineFolder += "\"
|
||||
OptiFineName = GetFolderNameFromPath(OptiFineFolder)
|
||||
OptiFineJsonPath = OptiFineFolder & OptiFineName & ".json"
|
||||
End If
|
||||
|
||||
If HasForge Then
|
||||
If Not ForgeFolder.EndsWith("\") Then ForgeFolder += "\"
|
||||
If Not ForgeFolder.EndsWithF("\") Then ForgeFolder += "\"
|
||||
ForgeName = GetFolderNameFromPath(ForgeFolder)
|
||||
ForgeJsonPath = ForgeFolder & ForgeName & ".json"
|
||||
End If
|
||||
|
||||
If HasLiteLoader Then
|
||||
If Not LiteLoaderFolder.EndsWith("\") Then LiteLoaderFolder += "\"
|
||||
If Not LiteLoaderFolder.EndsWithF("\") Then LiteLoaderFolder += "\"
|
||||
LiteLoaderName = GetFolderNameFromPath(LiteLoaderFolder)
|
||||
LiteLoaderJsonPath = LiteLoaderFolder & LiteLoaderName & ".json"
|
||||
End If
|
||||
|
||||
If HasFabric Then
|
||||
If Not FabricFolder.EndsWith("\") Then FabricFolder += "\"
|
||||
If Not FabricFolder.EndsWithF("\") Then FabricFolder += "\"
|
||||
FabricName = GetFolderNameFromPath(FabricFolder)
|
||||
FabricJsonPath = FabricFolder & FabricName & ".json"
|
||||
End If
|
||||
@@ -2121,30 +2123,30 @@ Retry:
|
||||
Dim OutputJson As JObject, MinecraftJson As JObject, OptiFineJson As JObject = Nothing, ForgeJson As JObject = Nothing, LiteLoaderJson As JObject = Nothing, FabricJson As JObject = Nothing
|
||||
#Region "读取文件并检查文件是否合规"
|
||||
Dim MinecraftJsonText As String = ReadFile(MinecraftJsonPath)
|
||||
If Not MinecraftJsonText.StartsWith("{") Then Throw New Exception("Minecraft json 有误,地址:" & MinecraftJsonPath & ",前段内容:" & MinecraftJsonText.Substring(0, Math.Min(MinecraftJsonText.Length, 1000)))
|
||||
If Not MinecraftJsonText.StartsWithF("{") Then Throw New Exception("Minecraft json 有误,地址:" & MinecraftJsonPath & ",前段内容:" & MinecraftJsonText.Substring(0, Math.Min(MinecraftJsonText.Length, 1000)))
|
||||
MinecraftJson = GetJson(MinecraftJsonText)
|
||||
|
||||
If HasOptiFine Then
|
||||
Dim OptiFineJsonText As String = ReadFile(OptiFineJsonPath)
|
||||
If Not OptiFineJsonText.StartsWith("{") Then Throw New Exception("OptiFine json 有误,地址:" & OptiFineJsonPath & ",前段内容:" & OptiFineJsonText.Substring(0, Math.Min(OptiFineJsonText.Length, 1000)))
|
||||
If Not OptiFineJsonText.StartsWithF("{") Then Throw New Exception("OptiFine json 有误,地址:" & OptiFineJsonPath & ",前段内容:" & OptiFineJsonText.Substring(0, Math.Min(OptiFineJsonText.Length, 1000)))
|
||||
OptiFineJson = GetJson(OptiFineJsonText)
|
||||
End If
|
||||
|
||||
If HasForge Then
|
||||
Dim ForgeJsonText As String = ReadFile(ForgeJsonPath)
|
||||
If Not ForgeJsonText.StartsWith("{") Then Throw New Exception("Forge json 有误,地址:" & ForgeJsonPath & ",前段内容:" & ForgeJsonText.Substring(0, Math.Min(ForgeJsonText.Length, 1000)))
|
||||
If Not ForgeJsonText.StartsWithF("{") Then Throw New Exception("Forge json 有误,地址:" & ForgeJsonPath & ",前段内容:" & ForgeJsonText.Substring(0, Math.Min(ForgeJsonText.Length, 1000)))
|
||||
ForgeJson = GetJson(ForgeJsonText)
|
||||
End If
|
||||
|
||||
If HasLiteLoader Then
|
||||
Dim LiteLoaderJsonText As String = ReadFile(LiteLoaderJsonPath)
|
||||
If Not LiteLoaderJsonText.StartsWith("{") Then Throw New Exception("LiteLoader json 有误,地址:" & LiteLoaderJsonPath & ",前段内容:" & LiteLoaderJsonText.Substring(0, Math.Min(LiteLoaderJsonText.Length, 1000)))
|
||||
If Not LiteLoaderJsonText.StartsWithF("{") Then Throw New Exception("LiteLoader json 有误,地址:" & LiteLoaderJsonPath & ",前段内容:" & LiteLoaderJsonText.Substring(0, Math.Min(LiteLoaderJsonText.Length, 1000)))
|
||||
LiteLoaderJson = GetJson(LiteLoaderJsonText)
|
||||
End If
|
||||
|
||||
If HasFabric Then
|
||||
Dim FabricJsonText As String = ReadFile(FabricJsonPath)
|
||||
If Not FabricJsonText.StartsWith("{") Then Throw New Exception("Fabric json 有误,地址:" & FabricJsonPath & ",前段内容:" & FabricJsonText.Substring(0, Math.Min(FabricJsonText.Length, 1000)))
|
||||
If Not FabricJsonText.StartsWithF("{") Then Throw New Exception("Fabric json 有误,地址:" & FabricJsonPath & ",前段内容:" & FabricJsonText.Substring(0, Math.Min(FabricJsonText.Length, 1000)))
|
||||
FabricJson = GetJson(FabricJsonText)
|
||||
End If
|
||||
#End Region
|
||||
@@ -2160,9 +2162,9 @@ Retry:
|
||||
Dim RawArguments As List(Of String) = AllArguments.Split(" ").Where(Function(l) l <> "").Select(Function(l) l.Trim).ToList
|
||||
Dim SplitArguments As New List(Of String)
|
||||
For i = 0 To RawArguments.Count - 1
|
||||
If RawArguments(i).StartsWith("-") Then
|
||||
If RawArguments(i).StartsWithF("-") Then
|
||||
SplitArguments.Add(RawArguments(i))
|
||||
ElseIf SplitArguments.Count > 0 AndAlso SplitArguments.Last.StartsWith("-") AndAlso Not SplitArguments.Last.Contains(" ") Then
|
||||
ElseIf SplitArguments.Count > 0 AndAlso SplitArguments.Last.StartsWithF("-") AndAlso Not SplitArguments.Last.Contains(" ") Then
|
||||
SplitArguments(SplitArguments.Count - 1) = SplitArguments.Last & " " & RawArguments(i)
|
||||
Else
|
||||
SplitArguments.Add(RawArguments(i))
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
PanMain.Children.Add(CardInfo)
|
||||
'添加其他版本
|
||||
For Each Pair As KeyValuePair(Of String, List(Of JObject)) In Dict
|
||||
If Pair.Value.Count = 0 Then Continue For
|
||||
If Not Pair.Value.Any() Then Continue For
|
||||
'增加卡片
|
||||
Dim NewCard As New MyCard With {.Title = Pair.Key & " (" & Pair.Value.Count & ")", .Margin = New Thickness(0, 0, 0, 15), .SwapType = 2}
|
||||
Dim NewStack As New StackPanel With {.Margin = New Thickness(20, MyCard.SwapedHeight, 18, 0), .VerticalAlignment = VerticalAlignment.Top, .RenderTransform = New TranslateTransform(0, 0), .Tag = Pair.Value}
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
PanMain.Children.Clear()
|
||||
'转化为 UI
|
||||
For Each Pair As KeyValuePair(Of String, List(Of CompFile)) In Dict
|
||||
If Pair.Value.Count = 0 Then Continue For
|
||||
If Not Pair.Value.Any() Then Continue For
|
||||
'增加卡片
|
||||
Dim NewCard As New MyCard With {.Title = Pair.Key, .Margin = New Thickness(0, 0, 0, 15), .SwapType = If(Project.Type = CompType.ModPack, 9, 8)} 'FUTURE: Res
|
||||
Dim NewStack As New StackPanel With {.Margin = New Thickness(20, MyCard.SwapedHeight, 18, 0), .VerticalAlignment = VerticalAlignment.Top, .RenderTransform = New TranslateTransform(0, 0), .Tag = Pair.Value}
|
||||
@@ -252,7 +252,7 @@
|
||||
For Each Version As McVersion In McVersionList.Values.SelectMany(Function(l) l)
|
||||
If IsVersionSuitable(Version) Then SuitableVersions.Add(Version)
|
||||
Next
|
||||
If SuitableVersions.Count = 0 Then
|
||||
If Not SuitableVersions.Any() Then
|
||||
DefaultFolder = PathMcFolder
|
||||
If NeedLoad Then
|
||||
Hint("当前 MC 文件夹中没有找到适合这个 Mod 的版本!")
|
||||
|
||||
@@ -562,7 +562,7 @@
|
||||
PanMinecraft.Children.Insert(0, CardInfo)
|
||||
'添加其他版本
|
||||
For Each Pair As KeyValuePair(Of String, List(Of JObject)) In Dict
|
||||
If Pair.Value.Count = 0 Then Continue For
|
||||
If Not Pair.Value.Any() Then Continue For
|
||||
'增加卡片
|
||||
Dim NewCard As New MyCard With {.Title = Pair.Key & " (" & Pair.Value.Count & ")", .Margin = New Thickness(0, 0, 0, 15), .SwapType = 7}
|
||||
Dim NewStack As New StackPanel With {.Margin = New Thickness(20, MyCard.SwapedHeight, 18, 0), .VerticalAlignment = VerticalAlignment.Top, .RenderTransform = New TranslateTransform(0, 0), .Tag = Pair.Value}
|
||||
@@ -656,7 +656,7 @@
|
||||
If SelectedForge IsNot Nothing AndAlso Not IsOptiFineSuitForForge(Version, SelectedForge) Then Continue For
|
||||
If Version.NameDisplay.StartsWith(SelectedMinecraftId & " ") Then Versions.Add(Version)
|
||||
Next
|
||||
If Versions.Count = 0 Then Exit Sub
|
||||
If Not Versions.Any() Then Exit Sub
|
||||
'排序
|
||||
Versions = Sort(Versions, Function(Left As DlOptiFineListEntry, Right As DlOptiFineListEntry) As Boolean
|
||||
If Not Left.IsPreview AndAlso Right.IsPreview Then Return True
|
||||
@@ -724,7 +724,7 @@
|
||||
For Each Version As DlLiteLoaderListEntry In DlLiteLoaderListLoader.Output.Value
|
||||
If Version.Inherit = SelectedMinecraftId Then Versions.Add(Version)
|
||||
Next
|
||||
If Versions.Count = 0 Then Exit Sub
|
||||
If Not Versions.Any() Then Exit Sub
|
||||
'可视化
|
||||
PanLiteLoader.Children.Clear()
|
||||
For Each Version In Versions
|
||||
@@ -804,7 +804,7 @@
|
||||
'获取要显示的版本
|
||||
Dim Versions As New List(Of DlForgeVersionEntry)
|
||||
Versions.AddRange(Loader.Output) '复制数组,以免 Output 在实例化后变空
|
||||
If Loader.Output.Count = 0 Then Exit Sub
|
||||
If Not Loader.Output.Any() Then Exit Sub
|
||||
PanForge.Children.Clear()
|
||||
Versions = Sort(Versions, Function(a, b) New Version(a.Version) > New Version(b.Version)).
|
||||
Where(Function(v)
|
||||
@@ -870,7 +870,7 @@
|
||||
If DlFabricListLoader.State <> LoadState.Finished Then Exit Sub
|
||||
'获取版本列表
|
||||
Dim Versions As JArray = DlFabricListLoader.Output.Value("loader")
|
||||
If Versions.Count = 0 Then Exit Sub
|
||||
If Not Versions.Any() Then Exit Sub
|
||||
'可视化
|
||||
PanFabric.Children.Clear()
|
||||
PanFabric.Tag = Versions
|
||||
@@ -983,7 +983,7 @@
|
||||
Versions.Add(Version)
|
||||
End If
|
||||
Next
|
||||
If Versions.Count = 0 Then Exit Sub
|
||||
If Not Versions.Any() Then Exit Sub
|
||||
Versions = Sort(Versions, Function(a, b) a.ReleaseDate > b.ReleaseDate)
|
||||
'可视化
|
||||
PanFabricApi.Children.Clear()
|
||||
@@ -1073,7 +1073,7 @@
|
||||
For Each Version In DlOptiFabricLoader.Output
|
||||
If IsSuitableOptiFabric(Version, SelectedMinecraftId) Then Versions.Add(Version)
|
||||
Next
|
||||
If Versions.Count = 0 Then Exit Sub
|
||||
If Not Versions.Any() Then Exit Sub
|
||||
'排序
|
||||
Versions = Sort(Versions, Function(a, b) a.ReleaseDate > b.ReleaseDate)
|
||||
'可视化
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
PanMain.Children.Clear()
|
||||
'转化为 UI
|
||||
For Each Pair As KeyValuePair(Of String, List(Of DlLiteLoaderListEntry)) In Dict
|
||||
If Pair.Value.Count = 0 Then Continue For
|
||||
If Not Pair.Value.Any() Then Continue For
|
||||
'增加卡片
|
||||
Dim NewCard As New MyCard With {.Title = Pair.Key & " (" & Pair.Value.Count & ")", .Margin = New Thickness(0, 0, 0, 15), .SwapType = 10}
|
||||
Dim NewStack As New StackPanel With {.Margin = New Thickness(20, MyCard.SwapedHeight, 18, 0), .VerticalAlignment = VerticalAlignment.Top, .RenderTransform = New TranslateTransform(0, 0), .Tag = Pair.Value}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
PanMain.Children.Clear()
|
||||
'转化为 UI
|
||||
For Each Pair As KeyValuePair(Of String, List(Of DlOptiFineListEntry)) In Dict
|
||||
If Pair.Value.Count = 0 Then Continue For
|
||||
If Not Pair.Value.Any() Then Continue For
|
||||
'增加卡片
|
||||
Dim NewCard As New MyCard With {.Title = Pair.Key & " (" & Pair.Value.Count & ")", .Margin = New Thickness(0, 0, 0, 15), .SwapType = 3}
|
||||
Dim NewStack As New StackPanel With {.Margin = New Thickness(20, MyCard.SwapedHeight, 18, 0), .VerticalAlignment = VerticalAlignment.Top, .RenderTransform = New TranslateTransform(0, 0), .Tag = Pair.Value}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
'无效的版本
|
||||
Log("[Launch] Minecraft 版本无效" & If(IsNothing(Version), ",没有有效版本", ":" & Version.Path), If(IsNothing(Version), LogLevel.Normal, LogLevel.Debug))
|
||||
If Not McVersionListLoader.State = LoadState.Finished Then LoaderFolderRun(McVersionListLoader, PathMcFolder, LoaderFolderRunType.ForceRun, MaxDepth:=1, ExtraPath:="versions\", WaitForExit:=True)
|
||||
If McVersionList.Count = 0 OrElse McVersionList.First.Value(0).Logo.Contains("RedstoneBlock") Then
|
||||
If Not McVersionList.Any() OrElse McVersionList.First.Value(0).Logo.Contains("RedstoneBlock") Then
|
||||
Version = Nothing
|
||||
Setup.Set("LaunchVersionSelect", "")
|
||||
Log("[Launch] 无可用 Minecraft 版本")
|
||||
|
||||
@@ -258,7 +258,7 @@ Public Class PageLinkIoi
|
||||
Public Function GetDescription() As String
|
||||
Return If(Progress < 1,
|
||||
"正在连接," & Math.Round(Progress * 100) & "%",
|
||||
"已连接," & If(PingRecord.Count = 0, "检查延迟中", Math.Round(PingRecord.Average) & "ms"))
|
||||
"已连接," & If(Not PingRecord.Any(), "检查延迟中", Math.Round(PingRecord.Average) & "ms"))
|
||||
End Function
|
||||
Public Function ToListItem() As MyListItem
|
||||
Dim Item As New MyListItem With {
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
'进行搜索,构造列表
|
||||
Dim SearchResult = Search(QueryList, SearchBox.Text, MaxBlurCount:=5, MinBlurSimilarity:=0.08)
|
||||
PanSearchList.Children.Clear()
|
||||
If SearchResult.Count = 0 Then
|
||||
If Not SearchResult.Any() Then
|
||||
PanSearch.Title = "无搜索结果"
|
||||
PanSearchList.Visibility = Visibility.Collapsed
|
||||
Else
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
Exit Sub
|
||||
End If
|
||||
Next
|
||||
If McFolderList.Count = 0 Then
|
||||
If Not McFolderList.Any() Then
|
||||
Throw New ArgumentNullException("没有可用的 Minecraft 文件夹")
|
||||
Else
|
||||
Setup.Set("LaunchFolderSelect", McFolderList(0).Path.Replace(Path, "$"))
|
||||
@@ -301,7 +301,7 @@
|
||||
End If
|
||||
Next
|
||||
'保存
|
||||
Setup.Set("LaunchFolders", If(Folders.Count = 0, "", Join(Folders.ToArray, "|")))
|
||||
Setup.Set("LaunchFolders", If(Not Folders.Any(), "", Join(Folders.ToArray, "|")))
|
||||
Hint(If(Folder.Type = McFolderType.Custom, "文件夹 " & Name & " 已从列表中移除!", "文件夹名称已复原!"), HintType.Finish)
|
||||
McFolderListLoader.Start(IsForceRestart:=True)
|
||||
|
||||
@@ -325,7 +325,7 @@
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Setup.Set("LaunchFolders", If(Folders.Count = 0, "", Join(Folders.ToArray, "|")))
|
||||
Setup.Set("LaunchFolders", If(Not Folders.Any(), "", Join(Folders.ToArray, "|")))
|
||||
End If
|
||||
RunInNewThread(Sub()
|
||||
'删除文件夹
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Text="JVM 参数头" Margin="0,0,25,0" />
|
||||
<local:MyTextBox x:Name="TextAdvanceJvm" Grid.Row="0" Grid.ColumnSpan="2" Tag="LaunchAdvanceJvm" Grid.Column="1" ToolTip="启动 Minecraft 时使用的额外 JVM 参数,在没有确定把握的情况下请不要尝试修改。
你可以通过点击左侧选项卡的初始化按钮来恢复到默认设置。" Text="-XX:+UseG1GC -XX:-UseAdaptiveSizePolicy -XX:-OmitStackTraceInFastThrow -Dfml.ignoreInvalidMinecraftCertificates=True -Dfml.ignorePatchDiscrepancies=True -Dlog4j2.formatMsgNoLookups=true"
|
||||
<local:MyTextBox x:Name="TextAdvanceJvm" Grid.Row="0" Grid.ColumnSpan="2" Tag="LaunchAdvanceJvm" Grid.Column="1" ToolTip="启动 Minecraft 时使用的额外 JVM 参数,在没有确定把握的情况下请不要尝试修改。
你可以通过点击左侧选项卡的初始化按钮来恢复到默认设置。" MaxLength="4000" Text="-XX:+UseG1GC -XX:-UseAdaptiveSizePolicy -XX:-OmitStackTraceInFastThrow -Dfml.ignoreInvalidMinecraftCertificates=True -Dfml.ignorePatchDiscrepancies=True -Dlog4j2.formatMsgNoLookups=true"
|
||||
Height="57" AcceptsReturn="True" TextWrapping="Wrap" VerticalContentAlignment="Top" Padding="0,5" />
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="JVM 参数尾" Margin="0,0,25,0" />
|
||||
<local:MyTextBox x:Name="TextAdvanceGame" Grid.Row="2" Grid.ColumnSpan="2" Tag="LaunchAdvanceGame" Grid.Column="1" ToolTip="文本框中的内容将会被直接拼合在启动参数的末尾。
例如输入 --demo 则会以试玩模式启动游戏。" />
|
||||
|
||||
@@ -518,7 +518,7 @@ PreFin:
|
||||
RunInThread(Sub()
|
||||
Hint("正在搜索 Java!")
|
||||
JavaSearchLoader.WaitForExit(IsForceRestart:=True)
|
||||
If JavaList.Count = 0 Then
|
||||
If Not JavaList.Any() Then
|
||||
Hint("未找到可用的 Java!", HintType.Critical)
|
||||
Else
|
||||
Hint("已找到 " & JavaList.Count & " 个 Java,请检查下拉框查看列表!", HintType.Finish)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
Try
|
||||
|
||||
#Region "更新左边栏"
|
||||
If LoaderTaskbar.Count = 0 Then
|
||||
If Not LoaderTaskbar.Any() Then
|
||||
'无任务
|
||||
LabProgress.Text = "100 %"
|
||||
LabSpeed.Text = "0 B/s"
|
||||
@@ -214,13 +214,14 @@
|
||||
End Sub
|
||||
Public Sub TaskRemove(Loader As Object)
|
||||
If RightCards.ContainsKey(Loader.Name) Then
|
||||
RunInUiWait(Sub()
|
||||
'移除已有的卡片
|
||||
Dim Card As Grid = RightCards(Loader.Name)
|
||||
FrmSpeedRight.PanMain.Children.Remove(Card)
|
||||
RightCards.Remove(Loader.Name)
|
||||
Log($"[Watcher] 移除下载管理卡片:{Loader.Name}")
|
||||
End Sub)
|
||||
RunInUiWait(
|
||||
Sub()
|
||||
'移除已有的卡片
|
||||
Dim Card As Grid = RightCards(Loader.Name)
|
||||
FrmSpeedRight.PanMain.Children.Remove(Card)
|
||||
RightCards.Remove(Loader.Name)
|
||||
Log($"[Watcher] 移除下载管理卡片:{Loader.Name}")
|
||||
End Sub)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
</local:MyCard.RenderTransform>
|
||||
<TextBlock x:Name="LabSelect" Text="已选择 8 个文件" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="9" Foreground="{DynamicResource ColorBrush2}" />
|
||||
<StackPanel Orientation="Horizontal" Margin="5,28,5,5">
|
||||
<local:MyIconTextButton x:Name="BtnSelectUpdate" Text="更新"
|
||||
LogoScale="1" Logo="M640 768H384l-32-32V509H213L190 454l298-298h45l298 298L810 509h-138v226z m-224-64h192V477l32-32h93L512 223 290 445H384l32 32zM352 831h320v64h-320z" />
|
||||
<local:MyIconTextButton x:Name="BtnSelectEnable" Text="启用"
|
||||
LogoScale="1.05" Logo="M512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m0 921.6a409.6 409.6 0 1 1 409.6-409.6 409.6 409.6 0 0 1-409.6 409.6z M716.8 339.968l-256 253.44L328.192 460.8A51.2 51.2 0 0 0 256 532.992l168.448 168.96a51.2 51.2 0 0 0 72.704 0l289.28-289.792A51.2 51.2 0 0 0 716.8 339.968z" />
|
||||
<local:MyIconTextButton x:Name="BtnSelectDisable" Text="禁用"
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
Imports System.Security.Principal
|
||||
|
||||
Public Class PageVersionMod
|
||||
Public Class PageVersionMod
|
||||
|
||||
#Region "初始化"
|
||||
|
||||
@@ -27,7 +25,6 @@ Public Class PageVersionMod
|
||||
''' 刷新 Mod 列表。
|
||||
''' </summary>
|
||||
Public Sub RefreshList(Optional ForceReload As Boolean = False)
|
||||
If McModLoader.State = LoadState.Loading Then Exit Sub
|
||||
If LoaderFolderRun(McModLoader, PageVersionLeft.Version.PathIndie & "mods\", If(ForceReload, LoaderFolderRunType.ForceRun, LoaderFolderRunType.RunOnUpdated)) Then
|
||||
Log("[System] 已刷新 Mod 列表")
|
||||
PanBack.ScrollToHome()
|
||||
@@ -82,7 +79,7 @@ Public Class PageVersionMod
|
||||
AniControlEnabled += 1
|
||||
Dim NewItem As New MyLocalModItem With {.SnapsToDevicePixels = True, .Entry = Entry,
|
||||
.ButtonHandler = AddressOf McModContent, .Checked = SelectedMods.Contains(Entry.RawFileName)}
|
||||
AddHandler Entry.OnGetCompProject, AddressOf NewItem.Refresh
|
||||
AddHandler Entry.OnCompUpdate, AddressOf NewItem.Refresh
|
||||
NewItem.Refresh()
|
||||
AniControlEnabled -= 1
|
||||
Return NewItem
|
||||
@@ -104,17 +101,14 @@ Public Class PageVersionMod
|
||||
ToolTipService.SetVerticalOffset(BtnCont, 30)
|
||||
ToolTipService.SetHorizontalOffset(BtnCont, 2)
|
||||
AddHandler BtnCont.Click, AddressOf Info_Click
|
||||
AddHandler sender.MouseRightButtonDown, AddressOf Info_Click
|
||||
AddHandler sender.MouseRightButtonUp, AddressOf Info_Click
|
||||
Dim BtnDelete As New MyIconButton With {.LogoScale = 1, .Logo = Logo.IconButtonDelete, .Tag = sender}
|
||||
BtnDelete.ToolTip = "删除"
|
||||
ToolTipService.SetPlacement(BtnDelete, Primitives.PlacementMode.Center)
|
||||
ToolTipService.SetVerticalOffset(BtnDelete, 30)
|
||||
ToolTipService.SetHorizontalOffset(BtnDelete, 2)
|
||||
AddHandler BtnDelete.Click, AddressOf Delete_Click
|
||||
Dim BtnED As New MyIconButton With {.LogoScale = 1, .Logo = If(sender.Entry.State = McMod.McModState.Fine,
|
||||
"M508 990.4c-261.6 0-474.4-212-474.4-474.4S246.4 41.6 508 41.6s474.4 212 474.4 474.4S769.6 990.4 508 990.4zM508 136.8c-209.6 0-379.2 169.6-379.2 379.2 0 209.6 169.6 379.2 379.2 379.2s379.2-169.6 379.2-379.2C887.2 306.4 717.6 136.8 508 136.8zM697.6 563.2 318.4 563.2c-26.4 0-47.2-21.6-47.2-47.2 0-26.4 21.6-47.2 47.2-47.2l379.2 0c26.4 0 47.2 21.6 47.2 47.2C744.8 542.4 724 563.2 697.6 563.2z",
|
||||
"M512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m0 921.6a409.6 409.6 0 1 1 409.6-409.6 409.6 409.6 0 0 1-409.6 409.6z M716.8 339.968l-256 253.44L328.192 460.8A51.2 51.2 0 0 0 256 532.992l168.448 168.96a51.2 51.2 0 0 0 72.704 0l289.28-289.792A51.2 51.2 0 0 0 716.8 339.968z"),
|
||||
.Tag = sender}
|
||||
Dim BtnED As New MyIconButton With {.LogoScale = 1, .Logo = If(sender.Entry.State = McMod.McModState.Fine, Logo.IconButtonStop, Logo.IconButtonCheck), .Tag = sender}
|
||||
BtnED.ToolTip = If(sender.Entry.State = McMod.McModState.Fine, "禁用", "启用")
|
||||
ToolTipService.SetPlacement(BtnED, Primitives.PlacementMode.Center)
|
||||
ToolTipService.SetVerticalOffset(BtnED, 30)
|
||||
@@ -242,10 +236,12 @@ Public Class PageVersionMod
|
||||
If Selected Then LabSelect.Text = $"已选择 {NewCount} 个文件" '取消所有选择时不更新数字
|
||||
'按钮可用性
|
||||
If Selected Then
|
||||
Dim HasUpdate As Boolean = False
|
||||
Dim HasEnabled As Boolean = False
|
||||
Dim HasDisabled As Boolean = False
|
||||
For Each ModEntity In McModLoader.Output
|
||||
If SelectedMods.Contains(ModEntity.RawFileName) Then
|
||||
If ModEntity.CanUpdate Then HasUpdate = True
|
||||
If ModEntity.State = McMod.McModState.Fine Then
|
||||
HasEnabled = True
|
||||
ElseIf ModEntity.State = McMod.McModState.Disabled Then
|
||||
@@ -255,9 +251,9 @@ Public Class PageVersionMod
|
||||
Next
|
||||
BtnSelectDisable.IsEnabled = HasEnabled
|
||||
BtnSelectEnable.IsEnabled = HasDisabled
|
||||
BtnSelectUpdate.IsEnabled = HasUpdate
|
||||
End If
|
||||
'更新显示状态
|
||||
CardSelect.IsHitTestVisible = Selected
|
||||
If AniControlEnabled = 0 Then
|
||||
If Selected Then
|
||||
'仅在数量增加时播放出现/跳跃动画
|
||||
@@ -374,7 +370,7 @@ Public Class PageVersionMod
|
||||
End Try
|
||||
'更改 Loader 中的列表
|
||||
Dim NewModEntity As New McMod(NewPath)
|
||||
NewModEntity.Comp = ModEntity.Comp
|
||||
NewModEntity.FromJson(ModEntity.ToJson)
|
||||
Dim IndexOfLoader As Integer = McModLoader.Output.IndexOf(ModEntity)
|
||||
McModLoader.Output.RemoveAt(IndexOfLoader)
|
||||
McModLoader.Output.Insert(IndexOfLoader, NewModEntity)
|
||||
@@ -395,10 +391,128 @@ Public Class PageVersionMod
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'更新
|
||||
Private Sub BtnSelectUpdate_Click() Handles BtnSelectUpdate.Click
|
||||
UpdateMods(McModLoader.Output.Where(Function(m) SelectedMods.Contains(m.RawFileName) AndAlso m.CanUpdate))
|
||||
End Sub
|
||||
''' <summary>
|
||||
''' 记录正在进行 Mod 更新的 mods 文件夹路径。
|
||||
''' </summary>
|
||||
Public Shared UpdatingVersions As New List(Of String)
|
||||
Public Sub UpdateMods(ModList As IEnumerable(Of McMod))
|
||||
'更新前警告
|
||||
If Not Setup.Get("HintUpdateMod") Then
|
||||
If MyMsgBox($"新版本 Mod 可能不兼容老版本的存档或者其他 Mod,这可能导致游戏崩溃,甚至存档损坏!{vbCrLf}除非整合包作者要求你更新,否则不要私自更新整合包里的 Mod!{vbCrLf}在更新 Mod 前,请先备份存档,并检查它的更新日志!{vbCrLf}更新时,老版本的 Mod 会被移动到回收站,以防万一。{vbCrLf}{vbCrLf}请在认真阅读上述警告后再继续!", "Mod 更新警告", "我已了解上述风险,继续更新", "取消", IsWarn:=True) = 1 Then
|
||||
Setup.Set("HintUpdateMod", True)
|
||||
Else
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
Try
|
||||
'构造下载信息
|
||||
ModList = ModList.ToList() '防止刷新影响迭代器
|
||||
Dim FileList As New List(Of NetFile)
|
||||
Dim FileCopyList As New Dictionary(Of String, String)
|
||||
For Each Entry As McMod In ModList
|
||||
Dim File As CompFile = Entry.UpdateFile
|
||||
If Not File.Available Then Continue For
|
||||
'确认更新后的文件名
|
||||
Dim CurrentReplaceName = Entry.CompFile.FileName.Replace(".jar", "").Replace(".old", "").Replace(".disabled", "")
|
||||
Dim NewestReplaceName = Entry.UpdateFile.FileName.Replace(".jar", "").Replace(".old", "").Replace(".disabled", "")
|
||||
Dim CurrentSegs = CurrentReplaceName.Split("-"c).ToList()
|
||||
Dim NewestSegs = NewestReplaceName.Split("-"c).ToList()
|
||||
Dim Shortened As Boolean = False
|
||||
For Each Seg In CurrentSegs.ToList()
|
||||
If Not NewestSegs.Contains(Seg) Then Continue For
|
||||
CurrentSegs.Remove(Seg)
|
||||
NewestSegs.Remove(Seg)
|
||||
Shortened = True
|
||||
Next
|
||||
If Shortened AndAlso CurrentSegs.Any() AndAlso NewestSegs.Any() Then
|
||||
CurrentReplaceName = Join(CurrentSegs, "-")
|
||||
NewestReplaceName = Join(NewestSegs, "-")
|
||||
End If
|
||||
'添加到下载列表
|
||||
Dim TempAddress As String = PathTemp & "DownloadedMods\" & Entry.FileName.Replace(CurrentReplaceName, NewestReplaceName)
|
||||
Dim RealAddress As String = GetPathFromFullPath(Entry.Path) & Entry.FileName.Replace(CurrentReplaceName, NewestReplaceName)
|
||||
FileList.Add(File.ToNetFile(TempAddress))
|
||||
FileCopyList(TempAddress) = RealAddress
|
||||
Next
|
||||
'构造加载器
|
||||
Dim InstallLoaders As New List(Of LoaderBase)
|
||||
Dim FinishedFileNames As New List(Of String)
|
||||
InstallLoaders.Add(New LoaderDownload("下载新版 Mod 文件", FileList) With {.ProgressWeight = ModList.Count * 1.5}) '每个 Mod 需要 1.5s
|
||||
InstallLoaders.Add(New LoaderTask(Of Integer, Integer)("替换旧版 Mod 文件",
|
||||
Sub()
|
||||
Try
|
||||
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}", LogLevel.Debug)
|
||||
End If
|
||||
If Directory.Exists(GetPathFromFullPath(Entry.Value)) Then
|
||||
File.Move(Entry.Key, Entry.Value)
|
||||
FinishedFileNames.Add(GetFileNameFromPath(Entry.Value))
|
||||
Else
|
||||
Log($"[Mod] 更新后的目标文件夹已被删除:{Entry.Value}", LogLevel.Debug)
|
||||
End If
|
||||
Next
|
||||
For Each Entry As McMod In ModList
|
||||
If File.Exists(Entry.Path) Then
|
||||
My.Computer.FileSystem.DeleteFile(Entry.Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin)
|
||||
Else
|
||||
Log($"[Mod] 未找到更新前的 Mod 文件,跳过对它的删除:{Entry.Path}", LogLevel.Debug)
|
||||
End If
|
||||
Next
|
||||
Catch ex As OperationCanceledException
|
||||
Log(ex, "替换旧版 Mod 文件时被主动取消")
|
||||
End Try
|
||||
End Sub))
|
||||
'结束处理
|
||||
Dim Loader As New LoaderCombo(Of IEnumerable(Of McMod))("Mod 更新:" & PageVersionLeft.Version.Name, InstallLoaders)
|
||||
Dim PathMods As String = PageVersionLeft.Version.PathIndie & "mods\"
|
||||
Loader.OnStateChanged =
|
||||
Sub()
|
||||
'结果提示
|
||||
Select Case Loader.State
|
||||
Case LoadState.Finished
|
||||
Hint(If(FinishedFileNames.Count > 1, $"已成功更新 {FinishedFileNames.Count} 个 Mod!", $"已成功更新:{FinishedFileNames.Single}"), HintType.Finish)
|
||||
Case LoadState.Failed
|
||||
Hint("Mod 更新失败:" & GetExceptionSummary(Loader.Error), HintType.Critical)
|
||||
Case LoadState.Aborted
|
||||
Hint("Mod 更新已中止!", HintType.Info)
|
||||
Case Else
|
||||
Exit Sub
|
||||
End Select
|
||||
UpdatingVersions.Remove(PathMods)
|
||||
'清理缓存
|
||||
RunInNewThread(
|
||||
Sub()
|
||||
Try
|
||||
For Each TempFile In FileCopyList.Keys
|
||||
If File.Exists(TempFile) Then File.Delete(TempFile)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Log(ex, "清理 Mod 更新缓存失败")
|
||||
End Try
|
||||
End Sub, "Clean Mod Update Cache", ThreadPriority.BelowNormal)
|
||||
End Sub
|
||||
'启动加载器
|
||||
Log($"[Mod] 开始更新 {ModList.Count} 个 Mod")
|
||||
UpdatingVersions.Add(PathMods)
|
||||
Loader.Start()
|
||||
LoaderTaskbarAdd(Loader)
|
||||
FrmMain.BtnExtraDownload.ShowRefresh()
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
RefreshList(True)
|
||||
Catch ex As Exception
|
||||
Log(ex, "初始化 Mod 更新失败")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'删除
|
||||
Private Sub BtnSelectDelete_Click() Handles BtnSelectDelete.Click
|
||||
Dim DeleteList As List(Of McMod) = McModLoader.Output.Where(Function(m) SelectedMods.Contains(m.RawFileName)).ToList()
|
||||
DeleteMods(DeleteList)
|
||||
DeleteMods(McModLoader.Output.Where(Function(m) SelectedMods.Contains(m.RawFileName)))
|
||||
End Sub
|
||||
Private Sub DeleteMods(ModList As IEnumerable(Of McMod))
|
||||
Try
|
||||
|
||||
@@ -191,7 +191,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Text="JVM 参数头" Margin="0,0,25,0" />
|
||||
<local:MyTextBox x:Name="TextAdvanceJvm" Grid.Row="0" Grid.ColumnSpan="2" Tag="VersionAdvanceJvm" Grid.Column="1" ToolTip="启动 Minecraft 时使用的额外 JVM 参数,在没有确定把握的情况下请不要尝试修改。
若留空,则使用全局设置的值。" HintText="使用全局设置"
|
||||
<local:MyTextBox x:Name="TextAdvanceJvm" Grid.Row="0" Grid.ColumnSpan="2" Tag="VersionAdvanceJvm" Grid.Column="1" MaxLength="4000" ToolTip="启动 Minecraft 时使用的额外 JVM 参数,在没有确定把握的情况下请不要尝试修改。
若留空,则使用全局设置的值。" HintText="使用全局设置"
|
||||
Height="57" AcceptsReturn="True" TextWrapping="Wrap" VerticalContentAlignment="Top" Padding="0,5" />
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="JVM 参数尾" Margin="0,0,25,0" />
|
||||
<local:MyTextBox x:Name="TextAdvanceGame" Grid.Row="2" Grid.ColumnSpan="2" Tag="VersionAdvanceGame" Grid.Column="1" ToolTip="文本框中的内容将会被直接拼合在启动参数的末尾。
例如输入 --demo 则会以试玩模式启动游戏。
若留空,则使用全局设置的值。" HintText="使用全局设置" />
|
||||
|
||||
Reference in New Issue
Block a user