Fit local command panel text

This commit is contained in:
2026-06-19 17:13:44 +09:00
parent 3b7f198044
commit 7db09930e7
2 changed files with 128 additions and 12 deletions

View File

@@ -9,6 +9,7 @@ func _init() -> void:
_check_deferred_move_events(failures)
_check_scene_post_move_menu_flow(failures)
_check_scene_post_move_edge_positioning(failures)
_check_scene_post_move_text_fit(failures)
_check_scene_post_move_tactic_picker_flow(failures)
_check_scene_post_move_item_picker_flow(failures)
@@ -166,6 +167,64 @@ func _check_scene_post_move_edge_positioning(failures: Array[String]) -> void:
scene.free()
func _check_scene_post_move_text_fit(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 post-move text fit")
scene.free()
return
scene.battle_started = true
scene.campaign_complete_screen = false
scene.briefing_panel.visible = false
scene.result_panel.visible = false
scene._clear_pending_move_state()
if not scene.state.select_unit("cao_cao"):
failures.append("could not select Cao Cao for post-move text fit")
scene.free()
return
var cao_cao: Dictionary = scene.state.get_unit("cao_cao")
cao_cao["name"] = "매우 긴 이름의 임시 선봉장"
cao_cao["pos"] = Vector2i(2, 3)
cao_cao["moved"] = true
cao_cao["acted"] = false
scene.pending_move_unit_id = "cao_cao"
scene.pending_move_from_cell = Vector2i(1, 3)
scene.pending_move_to_cell = Vector2i(2, 3)
scene._show_post_move_menu()
if scene.post_move_title_label == null:
failures.append("post-move menu should expose a fitted title label")
else:
_check_fitted_label_font(failures, scene.post_move_title_label, BattleSceneScript.LOCAL_COMMAND_TITLE_FONT_SIZE, BattleSceneScript.LOCAL_COMMAND_TITLE_MIN_FONT_SIZE, "post-move long unit title")
scene._show_post_move_picker("tactic")
if scene.post_move_picker_title_label == null:
failures.append("post-move picker should expose a fitted title label")
else:
_check_fitted_label_font(failures, scene.post_move_picker_title_label, BattleSceneScript.LOCAL_COMMAND_TITLE_FONT_SIZE, BattleSceneScript.LOCAL_COMMAND_TITLE_MIN_FONT_SIZE, "post-move picker long unit title")
if scene.post_move_picker_detail_label == null:
failures.append("post-move picker should expose a fitted detail label")
else:
_check_fitted_label_font(failures, scene.post_move_picker_detail_label, BattleSceneScript.LOCAL_COMMAND_DETAIL_FONT_SIZE, BattleSceneScript.LOCAL_COMMAND_DETAIL_MIN_FONT_SIZE, "post-move picker detail")
scene.selected_item_id = "very_long_supply_order_marker_name"
scene.selected_skill_id = ""
scene.basic_attack_targeting = false
scene._update_targeting_hint_panel()
if scene.targeting_hint_title_label == null:
failures.append("targeting hint should expose a fitted title label")
else:
_check_fitted_label_font(failures, scene.targeting_hint_title_label, BattleSceneScript.LOCAL_COMMAND_TITLE_FONT_SIZE, BattleSceneScript.LOCAL_COMMAND_TITLE_MIN_FONT_SIZE, "targeting long item title")
if scene.targeting_hint_detail_label == null:
failures.append("targeting hint should expose a fitted detail label")
else:
_check_fitted_label_font(failures, scene.targeting_hint_detail_label, BattleSceneScript.LOCAL_COMMAND_DETAIL_FONT_SIZE, BattleSceneScript.LOCAL_COMMAND_DETAIL_MIN_FONT_SIZE, "targeting detail")
scene.free()
func _check_scene_post_move_attack_targeting(failures: Array[String]) -> void:
var scene = BattleSceneScript.new()
scene._create_hud()
@@ -475,5 +534,13 @@ func _check_local_panel_position(failures: Array[String], scene, panel: Control,
failures.append("%s should not cover the moved unit cell: %s over %s" % [label, str(panel_rect), str(cell_rect)])
func _check_fitted_label_font(failures: Array[String], label: Label, base_size: int, min_size: int, label_name: String) -> void:
var font_size := label.get_theme_font_size("font_size")
if font_size < min_size or font_size > base_size:
failures.append("%s font size should stay inside fitted bounds %d..%d, got %d" % [label_name, min_size, base_size, font_size])
if label.custom_minimum_size.x <= 0.0 or label.custom_minimum_size.y <= 0.0:
failures.append("%s should reserve stable label space" % label_name)
func _screen_for_cell(cell: Vector2i) -> Vector2:
return BattleSceneScript.BOARD_OFFSET + Vector2(cell.x, cell.y) * BattleSceneScript.TILE_SIZE + Vector2.ONE * (BattleSceneScript.TILE_SIZE * 0.5)