Show the server's version history in the About popup
The About popup is twice as wide and shows the player's and the server's version history side by side, each in its own scrolling column. The server's comes from GET /api/v1/version/history every time the popup opens. The description, which is about both, is centred above the columns, and each history starts right under its version.
This commit is contained in:
1 parent
e1e05f3904
commit
13fdb3f68c
8 files changed
+749
-184
No files matched your search
+34
-7
@@ -1,6 +1,7 @@
|
||||
class_name AboutPopup
|
||||
extends BasePopup
|
||||
## Shows the game version and what is new in each version.
|
||||
## Shows the game's and the server's version, and what is new in each of their versions,
|
||||
## side by side.
|
||||
|
||||
## What is new in each version, newest first.
|
||||
const WHATS_NEW: Dictionary = {
|
||||
@@ -57,16 +58,42 @@ const WHATS_NEW: Dictionary = {
|
||||
@onready var about_panel: Panel = %AboutPanel
|
||||
@onready var version_label: Label = %VersionLabel
|
||||
@onready var whats_new_label: Label = %WhatsNewLabel
|
||||
@onready var server_version_label: Label = %ServerVersionLabel
|
||||
@onready var server_history_label: Label = %ServerHistoryLabel
|
||||
|
||||
|
||||
func open() -> void:
|
||||
super()
|
||||
version_label.text = Settings.version
|
||||
|
||||
# Build changelog text with version headers
|
||||
var changelog_text: String = ""
|
||||
var entries: Array = []
|
||||
for version: String in WHATS_NEW.keys():
|
||||
changelog_text += "\n" + version + "\n"
|
||||
changelog_text += WHATS_NEW[version] + "\n"
|
||||
entries.append([version, [WHATS_NEW[version]]])
|
||||
whats_new_label.text = changelog_text(entries)
|
||||
|
||||
whats_new_label.text = changelog_text
|
||||
# Asked every time, as another server can be picked in the settings
|
||||
server_version_label.text = "Loading…"
|
||||
server_history_label.text = ""
|
||||
MusicServerClient.fetch_version_history(_show_server_history, _show_server_history_failed)
|
||||
|
||||
|
||||
## The changelog text for [param entries], each a [code][version, lines][/code] pair, newest
|
||||
## first: every version on its own line, followed by its lines, with an empty line
|
||||
## between versions.
|
||||
static func changelog_text(entries: Array) -> String:
|
||||
var versions: PackedStringArray = []
|
||||
for entry: Array in entries:
|
||||
versions.append(entry[0] + "\n" + "\n".join(entry[1]))
|
||||
return "\n\n".join(versions)
|
||||
|
||||
|
||||
func _show_server_history(history: Array[VersionData]) -> void:
|
||||
server_version_label.text = history[0].version if !history.is_empty() else ""
|
||||
var entries: Array = []
|
||||
for version: VersionData in history:
|
||||
entries.append([version.version, version.changelog])
|
||||
server_history_label.text = changelog_text(entries)
|
||||
|
||||
|
||||
func _show_server_history_failed() -> void:
|
||||
server_version_label.text = "Could not reach the server"
|
||||
server_history_label.text = ""
|
||||
Reference in new issue
Block a user