spaceship/world/Main.tscn
Claude f1292db40a #228: shrink the HUD on a screen the canvas is short on
The layout is authored in CANVAS units. With stretch "canvas_items" and
aspect "expand" over a 1920x1080 base, a 720x1280 phone scales by 0.375 and
gets 1920x3413 canvas units - while ANY 16:9-or-wider screen lands on
1920x1080 units however many pixels it really has. The canvas is three times
shorter, so a 148-unit button went from 4.3% of the screen's height to
13.7%. Measured at 3.16x, and confirmed twice: once by hand off the scene
file, once by the test failing with the rule disabled.

Nothing collided. That was checked pair by pair on both canvases and the
same six pairs overlap on each, all of them same-slot alternatives. The
fault was only that everything was enormous.

HudScale captures each HUD control's authored offsets once, then moves it
toward the edge it hangs off and scales the NODE. Scaling the rect alone was
tried first and was wrong: half the HUD draws its own contents at fixed
sizes - ResourceReadout lays its rows out in code, Labels carry their own
font size - so shrunken boxes kept full-size content and the build button
slid up underneath the resource list. Scaling the node takes content and
children with it.

The cost is that position (parent space) and size (local space) now differ
by that scale, and a lot of code here assumed they did not. Five places:

  ResourceReadout.content_bottom() added a scaled position to an unscaled
  height, overstating itself by more than a button - so _seat_hud_columns
  pushed the whole column down to clear space nothing occupied. A live bug,
  not just a bad measurement.
  HUD_COLUMN_MARGIN would have been the one gap still phone-sized.
  _layout_context_buttons wrote its stride and pitch unscaled, landing the
  action row on the building-action row - which is the second of the two
  regressions test_hud_layout was written for, in a new disguise.
  test_hud_layout and test_hangar_management compared authored rects.

And HudScale reapplies on resize, which wiped the two layouts BuildController
writes at runtime - so dragging a desktop window left the context row where
it was. Both re-run on size_changed now, deferred, because which of two
siblings connected first is not a thing to depend on.

test_hud_layout ran at one window shape, which happened to be the desktop
canvas. It now runs every check at both, so this cannot hide at whichever
shape was not being exercised.

Rejected: scaling the UI CanvasLayer does not work at all - Control anchors
resolve against the viewport rect, so bottom-anchored elements land
mid-screen. A single scaled wrapper Control with the HUD reparented under it
is the genuinely clean shape and would need no scale-aware arithmetic
anywhere, but it changes every node path and would break every get_node in
the controllers and tests.

MIN_SCALE floors the shrink at 0.45 rather than the proportional 0.316: a
landscape phone gets the same short canvas as a desktop, and there the
sticks are still thumb targets. That leaves the HUD at 1.42x its phone share
on a PC rather than 1.0x.

177/177 at JOBS=3.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
2026-09-12 18:04:00 +02:00

584 lines
17 KiB
Text

