Skip to content

Commit

Permalink
fix: NeoForge 版本列表排序,但是抽象实现
Browse files Browse the repository at this point in the history
  • Loading branch information
Pigeon0v0 committed Jun 15, 2024
1 parent e731ef6 commit 8d9dc47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
14 changes: 10 additions & 4 deletions Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@
''' 是否是 Beta 版。若未提供则默认为 False。
''' </summary>
Public IsBeta As Boolean = False
''' <summary>
''' 标准的版本号
''' </summary>
Public StdVersion As String
Public Structure DlNeoForgeListResult
''' <summary>
''' 数据来源名称,如“Official”,“BMCLAPI”。
Expand Down Expand Up @@ -897,17 +901,19 @@
Dim Versions As New List(Of DlNeoForgeVersionEntry)
Try
For Each Token As JObject In Json
Dim Name As String
Dim Name As String '存储 rawVersion,貌似变化更加频繁
Dim StdVersion As String '存储 version,相对规则
Dim IsBeta As Boolean
If Token("version").Contains("-beta") Then
Name = Token("version").ToString() - "-beta"
StdVersion = Token("version").ToString() - "-beta"
IsBeta = True
Else
Name = Token("version")
StdVersion = Token("version").ToString()
IsBeta = False
End If
Name = Token("rawVersion")
Dim Inherit As String = Token("mcversion")
Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit, .IsBeta = IsBeta}
Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion}
Versions.Add(Entry)
Next
'For Each Token As JObject In Json
Expand Down
3 changes: 1 addition & 2 deletions Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2241,11 +2241,10 @@ Retry:
'获取最新版本
Dim FreshVersion As DlNeoForgeVersionEntry = Nothing
If Entrys.Any Then
FreshVersion = Entrys(0)
FreshVersion = Entrys.Last()
Else
Log("[System] 未找到可用的 NeoForge 版本", LogLevel.Debug)
End If
Dim RecommendedVersion As DlNeoForgeVersionEntry = Nothing
'显示各个版本
If FreshVersion IsNot Nothing Then
Dim Fresh = NeoForgeDownloadListItem(FreshVersion, OnClick, IsSaveOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,9 +974,11 @@
If Not Loader.Output.Any() Then Exit Sub
PanNeoForge.Children.Clear()

Dim VersionsArray As Array = Versions.ToArray()
VersionsArray.Reverse(VersionsArray)
'Versions = Sort(Versions, Function(a, b) New Version(a.Version) > New Version(b.Version)).ToList
NeoForgeDownloadListItemPreload(PanNeoForge, Versions, AddressOf NeoForge_Selected, False)
For Each Version In Versions
For Each Version In VersionsArray
PanNeoForge.Children.Add(NeoForgeDownloadListItem(Version, AddressOf NeoForge_Selected, False))
Next
Catch ex As Exception
Expand Down

0 comments on commit 8d9dc47

Please sign in to comment.