Eight tickets. The last one is the interesting one. #166 - PLAINER DIALOG. Every spoken line rewritten: the nine prologue lines and all twenty quest brief/done pairs. Mostly splitting em-dash subclauses into sentences and dropping the literary register ("hulls" -> "ships", "That is our hands back" -> "That frees us for other work"). Same meaning, same voice. #167 - NOTHING ANNOUNCED TWICE. Quests carry an `important` flag; seven of the twenty have it, and they are the search for the World Ship. A quest handed out with its goal ALREADY met is now credited in silence unless it is one of those - no brief, no answer, both signals still fired and the index still moved, so it appears ticked in the objectives panel. The chain used to stop the game to set a task the player had already done, then stop it again to congratulate them on it. #168 - THE KEYBOARD CAN ANSWER A DIALOG. The rule the ticket asks for (still arriving, show it all; already whole, move on) was already the rule for a click since #149, but a key press reached the banner and did nothing - and this game is played with WASD and a mouse. Touch, click and key now go through one door. Modifiers alone and auto-repeat echoes are not presses. #169 - A LOADING SCREEN. A press raises a cover, and the load happens after it has been on screen for a frame, so the wait is something the player is watching. Deliberately still a blocking load: load_threaded_request() comes back FAILED for these scenes, reporting text-parse errors that load() does not produce, because the global class names and preloads they reach each other through are not resolvable off the loading thread. A progress bar is not worth a menu that sometimes refuses to start the game, and the web build ships with thread support off anyway. Further presses while loading are ignored - on the web a button fires on PRESS, so an impatient double tap costs nothing to make and used to build the world twice. #170 - THE PICTURE BEFORE THE CAPTION. The prologue's first line was up before the scene had finished arriving, so the game opened STOPPED (#128) over a convoy nobody had seen yet. It flies for three seconds first. #171 - THE CONTROLS FOLLOW WHAT IS BEING HELD. is_touchscreen_available() asks whether a touch COULD arrive, and in a browser that is yes on any laptop whose panel reports touch support - so the web build put thumb sticks over a screen being played with a mouse, and switched mouse aiming off on the machine it exists for. The reading is now the last input actually used, it lives in GameState so the sticks and the guns cannot disagree, and it is two-way: nothing can strand a tablet, because the gesture that needs the controls is the gesture that brings them back. A touch suppresses mouse evidence for a second, so the click Godot manufactures out of a tap is not mistaken for a mouse. #172 - AIM AT A PLACE. Every gun was handed the same direction, so a fleet firing at something threw a sheet of parallel bolts past either side of it and only the middle hull could hit - worse the wider the formation. Guns now take a POINT and each hull works out its own heading to it, so the fleet's fire converges. The mouse already had a place and was flattening it into a bearing; a pushed stick names the point at the guns' reach along it, so touch loses nothing. The assist (#89) still bends a shot onto an enemy, now per hull and around that hull's own heading. The aim guide stops at the point and marks it. #173 - AND THE ONE THAT EXPLAINS ITSELF. "In the web export version the fleet can not store any resources" is not a web bug. It is the third time the Godot editor's .tres writer has quietly dropped a property it thought was default-valued: InterceptorVesselDefinition losing `capabilities` leaves cargo_capacity at 20 and takes away the "cargo" claim that fleet_cargo_capacity() actually gates on, so the hold is zero and nothing can be mined or carried. That is the symptom, word for word. test_definitions_intact caught it in the suite. What it could not do is catch it in a BUILD - an export is taken from the working tree at whatever moment the editor last touched it, which is exactly when the damage is done and exactly where nobody is running tests. The checks move to core/CatalogCheck.gd and now run at startup in every build as well as in the test, from the same function. On the web push_error lands in the on-page log web_shell.html mirrors, which is the only error a phone can read. The tree is intact today, so a fresh export should restore the hold. The point of the change is that the next time it is not, the build says so. Full suite green at 154/154. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139MmxRAJSUe1j77kftAWv3
132 lines
5 KiB
GDScript
132 lines
5 KiB
GDScript
extends Node2D
|
|
|
|
# Forgejo #80: on a computer the mouse aims and the left button fires, and the
|
|
# number keys choose which weapon the click uses - 1 the fleet's own guns, 2
|
|
# and up the special abilities.
|
|
#
|
|
# The twin sticks are built for thumbs. On a desktop they mean dragging a
|
|
# virtual stick with a pointer that could simply BE the crosshair, so this
|
|
# offers the shape a mouse actually wants: point, click, hold to keep firing.
|
|
#
|
|
# Touch is unaffected, and deliberately so: Godot emulates a mouse button from
|
|
# every touch, so without a guard a tap anywhere on a phone would fire the
|
|
# guns.
|
|
#
|
|
# #171 changed what that guard asks. It used to be the presence of a
|
|
# touchscreen, which fails safe but fails often: a desktop browser reporting a
|
|
# touch-capable panel switched mouse aiming off on exactly the machine it was
|
|
# written for. It now asks what the player last actually used
|
|
# (GameState.pointer_is_touch), which still fails safe - a tap makes the
|
|
# reading "touch" before the emulated click arrives, so a phone can never fire
|
|
# through this path - and stops being wrong about desktops.
|
|
|
|
# A literal, not PackedStringArray(...): a constructor call is not a constant
|
|
# expression, and the script fails to PARSE rather than to run - which shows up
|
|
# as "nonexistent function" on a node that looks fine in the scene.
|
|
const ABILITY_ORDER: PackedStringArray = ["GasBombController", "LaserController"]
|
|
|
|
@onready var fleet: Node2D = get_node("../Fleet")
|
|
@onready var camera: Camera2D = get_node("../Camera2D")
|
|
@onready var fire_stick_controller: Node = get_node_or_null("../FireStickController")
|
|
|
|
# 0 is the fleet's own guns; 1.. index into `abilities` below.
|
|
var selected_weapon: int = 0
|
|
var firing: bool = false
|
|
var aim_world: Vector2 = Vector2.ZERO
|
|
var abilities: Array = []
|
|
|
|
|
|
func _ready() -> void:
|
|
# Resolved by NAME in a fixed order, so "2" is the gas bomb on every
|
|
# scene and in every session. Discovering them by scanning children would
|
|
# make the number keys depend on scene node order, which is not something
|
|
# a player can see or rely on.
|
|
for node_name in ABILITY_ORDER:
|
|
var controller: Node = get_node_or_null("../%s" % node_name)
|
|
if controller != null:
|
|
abilities.append(controller)
|
|
|
|
|
|
# AUTO follows the last input the player actually used, which is what every
|
|
# scene ships with. The explicit settings exist because that reading is seeded
|
|
# from the display in an environment - headless - where the answer varies by
|
|
# platform, so with AUTO alone the aiming below could never be exercised by a
|
|
# test at all, and the only covered behaviour would be the guard itself.
|
|
enum PointerMode { AUTO, ON, OFF }
|
|
|
|
@export var pointer_mode: PointerMode = PointerMode.AUTO
|
|
|
|
|
|
func is_enabled() -> bool:
|
|
match pointer_mode:
|
|
PointerMode.ON:
|
|
return true
|
|
PointerMode.OFF:
|
|
return false
|
|
return not GameState.pointer_is_touch
|
|
|
|
|
|
func weapon_count() -> int:
|
|
return abilities.size() + 1
|
|
|
|
|
|
# Which weapon a given number key selects. Public so a test can ask rather
|
|
# than hardcode the mapping a second time.
|
|
func select_weapon(index: int) -> bool:
|
|
if index < 0 or index >= weapon_count():
|
|
return false
|
|
selected_weapon = index
|
|
_refresh_highlight()
|
|
return true
|
|
|
|
|
|
func _refresh_highlight() -> void:
|
|
# The chosen ability's own button carries the selection, so the answer to
|
|
# "what will a click do" is on screen rather than remembered.
|
|
for i in range(abilities.size()):
|
|
var button: Node = abilities[i].get("button")
|
|
if button != null:
|
|
button.highlighted = selected_weapon == i + 1
|
|
button.queue_redraw()
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if not is_enabled():
|
|
return
|
|
if event is InputEventMouseMotion:
|
|
aim_world = get_global_mouse_position()
|
|
return
|
|
if event is InputEventKey and event.pressed and not event.echo:
|
|
var index: int = event.keycode - KEY_1
|
|
if index >= 0 and index < weapon_count() and select_weapon(index):
|
|
get_viewport().set_input_as_handled()
|
|
return
|
|
if not (event is InputEventMouseButton) or event.button_index != MOUSE_BUTTON_LEFT:
|
|
return
|
|
|
|
aim_world = get_global_mouse_position()
|
|
firing = event.pressed
|
|
if not event.pressed:
|
|
return
|
|
get_viewport().set_input_as_handled()
|
|
if selected_weapon > 0:
|
|
# One shot per click. Abilities have their own cooldowns and costs;
|
|
# holding the button down must not queue them up.
|
|
abilities[selected_weapon - 1].fire_at(aim_world)
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
if fire_stick_controller == null:
|
|
return
|
|
# Handed to the stick controller rather than driving the weapons here, so
|
|
# there is still exactly one thing in the scene that aims a gun. The stick
|
|
# wins when both are live - a finger on it is a deliberate act, while a
|
|
# mouse merely resting somewhere is not.
|
|
#
|
|
# #172: the cursor's world position goes across as a PLACE. It always was
|
|
# one; it used to be flattened into a heading from the fleet's centre on
|
|
# the way out, which threw away the distance and made every hull fire
|
|
# parallel past the thing being clicked on.
|
|
fire_stick_controller.has_external_target = is_enabled() and firing \
|
|
and selected_weapon == 0 and not fleet.ships.is_empty()
|
|
fire_stick_controller.external_target = aim_world
|