The fleet had a second of inertia in it: every vessel's acceleration sat at roughly its own top speed, so flipping the stick while cruising took 0.58s to take effect and let go coasted 222 units, while the formation anchor the ships chase turns instantly. Acceleration is now ~3x top speed, chosen by measuring rather than taste - past 3x the reversal time stops improving because max_speed becomes the limit. Measured after: 0.18s and 23 units. test_fleet_agility guards all three numbers and proves the bounds discriminate by re-running the same measurement at the old value. The laser reaches 1450 instead of 950 and strikes 38 units either side instead of 22. Its drawn width is now derived from the hit width: the two were independent numbers that had drifted, so the beam killed things it visibly missed. LaserController's aim range also stopped hardcoding a second copy of 950. Tapping the laser button without dragging used to do nothing at all - the press was claimed, the aim begun, then thrown away on release. It now fires at the nearest enemy in range; dragging still aims precisely. That lives in the shared aimed-ability controller, so the gas bomb gains it too. Planets sat one per ~29 chunks - some 35,000 units of nothing between them. Now one per ~12, measured over 14,641 chunks. The two thresholds moved by different amounts deliberately: every SPACE-biome planet is a gas giant, so lowering both equally would have tripled the gas-giant share as well. This changes how often you find a planet, not what you find. Extractors produce half as fast to match, so expanding is what grows the economy. The research screen gave its tree 386px of 1280 and the text below it 520. The text is now at the bottom, the tree has 550, and the resource table has room and legible type - and its LOCAL column is no longer hidden behind the close button. Two map-editor bugs turned out to be one cause: a setup's id and its FILENAME are not the same thing, and both save and delete rebuilt the path from the id. ResearchLabSetup.tres holds setup_id "research_lab_1", so deleting it looked for a file that does not exist and silently refused - which read as "the first item in the list cannot be deleted" - while saving it wrote a second file under the derived name and left the original behind, so the pool served the stale twin. A third bug hid behind those: rescan() re-read through Godot's resource cache and handed back pre-save values even when the file on disk was correct. All three present to a player as "my change was not saved". Research labs no longer grant a point of their own; what conquering one is worth comes entirely from its authored map, as asked. The shipped lab map carries 1 so the balance is unchanged - only where it is configured moved. Suite 109/109. Four tests changed because the behaviour they pinned changed: the joystick coast is now derived from cruise_speed^2/(2*acceleration) rather than a constant tuned to one acceleration; the extractor wait derives from EXTRACTOR_RATE; the research-point test asserts the delegation; and the black hole test no longer assumes nobody will ever author a void-profile map. test_planet_setups and test_planet_map_assignment stopped depending on which maps happen to be in the content folder, which was making them fail when maps were added or deleted elsewhere. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
128 lines
4.8 KiB
GDScript
128 lines
4.8 KiB
GDScript
class_name ResourceBar
|
|
extends Control
|
|
|
|
# Compact resource table shared by crafting, research and the ship lab.
|
|
# Rows are resources; columns are locations. Adding another material to
|
|
# The resource-definition catalog automatically gives each material a row.
|
|
|
|
var building_id: int = 0
|
|
|
|
# Header band and font sizes were all set for a 84px-tall box, which made the
|
|
# table read as a dense strip of small numbers. The hosting menus now give it
|
|
# 136px, so the rows have somewhere to breathe and the text can be legible at
|
|
# arm's length on a phone.
|
|
const HEADER_HEIGHT: float = 30.0
|
|
# Vertical gap between rows. Previously rows were flush against each other and
|
|
# the only separation was colour.
|
|
const ROW_GAP: float = 4.0
|
|
const HEADER_FONT_SIZE: int = 20
|
|
const NAME_FONT_SIZE: int = 23
|
|
const VALUE_FONT_SIZE: int = 24
|
|
const RULE_COLOR: Color = Color(0.25, 0.55, 0.7)
|
|
const FLEET_COLOR: Color = Color(1.0, 0.78, 0.25)
|
|
const LOCAL_COLOR: Color = Color(0.45, 0.9, 0.55)
|
|
|
|
var _header_labels: Array[Label] = []
|
|
var _rows: Dictionary = {}
|
|
|
|
|
|
func _ready() -> void:
|
|
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
for heading in ["", "BANKED", "FLEET", "LOCAL"]:
|
|
var label := _make_label(heading, HEADER_FONT_SIZE, Color(0.62, 0.78, 0.86))
|
|
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
add_child(label)
|
|
_header_labels.append(label)
|
|
|
|
for resource_type in GameState.resource_types():
|
|
var glyph := ResourceGlyph.new()
|
|
glyph.resource_type = resource_type
|
|
add_child(glyph)
|
|
var name_label := _make_label(GameState.resource_name(resource_type).to_upper(),
|
|
NAME_FONT_SIZE, GameState.resource_color(resource_type))
|
|
add_child(name_label)
|
|
var bank_label := _make_value_label(GameState.resource_color(resource_type))
|
|
var fleet_label := _make_value_label(FLEET_COLOR)
|
|
var local_label := _make_value_label(LOCAL_COLOR)
|
|
for label in [bank_label, fleet_label, local_label]:
|
|
add_child(label)
|
|
_rows[resource_type] = {
|
|
"glyph": glyph, "name": name_label, "bank": bank_label,
|
|
"fleet": fleet_label, "local": local_label,
|
|
}
|
|
|
|
resized.connect(_layout)
|
|
_layout()
|
|
queue_redraw()
|
|
|
|
|
|
func _make_label(text_value: String, font_size: int, colour: Color) -> Label:
|
|
var label := Label.new()
|
|
label.text = text_value
|
|
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
label.add_theme_font_size_override("font_size", font_size)
|
|
label.add_theme_color_override("font_color", colour)
|
|
label.add_theme_color_override("font_outline_color", Color(0.01, 0.01, 0.035, 0.95))
|
|
label.add_theme_constant_override("outline_size", 2)
|
|
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
|
return label
|
|
|
|
|
|
func _make_value_label(colour: Color) -> Label:
|
|
var label := _make_label("0", VALUE_FONT_SIZE, colour)
|
|
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
return label
|
|
|
|
|
|
func _layout() -> void:
|
|
if _header_labels.is_empty():
|
|
return
|
|
var resource_width: float = size.x * 0.25
|
|
var value_width: float = (size.x - resource_width) / 3.0
|
|
var columns: Array = [0.0, resource_width, resource_width + value_width,
|
|
resource_width + value_width * 2.0]
|
|
var widths: Array = [resource_width, value_width, value_width, value_width]
|
|
for i in range(_header_labels.size()):
|
|
_header_labels[i].position = Vector2(columns[i], 0.0)
|
|
_header_labels[i].size = Vector2(widths[i], HEADER_HEIGHT)
|
|
|
|
var rows: float = maxf(1.0, float(_rows.size()))
|
|
# The gap is taken OUT of the available height rather than added on top of
|
|
# each row, so the table still ends exactly where its box does however many
|
|
# resources the catalog grows to.
|
|
var row_height: float = (size.y - HEADER_HEIGHT - ROW_GAP) / rows
|
|
var row_index: int = 0
|
|
for resource_type in GameState.resource_types():
|
|
var row: Dictionary = _rows[resource_type]
|
|
var y: float = HEADER_HEIGHT + float(row_index) * row_height
|
|
var content_height: float = row_height - ROW_GAP
|
|
row.glyph.position = Vector2(2.0, y + ROW_GAP * 0.5)
|
|
row.glyph.size = Vector2(content_height, content_height)
|
|
row.name.position = Vector2(content_height + 10.0, y)
|
|
row.name.size = Vector2(resource_width - content_height - 10.0, row_height)
|
|
for i in range(3):
|
|
var label: Label = row[["bank", "fleet", "local"][i]]
|
|
label.position = Vector2(columns[i + 1], y)
|
|
label.size = Vector2(widths[i + 1], row_height)
|
|
row_index += 1
|
|
queue_redraw()
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
for resource_type in GameState.resource_types():
|
|
var row: Dictionary = _rows.get(resource_type, {})
|
|
if row.is_empty():
|
|
continue
|
|
row.bank.text = str(GameState.banked_resource(resource_type))
|
|
row.fleet.text = str(GameState.fleet_resource(resource_type))
|
|
row.local.text = str(GameState.building_resource(building_id, resource_type)) \
|
|
if building_id != 0 else "—"
|
|
|
|
|
|
static func natural_height() -> float:
|
|
return 84.0
|
|
|
|
|
|
func _draw() -> void:
|
|
NeonDraw.draw_glowing_line(self, Vector2(0.0, size.y), Vector2(size.x, size.y),
|
|
RULE_COLOR, 0.55, 1.0)
|