updates
This commit is contained in:
parent
276d43613d
commit
4298caf5cb
552 changed files with 42990 additions and 776 deletions
98
game/scripts/pause_menu.gd
Normal file
98
game/scripts/pause_menu.gd
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
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).
|
||||
|
||||
signal resume_requested
|
||||
signal restart_requested
|
||||
signal settings_requested
|
||||
signal menu_requested
|
||||
signal quit_requested
|
||||
|
||||
var resume_button: Button
|
||||
var restart_button: Button
|
||||
var settings_button: Button
|
||||
var menu_button: Button
|
||||
var quit_button: Button
|
||||
var _where: Label
|
||||
var _note: Label
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
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)
|
||||
panel.add_child(margin)
|
||||
var box := VBoxContainer.new()
|
||||
box.add_theme_constant_override("separation", 14)
|
||||
margin.add_child(box)
|
||||
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)
|
||||
box.add_child(title)
|
||||
_where = Label.new()
|
||||
_where.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_where.add_theme_font_size_override("font_size", 22)
|
||||
box.add_child(_where)
|
||||
resume_button = _button(box, "Resume")
|
||||
resume_button.pressed.connect(func() -> void: resume_requested.emit())
|
||||
restart_button = _button(box, "Restart the night")
|
||||
restart_button.pressed.connect(func() -> void: restart_requested.emit())
|
||||
settings_button = _button(box, "Settings")
|
||||
settings_button.pressed.connect(func() -> void: settings_requested.emit())
|
||||
menu_button = _button(box, "Save & quit to menu")
|
||||
menu_button.pressed.connect(func() -> void: menu_requested.emit())
|
||||
quit_button = _button(box, "Quit the game")
|
||||
quit_button.pressed.connect(func() -> void: quit_requested.emit())
|
||||
_note = Label.new()
|
||||
_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))
|
||||
box.add_child(_note)
|
||||
visible = false
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
|
||||
|
||||
## coop: 0 solo, 1 hosting a co-op game, 2 a partner in one (the farm doesn't stop for menus).
|
||||
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 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"
|
||||
_note.text = "The vacation is finished." if over else \
|
||||
"The vacation is saved every morning: Continue picks up at the morning of day %d." % s.night
|
||||
if coop == 1:
|
||||
_note.text += " Co-op: the farm keeps going while you're in this menu, and quitting ends the game for your friend."
|
||||
elif coop == 2:
|
||||
_note.text = "Co-op: the farm keeps going while you're in this menu. Only the host can restart the night; the host's game is saved."
|
||||
visible = true
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
resume_button.grab_focus.call_deferred()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
draw_rect(Rect2(Vector2.ZERO, size), Color(0.0, 0.0, 0.0, 0.4)) # dims what's behind
|
||||
|
||||
|
||||
func close() -> void:
|
||||
visible = false
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
|
||||
|
||||
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)
|
||||
parent.add_child(b)
|
||||
return b
|
||||
Loading…
Add table
Add a link
Reference in a new issue