fix(ui): adapt client to new ui-strings.yaml structure

The copy team rewrote ui-strings.yaml with multi-level nesting,
renamed sections, and inline comments. Update the YAML parser to
use a stack-based approach for arbitrary nesting depth, update HUD
and interaction prompt to reference the new key names, and align
tests with the new structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 18:07:15 +01:00
co-authored by Claude Opus 4.6
parent 15ea6f1375
commit 470ec59b63
4 changed files with 92 additions and 18 deletions
+29 -9
View File
@@ -47,11 +47,11 @@ func reload() -> void:
_loaded = false
_load_strings()
## Parse subset of YAML: one-level-nested key-value pairs.
## Returns flat Dictionary with dotted keys: { "section.key": "value" }.
## Parse YAML with arbitrary nesting depth.
## Returns flat Dictionary with dotted keys: { "section.sub.key": "value" }.
static func _parse_yaml(text: String) -> Dictionary:
var strings := {}
var current_section := ""
var stack: Array = [] # [[indent, key], ...]
for line in text.split("\n"):
var stripped := line.strip_edges(false, true)
if stripped.is_empty() or stripped.begins_with("#"):
@@ -63,10 +63,30 @@ static func _parse_yaml(text: String) -> Dictionary:
continue
var key := content.substr(0, colon_pos).strip_edges()
var val := content.substr(colon_pos + 1).strip_edges()
if val.length() >= 2 and val.begins_with("\"") and val.ends_with("\""):
val = val.substr(1, val.length() - 2)
if indent == 0:
current_section = key
elif indent >= 2 and not current_section.is_empty():
strings[current_section + "." + key] = val
# Trailing comment without a value — treat as section header
if val.begins_with("#"):
val = ""
# Pop sections at same or deeper indent
while stack.size() > 0 and stack.back()[0] >= indent:
stack.pop_back()
if val.is_empty():
# Section header — push onto stack
stack.push_back([indent, key])
else:
# Leaf value — extract from quotes or strip inline comment
if val.begins_with("\""):
var end_quote := val.find("\"", 1)
if end_quote > 0:
val = val.substr(1, end_quote - 1)
else:
val = val.substr(1)
else:
var comment_pos := val.find(" #")
if comment_pos >= 0:
val = val.substr(0, comment_pos).strip_edges()
var dotted_key := ""
for entry in stack:
dotted_key += entry[1] + "."
dotted_key += key
strings[dotted_key] = val
return strings