Highlight selected ship lab cards

This commit is contained in:
Loïc Wisniewski 2026-08-13 20:56:24 +02:00
commit 8f7b58f2a8
3 changed files with 27 additions and 4 deletions

View file

@ -905,8 +905,8 @@ func _refresh_lab() -> void:
var this_vessel: String = [GameState.VESSEL_INTERCEPTOR, GameState.VESSEL_SHIELD,
GameState.VESSEL_TRANSPORTER][i]
lab_vessel_buttons[i].enabled = true
lab_vessel_buttons[i].glow_color = Color(0.45, 0.9, 0.55) if this_vessel == lab_vessel \
else _vessel_colour(this_vessel)
lab_vessel_buttons[i].glow_color = _vessel_colour(this_vessel)
lab_vessel_buttons[i].highlighted = this_vessel == lab_vessel
lab_vessel_buttons[i].queue_redraw()
lab_vessel_label.text = "%s research" % GameState.VESSEL_NAMES.get(lab_vessel, lab_vessel)
@ -925,7 +925,8 @@ func _refresh_lab() -> void:
GameState.upgrade_level(option.id), int(GameState.upgrade_def(option.id).max_level)]
lab_upgrade_labels[i].text = "%s%s\n%s" % [option.name, level_note, price_text]
lab_upgrade_buttons[i].icon = _upgrade_icon(option)
lab_upgrade_buttons[i].glow_color = Color(1.0, 0.85, 0.4) if i == lab_choice else _vessel_colour(lab_vessel)
lab_upgrade_buttons[i].glow_color = _vessel_colour(lab_vessel)
lab_upgrade_buttons[i].highlighted = i == lab_choice
lab_upgrade_buttons[i].enabled = true
lab_upgrade_buttons[i].queue_redraw()
if options.is_empty():

View file

@ -35,6 +35,10 @@ const REFERENCE_SIZE: float = 56.0
@export var icon: int = Icon.MAP
@export var glow_color: Color = Color(0.25, 0.85, 1.0)
# Selection is an additional frame, never a recolour. It lets menus retain
# semantic colours (vessel class, danger, cargo) while still making the
# active choice unmistakable.
@export var highlighted: bool = false: set = set_highlighted
# Colour of the bright core stroke. Defaults to near-white, which reads well
# on the dark space background; scenes drawing over a bright backdrop (the
# lunar surface) override this with a dark colour so the button doesn't wash
@ -56,6 +60,13 @@ func set_enabled(value: bool) -> void:
queue_redraw()
func set_highlighted(value: bool) -> void:
if highlighted == value:
return
highlighted = value
queue_redraw()
func _ready() -> void:
queue_redraw()
@ -126,6 +137,16 @@ func _draw() -> void:
Vector2(margin, rect_size.y - margin),
])
NeonDraw.draw_glowing_polygon(self, square, _active_color(), pulse, core_color)
if highlighted:
# The inset frame reads as a selection focus ring. It deliberately uses
# the bright core rather than the button's glow colour, so selecting a
# blue shield or pink transporter does not change what that colour means.
var inset: float = 10.0 * s
var focus: PackedVector2Array = PackedVector2Array([
Vector2(inset, inset), Vector2(rect_size.x - inset, inset),
Vector2(rect_size.x - inset, rect_size.y - inset), Vector2(inset, rect_size.y - inset),
])
NeonDraw.draw_glowing_polygon(self, focus, core_color, 1.0, core_color, 0.72 * s)
var center: Vector2 = rect_size / 2.0
match icon:

View file

@ -96,6 +96,7 @@ func _process(delta: float) -> bool:
var lab_menu: Control = controller.get_node("../UI/LabMenu")
var lab_card_0: Control = controller.get_node("../UI/LabMenu/Upgrade0")
var lab_card_1: Control = controller.get_node("../UI/LabMenu/Upgrade1")
var lab_card_2: Control = controller.get_node("../UI/LabMenu/Upgrade2")
var lab_card_3: Control = controller.get_node("../UI/LabMenu/Upgrade3")
var lab_detail: Label = controller.get_node("../UI/LabMenu/DetailLabel")
var lab_buy: IconButton = controller.get_node("../UI/LabMenu/BuyButton")
@ -116,7 +117,7 @@ func _process(delta: float) -> bool:
quit(1)
return true
controller.call("_on_lab_upgrade", 2)
if not "Targeting Array" in lab_detail.text:
if not "Targeting Array" in lab_detail.text or not lab_card_2.highlighted or lab_card_0.highlighted:
print("TEST_SHIP_LAB: FAIL (tapping an upgrade did not update its detail)")
quit(1)
return true