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
|
||||
|
|
|
|||
|
|
@ -12,10 +12,13 @@ extends "res://ui/menus/ModalMenu.gd"
|
|||
# it does, so the bar row below shows what each of them has left, worst first,
|
||||
# which is the number that decides whether another needs building.
|
||||
|
||||
const BAR_WIDTH: float = 54.0
|
||||
const BAR_HEIGHT: float = 18.0
|
||||
const BAR_GAP: float = 10.0
|
||||
const BAR_TOP: float = 470.0
|
||||
# One bar, wide, for the vessel closest to being spent - the one that decides
|
||||
# whether another needs building. The per-vessel figures are listed as TEXT
|
||||
# below it: a row of small bars was unreadable at the size a phone draws this
|
||||
# menu, and "cycles left" is a number the player wants to actually read.
|
||||
const BAR_WIDTH: float = 420.0
|
||||
const BAR_HEIGHT: float = 40.0
|
||||
const BAR_TOP: float = 494.0
|
||||
const WORN_COLOR: Color = Color(1.0, 0.35, 0.25)
|
||||
const FRESH_COLOR: Color = Color(0.5, 1.0, 0.55)
|
||||
const PLATE_COLOR: Color = Color(0.02, 0.02, 0.06, 0.9)
|
||||
|
|
@ -25,6 +28,7 @@ const FRAME_COLOR: Color = Color(0.85, 0.96, 1.0, 0.85)
|
|||
@onready var assigned_label: Label = $AssignedLabel
|
||||
@onready var status: Label = $StatusLabel
|
||||
@onready var condition_label: Label = $ConditionLabel
|
||||
@onready var condition_list: Label = $ConditionList
|
||||
@onready var less_button: IconButton = $LessButton
|
||||
@onready var more_button: IconButton = $MoreButton
|
||||
|
||||
|
|
@ -83,7 +87,20 @@ func refresh() -> void:
|
|||
status.text = "%d on order - sent from the mothership hangar as they are built." % (wanted - here)
|
||||
|
||||
var left: Array = GameState.station_condition(building_id)
|
||||
condition_label.text = "CONDITION" if not left.is_empty() else ""
|
||||
var full: int = maxi(GameState.station_work_capacity(building_id), 1)
|
||||
var unit: String = "RUNS" if vessel_type == GameState.VESSEL_TRANSPORTER else "REPAIRS"
|
||||
if left.is_empty():
|
||||
condition_label.text = ""
|
||||
condition_list.text = ""
|
||||
else:
|
||||
condition_label.text = "CONDITION - %s LEFT" % unit
|
||||
# Worst first, which is the order station_condition() answers in: the
|
||||
# one about to be spent is the one being decided about.
|
||||
var lines: PackedStringArray = PackedStringArray()
|
||||
for i in range(left.size()):
|
||||
lines.append("%s %d %d / %d %s" % [
|
||||
name.to_upper(), i + 1, int(left[i]), full, unit])
|
||||
condition_list.text = "\n".join(lines)
|
||||
queue_redraw()
|
||||
|
||||
|
||||
|
|
@ -98,13 +115,13 @@ func _draw() -> void:
|
|||
if left.is_empty():
|
||||
return
|
||||
var full: int = maxi(GameState.station_work_capacity(building_id), 1)
|
||||
var total: float = float(left.size()) * BAR_WIDTH + float(left.size() - 1) * BAR_GAP
|
||||
var x: float = (size.x - total) * 0.5
|
||||
for remaining in left:
|
||||
var fraction: float = clampf(float(remaining) / float(full), 0.0, 1.0)
|
||||
draw_rect(Rect2(x - 2.0, BAR_TOP - 2.0, BAR_WIDTH + 4.0, BAR_HEIGHT + 4.0),
|
||||
PLATE_COLOR)
|
||||
draw_rect(Rect2(x, BAR_TOP, BAR_WIDTH * fraction, BAR_HEIGHT),
|
||||
WORN_COLOR.lerp(FRESH_COLOR, fraction))
|
||||
draw_rect(Rect2(x, BAR_TOP, BAR_WIDTH, BAR_HEIGHT), FRAME_COLOR, false, 1.5)
|
||||
x += BAR_WIDTH + BAR_GAP
|
||||
# The worst of them. station_condition() answers worst first.
|
||||
var fraction: float = clampf(float(left[0]) / float(full), 0.0, 1.0)
|
||||
var x: float = (size.x - BAR_WIDTH) * 0.5
|
||||
draw_rect(Rect2(x - 3.0, BAR_TOP - 3.0, BAR_WIDTH + 6.0, BAR_HEIGHT + 6.0),
|
||||
PLATE_COLOR)
|
||||
draw_rect(Rect2(x, BAR_TOP, BAR_WIDTH, BAR_HEIGHT),
|
||||
Color(FRESH_COLOR.r, FRESH_COLOR.g, FRESH_COLOR.b, 0.16))
|
||||
draw_rect(Rect2(x, BAR_TOP, BAR_WIDTH * fraction, BAR_HEIGHT),
|
||||
WORN_COLOR.lerp(FRESH_COLOR, fraction))
|
||||
draw_rect(Rect2(x, BAR_TOP, BAR_WIDTH, BAR_HEIGHT), FRAME_COLOR, false, 2.0)
|
||||
|
|
|
|||
|
|
@ -75,14 +75,25 @@ glow_color = Color(0.95, 0.55, 0.85, 1)
|
|||
mouse_filter = 2
|
||||
anchor_right = 1.0
|
||||
offset_left = 36.0
|
||||
offset_top = 420.0
|
||||
offset_top = 430.0
|
||||
offset_right = -36.0
|
||||
offset_bottom = 462.0
|
||||
theme_override_font_sizes/font_size = 22
|
||||
offset_bottom = 480.0
|
||||
theme_override_font_sizes/font_size = 28
|
||||
theme_override_colors/font_color = Color(0.55, 0.78, 0.86, 1)
|
||||
text = ""
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ConditionList" type="Label" parent="."]
|
||||
mouse_filter = 2
|
||||
anchor_right = 1.0
|
||||
offset_left = 36.0
|
||||
offset_top = 560.0
|
||||
offset_right = -36.0
|
||||
offset_bottom = 940.0
|
||||
theme_override_font_sizes/font_size = 30
|
||||
text = ""
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="StatusLabel" type="Label" parent="."]
|
||||
mouse_filter = 2
|
||||
anchor_right = 1.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue