Everything lived in one flat directory, so a diff gave no clue what area it touched and finding the file you wanted meant knowing its exact name. Twelve folders now, grouped by what a thing IS rather than what type it is - a vessel's definition, its component scenes and its upgrade resources sit together, because that is the set you read when you change one of them. buildings core controllers enemies logistics planets resources shaders surface ui vessels vfx world 332 files moved and every res:// reference rewritten - 306 files touched, including the autoload and main-scene paths in project.godot. Nothing renamed: this is purely where files sit, so the diff is a pile of pure moves and no behaviour is buried in it. ui_theme.tres, icon.svg and web_shell.html stay at the root, where Godot and the export preset expect them. Verified three ways, because a suite alone would not have caught all of it: the full 117 pass, the web export builds clean, and the game renders. The export is why that matters. The FIRST export after the move failed with "Attempt to open script 'res://GameState.gd'" - the old path - while project.godot on disk plainly said res://core/GameState.gd. That is this project's documented Android FUSE mtime trap: Godot served a cached copy of a file whose content had changed. A `touch` fixed it. Nothing in the test suite would have found that, because the suite runs from a copy on a native filesystem - the one place the bug cannot happen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
94 lines
2.7 KiB
GDScript
94 lines
2.7 KiB
GDScript
extends SceneTree
|
|
|
|
# Headless gameplay test: run with
|
|
# godot --headless -s res://tests/test_pinch_zoom.gd
|
|
# Injects synthetic two-finger touch/drag events (via Input.parse_input_event)
|
|
# to exercise the real GameController input-handling code path: spreading two
|
|
# fingers apart should zoom the camera IN (lower Camera2D.zoom value) and must
|
|
# not be misread as a single-finger fleet move order.
|
|
|
|
var main_scene: Node
|
|
var fleet: Node
|
|
var camera: Camera2D
|
|
var elapsed: float = 0.0
|
|
var stage: int = 0
|
|
var initial_zoom: float
|
|
var fleet_target_before: Vector2
|
|
var baseline_captured: bool = false
|
|
|
|
|
|
func _initialize() -> void:
|
|
var packed: PackedScene = load("res://world/Main.tscn")
|
|
main_scene = packed.instantiate()
|
|
root.add_child(main_scene)
|
|
camera = main_scene.get_node("Camera2D")
|
|
fleet = main_scene.get_node("Fleet")
|
|
|
|
|
|
func _physics_process(delta: float) -> bool:
|
|
if not baseline_captured:
|
|
# Fleet._ready() runs on the first physics tick in `-s` script mode,
|
|
# not synchronously inside _initialize(), so capture baselines here.
|
|
initial_zoom = camera.zoom.x
|
|
fleet_target_before = fleet.fleet_target
|
|
baseline_captured = true
|
|
return false
|
|
|
|
elapsed += delta
|
|
match stage:
|
|
0:
|
|
_touch(0, true, Vector2(300, 600))
|
|
_touch(1, true, Vector2(340, 600))
|
|
stage = 1
|
|
1:
|
|
if elapsed > 0.1:
|
|
# Spread fingers apart: should zoom IN (Camera2D.zoom is a
|
|
# magnification, so zooming in means zoom.x increases), and
|
|
# must not move the fleet.
|
|
_drag(0, Vector2(100, 600))
|
|
_drag(1, Vector2(540, 600))
|
|
stage = 2
|
|
2:
|
|
if elapsed > 0.4:
|
|
_touch(0, false, Vector2(100, 600))
|
|
_touch(1, false, Vector2(540, 600))
|
|
stage = 3
|
|
3:
|
|
if elapsed > 0.7:
|
|
_finish()
|
|
return true
|
|
return false
|
|
|
|
|
|
func _touch(index: int, pressed: bool, pos: Vector2) -> void:
|
|
var ev: InputEventScreenTouch = InputEventScreenTouch.new()
|
|
ev.index = index
|
|
ev.pressed = pressed
|
|
ev.position = pos
|
|
Input.parse_input_event(ev)
|
|
|
|
|
|
func _drag(index: int, pos: Vector2) -> void:
|
|
var ev: InputEventScreenDrag = InputEventScreenDrag.new()
|
|
ev.index = index
|
|
ev.position = pos
|
|
Input.parse_input_event(ev)
|
|
|
|
|
|
func _finish() -> void:
|
|
var zoomed_in: bool = camera.zoom.x > initial_zoom + 0.01
|
|
var fleet_untouched: bool = fleet.fleet_target == fleet_target_before
|
|
|
|
print("initial_zoom=%.3f final_zoom=%.3f" % [initial_zoom, camera.zoom.x])
|
|
print("fleet_target_before=%s fleet_target_after=%s" % [fleet_target_before, fleet.fleet_target])
|
|
|
|
if zoomed_in and fleet_untouched:
|
|
print("TEST_PINCH_ZOOM: PASS")
|
|
quit(0)
|
|
else:
|
|
if not zoomed_in:
|
|
print("FAIL: camera did not zoom in on pinch-out gesture")
|
|
if not fleet_untouched:
|
|
print("FAIL: pinch gesture incorrectly triggered a fleet move order")
|
|
print("TEST_PINCH_ZOOM: FAIL")
|
|
quit(1)
|