UI and other changes

This commit is contained in:
Forrest 2026-10-07 13:41:38 -04:00
parent 87b5c11fcf
commit 215e24e246
79 changed files with 70023 additions and 2201 deletions

View file

@ -1,8 +1,10 @@
class_name PauseMenu
extends CenterContainer
## Escape / Start during play (Main pauses the tree): where you are, then Resume, Restart the
## night, Settings, Save & quit to the menu, and Quit the game, with a reminder of what Continue
## picks up (the vacation is saved every morning).
## Escape / Start during play (Main pauses the tree), hand-drawn like the HUD's pouch panel
## (UiTheme.sketch): where you are and what's left to protect
## (crops, animals, supplies; asset_counts), then Resume, Restart the night, Settings, Save & quit
## to the menu, and Quit the game, with a reminder of what Continue picks up (the vacation is
## saved every morning).
signal resume_requested
signal restart_requested
@ -17,15 +19,17 @@ var menu_button: Button
var quit_button: Button
var _where: Label
var _note: Label
var _assets: Array[Label] = []
func _ready() -> void:
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
theme = UiTheme.sketch()
var panel := PanelContainer.new()
add_child(panel)
var margin := MarginContainer.new()
for side in ["left", "right", "top", "bottom"]:
margin.add_theme_constant_override("margin_" + side, 32)
margin.add_theme_constant_override("margin_" + side, 14)
panel.add_child(margin)
var box := VBoxContainer.new()
box.add_theme_constant_override("separation", 14)
@ -33,13 +37,24 @@ func _ready() -> void:
var title := Label.new()
title.text = "Paused"
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
title.add_theme_font_size_override("font_size", 48)
title.add_theme_color_override("font_color", UiTheme.GOLD)
title.add_theme_font_size_override("font_size", 56)
box.add_child(title)
box.add_child(HSeparator.new())
_where = Label.new()
_where.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
_where.add_theme_font_size_override("font_size", 22)
_where.add_theme_font_size_override("font_size", 28)
_where.add_theme_color_override("font_color", Sketch.DIM)
box.add_child(_where)
var assets := HBoxContainer.new()
assets.alignment = BoxContainer.ALIGNMENT_CENTER
assets.add_theme_constant_override("separation", 30)
box.add_child(assets)
for c in 3:
var l := Label.new()
l.add_theme_font_size_override("font_size", 30)
l.add_theme_color_override("font_color", LootSystem.CATEGORY_COLORS[c])
assets.add_child(l)
_assets.append(l)
resume_button = _button(box, "Resume")
resume_button.pressed.connect(func() -> void: resume_requested.emit())
restart_button = _button(box, "Restart the night")
@ -54,8 +69,8 @@ func _ready() -> void:
_note.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
_note.custom_minimum_size = Vector2(520.0, 0.0)
_note.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
_note.add_theme_font_size_override("font_size", 18)
_note.add_theme_color_override("font_color", Color(0.72, 0.74, 0.68))
_note.add_theme_font_size_override("font_size", 22)
_note.add_theme_color_override("font_color", Sketch.DIM)
box.add_child(_note)
visible = false
mouse_filter = Control.MOUSE_FILTER_IGNORE
@ -66,6 +81,10 @@ func open(campaign: CampaignController, coop: int = 0) -> void:
var s := campaign.state
var phase: String = CampaignController.Phase.keys()[s.phase]
_where.text = "Night %d of %d · %s" % [s.night, campaign.config.campaign_nights, phase.replace("_", " ").capitalize()]
var counts := asset_counts(s)
for c in 3:
_assets[c].text = counts[c]
_assets[c].visible = counts[c] != ""
var over := campaign.outcome == CampaignController.Outcome.VACATION_COMPLETE
restart_button.disabled = over or coop == 2
menu_button.text = "Leave the game" if coop == 2 else "Save & quit to menu"
@ -80,6 +99,23 @@ func open(campaign: CampaignController, coop: int = 0) -> void:
resume_button.grab_focus.call_deferred()
## "Crops 28/30", "Animals 7/8", "Supplies 23" (the shed's stock plus any sacks still on the
## farm): what's left to protect, "" for a category not in play.
static func asset_counts(s: FarmState) -> PackedStringArray:
return PackedStringArray(["Crops %d/%d" % [s.crops, s.crops_total] if s.crops_total > 0 else "",
"Animals %d/%d" % [s.animals, s.animals_total] if s.animals_total > 0 else "",
"Supplies %d" % s.supplies if s.supplies_total > 0 else ""])
## The assets line as shown: "Crops 28/30 · Animals 7/8 · Supplies 23" (tests).
func describe_assets() -> String:
var parts := PackedStringArray()
for l in _assets:
if l.visible:
parts.append(l.text)
return " · ".join(parts)
func _draw() -> void:
draw_rect(Rect2(Vector2.ZERO, size), Color(0.0, 0.0, 0.0, 0.4)) # dims what's behind
@ -93,6 +129,6 @@ func _button(parent: Control, text: String) -> Button:
var b := Button.new()
b.text = text
b.custom_minimum_size = Vector2(420.0, 56.0)
b.add_theme_font_size_override("font_size", 24)
b.add_theme_font_size_override("font_size", 30)
parent.add_child(b)
return b