2.12.7.0
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
Imports System.IO.Compression
|
||||
|
||||
Public Module ModDownloadLib
|
||||
Public Module ModDownloadLib
|
||||
|
||||
#Region "Minecraft 下载"
|
||||
|
||||
@@ -51,7 +49,7 @@ Public Module ModDownloadLib
|
||||
Try
|
||||
Dim InstanceJson As JObject = GetJson(ReadFile(VersionFolder & InstanceName & ".json"))
|
||||
InstanceJson.Add("clientVersion", Id)
|
||||
WriteFile($"{VersionFolder}{InstanceName}.json", InstanceJson.ToString)
|
||||
FileUtils.Write($"{VersionFolder}{InstanceName}.json", InstanceJson.ToString)
|
||||
Catch ex As Exception
|
||||
Throw New Exception("添加客户端版本失败", ex)
|
||||
End Try
|
||||
@@ -206,7 +204,7 @@ echo ------------------------------
|
||||
echo ----------------------
|
||||
echo 服务端已停止。
|
||||
pause"
|
||||
WriteFile(VersionFolder & "Launch Server.bat", Bat,
|
||||
FileUtils.Write(VersionFolder & "Launch Server.bat", Bat,
|
||||
Encoding:=If(Encoding.Default.Equals(Encoding.UTF8), Encoding.UTF8, Encoding.GetEncoding("GB18030")))
|
||||
'删除版本 JSON
|
||||
File.Delete(VersionFolder & Id & ".json")
|
||||
@@ -221,7 +219,7 @@ pause"
|
||||
FrmMain.BtnExtraDownload.ShowRefresh()
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
Catch ex As Exception
|
||||
Log(ex, "开始 Minecraft 服务端下载失败", LogLevel.Feedback)
|
||||
Log(ex, "开始 Minecraft 服务端下载失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
Public Sub McDownloadMenuSave(sender As Object, e As RoutedEventArgs)
|
||||
@@ -266,7 +264,7 @@ pause"
|
||||
FrmMain.BtnExtraDownload.ShowRefresh()
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
Catch ex As Exception
|
||||
Log(ex, "开始 Minecraft 下载失败", LogLevel.Feedback)
|
||||
Log(ex, "开始 Minecraft 下载失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
''' <summary>
|
||||
@@ -325,7 +323,7 @@ pause"
|
||||
ElseIf Id.StartsWithF("rd-") Then
|
||||
WikiName = "Java版Pre-classic_" & Id
|
||||
Else
|
||||
Log("[Error] 未知的版本格式:" & Id & "。", LogLevel.Feedback)
|
||||
Log("[Error] 未知的版本格式:" & Id & "。", NotifyLevel.MsgBoxAndFeedback)
|
||||
Return
|
||||
End If
|
||||
OpenWebsite("https://zh.minecraft.wiki/w/" & WikiName.Replace("_experimental-snapshot-", "-exp"))
|
||||
@@ -355,7 +353,7 @@ pause"
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
|
||||
Catch ex As Exception
|
||||
Log(ex, "开始 OptiFine 下载失败", LogLevel.Feedback)
|
||||
Log(ex, "开始 OptiFine 下载失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub McDownloadOptiFineInstall(BaseMcFolderHome As String, Target As String, Task As LoaderTask(Of List(Of NetFile), Boolean), UseJavaWrapper As Boolean)
|
||||
@@ -397,7 +395,7 @@ pause"
|
||||
.CreateNoWindow = True,
|
||||
.RedirectStandardError = True,
|
||||
.RedirectStandardOutput = True,
|
||||
.WorkingDirectory = ShortenPath(BaseMcFolderHome)
|
||||
.WorkingDirectory = FileUtils.ShortenPath(BaseMcFolderHome)
|
||||
}
|
||||
If Info.EnvironmentVariables.ContainsKey("appdata") Then
|
||||
Info.EnvironmentVariables("appdata") = BaseMcFolderHome
|
||||
@@ -534,7 +532,7 @@ pause"
|
||||
If Not IsCustomFolder Then Return
|
||||
SyncLock VanillaSyncLock
|
||||
Dim ClientName As String = GetFolderNameFromPath(ClientFolder)
|
||||
Directory.CreateDirectory(McFolder & "versions\" & DownloadInfo.Inherit)
|
||||
DirectoryUtils.Create(McFolder & "versions\" & DownloadInfo.Inherit)
|
||||
If Not File.Exists(McFolder & "versions\" & DownloadInfo.Inherit & "\" & DownloadInfo.Inherit & ".json") Then
|
||||
CopyFile($"{ClientFolder}{ClientName}.json", $"{McFolder}versions\{DownloadInfo.Inherit}\{DownloadInfo.Inherit}.json")
|
||||
End If
|
||||
@@ -556,7 +554,7 @@ pause"
|
||||
If Directory.Exists(BaseMcFolder & "versions\" & DownloadInfo.Inherit) Then
|
||||
DeleteDirectory(BaseMcFolder & "versions\" & DownloadInfo.Inherit)
|
||||
End If
|
||||
Directory.CreateDirectory(BaseMcFolder & "versions\" & DownloadInfo.Inherit & "\")
|
||||
DirectoryUtils.Create(BaseMcFolder & "versions\" & DownloadInfo.Inherit & "\")
|
||||
McFolderLauncherProfilesJsonCreate(BaseMcFolder)
|
||||
CopyFile(McFolder & "versions\" & DownloadInfo.Inherit & "\" & DownloadInfo.Inherit & ".json",
|
||||
BaseMcFolder & "versions\" & DownloadInfo.Inherit & "\" & DownloadInfo.Inherit & ".json")
|
||||
@@ -595,7 +593,7 @@ Retry:
|
||||
Sub(Task As LoaderTask(Of List(Of NetFile), Boolean))
|
||||
Try
|
||||
'新建版本文件夹
|
||||
Directory.CreateDirectory(VersionFolder)
|
||||
DirectoryUtils.Create(VersionFolder)
|
||||
Task.Progress = 0.1
|
||||
'复制 Jar 文件
|
||||
If File.Exists(VersionFolder & Id & ".jar") Then File.Delete(VersionFolder & Id & ".jar")
|
||||
@@ -633,7 +631,7 @@ Retry:
|
||||
}
|
||||
}"
|
||||
End If
|
||||
WriteFile(VersionFolder & Id & ".json", Json)
|
||||
FileUtils.Write(VersionFolder & Id & ".json", Json)
|
||||
Catch ex As Exception
|
||||
Throw New Exception("安装 OptiFine(方式 B)失败", ex)
|
||||
End Try
|
||||
@@ -798,7 +796,7 @@ Retry:
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
|
||||
Catch ex As Exception
|
||||
Log(ex, "开始 LiteLoader 安装器下载失败", LogLevel.Feedback)
|
||||
Log(ex, "开始 LiteLoader 安装器下载失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -820,8 +818,6 @@ Retry:
|
||||
Loaders.Add(New LoaderTask(Of String, String)("安装 LiteLoader",
|
||||
Sub(Task As LoaderTask(Of String, String))
|
||||
Try
|
||||
'新建版本文件夹
|
||||
Directory.CreateDirectory(VersionFolder)
|
||||
'构造版本 Json
|
||||
Dim VersionJson As New JObject
|
||||
VersionJson.Add("id", VersionName)
|
||||
@@ -835,8 +831,8 @@ Retry:
|
||||
VersionJson.Add("minimumLauncherVersion", 18)
|
||||
VersionJson.Add("inheritsFrom", DownloadInfo.Inherit)
|
||||
VersionJson.Add("jar", DownloadInfo.Inherit)
|
||||
'输出 Json 文件
|
||||
WriteFile(VersionFolder & VersionName & ".json", VersionJson.ToString)
|
||||
'输出 Json 文件,同时会新建该文件夹
|
||||
FileUtils.Write(VersionFolder & VersionName & ".json", VersionJson.ToString)
|
||||
Catch ex As Exception
|
||||
Throw New Exception("安装新 LiteLoader 版本失败", ex)
|
||||
End Try
|
||||
@@ -966,7 +962,7 @@ Retry:
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
|
||||
Catch ex As Exception
|
||||
Log(ex, $"开始 {Info.LoaderName} 安装器下载失败", LogLevel.Feedback)
|
||||
Log(ex, $"开始 {Info.LoaderName} 安装器下载失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -1235,7 +1231,7 @@ Retry:
|
||||
For i = 0 To Libs.Count - 1
|
||||
If Libs(i).LocalPath.EndsWithF($"{LoaderName.Lower}-{Inherit}-{LoaderVersion}.jar") OrElse
|
||||
Libs(i).LocalPath.EndsWithF($"{LoaderName.Lower}-{Inherit}-{LoaderVersion}-client.jar") Then
|
||||
Log($"[Download] 已从待下载 {LoaderName} 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug)
|
||||
Log($"[Download] 已从待下载 {LoaderName} 支持库中移除:" & Libs(i).LocalPath, NotifyLevel.DebugModeOnly)
|
||||
Libs.RemoveAt(i)
|
||||
Exit For
|
||||
End If
|
||||
@@ -1256,7 +1252,7 @@ Retry:
|
||||
For Each LibFile As McLibToken In Libs
|
||||
Dim RealPath As String = LibFile.LocalPath.Replace(McFolderSelected, McFolder)
|
||||
If Not File.Exists(RealPath) Then
|
||||
Directory.CreateDirectory(IO.Path.GetDirectoryName(RealPath))
|
||||
DirectoryUtils.Create(RealPath, isFilePath:=True)
|
||||
CopyFile(LibFile.LocalPath, RealPath)
|
||||
End If
|
||||
If ModeDebug Then Log($"[Download] 复制的 {LoaderName} 支持库文件:" & LibFile.LocalPath)
|
||||
@@ -1278,7 +1274,7 @@ Retry:
|
||||
If Not IsCustomFolder Then Return
|
||||
SyncLock VanillaSyncLock
|
||||
Dim ClientName As String = GetFolderNameFromPath(ClientFolder)
|
||||
Directory.CreateDirectory(McFolder & "versions\" & Inherit)
|
||||
DirectoryUtils.Create(McFolder & "versions\" & Inherit)
|
||||
If Not File.Exists(McFolder & "versions\" & Inherit & "\" & Inherit & ".json") Then
|
||||
CopyFile(ClientFolder & ClientName & ".json", McFolder & "versions\" & Inherit & "\" & Inherit & ".json")
|
||||
End If
|
||||
@@ -1299,7 +1295,7 @@ Retry:
|
||||
Installer = New ZipArchive(New FileStream(InstallerAddress, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Dim Json As JObject = GetJson(ReadFile(Installer.GetEntry("install_profile.json").Open))
|
||||
'新建目标版本文件夹
|
||||
Directory.CreateDirectory(VersionFolder)
|
||||
DirectoryUtils.Create(VersionFolder)
|
||||
Task.Progress = 0.04
|
||||
'释放 launcher_installer.json
|
||||
McFolderLauncherProfilesJsonCreate(McFolder)
|
||||
@@ -1309,7 +1305,7 @@ Retry:
|
||||
Retry:
|
||||
Try
|
||||
'释放 Forge 注入器
|
||||
WriteFile(PathTemp & "Cache\forge_installer.jar", GetResources("ForgeInstaller"))
|
||||
FileUtils.Write(PathTemp & "Cache\forge_installer.jar", GetResources("ForgeInstaller"))
|
||||
Task.Progress = 0.06
|
||||
'运行注入器
|
||||
ForgelikeInjector(InstallerAddress, Task, McFolder, UseJavaWrapper, IsNeoForge)
|
||||
@@ -1329,13 +1325,13 @@ Retry:
|
||||
If DeltaList.Count > 1 Then
|
||||
'它可能和 OptiFine 安装同时运行,导致增加的文件不止一个(这导致了 #151)
|
||||
'也可能是因为 Forge 安装器的 Bug,生成了一个名字错误的文件夹,所以需要检查文件夹是否为空
|
||||
DeltaList = DeltaList.Where(Function(l) l.Name.ContainsF("forge", True) AndAlso l.EnumerateFiles.Any).ToList
|
||||
DeltaList = DeltaList.Where(Function(l) l.Name.ContainsIgnoreCase("forge") AndAlso l.EnumerateFiles.Any).ToList
|
||||
End If
|
||||
If DeltaList.Count = 1 Then
|
||||
'如果没有新增文件夹,那么预测的文件夹名就是正确的
|
||||
'如果只新增 1 个文件夹,那么拷贝 json 文件
|
||||
Dim JsonFile As FileInfo = DeltaList(0).EnumerateFiles.First()
|
||||
WriteFile(VersionFolder & NewInstanceName & ".json", ReadFile(JsonFile.FullName))
|
||||
FileUtils.Write(VersionFolder & NewInstanceName & ".json", ReadFile(JsonFile.FullName))
|
||||
Log($"[Download] 已拷贝新增的版本 JSON 文件:{JsonFile.FullName} -> {VersionFolder}{NewInstanceName}.json")
|
||||
ElseIf DeltaList.Count > 1 Then
|
||||
'新增了多个文件夹
|
||||
@@ -1368,7 +1364,7 @@ Retry:
|
||||
Dim Json As JObject = GetJson(ReadFile(Installer.GetEntry("install_profile.json").Open))
|
||||
Task.Progress = 0.4
|
||||
'新建版本文件夹
|
||||
Directory.CreateDirectory(VersionFolder)
|
||||
DirectoryUtils.Create(VersionFolder)
|
||||
Task.Progress = 0.5
|
||||
If Json("install") Is Nothing Then
|
||||
'中版:Legacy 方式 1
|
||||
@@ -1376,7 +1372,7 @@ Retry:
|
||||
'建立 Json 文件
|
||||
Dim JsonVersion As JObject = GetJson(ReadFile(Installer.GetEntry(Json("json").ToString.TrimStart("/")).Open))
|
||||
JsonVersion("id") = NewInstanceName
|
||||
WriteFile(VersionFolder & NewInstanceName & ".json", JsonVersion.ToString)
|
||||
FileUtils.Write(VersionFolder & NewInstanceName & ".json", JsonVersion.ToString)
|
||||
Task.Progress = 0.6
|
||||
'解压支持库文件
|
||||
Installer.Dispose()
|
||||
@@ -1389,12 +1385,12 @@ Retry:
|
||||
'解压 Jar 文件
|
||||
Dim JarAddress As String = McLibGet(Json("install")("path"), CustomMcFolder:=McFolder)
|
||||
If File.Exists(JarAddress) Then File.Delete(JarAddress)
|
||||
WriteFile(JarAddress, Installer.GetEntry(Json("install")("filePath")).Open)
|
||||
FileUtils.Write(JarAddress, Installer.GetEntry(Json("install")("filePath")).Open)
|
||||
Task.Progress = 0.9
|
||||
'建立 Json 文件
|
||||
Json("versionInfo")("id") = NewInstanceName
|
||||
If Json("versionInfo")("inheritsFrom") Is Nothing Then CType(Json("versionInfo"), JObject).Add("inheritsFrom", Inherit)
|
||||
WriteFile(VersionFolder & NewInstanceName & ".json", Json("versionInfo").ToString)
|
||||
FileUtils.Write(VersionFolder & NewInstanceName & ".json", Json("versionInfo").ToString)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Throw New Exception("非新版方式安装 Forge 失败", ex)
|
||||
@@ -1542,7 +1538,7 @@ Retry:
|
||||
If RecommendedList.Count < 5 Then Throw New Exception("获取的推荐版本数过少(" & Result & ")")
|
||||
'保存
|
||||
Dim CacheJson As String = "{" & RecommendedList.Join(",") & "}"
|
||||
WriteFile(PathTemp & "Cache\ForgeRecommendedList.json", CacheJson)
|
||||
FileUtils.Write(PathTemp & "Cache\ForgeRecommendedList.json", CacheJson)
|
||||
Log("[Download] 刷新 Forge 推荐版本缓存成功")
|
||||
Catch ex As Exception
|
||||
Log(ex, "刷新 Forge 推荐版本缓存失败")
|
||||
@@ -1566,7 +1562,7 @@ Retry:
|
||||
If Json Is Nothing OrElse (Not If(McVersion, "").Contains(".")) OrElse Not Json.ContainsKey(McVersion) Then Return Nothing
|
||||
Return If(Json(McVersion), "").ToString
|
||||
Catch ex As Exception
|
||||
Log(ex, "获取 Forge 推荐版本失败(" & If(McVersion, "null") & ")", LogLevel.Feedback)
|
||||
Log(ex, "获取 Forge 推荐版本失败(" & If(McVersion, "null") & ")", NotifyLevel.MsgBoxAndFeedback)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
@@ -1591,7 +1587,7 @@ Retry:
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
Log("[System] 未找到可用的 NeoForge 版本", LogLevel.Debug)
|
||||
Log("[System] 未找到可用的 NeoForge 版本", NotifyLevel.DebugModeOnly)
|
||||
End If
|
||||
'显示各个版本
|
||||
If FreshStableVersion IsNot Nothing Then
|
||||
@@ -1705,7 +1701,7 @@ Retry:
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
|
||||
Catch ex As Exception
|
||||
Log(ex, "开始 Fabric 安装器下载失败", LogLevel.Feedback)
|
||||
Log(ex, "开始 Fabric 安装器下载失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -1751,24 +1747,24 @@ Retry:
|
||||
Return NewItem
|
||||
End Function) With {.Height = 42}
|
||||
End Function
|
||||
Public Function FabricApiDownloadListItem(Entry As CompFile, OnClick As MyListItem.ClickEventHandler) As MyVirtualizingElement(Of MyListItem)
|
||||
Public Function FabricApiDownloadListItem(Entry As ResourceVersion, OnClick As MyListItem.ClickEventHandler) As MyVirtualizingElement(Of MyListItem)
|
||||
Return New MyVirtualizingElement(Of MyListItem)(
|
||||
Function()
|
||||
Dim NewItem As New MyListItem With {
|
||||
.Title = Entry.DisplayName.Split("]")(1).Replace("Fabric API ", "").Replace(" build ", ".").BeforeFirst("+").Trim, .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry,
|
||||
.Info = Entry.StatusDescription & ",发布于 " & Entry.ReleaseDate.ToString("yyyy'/'MM'/'dd HH':'mm"),
|
||||
.Title = Entry.Display.Split("]")(1).Replace("Fabric API ", "").Replace(" build ", ".").BeforeFirst("+").Trim, .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry,
|
||||
.Info = Entry.ReleaseTypeDisplay & ",发布于 " & Entry.ReleaseDate.ToString("yyyy'/'MM'/'dd HH':'mm"),
|
||||
.Logo = PathImage & "Blocks/Fabric.png"
|
||||
}
|
||||
AddHandler NewItem.Click, OnClick
|
||||
Return NewItem
|
||||
End Function) With {.Height = 42}
|
||||
End Function
|
||||
Public Function OptiFabricDownloadListItem(Entry As CompFile, OnClick As MyListItem.ClickEventHandler) As MyVirtualizingElement(Of MyListItem)
|
||||
Public Function OptiFabricDownloadListItem(Entry As ResourceVersion, OnClick As MyListItem.ClickEventHandler) As MyVirtualizingElement(Of MyListItem)
|
||||
Return New MyVirtualizingElement(Of MyListItem)(
|
||||
Function()
|
||||
Dim NewItem As New MyListItem With {
|
||||
.Title = Entry.DisplayName.Lower.Replace("optifabric-", "").Replace(".jar", "").Trim.TrimStart("v"), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry,
|
||||
.Info = Entry.StatusDescription & ",发布于 " & Entry.ReleaseDate.ToString("yyyy'/'MM'/'dd HH':'mm"),
|
||||
.Title = Entry.Display.Lower.Replace("optifabric-", "").Replace(".jar", "").Trim.TrimStart("v"), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry,
|
||||
.Info = Entry.ReleaseTypeDisplay & ",发布于 " & Entry.ReleaseDate.ToString("yyyy'/'MM'/'dd HH':'mm"),
|
||||
.Logo = PathImage & "Blocks/OptiFabric.png"
|
||||
}
|
||||
AddHandler NewItem.Click, OnClick
|
||||
@@ -1841,12 +1837,12 @@ Retry:
|
||||
''' <summary>
|
||||
''' 欲下载的 Fabric API 信息。
|
||||
''' </summary>
|
||||
Public FabricApi As CompFile = Nothing
|
||||
Public FabricApi As ResourceVersion = Nothing
|
||||
|
||||
''' <summary>
|
||||
''' 欲下载的 OptiFabric 信息。
|
||||
''' </summary>
|
||||
Public OptiFabric As CompFile = Nothing
|
||||
Public OptiFabric As ResourceVersion = Nothing
|
||||
|
||||
''' <summary>
|
||||
''' 欲下载的 LiteLoader 详细信息。
|
||||
@@ -1894,9 +1890,9 @@ Retry:
|
||||
If Loader.State = LoadState.Failed OrElse Loader.State = LoadState.Interrupted Then
|
||||
'删除版本文件夹
|
||||
If Directory.Exists(Loader.Input & "saves\") OrElse Directory.Exists(Loader.Input & "versions\") Then
|
||||
Log("[Download] 由于版本已被独立启动,不清理版本文件夹:" & Loader.Input, LogLevel.Developer)
|
||||
Log("[Download] 由于版本已被独立启动,不清理版本文件夹:" & Loader.Input, NotifyLevel.DevelopOnly)
|
||||
Else
|
||||
Log("[Download] 由于下载失败或取消,清理版本文件夹:" & Loader.Input, LogLevel.Developer)
|
||||
Log("[Download] 由于下载失败或取消,清理版本文件夹:" & Loader.Input, NotifyLevel.DevelopOnly)
|
||||
DeleteDirectory(Loader.Input)
|
||||
End If
|
||||
End If
|
||||
@@ -1924,7 +1920,7 @@ Retry:
|
||||
Catch ex As CancelledException
|
||||
Return False
|
||||
Catch ex As Exception
|
||||
Log(ex, "开始合并安装失败", LogLevel.Feedback)
|
||||
Log(ex, "开始合并安装失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
@@ -1945,9 +1941,9 @@ Retry:
|
||||
Request.OptiFineEntry = New DlOptiFineListEntry With {
|
||||
.DisplayName = Request.MinecraftName & " " & Request.OptiFineVersion.Replace("HD_U_", "").Replace("_", "").Replace("pre", " pre"),
|
||||
.Inherit = Request.MinecraftName,
|
||||
.IsPreview = Request.OptiFineVersion.ContainsF("pre", True),
|
||||
.IsPreview = Request.OptiFineVersion.ContainsIgnoreCase("pre"),
|
||||
.InstanceName = Request.MinecraftName & "-OptiFine_" & Request.OptiFineVersion,
|
||||
.FileName = If(Request.OptiFineVersion.ContainsF("pre", True), "preview_", "") &
|
||||
.FileName = If(Request.OptiFineVersion.ContainsIgnoreCase("pre"), "preview_", "") &
|
||||
"OptiFine_" & Request.MinecraftName & "_" & Request.OptiFineVersion & ".jar"
|
||||
}
|
||||
End If
|
||||
@@ -1992,7 +1988,7 @@ Retry:
|
||||
|
||||
Dim LoaderList As New List(Of LoaderBase)
|
||||
'添加忽略标识
|
||||
LoaderList.Add(New LoaderTask(Of Integer, Integer)("添加忽略标识", Sub() WriteFile(VersionFolder & ".pclignore", "用于临时地在 PCL 的版本列表中屏蔽此版本。")) With {.Show = False, .Block = False})
|
||||
LoaderList.Add(New LoaderTask(Of Integer, Integer)("添加忽略标识", Sub() FileUtils.Write(VersionFolder & ".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(ModsTempFolder)}) With {.ProgressWeight = 3, .Block = False})
|
||||
@@ -2049,11 +2045,11 @@ Retry:
|
||||
If Directory.Exists(ModsTempFolder) Then
|
||||
CopyDirectory(ModsTempFolder, ModsFolder)
|
||||
ElseIf Modable Then
|
||||
Directory.CreateDirectory(ModsFolder)
|
||||
DirectoryUtils.Create(ModsFolder)
|
||||
Log("[Download] 自动创建 Mod 文件夹:" & ModsFolder)
|
||||
End If
|
||||
Dim ResourcepacksFolder = New McInstance(VersionFolder).PathIndie & "resourcepacks\"
|
||||
Directory.CreateDirectory(ResourcepacksFolder)
|
||||
DirectoryUtils.Create(ResourcepacksFolder)
|
||||
Log("[Download] 自动创建资源包文件夹:" & ResourcepacksFolder)
|
||||
End Sub) With {.ProgressWeight = 2, .Block = True})
|
||||
'补全文件
|
||||
@@ -2079,7 +2075,7 @@ Retry:
|
||||
If(NeoForgeFolder IsNot Nothing, ",NeoForge:" & NeoForgeFolder, "") &
|
||||
If(LiteLoaderFolder IsNot Nothing, ",LiteLoader:" & LiteLoaderFolder, "") &
|
||||
If(FabricFolder IsNot Nothing, ",Fabric:" & FabricFolder, ""))
|
||||
Directory.CreateDirectory(OutputFolder)
|
||||
DirectoryUtils.Create(OutputFolder)
|
||||
|
||||
Dim HasOptiFine As Boolean = OptiFineFolder IsNot Nothing AndAlso Not OptiFineAsMod, HasForge As Boolean = ForgeFolder IsNot Nothing, HasNeoForge As Boolean = NeoForgeFolder IsNot Nothing, HasLiteLoader As Boolean = LiteLoaderFolder IsNot Nothing, HasFabric As Boolean = FabricFolder IsNot Nothing
|
||||
Dim OutputName As String, MinecraftName As String, OptiFineName As String, ForgeName As String, NeoForgeName As String, LiteLoaderName As String, FabricName As String
|
||||
@@ -2227,7 +2223,7 @@ Retry:
|
||||
#End Region
|
||||
|
||||
#Region "保存"
|
||||
WriteFile(OutputJsonPath, OutputJson.ToString)
|
||||
FileUtils.Write(OutputJsonPath, OutputJson.ToString)
|
||||
If MinecraftJar <> OutputJar Then '可能是同一个文件
|
||||
If File.Exists(OutputJar) Then File.Delete(OutputJar)
|
||||
CopyFile(MinecraftJar, OutputJar)
|
||||
@@ -2258,19 +2254,19 @@ Retry:
|
||||
Static Lock As New Object
|
||||
SyncLock Lock '避免 OptiFine 和 Forge 安装时同时释放导致冲突
|
||||
Try
|
||||
WriteFile(PatchPath, GetResources(Patch))
|
||||
FileUtils.Write(PatchPath, GetResources(Patch))
|
||||
Catch ex As Exception
|
||||
If File.Exists(PatchPath) Then
|
||||
'因为未知原因可能变为只读文件(#4243)
|
||||
Log(ex, $"{Patch} 文件释放失败,但文件已存在,将在删除后尝试重新生成", LogLevel.Developer)
|
||||
Log(ex, $"{Patch} 文件释放失败,但文件已存在,将在删除后尝试重新生成", NotifyLevel.DevelopOnly)
|
||||
Try
|
||||
File.Delete(PatchPath)
|
||||
WriteFile(PatchPath, GetResources(Patch))
|
||||
FileUtils.Write(PatchPath, GetResources(Patch))
|
||||
Catch ex2 As Exception
|
||||
Log(ex2, $"{Patch} 文件重新释放失败,将尝试更换文件名重新生成", LogLevel.Developer)
|
||||
Log(ex2, $"{Patch} 文件重新释放失败,将尝试更换文件名重新生成", NotifyLevel.DevelopOnly)
|
||||
PatchPath = $"{PathPure}{Patch}2.jar"
|
||||
Try
|
||||
WriteFile(PatchPath, GetResources(Patch))
|
||||
FileUtils.Write(PatchPath, GetResources(Patch))
|
||||
Catch ex3 As Exception
|
||||
Throw New FileNotFoundException($"释放 {Patch} 最终尝试失败", ex3)
|
||||
End Try
|
||||
|
||||
@@ -171,8 +171,8 @@
|
||||
Private SelectedForge As DlForgeVersionEntry = Nothing
|
||||
Private SelectedNeoForge As DlNeoForgeListEntry = Nothing
|
||||
Private SelectedFabric As String = Nothing
|
||||
Private SelectedFabricApi As CompFile = Nothing
|
||||
Private SelectedOptiFabric As CompFile = Nothing
|
||||
Private SelectedFabricApi As ResourceVersion = Nothing
|
||||
Private SelectedOptiFabric As ResourceVersion = Nothing
|
||||
|
||||
''' <summary>
|
||||
''' 重载已选择的项目的显示。
|
||||
@@ -301,7 +301,7 @@
|
||||
Else
|
||||
BtnFabricApiClear.Visibility = Visibility.Visible
|
||||
ImgFabricApi.Visibility = Visibility.Visible
|
||||
LabFabricApi.Text = SelectedFabricApi.DisplayName.Split("]")(1).Replace("Fabric API ", "").Replace(" build ", ".").Split("+").First.Trim
|
||||
LabFabricApi.Text = SelectedFabricApi.Display.Split("]")(1).Replace("Fabric API ", "").Replace(" build ", ".").Split("+").First.Trim
|
||||
LabFabricApi.Foreground = ColorGray1
|
||||
End If
|
||||
End If
|
||||
@@ -322,7 +322,7 @@
|
||||
Else
|
||||
BtnOptiFabricClear.Visibility = Visibility.Visible
|
||||
ImgOptiFabric.Visibility = Visibility.Visible
|
||||
LabOptiFabric.Text = SelectedOptiFabric.DisplayName.Lower.Replace("optifabric-", "").Replace(".jar", "").Trim.TrimStart("v")
|
||||
LabOptiFabric.Text = SelectedOptiFabric.Display.Lower.Replace("optifabric-", "").Replace(".jar", "").Trim.TrimStart("v")
|
||||
LabOptiFabric.Foreground = ColorGray1
|
||||
End If
|
||||
End If
|
||||
@@ -531,9 +531,11 @@
|
||||
Dim Item = McDownloadListItem(Version, Sub()
|
||||
End Sub, False).Init()
|
||||
MinecraftSelected(Item, Nothing)
|
||||
VersionWaitingSelect = Nothing
|
||||
Return
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Log(ex, "可视化安装版本列表出错", LogLevel.Feedback)
|
||||
Log(ex, "可视化安装版本列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
''' <summary>
|
||||
@@ -625,7 +627,7 @@
|
||||
PanOptiFine.Children.Add(OptiFineDownloadListItem(Version, AddressOf OptiFine_Selected, False))
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Log(ex, "可视化 OptiFine 安装版本列表出错", LogLevel.Feedback)
|
||||
Log(ex, "可视化 OptiFine 安装版本列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -687,7 +689,7 @@
|
||||
PanLiteLoader.Children.Add(LiteLoaderDownloadListItem(Version, AddressOf LiteLoader_Selected, False))
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Log(ex, "可视化 LiteLoader 安装版本列表出错", LogLevel.Feedback)
|
||||
Log(ex, "可视化 LiteLoader 安装版本列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -761,7 +763,7 @@
|
||||
PanForge.Children.Add(ForgeDownloadListItem(Version, AddressOf Forge_Selected, False))
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Log(ex, "可视化 Forge 安装版本列表出错", LogLevel.Feedback)
|
||||
Log(ex, "可视化 Forge 安装版本列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -819,7 +821,7 @@
|
||||
PanNeoForge.Children.Add(NeoForgeDownloadListItem(Version, AddressOf NeoForge_Selected, False))
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Log(ex, "可视化 NeoForge 安装版本列表出错", LogLevel.Feedback)
|
||||
Log(ex, "可视化 NeoForge 安装版本列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -881,7 +883,7 @@
|
||||
CardFabric.SwapControl = PanFabric
|
||||
CardFabric.SwapType = 12
|
||||
Catch ex As Exception
|
||||
Log(ex, "可视化 Fabric 安装版本列表出错", LogLevel.Feedback)
|
||||
Log(ex, "可视化 Fabric 安装版本列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -911,8 +913,8 @@
|
||||
''' <summary>
|
||||
''' 判断某 Fabric API 是否适配当前选择的原版版本。
|
||||
''' </summary>
|
||||
Public Function IsFabricApiCompatible(FabricApi As CompFile) As Boolean
|
||||
Dim FabricApiName = FabricApi.DisplayName
|
||||
Public Function IsFabricApiCompatible(FabricApi As ResourceVersion) As Boolean
|
||||
Dim FabricApiName = FabricApi.Display
|
||||
Try
|
||||
If FabricApiName Is Nothing OrElse VanillaName Is Nothing Then Return False
|
||||
FabricApiName = FabricApiName.Lower
|
||||
@@ -978,12 +980,12 @@
|
||||
If DlFabricApiLoader.State <> LoadState.Finished Then Return
|
||||
If VanillaName Is Nothing OrElse SelectedFabric Is Nothing Then Return
|
||||
'获取版本列表
|
||||
Dim Versions As New List(Of CompFile)
|
||||
Dim Versions As New List(Of ResourceVersion)
|
||||
For Each Version In DlFabricApiLoader.Output
|
||||
If IsFabricApiCompatible(Version) Then
|
||||
If Not Version.DisplayName.StartsWithF("[") Then
|
||||
Log("[Download] 已特判修改 Fabric API 显示名:" & Version.DisplayName, LogLevel.Debug)
|
||||
Version.DisplayName = "[" & VanillaName & "] " & Version.DisplayName
|
||||
If Not Version.Display.StartsWithF("[") Then
|
||||
Log("[Download] 已特判修改 Fabric API 显示名:" & Version.Display, NotifyLevel.DebugModeOnly)
|
||||
Version.Display = "[" & VanillaName & "] " & Version.Display
|
||||
End If
|
||||
Versions.Add(Version)
|
||||
End If
|
||||
@@ -1004,7 +1006,7 @@
|
||||
FabricApi_Selected(Item, Nothing)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Log(ex, "可视化 Fabric API 安装版本列表出错", LogLevel.Feedback)
|
||||
Log(ex, "可视化 Fabric API 安装版本列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -1028,7 +1030,7 @@
|
||||
''' <summary>
|
||||
''' 判断某 OptiFabric 是否适配当前选择的原版版本。
|
||||
''' </summary>
|
||||
Private Function IsOptiFabricCompatible(ModFile As CompFile) As Boolean
|
||||
Private Function IsOptiFabricCompatible(ModFile As ResourceVersion) As Boolean
|
||||
Try
|
||||
If VanillaName Is Nothing Then Return False
|
||||
Return ModFile.GameVersions.Contains(VanillaName)
|
||||
@@ -1076,7 +1078,7 @@
|
||||
If DlOptiFabricLoader.State <> LoadState.Finished Then Return
|
||||
If VanillaName Is Nothing OrElse SelectedFabric Is Nothing OrElse SelectedOptiFine Is Nothing Then Return
|
||||
'获取版本列表
|
||||
Dim Versions As New List(Of CompFile)
|
||||
Dim Versions As New List(Of ResourceVersion)
|
||||
For Each Version In DlOptiFabricLoader.Output
|
||||
If IsOptiFabricCompatible(Version) Then Versions.Add(Version)
|
||||
Next
|
||||
@@ -1096,7 +1098,7 @@
|
||||
Log($"[Download] 已自动选择 OptiFabric:{Item.Title}")
|
||||
OptiFabric_Selected(Item, Nothing)
|
||||
Catch ex As Exception
|
||||
Log(ex, "可视化 OptiFabric 安装版本列表出错", LogLevel.Feedback)
|
||||
Log(ex, "可视化 OptiFabric 安装版本列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
PageChangeRun(PageGet(ID))
|
||||
PageID = ID
|
||||
Catch ex As Exception
|
||||
Log(ex, "切换分页面失败(ID " & ID & ")", LogLevel.Feedback)
|
||||
Log(ex, "切换分页面失败(ID " & ID & ")", NotifyLevel.MsgBoxAndFeedback)
|
||||
Finally
|
||||
AniControlEnabled -= 1
|
||||
End Try
|
||||
@@ -89,6 +89,8 @@
|
||||
Refresh(FrmMain.PageCurrentSub)
|
||||
End Sub
|
||||
Public Sub Refresh(SubType As FormMain.PageSubType)
|
||||
ResourceProject.Cache.Clear()
|
||||
ResourceVersion.ProjectFilesCache.Clear()
|
||||
Select Case SubType
|
||||
Case FormMain.PageSubType.DownloadInstall
|
||||
DlClientListLoader.Start(IsForceRestart:=True)
|
||||
@@ -101,46 +103,36 @@
|
||||
DlOptiFabricLoader.Start(IsForceRestart:=True)
|
||||
ItemInstall.Checked = True
|
||||
Case FormMain.PageSubType.DownloadMod
|
||||
CompProjectCache.Clear()
|
||||
CompFilesCache.Clear()
|
||||
If FrmDownloadMod IsNot Nothing Then
|
||||
FrmDownloadMod.Content.Storage = New CompProjectStorage
|
||||
FrmDownloadMod.Content.Storage = New ResourceSearcher.SearchResult
|
||||
FrmDownloadMod.Content.Page = 0
|
||||
FrmDownloadMod.PageLoaderRestart()
|
||||
End If
|
||||
ItemMod.Checked = True
|
||||
Case FormMain.PageSubType.DownloadPack
|
||||
CompProjectCache.Clear()
|
||||
CompFilesCache.Clear()
|
||||
If FrmDownloadPack IsNot Nothing Then
|
||||
FrmDownloadPack.Content.Storage = New CompProjectStorage
|
||||
FrmDownloadPack.Content.Storage = New ResourceSearcher.SearchResult
|
||||
FrmDownloadPack.Content.Page = 0
|
||||
FrmDownloadPack.PageLoaderRestart()
|
||||
End If
|
||||
ItemPack.Checked = True
|
||||
Case FormMain.PageSubType.DownloadResourcePack
|
||||
CompProjectCache.Clear()
|
||||
CompFilesCache.Clear()
|
||||
If FrmDownloadResourcePack IsNot Nothing Then
|
||||
FrmDownloadResourcePack.Content.Storage = New CompProjectStorage
|
||||
FrmDownloadResourcePack.Content.Storage = New ResourceSearcher.SearchResult
|
||||
FrmDownloadResourcePack.Content.Page = 0
|
||||
FrmDownloadResourcePack.PageLoaderRestart()
|
||||
End If
|
||||
ItemResourcePack.Checked = True
|
||||
Case FormMain.PageSubType.DownloadShader
|
||||
CompProjectCache.Clear()
|
||||
CompFilesCache.Clear()
|
||||
If FrmDownloadShader IsNot Nothing Then
|
||||
FrmDownloadShader.Content.Storage = New CompProjectStorage
|
||||
FrmDownloadShader.Content.Storage = New ResourceSearcher.SearchResult
|
||||
FrmDownloadShader.Content.Page = 0
|
||||
FrmDownloadShader.PageLoaderRestart()
|
||||
End If
|
||||
ItemShader.Checked = True
|
||||
Case FormMain.PageSubType.DownloadDataPack
|
||||
CompProjectCache.Clear()
|
||||
CompFilesCache.Clear()
|
||||
If FrmDownloadDataPack IsNot Nothing Then
|
||||
FrmDownloadDataPack.Content.Storage = New CompProjectStorage
|
||||
FrmDownloadDataPack.Content.Storage = New ResourceSearcher.SearchResult
|
||||
FrmDownloadDataPack.Content.Page = 0
|
||||
FrmDownloadDataPack.PageLoaderRestart()
|
||||
End If
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
<Grid x:Class="MyCompItem"
|
||||
<Grid x:Class="MyResourceItem"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:PCL"
|
||||
@@ -52,7 +52,7 @@
|
||||
IsHitTestVisible="False" SnapsToDevicePixels="False" UseLayoutRounding="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="ColumnVersion1" Width="Auto" />
|
||||
<ColumnDefinition x:Name="ColumnVersion2" Width="Auto" SharedSizeGroup="CompItemVersion" />
|
||||
<ColumnDefinition x:Name="ColumnVersion2" Width="Auto" SharedSizeGroup="ItemVersion" />
|
||||
<ColumnDefinition x:Name="ColumnVersion3" Width="0.7*" />
|
||||
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -60,11 +60,11 @@
|
||||
<ColumnDefinition Width="1*" />
|
||||
|
||||
<ColumnDefinition x:Name="ColumnTime1" Width="Auto" />
|
||||
<ColumnDefinition x:Name="ColumnTime2" Width="Auto" MinWidth="57" SharedSizeGroup="CompItemTime" />
|
||||
<ColumnDefinition x:Name="ColumnTime2" Width="Auto" MinWidth="57" SharedSizeGroup="ItemTime" />
|
||||
<ColumnDefinition x:Name="ColumnTime3" Width="1*" />
|
||||
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="CompItemSource" />
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="ItemSource" />
|
||||
<ColumnDefinition Width="1.7*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Path x:Name="PathVersion" Grid.Column="0" Fill="{StaticResource ColorBrushGray3}" Stretch="Uniform" Height="11"
|
||||
+17
-17
@@ -1,4 +1,4 @@
|
||||
Public Class MyCompItem
|
||||
Public Class MyResourceItem
|
||||
|
||||
#Region "基础属性"
|
||||
Public Uuid As Integer = GetUuid()
|
||||
@@ -82,47 +82,47 @@
|
||||
Log("[Control] 按下资源工程列表项:" & LabTitle.Text)
|
||||
End If
|
||||
End Sub
|
||||
Private Sub MyCompItem_Click(sender As MyCompItem, e As EventArgs) Handles Me.Click
|
||||
Private Sub MyResourceItem_Click(sender As MyResourceItem, e As EventArgs) Handles Me.Click
|
||||
'记录当前展开的卡片标题(#2712)
|
||||
Dim Titles As New List(Of String)
|
||||
If FrmMain.PageCurrent.Page = FormMain.PageType.CompDetail Then
|
||||
For Each Card As MyCard In FrmDownloadCompDetail.PanResults.Children
|
||||
If FrmMain.PageCurrent.Page = FormMain.PageType.ResourceDetail Then
|
||||
For Each Card As MyCard In FrmDownloadResourceDetail.PanResults.Children
|
||||
If Card.Title <> "" AndAlso Not Card.IsSwapped Then Titles.Add(Card.Title)
|
||||
Next
|
||||
Log("[Comp] 记录当前已展开的卡片:" & String.Join("、", Titles))
|
||||
Log("[Resource] 记录当前已展开的卡片:" & String.Join("、", Titles))
|
||||
FrmMain.PageCurrent.Additional(1) = Titles
|
||||
End If
|
||||
'打开详情页
|
||||
Dim TargetType As CompType
|
||||
Dim TargetType As ResourceTypes
|
||||
Dim TargetInstance As String = Nothing
|
||||
Dim TargetLoader As CompModLoaderType = CompModLoaderType.Any
|
||||
Dim TargetLoader As ModLoaderTypes = ModLoaderTypes.Any
|
||||
If FrmMain.PageCurrent.Page = FormMain.PageType.Download Then
|
||||
'从下载页进入
|
||||
Select Case FrmMain.PageCurrentSub
|
||||
Case FormMain.PageSubType.DownloadMod
|
||||
TargetType = CompType.Mod
|
||||
TargetType = ResourceTypes.Mod
|
||||
TargetInstance = FrmDownloadMod.Content.Loader.Input.GameVersion
|
||||
TargetLoader = FrmDownloadMod.Content.Loader.Input.ModLoader
|
||||
Case FormMain.PageSubType.DownloadPack
|
||||
TargetType = CompType.ModPack
|
||||
TargetType = ResourceTypes.ModPack
|
||||
TargetInstance = FrmDownloadPack.Content.Loader.Input.GameVersion
|
||||
Case FormMain.PageSubType.DownloadDataPack
|
||||
TargetType = CompType.DataPack
|
||||
TargetType = ResourceTypes.DataPack
|
||||
TargetInstance = FrmDownloadDataPack.Content.Loader.Input.GameVersion
|
||||
Case FormMain.PageSubType.DownloadResourcePack
|
||||
TargetType = CompType.ResourcePack
|
||||
TargetType = ResourceTypes.ResourcePack
|
||||
TargetInstance = FrmDownloadResourcePack.Content.Loader.Input.GameVersion
|
||||
Case FormMain.PageSubType.DownloadShader
|
||||
TargetType = CompType.Shader
|
||||
TargetType = ResourceTypes.Shader
|
||||
TargetInstance = FrmDownloadShader.Content.Loader.Input.GameVersion
|
||||
End Select
|
||||
Else
|
||||
'从详情页进入(查看前置)
|
||||
TargetType = CompType.Any '允许任意类别
|
||||
TargetType = ResourceTypes.Any '允许任意类别
|
||||
TargetInstance = FrmMain.PageCurrent.Additional(2)
|
||||
TargetLoader = FrmMain.PageCurrent.Additional(3)
|
||||
End If
|
||||
FrmMain.PageChange(New FormMain.PageStackData With {.Page = FormMain.PageType.CompDetail,
|
||||
FrmMain.PageChange(New FormMain.PageStackData With {.Page = FormMain.PageType.ResourceDetail,
|
||||
.Additional = {sender.Tag, New List(Of String), TargetInstance, TargetLoader, TargetType}})
|
||||
End Sub
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
|
||||
Private StateLast As String
|
||||
''' <summary>
|
||||
''' 是否允许交互。目前仅用于 PageDownloadCompDetail 的顶部栏展示:若关闭碰撞检测,则无法展开 Tooltip。
|
||||
''' 是否允许交互。目前仅用于 PageDownloadResourceDetail 的顶部栏展示:若关闭碰撞检测,则无法展开 Tooltip。
|
||||
''' </summary>
|
||||
Public Property CanInteraction As Boolean = True
|
||||
Public Sub RefreshColor(sender As Object, e As EventArgs) Handles Me.MouseEnter, Me.MouseLeave, Me.MouseLeftButtonDown, Me.MouseLeftButtonUp
|
||||
@@ -214,10 +214,10 @@
|
||||
AaScaleTransform(RectBack, -0.196, 1,,, True)
|
||||
})
|
||||
End If
|
||||
AniStart(Ani, "CompItem Color " & Uuid)
|
||||
AniStart(Ani, "MyResourceItem Color " & Uuid)
|
||||
Else
|
||||
'无动画
|
||||
AniStop("CompItem Color " & Uuid)
|
||||
AniStop("MyResourceItem Color " & Uuid)
|
||||
If _RectBack IsNot Nothing Then RectBack.Opacity = 0
|
||||
End If
|
||||
End Sub
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:PCL" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" x:Class="PageDownloadCompDetail"
|
||||
mc:Ignorable="d" x:Class="PageDownloadResourceDetail"
|
||||
PanScroll="PanBack">
|
||||
<local:MyScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" x:Name="PanBack">
|
||||
<Grid Margin="25,25,25,10">
|
||||
+116
-91
@@ -1,21 +1,21 @@
|
||||
Public Class PageDownloadCompDetail
|
||||
Private CompItem As MyCompItem = Nothing
|
||||
Public Class PageDownloadResourceDetail
|
||||
Private ResourceItem As MyResourceItem = Nothing
|
||||
|
||||
#Region "加载器"
|
||||
|
||||
Private CompFileLoader As New LoaderTask(Of Integer, List(Of CompFile))(
|
||||
"Comp File",
|
||||
Private ResourceFileLoader As New LoaderTask(Of Integer, List(Of ResourceVersion))(
|
||||
"Resource File",
|
||||
Sub(Task)
|
||||
LoadTargetFromAdditional()
|
||||
Dim Result = CompFilesGet(Project.Id, Project.FromCurseForge)
|
||||
Dim Result = ResourceVersion.FromProjectId(Project.Id, Project.Platform)
|
||||
If Task.IsInterrupted Then Return
|
||||
Task.Output = Result
|
||||
End Sub)
|
||||
|
||||
'初始化加载器信息
|
||||
Private Sub PageDownloadCompDetail_Inited(sender As Object, e As EventArgs) Handles Me.Initialized
|
||||
Private Sub PageDownloadResourceDetail_Inited(sender As Object, e As EventArgs) Handles Me.Initialized
|
||||
LoadTargetFromAdditional()
|
||||
PageLoaderInit(Load, PanLoad, PanMain, CardIntro, CompFileLoader, AddressOf Load_OnFinish)
|
||||
PageLoaderInit(Load, PanLoad, PanMain, CardIntro, ResourceFileLoader, AddressOf Load_OnFinish)
|
||||
End Sub
|
||||
Public Sub LoadTargetFromAdditional() Handles Me.Loaded
|
||||
Project = FrmMain.PageCurrent.Additional(0)
|
||||
@@ -23,21 +23,21 @@
|
||||
TargetLoader = FrmMain.PageCurrent.Additional(3)
|
||||
TargetType = FrmMain.PageCurrent.Additional(4)
|
||||
End Sub
|
||||
Private Project As CompProject
|
||||
Private TargetInstance As String, TargetLoader As CompModLoaderType
|
||||
Private Project As ResourceProject
|
||||
Private TargetInstance As String, TargetLoader As ModLoaderTypes
|
||||
''' <summary>
|
||||
''' 当前页面应展示的内容类别。
|
||||
''' 若当前页面是在查看前置时进入,则也可能为 Any。
|
||||
''' </summary>
|
||||
Private TargetType As CompType
|
||||
Private TargetType As ResourceTypes
|
||||
'自动重试
|
||||
Private Sub Load_State(sender As Object, state As MyLoading.MyLoadingState, oldState As MyLoading.MyLoadingState) Handles Load.StateChanged
|
||||
Select Case CompFileLoader.State
|
||||
Select Case ResourceFileLoader.State
|
||||
Case LoadState.Failed
|
||||
Dim ErrorMessage As String = ""
|
||||
If CompFileLoader.Error IsNot Nothing Then ErrorMessage = CompFileLoader.Error.Message
|
||||
If ResourceFileLoader.Error IsNot Nothing Then ErrorMessage = ResourceFileLoader.Error.Message
|
||||
If ErrorMessage.Contains("不是有效的 json 文件") Then
|
||||
Log("[Comp] 下载的文件 json 列表损坏,已自动重试", LogLevel.Debug)
|
||||
Log("[Resource] 下载的文件 json 列表损坏,已自动重试", NotifyLevel.DebugModeOnly)
|
||||
PageLoaderRestart()
|
||||
End If
|
||||
End Select
|
||||
@@ -73,15 +73,15 @@
|
||||
Private GroupedDrop As Boolean '是否按 Drop 筛选(1.21 / 1.20 / 1.19 / ...)而非小版本号(1.21.1 / 1.21 / 1.20.4 / ...)
|
||||
Private GroupedOld As Boolean '是否折叠远古版本为一个选项
|
||||
'筛选类型相同的结果(Modrinth 会返回 Mod、服务端插件、数据包混合的列表)
|
||||
Private Function GetResults() As List(Of CompFile)
|
||||
Dim Results As List(Of CompFile) = CompFileLoader.Output
|
||||
Private Function GetResults() As List(Of ResourceVersion)
|
||||
Dim Results As List(Of ResourceVersion) = ResourceFileLoader.Output
|
||||
Select Case TargetType
|
||||
Case CompType.Any
|
||||
Results = Results.Where(Function(r) r.Type <> CompType.Plugin).ToList
|
||||
Case CompType.Shader, CompType.ResourcePack
|
||||
Case ResourceTypes.Any
|
||||
Results = Results.Where(Function(r) r.ResourceType <> ResourceTypes.Plugin).ToList
|
||||
Case ResourceTypes.Shader, ResourceTypes.ResourcePack
|
||||
'不筛选光影和资源包,否则原版光影会因为是资源包格式而被过滤(#6473)
|
||||
Case Else
|
||||
Results = Results.Where(Function(r) r.Type = TargetType).ToList
|
||||
Results = Results.Where(Function(r) r.ResourceType = TargetType).ToList
|
||||
End Select
|
||||
Return Results
|
||||
End Function
|
||||
@@ -153,13 +153,13 @@ GroupDone:
|
||||
Private Sub UpdateFilterResult()
|
||||
Dim Results = GetResults()
|
||||
|
||||
Dim TargetCardName As String = If(TargetInstance <> "" OrElse TargetLoader <> CompModLoaderType.Any,
|
||||
$"{If(TargetLoader <> CompModLoaderType.Any, TargetLoader.ToString & " ", "")}{TargetInstance}(所选版本)", "")
|
||||
Dim TargetCardName As String = If(TargetInstance <> "" OrElse TargetLoader <> ModLoaderTypes.Any,
|
||||
$"{If(TargetLoader <> ModLoaderTypes.Any, TargetLoader.ToString & " ", "")}{TargetInstance}(所选版本)", "")
|
||||
'归类到卡片下
|
||||
Dim Dict As New SortedDictionary(Of String, List(Of CompFile))(New CardSorter(TargetCardName))
|
||||
Dict.Add("其他", New List(Of CompFile))
|
||||
Dim SupportedLoaders As New List(Of Integer)([Enum].GetValues(GetType(CompModLoaderType)))
|
||||
For Each Version As CompFile In Results
|
||||
Dim Dict As New SortedDictionary(Of String, List(Of ResourceVersion))(New CardSorter(TargetCardName))
|
||||
Dict.Add("其他", New List(Of ResourceVersion))
|
||||
Dim SupportedLoaders As New List(Of Integer)([Enum].GetValues(GetType(ModLoaderTypes)))
|
||||
For Each Version As ResourceVersion In Results
|
||||
For Each GameVersion In Version.GameVersions
|
||||
'检查是否符合版本筛选器
|
||||
If VersionFilter IsNot Nothing AndAlso
|
||||
@@ -168,11 +168,11 @@ GroupDone:
|
||||
Dim VerName As String = GetGroupedVersionName(GameVersion, False, False)
|
||||
'遍历加入的加载器列表
|
||||
Dim Loaders As New List(Of String)
|
||||
If Project.ModLoaders.Count > 1 AndAlso '工程至少有两个加载器
|
||||
Version.Type = CompType.Mod AndAlso '是 Mod
|
||||
If Project.Loaders.Count > 1 AndAlso '工程至少有两个加载器
|
||||
Version.ResourceType = ResourceTypes.Mod AndAlso '是 Mod
|
||||
McVersion.IsFormatFit(VerName) Then '不是 “快照版本” 之类的
|
||||
For Each Loader In Version.ModLoaders
|
||||
If Loader = CompModLoaderType.Quilt AndAlso Settings.Get("ToolDownloadIgnoreQuilt") Then Continue For
|
||||
For Each Loader In Version.Loaders
|
||||
If Loader = ModLoaderTypes.Quilt AndAlso Settings.Get("ToolDownloadIgnoreQuilt") Then Continue For
|
||||
If SupportedLoaders.Contains(Loader) Then Loaders.Add(Loader.ToString & " ")
|
||||
Next
|
||||
End If
|
||||
@@ -180,17 +180,17 @@ GroupDone:
|
||||
'实际添加
|
||||
For Each Loader In Loaders
|
||||
Dim TargetCard As String = Loader & VerName
|
||||
If Not Dict.ContainsKey(TargetCard) Then Dict.Add(TargetCard, New List(Of CompFile))
|
||||
If Not Dict.ContainsKey(TargetCard) Then Dict.Add(TargetCard, New List(Of ResourceVersion))
|
||||
If Not Dict(TargetCard).Contains(Version) Then Dict(TargetCard).Add(Version)
|
||||
Next
|
||||
Next
|
||||
Next
|
||||
'添加筛选的版本的卡片
|
||||
If TargetCardName <> "" AndAlso (VersionFilter Is Nothing OrElse GetGroupedVersionName(TargetInstance, GroupedDrop, GroupedOld).StartsWithF(VersionFilter)) Then
|
||||
Dict.Add(TargetCardName, New List(Of CompFile))
|
||||
For Each Version As CompFile In Results
|
||||
Dict.Add(TargetCardName, New List(Of ResourceVersion))
|
||||
For Each Version As ResourceVersion In Results
|
||||
If Version.GameVersions.Contains(TargetInstance) AndAlso
|
||||
(TargetLoader = CompModLoaderType.Any OrElse Version.ModLoaders.Contains(TargetLoader)) Then
|
||||
(TargetLoader = ModLoaderTypes.Any OrElse Version.Loaders.Contains(TargetLoader)) Then
|
||||
'检查是否符合版本筛选器
|
||||
If VersionFilter IsNot Nothing AndAlso
|
||||
Not Version.GameVersions.Any(Function(v) GetGroupedVersionName(v, GroupedDrop, GroupedOld) = VersionFilter) Then Continue For
|
||||
@@ -201,11 +201,11 @@ GroupDone:
|
||||
'转化为 UI
|
||||
Try
|
||||
PanResults.Children.Clear()
|
||||
For Each Pair As KeyValuePair(Of String, List(Of CompFile)) In Dict
|
||||
For Each Pair As KeyValuePair(Of String, List(Of ResourceVersion)) In Dict
|
||||
If Not Pair.Value.Any() Then Continue For
|
||||
If Pair.Key = TargetCardName.Replace("(所选版本)", "") Then Continue For
|
||||
'增加卡片
|
||||
Dim NewCard As New MyCard With {.Title = Pair.Key, .Margin = New Thickness(0, 0, 0, 15), .SwapType = If(TargetType = CompType.ModPack, 9, 8)} '9 是安装,8 是另存为
|
||||
Dim NewCard As New MyCard With {.Title = Pair.Key, .Margin = New Thickness(0, 0, 0, 15), .SwapType = If(TargetType = ResourceTypes.ModPack, 9, 8)} '9 是安装,8 是另存为
|
||||
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}
|
||||
NewCard.Children.Add(NewStack)
|
||||
NewCard.SwapControl = NewStack
|
||||
@@ -214,7 +214,7 @@ GroupDone:
|
||||
If Pair.Key = TargetCardName OrElse
|
||||
(FrmMain.PageCurrent.Additional IsNot Nothing AndAlso '#2761
|
||||
CType(FrmMain.PageCurrent.Additional(1), List(Of String)).Contains(NewCard.Title)) Then
|
||||
MyCard.StackInstall(NewStack, If(TargetType = CompType.ModPack, 9, 8), Pair.Key) '9 是安装,8 是另存为
|
||||
MyCard.StackInstall(NewStack, If(TargetType = ResourceTypes.ModPack, 9, 8), Pair.Key) '9 是安装,8 是另存为
|
||||
Else
|
||||
NewCard.IsSwapped = True
|
||||
End If
|
||||
@@ -228,15 +228,15 @@ GroupDone:
|
||||
CType(PanResults.Children(0), MyCard).IsSwapped = False
|
||||
End If
|
||||
'替代提示
|
||||
If Project.Types = CompType.ModOrDataPack AndAlso (TargetType = CompType.Mod OrElse TargetType = CompType.DataPack) Then
|
||||
If Project.Types = ResourceTypes.ModOrDataPack AndAlso (TargetType = ResourceTypes.Mod OrElse TargetType = ResourceTypes.DataPack) Then
|
||||
HintAlternative.Visibility = Visibility.Visible
|
||||
HintAlternative.Text = If(TargetType = CompType.Mod,
|
||||
HintAlternative.Text = If(TargetType = ResourceTypes.Mod,
|
||||
"以下是该项目的 Mod 版本。点击这里查看其数据包版本。", "以下是该项目的数据包版本。点击这里查看其 Mod 版本。")
|
||||
Else
|
||||
HintAlternative.Visibility = Visibility.Collapsed
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Log(ex, "可视化工程下载列表出错", LogLevel.Feedback)
|
||||
Log(ex, "可视化工程下载列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
Private Function GetGroupedVersionName(Name As String, GroupedByDrop As Boolean, FoldOld As Boolean) As String
|
||||
@@ -271,14 +271,14 @@ GroupDone:
|
||||
End If
|
||||
|
||||
'放置当前工程
|
||||
If CompItem IsNot Nothing Then PanIntro.Children.Remove(CompItem)
|
||||
CompItem = Project.ToCompItem(True, True).Init()
|
||||
CompItem.CanInteraction = False
|
||||
CompItem.Margin = New Thickness(-7, -7, 0, 8)
|
||||
PanIntro.Children.Insert(0, CompItem)
|
||||
If ResourceItem IsNot Nothing Then PanIntro.Children.Remove(ResourceItem)
|
||||
ResourceItem = Project.ToResourceItem(True, True).Init()
|
||||
ResourceItem.CanInteraction = False
|
||||
ResourceItem.Margin = New Thickness(-7, -7, 0, 8)
|
||||
PanIntro.Children.Insert(0, ResourceItem)
|
||||
|
||||
'决定按钮显示
|
||||
BtnIntroWeb.Text = If(Project.FromCurseForge, "转到 CurseForge", "转到 Modrinth")
|
||||
BtnIntroWeb.Text = $"转到 {Project.Platform}"
|
||||
BtnIntroWiki.Visibility = If(Project.WikiId = 0, Visibility.Collapsed, Visibility.Visible)
|
||||
|
||||
AniControlEnabled -= 1
|
||||
@@ -289,8 +289,8 @@ GroupDone:
|
||||
Try
|
||||
|
||||
'获取基本信息
|
||||
Dim File As CompFile = sender.Tag
|
||||
Dim LoaderName As String = $"{If(Project.FromCurseForge, "CurseForge", "Modrinth")} 整合包下载:{Project.TranslatedName} "
|
||||
Dim File As ResourceVersion = sender.Tag
|
||||
Dim LoaderName As String = $"{Project.Platform} 整合包下载:{Project.TranslatedName} "
|
||||
|
||||
'获取版本名
|
||||
Dim PackName As String = Project.TranslatedName.Replace(".zip", "").Replace(".rar", "").Replace(".mrpack", "").Replace("\", "\").Replace("/", "/").Replace("|", "|").Replace(":", ":").Replace("<", "<").Replace(">", ">").Replace("*", "*").Replace("?", "?").Replace("""", "").Replace(": ", ":")
|
||||
@@ -301,8 +301,8 @@ GroupDone:
|
||||
|
||||
'构造步骤加载器
|
||||
Dim Loaders As New List(Of LoaderBase)
|
||||
Dim Target As String = $"{McFolderSelected}versions\{InstanceName}\原始整合包.{If(Project.FromCurseForge, "zip", "mrpack")}"
|
||||
Dim LogoFileAddress As String = CompItem.PathLogo.ActualSource
|
||||
Dim Target As String = $"{McFolderSelected}versions\{InstanceName}\原始整合包.{If(Project.Platform = ResourcePlatforms.CurseForge, "zip", "mrpack")}"
|
||||
Dim LogoFileAddress As String = ResourceItem.PathLogo.ActualSource
|
||||
Loaders.Add(New LoaderDownload("下载整合包文件", New List(Of NetFile) From {File.ToNetFile(Target)}) With {.ProgressWeight = 10, .Block = True})
|
||||
Loaders.Add(New LoaderTask(Of Integer, Integer)("准备安装整合包",
|
||||
Sub() ModpackInstall(Target, InstanceName, If(IO.File.Exists(LogoFileAddress), LogoFileAddress, Nothing))) With {.ProgressWeight = 0.1})
|
||||
@@ -326,49 +326,49 @@ GroupDone:
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
|
||||
Catch ex As Exception
|
||||
Log(ex, "下载资源整合包失败", LogLevel.Feedback)
|
||||
Log(ex, "下载资源整合包失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
'资源下载;整合包另存为
|
||||
Public Shared CachedFolder As New Dictionary(Of CompType, String) '仅在本次缓存的下载文件夹
|
||||
Public Shared CachedFolder As New Dictionary(Of ResourceTypes, String) '仅在本次缓存的下载文件夹
|
||||
Public Sub Save_Click(sender As Object, e As EventArgs)
|
||||
Dim File As CompFile = If(TypeOf sender Is MyListItem, sender, sender.Parent).Tag
|
||||
Dim File As ResourceVersion = If(TypeOf sender Is MyListItem, sender, sender.Parent).Tag
|
||||
RunInNewThread(
|
||||
Sub()
|
||||
Try
|
||||
Dim Desc As String = Nothing
|
||||
Select Case File.Type
|
||||
Case CompType.ModPack : Desc = "整合包"
|
||||
Case CompType.Mod : Desc = "Mod "
|
||||
Case CompType.ResourcePack : Desc = "资源包"
|
||||
Case CompType.Shader : Desc = "光影包"
|
||||
Case CompType.DataPack : Desc = "数据包"
|
||||
Select Case File.ResourceType
|
||||
Case ResourceTypes.ModPack : Desc = "整合包"
|
||||
Case ResourceTypes.Mod : Desc = "Mod "
|
||||
Case ResourceTypes.ResourcePack : Desc = "资源包"
|
||||
Case ResourceTypes.Shader : Desc = "光影包"
|
||||
Case ResourceTypes.DataPack : Desc = "数据包"
|
||||
End Select
|
||||
'确认默认保存位置
|
||||
Dim DefaultFolder As String = Nothing
|
||||
If File.Type <> CompType.ModPack Then
|
||||
If File.ResourceType <> ResourceTypes.ModPack Then
|
||||
Dim SubFolder As String = Nothing
|
||||
Select Case File.Type
|
||||
Case CompType.Mod : SubFolder = "mods\"
|
||||
Case CompType.ResourcePack : SubFolder = "resourcepacks\"
|
||||
Case CompType.Shader : SubFolder = "shaderpacks\"
|
||||
Case CompType.DataPack : SubFolder = "" '导航到版本根目录
|
||||
Select Case File.ResourceType
|
||||
Case ResourceTypes.Mod : SubFolder = "mods\"
|
||||
Case ResourceTypes.ResourcePack : SubFolder = "resourcepacks\"
|
||||
Case ResourceTypes.Shader : SubFolder = "shaderpacks\"
|
||||
Case ResourceTypes.DataPack : SubFolder = "" '导航到版本根目录
|
||||
End Select
|
||||
Dim IsInstanceSuitable As Func(Of McInstance, Boolean) = Nothing
|
||||
'获取资源所需的加载器
|
||||
Dim AllowedLoaders As New List(Of CompModLoaderType)
|
||||
If File.ModLoaders.Any Then
|
||||
AllowedLoaders = File.ModLoaders
|
||||
ElseIf Project.ModLoaders.Any Then
|
||||
AllowedLoaders = Project.ModLoaders
|
||||
Dim AllowedLoaders As New List(Of ModLoaderTypes)
|
||||
If File.Loaders.Any Then
|
||||
AllowedLoaders = File.Loaders
|
||||
ElseIf Project.Loaders.Any Then
|
||||
AllowedLoaders = Project.Loaders
|
||||
End If
|
||||
Log($"[Comp] {Desc}要求的加载器种类:" & If(AllowedLoaders.Any(), AllowedLoaders.Join(" / "), "无要求"))
|
||||
Log($"[Resource] {Desc}要求的加载器种类:" & If(AllowedLoaders.Any(), AllowedLoaders.Join(" / "), "无要求"))
|
||||
'判断某个版本是否符合资源要求
|
||||
IsInstanceSuitable =
|
||||
Function(Instance As McInstance)
|
||||
If Not Instance.IsLoaded Then Instance.Load()
|
||||
'只对 Mod 和数据包进行版本检测
|
||||
If File.Type = CompType.Mod OrElse File.Type = CompType.DataPack Then
|
||||
If File.ResourceType = ResourceTypes.Mod OrElse File.ResourceType = ResourceTypes.DataPack Then
|
||||
If Not File.GameVersions.Any( '判断是否有任何一个版本匹配
|
||||
Function(FileVersion)
|
||||
Dim FileIsSnapshot As Boolean = FileVersion.Contains("预览版") OrElse Not FileVersion.Contains(".")
|
||||
@@ -404,20 +404,20 @@ GroupDone:
|
||||
End If
|
||||
'加载器
|
||||
If Not AllowedLoaders.Any() Then Return True '无要求
|
||||
If AllowedLoaders.Contains(CompModLoaderType.Forge) AndAlso Instance.Version.HasForge Then Return True
|
||||
If AllowedLoaders.Contains(CompModLoaderType.Fabric) AndAlso Instance.Version.HasFabric Then Return True
|
||||
If AllowedLoaders.Contains(CompModLoaderType.NeoForge) AndAlso Instance.Version.HasNeoForge Then Return True
|
||||
If AllowedLoaders.Contains(CompModLoaderType.LiteLoader) AndAlso Instance.Version.HasLiteLoader Then Return True
|
||||
If AllowedLoaders.Contains(ModLoaderTypes.Forge) AndAlso Instance.Version.HasForge Then Return True
|
||||
If AllowedLoaders.Contains(ModLoaderTypes.Fabric) AndAlso Instance.Version.HasFabric Then Return True
|
||||
If AllowedLoaders.Contains(ModLoaderTypes.NeoForge) AndAlso Instance.Version.HasNeoForge Then Return True
|
||||
If AllowedLoaders.Contains(ModLoaderTypes.LiteLoader) AndAlso Instance.Version.HasLiteLoader Then Return True
|
||||
Return False
|
||||
End Function
|
||||
'获取常规资源默认下载位置
|
||||
If CachedFolder.ContainsKey(File.Type) Then
|
||||
DefaultFolder = CachedFolder(File.Type)
|
||||
Log($"[Comp] 使用上次下载时的文件夹作为默认下载位置:{DefaultFolder}")
|
||||
If CachedFolder.ContainsKey(File.ResourceType) Then
|
||||
DefaultFolder = CachedFolder(File.ResourceType)
|
||||
Log($"[Resource] 使用上次下载时的文件夹作为默认下载位置:{DefaultFolder}")
|
||||
ElseIf McInstanceSelected IsNot Nothing AndAlso IsInstanceSuitable(McInstanceSelected) Then
|
||||
DefaultFolder = $"{McInstanceSelected.PathIndie}{SubFolder}"
|
||||
Directory.CreateDirectory(DefaultFolder)
|
||||
Log($"[Comp] 使用当前版本作为默认下载位置:{DefaultFolder}")
|
||||
DirectoryUtils.Create(DefaultFolder)
|
||||
Log($"[Resource] 使用当前版本作为默认下载位置:{DefaultFolder}")
|
||||
Else
|
||||
'查找所有可能的版本
|
||||
Dim NeedLoad As Boolean = McInstanceListLoader.State <> LoadState.Finished
|
||||
@@ -433,14 +433,14 @@ GroupDone:
|
||||
ThenByDescending(Function(Dir) If(Dir.Exists, Dir.GetFiles().Length, -1)). '再按文件夹中的文件数量降序
|
||||
First()
|
||||
DefaultFolder = SelectedInstance.FullName
|
||||
Directory.CreateDirectory(DefaultFolder)
|
||||
Log($"[Comp] 使用适合的游戏版本作为默认下载位置:{DefaultFolder}")
|
||||
DirectoryUtils.Create(DefaultFolder)
|
||||
Log($"[Resource] 使用适合的游戏版本作为默认下载位置:{DefaultFolder}")
|
||||
Else
|
||||
DefaultFolder = McFolderSelected
|
||||
If NeedLoad Then
|
||||
Hint($"当前 MC 文件夹中没有找到合适的版本!")
|
||||
Else
|
||||
Log("[Comp] 由于当前版本不兼容,使用当前的 MC 文件夹作为默认下载位置")
|
||||
Log("[Resource] 由于当前版本不兼容,使用当前的 MC 文件夹作为默认下载位置")
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
@@ -465,20 +465,20 @@ GroupDone:
|
||||
FileName = File.FileName
|
||||
End Select
|
||||
End If
|
||||
If File.Type = CompType.Mod Then FileName = FileName.Replace("~", "-") '~ 会导致 Mixin 加载失败
|
||||
If File.ResourceType = ResourceTypes.Mod Then FileName = FileName.Replace("~", "-") '~ 会导致 Mixin 加载失败
|
||||
RunInUi(
|
||||
Sub()
|
||||
'弹窗要求选择保存位置
|
||||
Dim Target As String
|
||||
Target = SelectSaveFile("选择保存位置", FileName,
|
||||
Desc & "文件|" &
|
||||
If(File.Type = CompType.Mod,
|
||||
If(File.ResourceType = ResourceTypes.Mod,
|
||||
If(File.FileName.EndsWithF(".litemod"), "*.litemod", "*.jar"),
|
||||
If(File.FileName.EndsWithF(".mrpack"), "*.mrpack", "*.zip")), DefaultFolder)
|
||||
If Not Target.Contains("\") Then Return
|
||||
'构造步骤加载器
|
||||
Dim LoaderName As String = Desc & "下载:" & IO.Path.GetFileNameWithoutExtension(Target) & " "
|
||||
If Target <> DefaultFolder Then CachedFolder(File.Type) = GetPathFromFullPath(Target)
|
||||
Dim LoaderName As String = Desc & "下载:" & Path.GetFileNameWithoutExtension(Target) & " "
|
||||
If Target <> DefaultFolder Then CachedFolder(File.ResourceType) = GetPathFromFullPath(Target)
|
||||
Dim Loaders As New List(Of LoaderBase)
|
||||
Loaders.Add(New LoaderDownload("下载文件", New List(Of NetFile) From {File.ToNetFile(Target)}) With {.ProgressWeight = 6, .Block = True})
|
||||
'启动
|
||||
@@ -489,9 +489,9 @@ GroupDone:
|
||||
FrmMain.BtnExtraDownload.Ribble()
|
||||
End Sub)
|
||||
Catch ex As Exception
|
||||
Log(ex, "保存资源文件失败", LogLevel.Feedback)
|
||||
Log(ex, "保存资源文件失败", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub, "Download CompDetail Save")
|
||||
End Sub, "Download Resource Detail Save")
|
||||
End Sub
|
||||
|
||||
Private Sub BtnIntroWeb_Click(sender As Object, e As EventArgs) Handles BtnIntroWeb.Click
|
||||
@@ -501,14 +501,39 @@ GroupDone:
|
||||
OpenWebsite("https://www.mcmod.cn/class/" & Project.WikiId & ".html")
|
||||
End Sub
|
||||
Private Sub BtnIntroCopy_Click(sender As Object, e As EventArgs) Handles BtnIntroCopy.Click
|
||||
ClipboardSet(CompItem.LabTitle.Text & CompItem.LabTitleRaw.Text)
|
||||
ClipboardSet(ResourceItem.LabTitle.Text & ResourceItem.LabTitleRaw.Text)
|
||||
End Sub
|
||||
|
||||
'Mod / 数据包 互相跳转
|
||||
Private Sub HintAlternative_Click() Handles HintAlternative.Click
|
||||
TargetType = If(TargetType = CompType.Mod, CompType.DataPack, CompType.Mod)
|
||||
TargetType = If(TargetType = ResourceTypes.Mod, ResourceTypes.DataPack, ResourceTypes.Mod)
|
||||
FrmMain.PageCurrent.Additional(4) = TargetType '加载器会从这里重新拿数据
|
||||
PageLoaderRestart(IsForceRestart:=True)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 预载包含大量 ProjectVersion 的卡片,添加必要的元素和前置列表。
|
||||
''' </summary>
|
||||
Public Shared Sub ResourceFilesCardPreload(Stack As StackPanel, Files As List(Of ResourceVersion))
|
||||
'获取卡片对应的前置 ID
|
||||
'如果为整合包就不会有 Dependencies 信息,所以不用管
|
||||
Dim Deps As List(Of String) = Files.SelectMany(Function(f) f.Dependencies).Distinct.ToList()
|
||||
Deps.Sort()
|
||||
If Not Deps.Any() Then Return
|
||||
Deps = Deps.Where(
|
||||
Function(dep)
|
||||
If Not ResourceProject.Cache.ContainsKey(dep) Then Log($"[Resource] 未找到 ID {dep} 的前置信息", NotifyLevel.DebugModeOnly)
|
||||
Return ResourceProject.Cache.ContainsKey(dep)
|
||||
End Function).ToList
|
||||
'添加开头间隔
|
||||
Stack.Children.Add(New TextBlock With {.Text = "前置资源", .FontSize = 14, .HorizontalAlignment = HorizontalAlignment.Left, .Margin = New Thickness(6, 2, 0, 5)})
|
||||
'添加前置列表
|
||||
For Each Dep In Deps
|
||||
Dim Item = ResourceProject.Cache(Dep).ToResourceItem(False, False)
|
||||
Stack.Children.Add(Item)
|
||||
Next
|
||||
'添加结尾间隔
|
||||
Stack.Children.Add(New TextBlock With {.Text = "版本列表", .FontSize = 14, .HorizontalAlignment = HorizontalAlignment.Left, .Margin = New Thickness(6, 12, 0, 5)})
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
xmlns:local="clr-namespace:PCL" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" x:Class="PageDownloadDataPack"
|
||||
PanScroll="Content">
|
||||
<local:PageComp x:Name="Content" PageType="DataPack" TypeName="数据包" TypeNameSpaced="数据包">
|
||||
<local:PageResource x:Name="Content" PageType="DataPack" TypeName="数据包" TypeNameSpaced="数据包">
|
||||
<local:MyComboBoxItem Tag="" Content="全部" IsSelected="True" />
|
||||
<local:MyComboBoxItem Content="世界元素" Tag="/worldgen" />
|
||||
<local:MyComboBoxItem Content="科技" Tag="6951/technology" />
|
||||
@@ -22,5 +22,5 @@
|
||||
<local:MyComboBoxItem Content="服务器" Tag="/social" />
|
||||
<local:MyComboBoxItem Content="支持库" Tag="6950/library" />
|
||||
<local:MyComboBoxItem Content="Mod 相关" Tag="6946/" />
|
||||
</local:PageComp>
|
||||
</local:PageResource>
|
||||
</local:MyPageRight>
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
xmlns:local="clr-namespace:PCL" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" x:Class="PageDownloadMod"
|
||||
PanScroll="Content">
|
||||
<local:PageComp x:Name="Content" PageType="Mod" TypeName="Mod" TypeNameSpaced=" Mod ">
|
||||
<local:PageResource x:Name="Content" PageType="Mod" TypeName="Mod" TypeNameSpaced=" Mod ">
|
||||
<local:MyComboBoxItem Content="全部" Tag="" IsSelected="True" />
|
||||
<local:MyComboBoxItem Content="世界元素" Tag="406/worldgen" />
|
||||
<local:MyComboBoxItem Content="生物群系" Tag="407/" Margin="15,0,0,0" />
|
||||
@@ -32,5 +32,5 @@
|
||||
<local:MyComboBoxItem Content="信息显示" Tag="423/" />
|
||||
<local:MyComboBoxItem Content="服务器" Tag="435/social" />
|
||||
<local:MyComboBoxItem Content="支持库" Tag="421/library" />
|
||||
</local:PageComp>
|
||||
</local:PageResource>
|
||||
</local:MyPageRight>
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
xmlns:local="clr-namespace:PCL" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" x:Class="PageDownloadPack"
|
||||
PanScroll="Content">
|
||||
<local:PageComp x:Name="Content" PageType="ModPack" TypeName="整合包" TypeNameSpaced="整合包">
|
||||
<local:PageResource x:Name="Content" PageType="ModPack" TypeName="整合包" TypeNameSpaced="整合包">
|
||||
<local:MyComboBoxItem Tag="" Content="全部" IsSelected="True" />
|
||||
<local:MyComboBoxItem Tag="4484/" Content="多人" />
|
||||
<local:MyComboBoxItem Tag="/optimization" Content="性能优化" />
|
||||
@@ -24,5 +24,5 @@
|
||||
<local:MyComboBoxItem Tag="4480/" Content="基于地图" />
|
||||
<local:MyComboBoxItem Tag="4481/lightweight" Content="轻量整合" />
|
||||
<local:MyComboBoxItem Tag="4482/" Content="大型整合" />
|
||||
</local:PageComp>
|
||||
</local:PageResource>
|
||||
</local:MyPageRight>
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
xmlns:local="clr-namespace:PCL" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" x:Class="PageDownloadResourcePack"
|
||||
PanScroll="Content">
|
||||
<local:PageComp x:Name="Content" PageType="ResourcePack" TypeName="资源包" TypeNameSpaced="资源包">
|
||||
<local:PageResource x:Name="Content" PageType="ResourcePack" TypeName="资源包" TypeNameSpaced="资源包">
|
||||
<local:MyComboBoxItem Tag="" Content="全部" IsSelected="True" />
|
||||
|
||||
<local:MyComboBoxItem Content="风格" IsEnabled="False" />
|
||||
@@ -41,5 +41,5 @@
|
||||
<local:MyComboBoxItem Margin="15,0,0,0" Content="128x" Tag="396/128x" />
|
||||
<local:MyComboBoxItem Margin="15,0,0,0" Content="256x" Tag="397/256x" />
|
||||
<local:MyComboBoxItem Margin="15,0,0,0" Content="512x 或更高" Tag="398/512x+" />
|
||||
</local:PageComp>
|
||||
</local:PageResource>
|
||||
</local:MyPageRight>
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
xmlns:local="clr-namespace:PCL" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" x:Class="PageDownloadShader"
|
||||
PanScroll="Content">
|
||||
<local:PageComp x:Name="Content" PageType="Shader" TypeName="光影包" TypeNameSpaced="光影包">
|
||||
<local:PageResource x:Name="Content" PageType="Shader" TypeName="光影包" TypeNameSpaced="光影包">
|
||||
<local:MyComboBoxItem Tag="" Content="全部" IsSelected="True" />
|
||||
|
||||
<local:MyComboBoxItem Content="风格" IsEnabled="False" />
|
||||
@@ -30,5 +30,5 @@
|
||||
<local:MyComboBoxItem Margin="15,0,0,0" Content="原版可用" Tag="/vanilla" ToolTip="作为资源包加载,可以直接在原版游戏里使用。" ToolTipService.HorizontalOffset="70" />
|
||||
<local:MyComboBoxItem Margin="15,0,0,0" Content="Iris" Tag="/iris" />
|
||||
<local:MyComboBoxItem Margin="15,0,0,0" Content="OptiFine" Tag="/optifine" />
|
||||
</local:PageComp>
|
||||
</local:PageResource>
|
||||
</local:MyPageRight>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<local:MyScrollViewer x:Class="PageComp"
|
||||
<local:MyScrollViewer x:Class="PageResource"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
+20
-20
@@ -1,7 +1,7 @@
|
||||
Imports System.Windows.Markup
|
||||
|
||||
<ContentProperty("SearchTags")>
|
||||
Public Class PageComp
|
||||
Public Class PageResource
|
||||
|
||||
#Region "属性"
|
||||
|
||||
@@ -48,17 +48,17 @@ Public Class PageComp
|
||||
''' <summary>
|
||||
''' 该页面对应的资源类型。
|
||||
''' </summary>
|
||||
Public Property PageType As CompType
|
||||
Public Property PageType As ResourceTypes
|
||||
Get
|
||||
Return _Type
|
||||
End Get
|
||||
Set(Value As CompType)
|
||||
Set(Value As ResourceTypes)
|
||||
If _Type = Value Then Return
|
||||
_Type = Value
|
||||
BtnSearchInstallModPack.Visibility = If(Value = CompType.ModPack, Visibility.Visible, Visibility.Collapsed)
|
||||
BtnSearchInstallModPack.Visibility = If(Value = ResourceTypes.ModPack, Visibility.Visible, Visibility.Collapsed)
|
||||
End Set
|
||||
End Property
|
||||
Private _Type As CompType = -1
|
||||
Private _Type As ResourceTypes = -1
|
||||
|
||||
#End Region
|
||||
|
||||
@@ -73,10 +73,10 @@ Public Class PageComp
|
||||
''' </summary>
|
||||
Public Shared TargetName As String = Nothing
|
||||
|
||||
'在点击 MyCompItem 时会获取 Loader 的输入,以使资源详情页面可以应用相同的筛选项
|
||||
Public Loader As New LoaderTask(Of CompProjectRequest, Integer)("社区资源获取:XXX", AddressOf CompProjectsGet, AddressOf LoaderInput) With {.ReloadTimeout = 60 * 1000}
|
||||
'在点击 MyResourceItem 时会获取 Loader 的输入,以使资源详情页面可以应用相同的筛选项
|
||||
Public Loader = ResourceSearcher.GetLoader(AddressOf LoaderInput)
|
||||
|
||||
Private Sub PageCompControls_Inited(sender As Object, e As EventArgs) Handles Me.Loaded
|
||||
Private Sub PageResource_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
|
||||
Static IsFirstLoaded As Boolean = False
|
||||
'不知道从 Initialized 改成 Loaded 会不会有问题,但用 Initialized 会导致初始的筛选器修改被覆盖回默认值
|
||||
If TargetInstance IsNot Nothing Then
|
||||
@@ -118,23 +118,23 @@ Public Class PageComp
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Private Function LoaderInput() As CompProjectRequest
|
||||
Dim Request As New CompProjectRequest(PageType, Storage, (Page + 1) * PAGE_SIZE)
|
||||
Private Function LoaderInput() As ResourceSearcher.SearchRequest
|
||||
Dim Request As New ResourceSearcher.SearchRequest(PageType, Storage, (Page + 1) * PAGE_SIZE)
|
||||
Dim GameVersion As String = If(TextSearchVersion.Text = "全部 (也可自行输入)", Nothing,
|
||||
If(TextSearchVersion.Text.Contains(".") OrElse TextSearchVersion.Text.Contains("w"), TextSearchVersion.Text, Nothing))
|
||||
With Request
|
||||
.SearchText = TextSearchName.Text
|
||||
.GameVersion = GameVersion
|
||||
.Tag = ComboSearchTag.SelectedItem.Tag
|
||||
.ModLoader = If(PageType = CompType.Mod, Val(ComboSearchLoader.SelectedItem.Tag), CompModLoaderType.Any)
|
||||
.Sources = CType(Val(ComboSearchSource.SelectedItem.Tag), CompSourceType)
|
||||
.ModLoader = If(PageType = ResourceTypes.Mod, Val(ComboSearchLoader.SelectedItem.Tag), ModLoaderTypes.Any)
|
||||
.Sources = CType(Val(ComboSearchSource.SelectedItem.Tag), ResourcePlatforms)
|
||||
End With
|
||||
Return Request
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
Public Storage As New CompProjectStorage
|
||||
Public Storage As New ResourceSearcher.SearchResult
|
||||
''' <summary>
|
||||
''' 每页展示的结果数量。
|
||||
''' </summary>
|
||||
@@ -144,14 +144,14 @@ Public Class PageComp
|
||||
'结果 UI 化
|
||||
Private Sub Load_OnFinish()
|
||||
Try
|
||||
Log($"[Comp] 开始可视化{TypeNameSpaced}列表,已储藏 {Storage.Results.Count} 个结果,当前在第 {Page + 1} 页")
|
||||
Log($"[Resource] 开始可视化{TypeNameSpaced}列表,已储藏 {Storage.Results.Count} 个结果,当前在第 {Page + 1} 页")
|
||||
'列表项
|
||||
PanProjects.Children.Clear()
|
||||
Dim Index As Integer = Math.Min(Page * PAGE_SIZE, Storage.Results.Count - 1)
|
||||
For Each Result In Storage.Results.GetRange(Index, Math.Min(Storage.Results.Count - Index, PAGE_SIZE))
|
||||
PanProjects.Children.Add(Result.ToCompItem(
|
||||
PanProjects.Children.Add(Result.ToResourceItem(
|
||||
ShowMcVersionDesc:=Loader.Input.GameVersion Is Nothing,
|
||||
ShowLoaderDesc:=Loader.Input.ModLoader = CompModLoaderType.Any AndAlso (PageType = CompType.Mod OrElse PageType = CompType.ModPack)))
|
||||
ShowLoaderDesc:=Loader.Input.ModLoader = ModLoaderTypes.Any AndAlso (PageType = ResourceTypes.Mod OrElse PageType = ResourceTypes.ModPack)))
|
||||
Next
|
||||
'页码
|
||||
CardPages.Visibility = If(Storage.Results.Count > 40 OrElse
|
||||
@@ -177,7 +177,7 @@ Public Class PageComp
|
||||
'强制返回顶部
|
||||
ScrollToTop()
|
||||
Catch ex As Exception
|
||||
Log(ex, $"可视化{TypeNameSpaced}列表出错", LogLevel.Feedback)
|
||||
Log(ex, $"可视化{TypeNameSpaced}列表出错", NotifyLevel.MsgBoxAndFeedback)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -188,7 +188,7 @@ Public Class PageComp
|
||||
Dim ErrorMessage As String = ""
|
||||
If Loader.Error IsNot Nothing Then ErrorMessage = Loader.Error.Message
|
||||
If ErrorMessage.Contains("不是有效的 json 文件") Then
|
||||
Log($"[Download] 下载的{TypeNameSpaced}列表 json 文件损坏,已自动重试", LogLevel.Debug)
|
||||
Log($"[Download] 下载的{TypeNameSpaced}列表 json 文件损坏,已自动重试", NotifyLevel.DebugModeOnly)
|
||||
CType(Parent, MyPageRight).PageLoaderRestart()
|
||||
End If
|
||||
End Select
|
||||
@@ -222,7 +222,7 @@ Public Class PageComp
|
||||
'搜索按钮
|
||||
Private Sub StartNewSearch() Handles BtnSearchRun.Click
|
||||
Page = 0
|
||||
If Loader.ShouldStart(LoaderInput()) Then Storage = New CompProjectStorage '避免连续搜索两次使得 CompProjectStorage 引用丢失(#1311)
|
||||
If Loader.ShouldStart(LoaderInput()) Then Storage = New ResourceSearcher.SearchResult '避免连续搜索两次导致 ProjectStorage 引用丢失(#1311)
|
||||
Loader.Start()
|
||||
End Sub
|
||||
Private Sub EnterTrigger(sender As Object, e As KeyEventArgs) Handles TextSearchName.KeyDown, TextSearchVersion.KeyDown
|
||||
@@ -246,7 +246,7 @@ Public Class PageComp
|
||||
If Not TextSearchVersion.IsDropDownOpen Then UpdateSearchLoaderVisibility()
|
||||
End Sub
|
||||
Private Sub UpdateSearchLoaderVisibility() Handles TextSearchVersion.DropDownClosed
|
||||
If PageType = CompType.Mod AndAlso (TextSearchVersion.Text.Contains(".") OrElse TextSearchVersion.Text.Contains("w")) Then
|
||||
If PageType = ResourceTypes.Mod AndAlso (TextSearchVersion.Text.Contains(".") OrElse TextSearchVersion.Text.Contains("w")) Then
|
||||
ComboSearchLoader.Visibility = Visibility.Visible
|
||||
Grid.SetColumnSpan(TextSearchVersion, 1)
|
||||
Else
|
||||
Reference in New Issue
Block a user