Expand contextual actions horizontally

This commit is contained in:
Loïc Wisniewski 2026-08-13 20:54:22 +02:00
commit d20a62a26f
2 changed files with 10 additions and 5 deletions

View file

@ -397,11 +397,16 @@ func _layout_context_buttons() -> void:
for button in buttons:
button.visible = false
return
# Expand sideways so the controls stay in the same visual band instead of
# pushing the player down a vertical stack. Three actions fit across the
# 720px phone layout with the same generous 148px touch targets.
for i in range(buttons.size()):
var button: Control = buttons[i]
button.visible = true
button.offset_top = 488 + i * 164
button.offset_bottom = button.offset_top + 148
button.offset_left = 188 + i * 164
button.offset_right = button.offset_left + 148
button.offset_top = 324
button.offset_bottom = 472
func _context_action_buttons() -> Array:

View file

@ -64,8 +64,8 @@ func _process(delta: float) -> bool:
return true
# Context actions are compact until expanded. A mothership has three
# choices: research, transfer cargo and hangar, which must receive
# their own non-overlapping berth only after expansion.
# choices: research, transfer cargo and hangar, which unfold in their
# own non-overlapping berths to the right only after expansion.
var mothership: Node2D = load("res://Building.tscn").instantiate()
mothership.set("building_type", GameState.BUILDING_MOTHERSHIP)
controller.current_building = mothership
@ -73,7 +73,7 @@ func _process(delta: float) -> bool:
controller._layout_context_buttons()
var buttons: Array = [controller.building_action_button, controller.transfer_button, controller.hangar_button]
for i in range(buttons.size() - 1):
if buttons[i].offset_bottom > buttons[i + 1].offset_top:
if buttons[i].offset_right > buttons[i + 1].offset_left:
_fail("context buttons %d and %d overlap" % [i, i + 1])
return true
controller._collapse_context_actions()