feat(ui): show client and protocol version on loading screen (#724)

Loading screen reads the client version from project.yaml (root version
field) and displays it alongside Protocol.PROTOCOL_VERSION at the bottom
of the overlay: "v0.1.35  ·  protocol 21".

Falls back to "?.?.?" if project.yaml is missing or unreadable (e.g.
when run from an exported pck where the relative path is unavailable).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-19 11:54:07 +02:00
co-authored by Claude Opus 4.6
parent 3f4d60c8bb
commit ebc731cdf0
+37
View File
@@ -2,12 +2,16 @@ extends Control
## #257: Loading screen overlay — blocks input during save/load round-trip.
## Shown when LOAD_GAME fires; hidden when save_result arrives (success or failure).
## Full-screen, dark overlay with centered status text.
## #724: Shows client version (from project.yaml) and protocol version below the status text.
const BG_COLOR := Color(0.0, 0.0, 0.0, 0.75)
const TEXT_COLOR := Color("#c8d0e0")
const VERSION_COLOR := Color("#667788")
const FONT_SIZE := 18
const VERSION_FONT_SIZE := 11
var _label: Label = null
var _version_label: Label = null
func _ready() -> void:
@@ -34,6 +38,39 @@ func _build_ui() -> void:
_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(_label)
var client_ver := _read_client_version()
var proto_ver: int = Protocol.PROTOCOL_VERSION
_version_label = Label.new()
_version_label.text = "v%s · protocol %d" % [client_ver, proto_ver]
_version_label.add_theme_font_size_override("font_size", VERSION_FONT_SIZE)
_version_label.add_theme_color_override("font_color", VERSION_COLOR)
_version_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
_version_label.anchor_left = 0.0
_version_label.anchor_right = 1.0
_version_label.anchor_top = 1.0
_version_label.anchor_bottom = 1.0
_version_label.offset_top = -32.0
_version_label.offset_bottom = -8.0
_version_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(_version_label)
func _read_client_version() -> String:
var yaml_path := ProjectSettings.globalize_path("res://") + "/../project.yaml"
if not FileAccess.file_exists(yaml_path):
return "?.?.?"
var file := FileAccess.open(yaml_path, FileAccess.READ)
if file == null:
return "?.?.?"
var content := file.get_as_text()
file.close()
for line: String in content.split("\n"):
if line.begins_with("version:"):
var parts := line.split(":", false, 1)
if parts.size() >= 2:
return parts[1].strip_edges()
return "?.?.?"
func show_loading() -> void:
visible = true