Add battle unit list panel

This commit is contained in:
2026-06-19 22:55:26 +09:00
parent 3b91344b6f
commit 5e470d0544
2 changed files with 379 additions and 1 deletions

View File

@@ -97,6 +97,7 @@ func _init() -> void:
_check_hover_intent_badges(failures)
_check_counter_attack_badge_variants(failures)
_check_hud_command_grid_layout(failures)
_check_battle_unit_list_panel(failures)
_check_action_button_disabled_reasons(failures)
_check_terrain_and_unit_presentation(failures)
_check_objective_and_status_marker_helpers(failures)
@@ -3631,6 +3632,7 @@ func _check_hud_command_grid_layout(failures: Array[String]) -> void:
for button in [
scene.end_turn_button,
scene.threat_button,
scene.battle_unit_list_button,
scene.top_save_button,
scene.top_load_button,
scene.restart_button,
@@ -3648,6 +3650,78 @@ func _check_hud_command_grid_layout(failures: Array[String]) -> void:
scene.free()
func _check_battle_unit_list_panel(failures: Array[String]) -> void:
var scene = BattleSceneScript.new()
scene._create_hud()
if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"):
failures.append("could not load opening battle for battle unit list")
scene.free()
return
scene.battle_started = true
scene.campaign_complete_screen = false
scene.briefing_panel.visible = false
scene.result_panel.visible = false
scene._update_hud()
if scene.battle_unit_list_button == null:
failures.append("top toolbar should expose a battle unit list button")
scene.free()
return
if scene.battle_unit_list_button.disabled:
failures.append("battle unit list button should be enabled during active battle")
if scene.battle_unit_list_button.icon == null or not bool(scene.battle_unit_list_button.get_meta("icon_only", false)):
failures.append("battle unit list button should be an icon-only top command")
scene._on_battle_unit_list_pressed()
if scene.battle_unit_list_panel == null or not scene.battle_unit_list_panel.visible:
failures.append("battle unit list panel should open from the top toolbar")
else:
_check_panel_style_fill(failures, scene.battle_unit_list_panel, "battle unit list panel", Color(0.10, 0.055, 0.030, 0.93))
if scene.battle_unit_list_title_label == null or not scene.battle_unit_list_title_label.text.contains("아군"):
failures.append("battle unit list should open on the ally tab")
if scene.battle_unit_list_rows == null or scene.battle_unit_list_rows.get_child_count() < 2:
failures.append("ally battle unit list should include deployed officers")
elif not _row_texts_contain(scene.battle_unit_list_rows, "조조") or not _row_texts_contain(scene.battle_unit_list_rows, "하후돈"):
failures.append("ally battle unit list should show Cao Cao and Xiahou Dun")
scene._on_battle_unit_list_row_pressed("cao_cao")
var selected: Dictionary = scene.state.get_selected_unit()
if selected.is_empty() or str(selected.get("id", "")) != "cao_cao":
failures.append("clicking an available ally in the battle unit list should select that officer")
scene._on_battle_unit_list_tab_pressed("enemy")
if scene.battle_unit_list_title_label == null or not scene.battle_unit_list_title_label.text.contains("적군"):
failures.append("battle unit list should switch to the enemy tab")
if scene.battle_unit_list_status_label == null or not scene.battle_unit_list_status_label.text.contains("잔적"):
failures.append("enemy battle unit list should summarize remaining enemies")
if scene.battle_unit_list_rows == null or scene.battle_unit_list_rows.get_child_count() < 1:
failures.append("enemy battle unit list should show living enemies")
elif not _row_texts_contain(scene.battle_unit_list_rows, "장만성"):
failures.append("enemy battle unit list should include the enemy commander")
scene._on_battle_unit_list_row_pressed("yellow_turban_1")
selected = scene.state.get_selected_unit()
if selected.is_empty() or str(selected.get("id", "")) != "cao_cao":
failures.append("clicking an enemy in the battle unit list should focus without stealing ally selection")
var escape_event := InputEventKey.new()
escape_event.keycode = KEY_ESCAPE
scene._handle_key(escape_event)
if scene.battle_unit_list_panel != null and scene.battle_unit_list_panel.visible:
failures.append("Escape should close the battle unit list panel")
scene.free()
func _row_texts_contain(container: VBoxContainer, needle: String) -> bool:
if container == null:
return false
for child in container.get_children():
if child is Button and str((child as Button).text).contains(needle):
return true
if child is Label and str((child as Label).text).contains(needle):
return true
return false
func _check_action_button_disabled_reasons(failures: Array[String]) -> void:
var scene = BattleSceneScript.new()
scene.wait_button = Button.new()