Improve local post-move action UI
This commit is contained in:
@@ -8,6 +8,7 @@ func _init() -> void:
|
||||
var failures: Array[String] = []
|
||||
_check_deferred_move_events(failures)
|
||||
_check_scene_post_move_menu_flow(failures)
|
||||
_check_scene_post_move_edge_positioning(failures)
|
||||
_check_scene_post_move_tactic_picker_flow(failures)
|
||||
_check_scene_post_move_item_picker_flow(failures)
|
||||
|
||||
@@ -96,6 +97,8 @@ func _check_scene_post_move_menu_flow(failures: Array[String]) -> void:
|
||||
failures.append("scene should keep pending move metadata after move click")
|
||||
if scene.post_move_menu == null or not scene.post_move_menu.visible:
|
||||
failures.append("post-move action menu should be visible after moving")
|
||||
else:
|
||||
_check_local_panel_position(failures, scene, scene.post_move_menu, Vector2i(2, 3), "post-move action menu")
|
||||
if cao_cao.get("pos", Vector2i.ZERO) != Vector2i(2, 3) or not bool(cao_cao.get("moved", false)) or bool(cao_cao.get("acted", false)):
|
||||
failures.append("scene move should be pending with action still available")
|
||||
if scene.state.get_selected_unit().is_empty():
|
||||
@@ -103,7 +106,11 @@ func _check_scene_post_move_menu_flow(failures: Array[String]) -> void:
|
||||
if not scene.attack_cells.is_empty():
|
||||
failures.append("attack cells should wait until Attack is chosen from the post-move menu")
|
||||
|
||||
scene._handle_cancel_input()
|
||||
var right_click := InputEventMouseButton.new()
|
||||
right_click.button_index = MOUSE_BUTTON_RIGHT
|
||||
right_click.pressed = true
|
||||
right_click.position = _screen_for_cell(Vector2i(2, 3))
|
||||
scene._unhandled_input(right_click)
|
||||
cao_cao = scene.state.get_unit("cao_cao")
|
||||
if scene._has_pending_move() or (scene.post_move_menu != null and scene.post_move_menu.visible):
|
||||
failures.append("right-click cancel handler should clear pending move menu state")
|
||||
@@ -124,6 +131,41 @@ func _check_scene_post_move_menu_flow(failures: Array[String]) -> void:
|
||||
scene.free()
|
||||
|
||||
|
||||
func _check_scene_post_move_edge_positioning(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 edge menu positioning")
|
||||
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 edge menu positioning")
|
||||
scene.free()
|
||||
return
|
||||
var edge_cell := Vector2i(scene.state.map_size.x - 1, 3)
|
||||
var cao_cao: Dictionary = scene.state.get_unit("cao_cao")
|
||||
cao_cao["pos"] = edge_cell
|
||||
cao_cao["moved"] = true
|
||||
cao_cao["acted"] = false
|
||||
scene.pending_move_unit_id = "cao_cao"
|
||||
scene.pending_move_from_cell = Vector2i(edge_cell.x - 1, edge_cell.y)
|
||||
scene.pending_move_to_cell = edge_cell
|
||||
scene._show_post_move_menu()
|
||||
|
||||
if scene.post_move_menu == null or not scene.post_move_menu.visible:
|
||||
failures.append("edge post-move action menu should be visible")
|
||||
else:
|
||||
_check_local_panel_position(failures, scene, scene.post_move_menu, edge_cell, "edge post-move action menu")
|
||||
|
||||
scene.free()
|
||||
|
||||
|
||||
func _check_scene_post_move_attack_targeting(failures: Array[String]) -> void:
|
||||
var scene = BattleSceneScript.new()
|
||||
scene._create_hud()
|
||||
@@ -252,13 +294,13 @@ func _check_scene_post_move_tactic_picker_flow(failures: Array[String]) -> void:
|
||||
if scene.post_move_tactic_button == null or scene.post_move_tactic_button.disabled:
|
||||
failures.append("post-move Tactic should be enabled when Spark has a valid target")
|
||||
|
||||
scene._on_post_move_tactic_pressed()
|
||||
scene._on_tactic_pressed()
|
||||
if scene.post_move_picker_panel == null or not scene.post_move_picker_panel.visible or scene.post_move_picker_mode != "tactic":
|
||||
failures.append("post-move Tactic should open the local tactic picker")
|
||||
failures.append("post-move Tactic shortcut should open the local tactic picker")
|
||||
if scene.post_move_menu != null and scene.post_move_menu.visible:
|
||||
failures.append("post-move action menu should hide while the tactic picker is open")
|
||||
if scene.tactic_menu != null and scene.tactic_menu.visible:
|
||||
failures.append("post-move local tactic picker should not use the side tactic menu")
|
||||
failures.append("post-move tactic shortcut should not use the side tactic menu")
|
||||
|
||||
var escape := InputEventKey.new()
|
||||
escape.keycode = KEY_ESCAPE
|
||||
@@ -359,13 +401,13 @@ func _check_scene_post_move_item_picker_flow(failures: Array[String]) -> void:
|
||||
if scene.post_move_item_button == null or scene.post_move_item_button.disabled:
|
||||
failures.append("post-move Item should be enabled when Bean can heal an adjacent ally")
|
||||
|
||||
scene._on_post_move_item_pressed()
|
||||
scene._on_item_pressed()
|
||||
if scene.post_move_picker_panel == null or not scene.post_move_picker_panel.visible or scene.post_move_picker_mode != "item":
|
||||
failures.append("post-move Item should open the local item picker")
|
||||
failures.append("post-move Item shortcut should open the local item picker")
|
||||
if scene.post_move_menu != null and scene.post_move_menu.visible:
|
||||
failures.append("post-move action menu should hide while the item picker is open")
|
||||
if scene.item_menu != null and scene.item_menu.visible:
|
||||
failures.append("post-move local item picker should not use the side item menu")
|
||||
failures.append("post-move item shortcut should not use the side item menu")
|
||||
|
||||
scene._on_post_move_item_option_pressed("bean")
|
||||
if scene.selected_item_id != "bean":
|
||||
@@ -416,5 +458,22 @@ func _check_scene_post_move_item_picker_flow(failures: Array[String]) -> void:
|
||||
scene.free()
|
||||
|
||||
|
||||
func _check_local_panel_position(failures: Array[String], scene, panel: Control, cell: Vector2i, label: String) -> void:
|
||||
var padding := BattleSceneScript.LOCAL_COMMAND_PANEL_BOARD_PADDING
|
||||
var board_position := BattleSceneScript.BOARD_OFFSET + Vector2(padding, padding)
|
||||
var board_size := Vector2(scene.state.map_size.x, scene.state.map_size.y) * BattleSceneScript.TILE_SIZE - Vector2(padding * 2.0, padding * 2.0)
|
||||
var board_rect := Rect2(board_position, board_size)
|
||||
var panel_rect := Rect2(panel.position, panel.size)
|
||||
var cell_rect: Rect2 = scene._rect_for_cell(cell).grow(2.0)
|
||||
if panel_rect.size.x <= 0.0 or panel_rect.size.y <= 0.0:
|
||||
failures.append("%s should have a stable visible size" % label)
|
||||
if panel_rect.position.x < board_rect.position.x or panel_rect.position.y < board_rect.position.y:
|
||||
failures.append("%s should stay inside the board minimum: %s" % [label, str(panel_rect)])
|
||||
if panel_rect.end.x > board_rect.end.x or panel_rect.end.y > board_rect.end.y:
|
||||
failures.append("%s should stay inside the board maximum: %s" % [label, str(panel_rect)])
|
||||
if panel_rect.intersects(cell_rect):
|
||||
failures.append("%s should not cover the moved unit cell: %s over %s" % [label, str(panel_rect), str(cell_rect)])
|
||||
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user