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
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue