Share one backdrop between game and editor, and fix three input/economy bugs
The setup editor and the landed surface drew different backgrounds for the same planet. Each scene carried its own hand-written ShaderMaterial, and only the game side ever swapped in a profile's shader, so a gas giant authored in the editor showed recoloured craters while the game showed cloud bands. Both now instance one SurfaceBackground.tscn and configure it through one method, and every profile names its own shader - the old "null means keep whatever the scene already had" convention was the drift, since each scene "already had" something different. The shared material is resource_local_to_scene, or two live surfaces would repaint each other. The gas giant's bands broke into disjoint segments once per cell: the second turbulence octave doubled only the INTEGER half of a lattice coordinate, which is a different point in every cell rather than the same point at twice the frequency. Measured, the old form steps 0.153 at a cell boundary against 0.0002 now. A second discontinuity went with it - the camera cell index arrives pre-wrapped, so hashing it raw rearranged the whole sky every 32 cells; hashes are now wrapped per octave and the field is exactly periodic. Bands also gained low-frequency octaves and per-row differential drift. WorldMap swallowed every touch in _input(), which runs before the GUI system, so CloseButton never saw one: the map could be opened and not closed. Android and desktop hid it behind Godot's emulated mouse event, which this never swallowed; a phone browser gives no such second chance. Its test had been closing the map by calling the method the button was failing to reach. Construction now draws on the fleet hold as well as the bank. With an empty starting bank and ore bankable only at a mothership, charging construction to the bank alone made the first mothership cost ore that could not yet exist. Also: a conquered planet no longer re-spawns its garrison (guarded on having capture points, since a setup with none registers as vacuously conquered); planets keep the map they drew, with the candidate list sorted rather than left in filesystem order and assignments pruned rather than cleared on rescan; and the map editor lists setups at a tappable size and can delete one, as an explicit armed mode rather than a tap away from destroying work. Full suite 106/106. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
137e4e528d
commit
f5a16a7b95
35 changed files with 1783 additions and 152 deletions
|
|
@ -6,6 +6,18 @@ extends SceneTree
|
|||
# fleet, a single-finger drag while the map is open pans the map content
|
||||
# instead of leaking through to the gameplay fleet-move/zoom controls, and
|
||||
# closing hides it again.
|
||||
#
|
||||
# Open and close are driven by TAPPING THE BUTTONS, not by calling open_map()
|
||||
# and close_map(). Calling them directly is what let this ship broken: the
|
||||
# map took over touch input while it was visible and swallowed it in _input(),
|
||||
# which runs before the GUI system - so the close button never saw the touch
|
||||
# and the map could not be closed at all on a touch-only device. Every part
|
||||
# of that was reachable from a test; none of it was reached, because the test
|
||||
# closed the map by calling the method the button was failing to reach.
|
||||
#
|
||||
# The open tap doubles as the harness check: if a synthetic tap could not be
|
||||
# delivered at all, the close tap would "fail" for a reason that has nothing
|
||||
# to do with the map.
|
||||
|
||||
const POS_TOLERANCE: float = 3.0
|
||||
|
||||
|
|
@ -14,6 +26,8 @@ var fleet: Node
|
|||
var camera: Camera2D
|
||||
var world_map: Control
|
||||
var content: Node2D
|
||||
var map_button: Control
|
||||
var close_button: Control
|
||||
var fleet_target_before: Vector2
|
||||
var camera_zoom_before: float
|
||||
var content_pos_before_drag: Vector2
|
||||
|
|
@ -29,6 +43,8 @@ func _initialize() -> void:
|
|||
camera = main_scene.get_node("Camera2D")
|
||||
world_map = main_scene.get_node("UI/WorldMap")
|
||||
content = main_scene.get_node("UI/WorldMap/MapContent")
|
||||
map_button = main_scene.get_node("UI/MapButton")
|
||||
close_button = main_scene.get_node("UI/WorldMap/CloseButton")
|
||||
|
||||
|
||||
func _process(delta: float) -> bool:
|
||||
|
|
@ -41,7 +57,7 @@ func _process(delta: float) -> bool:
|
|||
print("TEST_WORLD_MAP_UI: FAIL (map visible by default)")
|
||||
quit(1)
|
||||
return true
|
||||
world_map.open_map()
|
||||
_tap(map_button)
|
||||
stage = 1
|
||||
elapsed = 0.0
|
||||
return false
|
||||
|
|
@ -55,6 +71,10 @@ func _process(delta: float) -> bool:
|
|||
print("open_visible=%s content_pos=%s expected=%s recenter_ok=%s" % [
|
||||
world_map.visible, content.position, expected_content_pos, recenter_ok
|
||||
])
|
||||
if not world_map.visible:
|
||||
print("TEST_WORLD_MAP_UI: FAIL (tapping the map button did not open the map)")
|
||||
quit(1)
|
||||
return true
|
||||
if not (world_map.visible and recenter_ok):
|
||||
print("TEST_WORLD_MAP_UI: FAIL (open/recenter)")
|
||||
quit(1)
|
||||
|
|
@ -102,7 +122,9 @@ func _process(delta: float) -> bool:
|
|||
quit(1)
|
||||
return true
|
||||
|
||||
world_map.close_map()
|
||||
# The subject: a tap on the close button, delivered exactly the
|
||||
# way the tap that opened the map was.
|
||||
_tap(close_button)
|
||||
stage = 4
|
||||
elapsed = 0.0
|
||||
return false
|
||||
|
|
@ -110,7 +132,11 @@ func _process(delta: float) -> bool:
|
|||
if elapsed < 0.1:
|
||||
return false
|
||||
var closed_ok: bool = not world_map.visible
|
||||
print("closed_ok=%s" % closed_ok)
|
||||
print("closed_by_button=%s map_button_back=%s" % [closed_ok, map_button.visible])
|
||||
if closed_ok and not map_button.visible:
|
||||
print("TEST_WORLD_MAP_UI: FAIL (map closed but its open button never came back)")
|
||||
quit(1)
|
||||
return true
|
||||
if closed_ok:
|
||||
print("TEST_WORLD_MAP_UI: PASS")
|
||||
quit(0)
|
||||
|
|
@ -121,6 +147,30 @@ func _process(delta: float) -> bool:
|
|||
return false
|
||||
|
||||
|
||||
# Taps a control at the centre of its own rect, pushed straight into the
|
||||
# viewport in local coordinates. Deliberately NOT Input.parse_input_event with
|
||||
# a hand-written position: headless rescales those through the stretch
|
||||
# transform (see the note in stage 3), which is fine for the pan check below -
|
||||
# it only cares about direction and ratio - but useless for hitting a target.
|
||||
# Its own touch index, away from the 0 the pan check below uses. push_input()
|
||||
# is delivered immediately while Input.parse_input_event() is queued for the
|
||||
# next frame, so the two can arrive out of order - and a release whose index
|
||||
# the map is still holding belongs to the map, correctly, which would make
|
||||
# this read as a broken button when nothing is broken. A finger cannot be in
|
||||
# two places at once, so distinct indices is what really happens anyway.
|
||||
const TAP_INDEX: int = 7
|
||||
|
||||
|
||||
func _tap(control: Control) -> void:
|
||||
var at: Vector2 = control.get_global_rect().get_center()
|
||||
for pressed in [true, false]:
|
||||
var ev := InputEventScreenTouch.new()
|
||||
ev.index = TAP_INDEX
|
||||
ev.pressed = pressed
|
||||
ev.position = at
|
||||
control.get_viewport().push_input(ev, true)
|
||||
|
||||
|
||||
func _touch(index: int, pressed: bool, pos: Vector2) -> void:
|
||||
var ev: InputEventScreenTouch = InputEventScreenTouch.new()
|
||||
ev.index = index
|
||||
|
|
|
|||
Loading…
Reference in a new issue