[gd_scene load_steps=49 format=3]
[ext_resource type="PackedScene" path="res://ui/menus/BuildMenu.tscn" id="menu_build"]
[ext_resource type="PackedScene" path="res://ui/menus/HangarMenu.tscn" id="menu_hangar"]
[ext_resource type="PackedScene" path="res://ui/menus/LabMenu.tscn" id="menu_lab"]
[ext_resource type="PackedScene" path="res://ui/menus/CraftMenu.tscn" id="menu_craft"]
[ext_resource type="PackedScene" path="res://ui/menus/TransferMenu.tscn" id="menu_transfer"]
[ext_resource type="PackedScene" path="res://ui/menus/FormationMenu.tscn" id="menu_formation"]
[ext_resource type="PackedScene" path="res://ui/menus/PlanningMenu.tscn" id="menu_planning"]
[ext_resource type="PackedScene" path="res://ui/menus/GarrisonMenu.tscn" id="menu_garrison"]
[ext_resource type="PackedScene" path="res://ui/menus/SkillMenu.tscn" id="menu_skill"]
[ext_resource type="PackedScene" path="res://ui/menus/DevMenu.tscn" id="menu_dev"]
[ext_resource type="PackedScene" path="res://ui/menus/ScannerMenu.tscn" id="menu_scanner"]
[ext_resource type="PackedScene" path="res://ui/menus/StationMenu.tscn" id="menu_station"]
[ext_resource type="PackedScene" path="res://ui/menus/FleetUpkeepMenu.tscn" id="menu_upkeep"]
[ext_resource type="PackedScene" path="res://ui/menus/ResearchPointsMenu.tscn" id="menu_points"]
[ext_resource type="PackedScene" path="res://ui/ScannerGuidance.tscn" id="scanner_guidance"]
[ext_resource type="Script" path="res://world/Starfield.gd" id="1"]
[ext_resource type="Script" path="res://ui/HudScale.gd" id="hud_scale"]
[ext_resource type="Script" path="res://vessels/Fleet.gd" id="2"]
[ext_resource type="Script" path="res://controllers/GameController.gd" id="3"]
[ext_resource type="Script" path="res://enemies/EnemySpawner.gd" id="4"]
[ext_resource type="Shader" path="res://shaders/starfield.gdshader" id="5"]
[ext_resource type="Script" path="res://world/ExplorationTracker.gd" id="6"]
[ext_resource type="Script" path="res://world/AsteroidField.gd" id="7"]
[ext_resource type="Script" path="res://world/WorldMap.gd" id="8"]
[ext_resource type="Script" path="res://world/WorldMapContent.gd" id="9"]
[ext_resource type="Script" path="res://ui/IconButton.gd" id="10"]
[ext_resource type="Script" path="res://planets/PlanetField.gd" id="11"]
[ext_resource type="Script" path="res://planets/PlanetAtmosphereController.gd" id="12"]
[ext_resource type="Script" path="res://ui/TouchJoystick.gd" id="13"]
[ext_resource type="Script" path="res://buildings/BuildingField.gd" id="14"]
[ext_resource type="Script" path="res://controllers/BuildController.gd" id="15"]
[ext_resource type="Script" path="res://ui/ResourceReadout.gd" id="16"]
[ext_resource type="Script" path="res://ui/WaveAlert.gd" id="32"]
[ext_resource type="Script" path="res://vessels/GarrisonField.gd" id="34"]
[ext_resource type="Script" path="res://ui/NarrationBanner.gd" id="36"]
[ext_resource type="Script" path="res://world/IntroDirector.gd" id="37"]
[ext_resource type="Script" path="res://ui/DevMenuButton.gd" id="38"]
[ext_resource type="Script" path="res://logistics/RepairDroneField.gd" id="40"]
[ext_resource type="Script" path="res://ui/BreachOverlay.gd" id="41"]
[ext_resource type="Script" path="res://logistics/TransporterField.gd" id="23"]
[ext_resource type="Script" path="res://logistics/VesselDeliveryField.gd" id="26"]
[ext_resource type="Script" path="res://controllers/MouseCombatController.gd" id="mouse_ctrl"]
[ext_resource type="Script" path="res://controllers/FireStickController.gd" id="fire_ctrl"]
[ext_resource type="Script" path="res://controllers/GasBombController.gd" id="29"]
[ext_resource type="Script" path="res://controllers/LaserController.gd" id="30"]
[ext_resource type="Script" path="res://controllers/DashController.gd" id="dash_ctrl"]
[ext_resource type="Script" path="res://ui/AbilityButtonLayout.gd" id="ability_layout"]
[ext_resource type="Script" path="res://ui/SpeedFader.gd" id="31"]
[ext_resource type="Script" path="res://world/QuestDirector.gd" id="quest_dir"]
[ext_resource type="Script" path="res://ui/QuestPanel.gd" id="quest_panel"]
[ext_resource type="Script" path="res://world/OctopusField.gd" id="octopus_field"]
[sub_resource type="ShaderMaterial" id="1"]
shader = ExtResource("5")
shader_parameter/camera_pos = Vector2(0, 0)
shader_parameter/camera_zoom = 1.0
shader_parameter/viewport_size = Vector2(720, 1280)
shader_parameter/cell_size = 60.0
shader_parameter/bg_color = Color(0.02, 0.02, 0.08, 1)
[node name="Main" type="Node2D"]
physics_interpolation_mode = 2
script = ExtResource("3")
[node name="BackgroundLayer" type="CanvasLayer" parent="."]
layer = -10
[node name="Starfield" type="ColorRect" parent="BackgroundLayer"]
material = SubResource("1")
mouse_filter = 2
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1")
[node name="Fleet" type="Node2D" parent="."]
script = ExtResource("2")
[node name="GasBombController" type="Node2D" parent="."]
script = ExtResource("29")
[node name="FireStickController" type="Node2D" parent="."]
script = ExtResource("fire_ctrl")
[node name="MouseCombatController" type="Node2D" parent="."]
script = ExtResource("mouse_ctrl")
[node name="LaserController" type="Node2D" parent="."]
script = ExtResource("30")
minimum_zoom = 0.1
[node name="DashController" type="Node2D" parent="."]
script = ExtResource("dash_ctrl")
[node name="AbilityButtonLayout" type="Node" parent="."]
script = ExtResource("ability_layout")
[node name="Camera2D" type="Camera2D" parent="."]
process_physics_priority = 2
physics_interpolation_mode = 1
position = Vector2(0, 0)
zoom = Vector2(1, 1)
process_callback = 0
[node name="EnemySpawner" type="Node2D" parent="."]
script = ExtResource("4")
[node name="ExplorationTracker" type="Node2D" parent="."]
script = ExtResource("6")
[node name="AsteroidField" type="Node2D" parent="."]
script = ExtResource("7")
[node name="OctopusField" type="Node2D" parent="."]
script = ExtResource("octopus_field")
[node name="PlanetField" type="Node2D" parent="."]
script = ExtResource("11")
[node name="BuildingField" type="Node2D" parent="."]
script = ExtResource("14")
[node name="IntroDirector" type="Node2D" parent="."]
script = ExtResource("37")
[node name="QuestDirector" type="Node" parent="."]
script = ExtResource("quest_dir")
[node name="GarrisonField" type="Node2D" parent="."]
script = ExtResource("34")
[node name="TransporterField" type="Node2D" parent="."]
script = ExtResource("23")
[node name="RepairDroneField" type="Node2D" parent="."]
script = ExtResource("40")
[node name="VesselDeliveryField" type="Node2D" parent="."]
script = ExtResource("26")
[node name="BuildController" type="Node2D" parent="."]
script = ExtResource("15")
[node name="LandingController" type="Node2D" parent="."]
script = ExtResource("12")
[node name="UI" type="CanvasLayer" parent="."]
layer = 1
[node name="HudScale" type="Node" parent="UI"]
script = ExtResource("hud_scale")
[node name="ResourceReadout" type="Control" parent="UI"]
mouse_filter = 2
offset_left = 28
offset_top = 38
offset_right = 696
offset_bottom = 154
script = ExtResource("16")
digit_height = 38.0
[node name="BankCaption" type="Label" parent="UI"]
mouse_filter = 2
offset_left = 28
offset_top = 6
offset_right = 220
offset_bottom = 34
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(0.55, 0.78, 0.86, 1)
text = "BANKED"
[node name="FleetCaption" type="Label" parent="UI"]
mouse_filter = 2
offset_left = 356
offset_top = 6
offset_right = 620
offset_bottom = 34
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(1, 0.78, 0.25, 1)
text = "FLEET HOLD"
[node name="PlanetNameLabel" type="Label" parent="UI"]
visible = false
offset_left = 24
offset_top = 480
offset_right = 696
offset_bottom = 532
text = ""
horizontal_alignment = 1
theme_override_font_sizes/font_size = 32
[node name="EnterAtmosphereButton" type="Control" parent="UI"]
visible = false
offset_left = 188
offset_top = 324
offset_right = 336
offset_bottom = 472
script = ExtResource("10")
icon = 3
[node name="BuildButton" type="Control" parent="UI"]
offset_left = 24
offset_right = 172
offset_top = 160
offset_bottom = 308
script = ExtResource("10")
icon = 5
[node name="BuildActionButton" type="Control" parent="UI"]
visible = false
offset_left = 24
offset_right = 172
offset_top = 324
offset_bottom = 472
script = ExtResource("10")
icon = 2
[node name="BuildingActionButton" type="Control" parent="UI"]
visible = false
offset_left = 24
offset_right = 172
offset_top = 488
offset_bottom = 636
script = ExtResource("10")
icon = 2
[node name="HangarButton" type="Control" parent="UI"]
visible = false
offset_left = 24
offset_right = 172
offset_top = 488
offset_bottom = 636
script = ExtResource("10")
icon = 2
glow_color = Color(0.45, 0.9, 0.55, 1)
[node name="TransferButton" type="Control" parent="UI"]
visible = false
offset_left = 188
offset_top = 160
offset_right = 336
offset_bottom = 308
script = ExtResource("10")
icon = 14
glow_color = Color(1, 0.78, 0.25, 1)
[node name="MapButton" type="Control" parent="UI"]
anchor_left = 1.0
anchor_right = 1.0
offset_left = -172
offset_right = -24
offset_top = 24
offset_bottom = 172
script = ExtResource("10")
icon = 0
[node name="DevMenuButton" type="Control" parent="UI"]
visible = false
mouse_filter = 2
anchor_left = 1.0
anchor_right = 1.0
offset_left = -140.0
offset_right = -24.0
offset_top = 268.0
offset_bottom = 416.0
script = ExtResource("38")
[node name="Button" type="Control" parent="UI/DevMenuButton"]
anchor_right = 1.0
offset_bottom = 116.0
script = ExtResource("10")
icon = 46
glow_color = Color(0.55, 0.9, 1, 1)
[node name="Label" type="Label" parent="UI/DevMenuButton"]
mouse_filter = 2
anchor_right = 1.0
offset_top = 118.0
offset_bottom = 148.0
theme_override_font_sizes/font_size = 18
text = "DEV"
horizontal_alignment = 1
[node name="BreachOverlay" type="ColorRect" parent="UI"]
visible = false
mouse_filter = 2
anchor_right = 1.0
anchor_bottom = 1.0
color = Color(1, 1, 1, 1)
script = ExtResource("41")
[node name="WaveAlert" type="Control" parent="UI"]
visible = false
mouse_filter = 2
anchor_left = 1.0
anchor_right = 1.0
offset_left = -300.0
offset_right = -24.0
offset_top = 188.0
offset_bottom = 252.0
script = ExtResource("32")
[node name="ScannerGuidance" parent="UI" instance=ExtResource("scanner_guidance")]
[node name="QuestButton" type="Control" parent="UI"]
anchor_left = 1.0
anchor_right = 1.0
offset_left = -344.0
offset_right = -196.0
offset_top = 24.0
offset_bottom = 172.0
script = ExtResource("10")
icon = 44
[node name="Joystick" type="Control" parent="UI"]
mouse_filter = 2
script = ExtResource("13")
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 12
offset_right = 492
offset_top = -430
offset_bottom = -80
[node name="FireStick" type="Control" parent="UI"]
mouse_filter = 2
script = ExtResource("13")
glow_color = Color(1, 0.45, 0.3, 1)
core_color = Color(1, 1, 1, 1)
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -492
offset_right = -12
offset_top = -430
offset_bottom = -80
[node name="SpeedFader" type="Control" parent="UI"]
visible = false
mouse_filter = 2
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -94
offset_right = -24
offset_top = -720
offset_bottom = -560
script = ExtResource("31")
[node name="Label" type="Label" parent="UI/SpeedFader"]
mouse_filter = 2
offset_left = -20
offset_right = 90
offset_top = -32
offset_bottom = -4
theme_override_font_sizes/font_size = 20
theme_override_colors/font_color = Color(0.7, 0.3, 1, 1)
horizontal_alignment = 1
text = "x1.0"
[node name="LaserButton" type="Control" parent="UI"]
visible = false
mouse_filter = 2
script = ExtResource("10")
round_frame = true
icon = 36
glow_color = Color(0.3, 0.9, 1, 1)
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -196
offset_right = -100
offset_top = -548
offset_bottom = -452
[node name="DashButton" type="Control" parent="UI"]
visible = false
mouse_filter = 2
script = ExtResource("10")
round_frame = true
icon = 45
glow_color = Color(0.85, 0.95, 0.15, 1)
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -452
offset_right = -356
offset_top = -548
offset_bottom = -452
[node name="PivotCCWButton" type="Control" parent="UI"]
mouse_filter = 2
script = ExtResource("10")
round_frame = true
icon = 7
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -620
offset_right = -516
offset_top = -130
offset_bottom = -26
[node name="GasBombButton" type="Control" parent="UI"]
visible = false
mouse_filter = 2
script = ExtResource("10")
round_frame = true
icon = 32
glow_color = Color(0.96, 0.22, 0.72, 1)
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -324
offset_right = -228
offset_top = -548
offset_bottom = -452
[node name="GasBombStatus" type="Label" parent="UI"]
mouse_filter = 2
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(0.96, 0.22, 0.72, 1)
autowrap_mode = 2
horizontal_alignment = 1
text = ""
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -420
offset_right = -24
offset_top = -560
offset_bottom = -512
[node name="LaserStatus" type="Label" parent="UI"]
mouse_filter = 2
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(0.3, 0.9, 1, 1)
autowrap_mode = 2
horizontal_alignment = 1
text = ""
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -420
offset_right = -24
offset_top = -616
offset_bottom = -568
[node name="DashStatus" type="Label" parent="UI"]
mouse_filter = 2
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(0.85, 0.95, 0.15, 1)
autowrap_mode = 2
horizontal_alignment = 1
text = ""
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -500
offset_right = -104
offset_top = -672
offset_bottom = -624
[node name="PivotCWButton" type="Control" parent="UI"]
mouse_filter = 2
script = ExtResource("10")
round_frame = true
icon = 6
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -508
offset_right = -404
offset_top = -130
offset_bottom = -26
[node name="WorldMap" type="Control" parent="UI" groups=["modal_menus"]]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource("8")
[node name="Backdrop" type="ColorRect" parent="UI/WorldMap"]
anchor_right = 1.0
anchor_bottom = 1.0
color = Color(0.03, 0.03, 0.08, 0.96)
[node name="MapContent" type="Node2D" parent="UI/WorldMap"]
script = ExtResource("9")
[node name="RecenterButton" type="Control" parent="UI/WorldMap"]
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 24
offset_right = 172
offset_top = -620
offset_bottom = -472
script = ExtResource("10")
icon = 2
[node name="CloseButton" type="Control" parent="UI/WorldMap"]
anchor_left = 1.0
anchor_right = 1.0
offset_left = -172
offset_right = -24
offset_top = 24
offset_bottom = 172
script = ExtResource("10")
icon = 1
[node name="BuildMenu" parent="UI" instance=ExtResource("menu_build")]
[node name="HangarMenu" parent="UI" instance=ExtResource("menu_hangar")]
[node name="LabMenu" parent="UI" instance=ExtResource("menu_lab")]
[node name="CraftMenu" parent="UI" instance=ExtResource("menu_craft")]
[node name="TransferMenu" parent="UI" instance=ExtResource("menu_transfer")]
[node name="FormationMenu" parent="UI" instance=ExtResource("menu_formation")]
[node name="PlanningMenu" parent="UI" instance=ExtResource("menu_planning")]
[node name="GarrisonMenu" parent="UI" instance=ExtResource("menu_garrison")]
[node name="SkillMenu" parent="UI" instance=ExtResource("menu_skill")]
[node name="DevMenu" parent="UI" instance=ExtResource("menu_dev")]
[node name="ScannerMenu" parent="UI" instance=ExtResource("menu_scanner")]
[node name="StationMenu" parent="UI" instance=ExtResource("menu_station")]
[node name="FleetUpkeepMenu" parent="UI" instance=ExtResource("menu_upkeep")]
[node name="ResearchPointsMenu" parent="UI" instance=ExtResource("menu_points")]
[node name="QuestPanel" type="Control" parent="UI" groups=["modal_menus"]]
visible = false
mouse_filter = 2
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 24.0
offset_top = 24.0
offset_right = -24.0
offset_bottom = -24.0
script = ExtResource("quest_panel")
[node name="CloseButton" type="Control" parent="UI/QuestPanel"]
anchor_left = 1.0
anchor_right = 1.0
offset_left = -140.0
offset_right = -24.0
offset_top = 20.0
offset_bottom = 136.0
script = ExtResource("10")
icon = 1
[node name="NarrationBanner" type="Control" parent="UI"]
visible = false
mouse_filter = 2
anchor_right = 1.0
offset_left = 60.0
offset_right = -60.0
offset_top = 300.0
offset_bottom = 428.0
script = ExtResource("36")
[node name="FadeOverlay" type="CanvasLayer" parent="."]
layer = 10
[node name="FadeRect" type="ColorRect" parent="FadeOverlay"]
mouse_filter = 2
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0)