#231, #230: a key per ability, and an upkeep sheet that adds up

#231 - the abilities were hard to use on a keyboard.

"The currently selected weapons" names a real mechanism: MouseCombatController
(#80) has number keys that SELECT which weapon a click fires. That is two
acts for one shot, and the selection is invisible unless you look at the
buttons. Q, E and space now fire the gas bomb, the laser and the dash
outright, wherever the mouse already points.

It goes through fire_at(), the same public entry the click path uses, so
every guard comes with it - no hull ready, cannot afford the shot, a panel
over the button. The number keys stay: they are not what this ticket is
about, and removing them would take the click path's abilities with them.

Q and E were already taken - they pivot the formation - so the pivot pair
moved to Z and C, one row under the movement keys and still left-hand. That
is a change to a control the ticket did not mention, and the one thing here
worth arguing with.

test_keyboard_input spelled Q and E out and so reported a broken pivot when
the pivot was fine. It reads KEY_PIVOT_CW/CCW off the controller now, and
additionally asserts the pair is not bound to an ability key - the failure
that would actually matter.

#230 - the upkeep menu never added anything up.

Two faults, and the second is invisible from the code. There was no TOTAL,
so the bill had to be done in the player's head. And the rows were one Label
padded with %-16s, which aligns only in a monospace font - the theme's is
CarroisGothicSC, which is proportional - with autowrap on top, so a long row
folded and the table lost its shape.

A real GridContainer now: header, a row per paying berth, and a TOTAL. The
headline carries both figures, because they answer different questions - the
per-charge bill is what the player watches happen, the per-minute rate is
what they plan against.

Amounts are listed in the game's resource order rather than the dictionary's.
The screenshot showed "2 ore 1 energy" on one row above "2 gas 2 ore" on the
next, which defeats the point of a column.

The sheet is rebuilt only when the numbers change. BuildController refreshes
this menu every frame while it is open, and rebuilding a dozen Labels per
frame for figures that move every 25 seconds is what #6 and #10 are about.
The test refreshes twice and asserts the same cell objects come back.

Every figure still comes from fleet_upkeep_breakdown(), the calculation the
charging loop itself runs - the new total sums those same per-berth costs
rather than recomputing them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
This commit is contained in:
Claude 2026-09-15 22:27:00 -04:00 • committed by Loïc Wisniewski
commit 34e252037e
7 changed files with 435 additions and 36 deletions

View file

@ -4,7 +4,7 @@ extends SceneTree
# godot --headless -s res://tests/test_keyboard_input.gd
# Desktop/web controls. The phone build is driven entirely by touch, but the
# web build is played with a keyboard and mouse, so WASD (and the arrows)
# must steer the fleet, Q/E must pivot the formation, and releasing the keys
# must steer the fleet, the pivot pair must turn the formation, and releasing
# must stop - the stick has a centred-again signal to hook, the keyboard has
# nothing equivalent, so a missed release would leave the fleet flying off
# forever.
@ -127,21 +127,32 @@ func _process(delta: float) -> bool:
quit(1)
return true
# --- Q/E pivot ------------------------------------------------
# --- the pivot pair -------------------------------------------
# Read off the controller's own constants rather than naming the
# keys again here. #231 moved this pair from Q/E to Z/C because
# the abilities took Q, E and space, and a test that spelled the
# old keys out reported a broken pivot when the pivot was fine.
var game_state: Node = root.get_node("GameState")
var cw_key: int = controller.KEY_PIVOT_CW
var ccw_key: int = controller.KEY_PIVOT_CCW
if cw_key in [KEY_Q, KEY_E, KEY_SPACE] or ccw_key in [KEY_Q, KEY_E, KEY_SPACE]:
print("TEST_KEYBOARD_INPUT: FAIL (pivot is bound to an ability key)")
quit(1)
return true
var before: float = game_state.formation[1].angle()
_key(KEY_E, true)
_key(KEY_E, false)
_key(cw_key, true)
_key(cw_key, false)
var after_cw: float = game_state.formation[1].angle()
_key(KEY_Q, true)
_key(KEY_Q, false)
_key(ccw_key, true)
_key(ccw_key, false)
var after_ccw: float = game_state.formation[1].angle()
var cw_turn: float = angle_difference(before, after_cw)
var ccw_turn: float = angle_difference(after_cw, after_ccw)
print("E turned %.3f rad, Q turned %.3f rad" % [cw_turn, ccw_turn])
print("key %d turned %.3f rad, key %d turned %.3f rad" \
% [cw_key, cw_turn, ccw_key, ccw_turn])
if absf(cw_turn) < 0.01 or absf(ccw_turn) < 0.01 or signf(cw_turn) == signf(ccw_turn):
print("TEST_KEYBOARD_INPUT: FAIL (Q/E did not pivot in opposite directions)")
print("TEST_KEYBOARD_INPUT: FAIL (the pivot pair did not turn in opposite directions)")
quit(1)
return true