Offer only orderable vessels, and read out crew condition
A ship crafter shows what can actually be ordered there: a hull whose research is done, and - for the support craft - one with somewhere to be assigned. A transporter with no hub and a drone with no workshop have nowhere to go and would sit in the hangar as spent resources, so the structure that uses one is part of its availability. Hidden rather than greyed, as the build menu already treats an unresearched structure, and gated in queue_order() too so the model refuses what the menu declines to show. The craft buttons bound their handlers to a definition captured at startup. With a list that changes length that is a live bug - a slot would order whatever hull was there when the menu was built - so they bind to the slot and resolve through the current offer. The hub and workshop crew menus now NAME what is left in each vessel: "TRANSPORTER 2 9 / 20 RUNS", worst first, with one wide bar for the vessel closest to spent. The per-vessel bars they replaced drew about seven pixels tall on a phone and carried no figure, so the number the player is deciding on could not be read. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
This commit is contained in:
parent
fe3ae97f94
commit
296b49c8b8
10 changed files with 359 additions and 41 deletions
|
|
@ -33,6 +33,8 @@ const PRICE_OFFSET := 154.0
|
|||
@onready var queue_slots: Array = [$QueueSlot0, $QueueSlot1, $QueueSlot2, $QueueSlot3]
|
||||
|
||||
var building_id: int = 0
|
||||
# Which vessel each visible slot is offering, in order. Empty slots are hidden.
|
||||
var shown_types: PackedStringArray = PackedStringArray()
|
||||
var message: String = ""
|
||||
var message_until: int = 0
|
||||
var price_tags: Array = []
|
||||
|
|
@ -41,10 +43,11 @@ var price_tags: Array = []
|
|||
func _ready() -> void:
|
||||
super._ready()
|
||||
_build_price_tags()
|
||||
for i in range(mini(vessel_buttons.size(), VESSEL_DEFINITIONS.craftable().size())):
|
||||
var definition: Resource = VESSEL_DEFINITIONS.craftable()[i]
|
||||
vessel_buttons[i].pressed.connect(
|
||||
func(): craft_requested.emit(String(definition.definition_id)))
|
||||
# Bound to the SLOT, not to a definition: which vessel sits in slot i
|
||||
# changes as things become available, so a handler that captured one at
|
||||
# startup would order the wrong hull the moment the list shortened.
|
||||
for i in range(vessel_buttons.size()):
|
||||
vessel_buttons[i].pressed.connect(func(): _on_vessel_pressed(i))
|
||||
for i in range(queue_slots.size()):
|
||||
queue_slots[i].pressed.connect(func(): queue_cancel_requested.emit(i))
|
||||
_layout_entries()
|
||||
|
|
@ -70,17 +73,34 @@ func say(next_message: String) -> void:
|
|||
|
||||
func refresh() -> void:
|
||||
status.text = ""
|
||||
var definitions: Array = VESSEL_DEFINITIONS.craftable()
|
||||
for i in range(mini(definitions.size(), vessel_buttons.size())):
|
||||
var definition: Resource = definitions[i]
|
||||
# Only what can actually be ordered here today: a hull whose research is
|
||||
# done, and - for the support craft - one with somewhere to be assigned.
|
||||
# Hidden rather than greyed, the way the build menu treats a structure
|
||||
# that has not been researched; a row nobody can press is clutter that
|
||||
# says nothing the absence does not.
|
||||
shown_types.clear()
|
||||
for definition in VESSEL_DEFINITIONS.craftable():
|
||||
if GameState.vessel_can_be_crafted(String(definition.definition_id)):
|
||||
shown_types.append(String(definition.definition_id))
|
||||
|
||||
for i in range(vessel_buttons.size()):
|
||||
var on_offer: bool = i < shown_types.size()
|
||||
vessel_buttons[i].visible = on_offer
|
||||
vessel_labels[i].visible = on_offer
|
||||
if i < price_tags.size():
|
||||
price_tags[i].visible = on_offer
|
||||
if not on_offer:
|
||||
continue
|
||||
var definition: Resource = VESSEL_DEFINITIONS.get_definition(String(shown_types[i]))
|
||||
var button: Control = vessel_buttons[i]
|
||||
vessel_labels[i].text = String(definition.display_name)
|
||||
if i < price_tags.size():
|
||||
price_tags[i].set_costs(GameState.product_costs(definition.definition_id))
|
||||
button.icon = definition.icon
|
||||
button.glow_color = definition.glow_color
|
||||
button.enabled = GameState.vessel_is_unlocked(definition.definition_id)
|
||||
button.enabled = true
|
||||
button.queue_redraw()
|
||||
_layout_entries()
|
||||
refresh_queue()
|
||||
if message != "":
|
||||
if Time.get_ticks_msec() < message_until:
|
||||
|
|
@ -133,8 +153,17 @@ func row_height() -> float:
|
|||
return PRICE_OFFSET + PRICE_HEIGHT
|
||||
|
||||
|
||||
func _on_vessel_pressed(slot: int) -> void:
|
||||
if slot < 0 or slot >= shown_types.size():
|
||||
return
|
||||
craft_requested.emit(String(shown_types[slot]))
|
||||
|
||||
|
||||
func _layout_entries() -> void:
|
||||
var rows: int = maxi(int(ceil(float(vessel_buttons.size()) / float(COLUMNS))), 1)
|
||||
# Laid out over what is ON OFFER, so a short list is centred and packed
|
||||
# rather than leaving holes where a hidden hull used to be.
|
||||
var offered: int = maxi(shown_types.size(), 1)
|
||||
var rows: int = maxi(int(ceil(float(offered) / float(COLUMNS))), 1)
|
||||
var band: Vector2 = MENU_LAYOUT.grid_band(status.offset_bottom, size.y)
|
||||
for i in range(vessel_buttons.size()):
|
||||
var row: int = i / COLUMNS
|
||||
|
|
|
|||
Loading…
Reference in a new issue