Add portrait roster rows
This commit is contained in:
@@ -9,6 +9,7 @@ func _init() -> void:
|
||||
_check_required_only_roster(failures)
|
||||
_check_optional_roster(failures)
|
||||
_check_roster_button_guard(failures)
|
||||
_check_roster_visual_rows(failures)
|
||||
|
||||
if failures.is_empty():
|
||||
print("roster choices smoke ok")
|
||||
@@ -54,9 +55,97 @@ func _check_roster_button_guard(failures: Array[String]) -> void:
|
||||
scene.free()
|
||||
|
||||
|
||||
func _check_roster_visual_rows(failures: Array[String]) -> void:
|
||||
var scene = BattleSceneScript.new()
|
||||
scene._create_hud()
|
||||
if not scene.state.load_battle(
|
||||
"res://data/scenarios/007_xian_emperor_escort.json",
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
["dian_wei", "xiahou_yuan", "cao_ren"]
|
||||
):
|
||||
failures.append("007 could not load for roster visual rows")
|
||||
scene.free()
|
||||
return
|
||||
scene._rebuild_roster_menu()
|
||||
if scene.roster_list == null or scene.roster_list.get_child_count() < 5:
|
||||
failures.append("roster visual rows should list required and optional officers")
|
||||
else:
|
||||
var visible_text := _collect_child_text(scene.roster_list)
|
||||
var tooltip_text := _collect_child_tooltips(scene.roster_list)
|
||||
if not visible_text.contains("조조") or not visible_text.contains("품계") or not visible_text.contains("출진"):
|
||||
failures.append("roster rows should show compact name/status badges: %s" % visible_text)
|
||||
if visible_text.contains("병장:") or visible_text.contains("청동검") or visible_text.contains("피갑"):
|
||||
failures.append("roster rows should leave equipment detail to tooltips: %s" % visible_text)
|
||||
if not tooltip_text.contains("병장:") or not tooltip_text.contains("필수 출진") or not tooltip_text.contains("호위 대상"):
|
||||
failures.append("roster row tooltips should preserve equipment and lock detail: %s" % tooltip_text)
|
||||
if not tooltip_text.contains("클릭하면 출진과 예비"):
|
||||
failures.append("roster row tooltips should explain optional toggle behavior: %s" % tooltip_text)
|
||||
if not _has_descendant_texture(scene.roster_list):
|
||||
failures.append("roster rows should reuse officer portrait artwork")
|
||||
var cao_cao: Dictionary = scene.state.get_unit("cao_cao_ch7")
|
||||
if scene._format_roster_unit_button_text(cao_cao).contains("품계"):
|
||||
failures.append("roster row button text should stay compact")
|
||||
scene.free()
|
||||
|
||||
|
||||
func _loaded_state(failures: Array[String], label: String, path: String):
|
||||
var state = BattleStateScript.new()
|
||||
if not state.load_battle(path):
|
||||
failures.append("%s could not load scenario: %s" % [label, path])
|
||||
return null
|
||||
return state
|
||||
|
||||
|
||||
func _collect_child_text(root: Node) -> String:
|
||||
if root == null:
|
||||
return ""
|
||||
var parts: Array[String] = []
|
||||
_collect_child_text_into(root, parts)
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
func _collect_child_text_into(root: Node, parts: Array[String]) -> void:
|
||||
if root == null:
|
||||
return
|
||||
if root is Button:
|
||||
var button_text := str((root as Button).text).strip_edges()
|
||||
if not button_text.is_empty():
|
||||
parts.append(button_text)
|
||||
elif root is Label:
|
||||
var label_text := str((root as Label).text).strip_edges()
|
||||
if not label_text.is_empty():
|
||||
parts.append(label_text)
|
||||
for child in root.get_children():
|
||||
_collect_child_text_into(child, parts)
|
||||
|
||||
|
||||
func _collect_child_tooltips(root: Node) -> String:
|
||||
if root == null:
|
||||
return ""
|
||||
var parts: Array[String] = []
|
||||
_collect_child_tooltips_into(root, parts)
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
func _collect_child_tooltips_into(root: Node, parts: Array[String]) -> void:
|
||||
if root == null:
|
||||
return
|
||||
if root is Control:
|
||||
var tooltip := str((root as Control).tooltip_text).strip_edges()
|
||||
if not tooltip.is_empty():
|
||||
parts.append(tooltip)
|
||||
for child in root.get_children():
|
||||
_collect_child_tooltips_into(child, parts)
|
||||
|
||||
|
||||
func _has_descendant_texture(root: Node) -> bool:
|
||||
if root == null:
|
||||
return false
|
||||
if root is TextureRect and (root as TextureRect).texture != null:
|
||||
return true
|
||||
for child in root.get_children():
|
||||
if _has_descendant_texture(child):
|
||||
return true
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user