updates
This commit is contained in:
parent
276d43613d
commit
4298caf5cb
552 changed files with 42990 additions and 776 deletions
113
game/scripts/main_menu.gd
Normal file
113
game/scripts/main_menu.gd
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
class_name MainMenu
|
||||
extends Control
|
||||
## The title screen over the farm (Main slowly circles a camera around it): the title, then
|
||||
## Continue (with which morning it resumes at, or why the save can't be continued), New
|
||||
## vacation, Play with a friend (co-op, CoopMenu), Settings, and Quit, and a notice line (e.g.
|
||||
## why a co-op game ended). Mouse, keyboard, and gamepad work through focus.
|
||||
|
||||
signal continue_requested
|
||||
signal new_requested
|
||||
signal settings_requested
|
||||
signal coop_requested
|
||||
signal quit_requested
|
||||
|
||||
var continue_button: Button
|
||||
var new_button: Button
|
||||
var settings_button: Button
|
||||
var coop_button: Button
|
||||
var notice: Label
|
||||
var quit_button: Button
|
||||
var save_note: Label
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
var shade := ColorRect.new() # darkens the left side behind the buttons
|
||||
shade.color = Color(0.03, 0.04, 0.03, 0.62)
|
||||
shade.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
add_child(shade)
|
||||
shade.set_anchors_and_offsets_preset(Control.PRESET_LEFT_WIDE)
|
||||
shade.offset_right = 700.0
|
||||
var box := VBoxContainer.new()
|
||||
box.position = Vector2(110.0, 150.0)
|
||||
box.add_theme_constant_override("separation", 16)
|
||||
add_child(box)
|
||||
var title := Label.new()
|
||||
title.text = "Harvest Season"
|
||||
title.add_theme_font_size_override("font_size", 92)
|
||||
title.add_theme_color_override("font_color", UiTheme.GOLD)
|
||||
title.add_theme_color_override("font_outline_color", Color(0.15, 0.1, 0.05))
|
||||
title.add_theme_constant_override("outline_size", 14)
|
||||
box.add_child(title)
|
||||
var sub := Label.new()
|
||||
sub.text = "The farmers are away. You're the scarecrow."
|
||||
sub.add_theme_font_size_override("font_size", 28)
|
||||
sub.add_theme_color_override("font_color", UiTheme.TEXT)
|
||||
box.add_child(sub)
|
||||
var gap := Control.new()
|
||||
gap.custom_minimum_size = Vector2(0.0, 50.0)
|
||||
box.add_child(gap)
|
||||
continue_button = _button(box, "Continue")
|
||||
continue_button.pressed.connect(func() -> void: continue_requested.emit())
|
||||
save_note = Label.new()
|
||||
save_note.add_theme_font_size_override("font_size", 19)
|
||||
save_note.add_theme_color_override("font_color", Color(0.75, 0.77, 0.7))
|
||||
box.add_child(save_note)
|
||||
new_button = _button(box, "New vacation")
|
||||
new_button.pressed.connect(func() -> void: new_requested.emit())
|
||||
coop_button = _button(box, "Play with a friend")
|
||||
coop_button.pressed.connect(func() -> void: coop_requested.emit())
|
||||
settings_button = _button(box, "Settings")
|
||||
settings_button.pressed.connect(func() -> void: settings_requested.emit())
|
||||
quit_button = _button(box, "Quit")
|
||||
quit_button.pressed.connect(func() -> void: quit_requested.emit())
|
||||
notice = Label.new()
|
||||
notice.add_theme_font_size_override("font_size", 22)
|
||||
notice.add_theme_color_override("font_color", Color(1.0, 0.75, 0.5))
|
||||
box.add_child(notice)
|
||||
var credits := Label.new()
|
||||
credits.text = "Art: KayKit and ithappy · Sounds: Kenney (CC0) · Music: \"On the Farm\"; DavidKBD, Purgatory · Co-op: GD-Sync · Made with Godot"
|
||||
credits.add_theme_font_size_override("font_size", 16)
|
||||
credits.add_theme_color_override("font_color", Color(0.6, 0.62, 0.56))
|
||||
add_child(credits)
|
||||
credits.set_anchors_and_offsets_preset(Control.PRESET_BOTTOM_LEFT)
|
||||
credits.offset_top = -60.0
|
||||
credits.offset_left = 110.0
|
||||
visible = false
|
||||
|
||||
|
||||
## Shows the menu for the save as read (SaveGame.read): Continue says where it resumes, or is
|
||||
## off with the reason.
|
||||
func open(saved: SaveGame.Loaded, nights: int) -> void:
|
||||
visible = true
|
||||
var ok := saved != null and saved.status == SaveGame.Status.OK
|
||||
continue_button.disabled = not ok
|
||||
continue_button.focus_mode = Control.FOCUS_ALL if ok else Control.FOCUS_NONE
|
||||
if ok:
|
||||
save_note.text = "Morning of day %d of %d%s" % [saved.state.night, nights,
|
||||
(" · saved " + saved.saved_at.replace("T", " ").left(16)) if saved.saved_at != "" else ""]
|
||||
else:
|
||||
save_note.text = saved.message if saved != null else "No saved vacation"
|
||||
_focus_first.call_deferred()
|
||||
|
||||
|
||||
func close() -> void:
|
||||
visible = false
|
||||
|
||||
|
||||
## Continue when it can be used, else New vacation (checked when it runs: open() may have been
|
||||
## called again since).
|
||||
func _focus_first() -> void:
|
||||
if visible:
|
||||
(new_button if continue_button.disabled else continue_button).grab_focus()
|
||||
|
||||
|
||||
func _button(parent: Control, text: String) -> Button:
|
||||
var b := Button.new()
|
||||
b.text = text
|
||||
b.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
b.custom_minimum_size = Vector2(380.0, 62.0)
|
||||
b.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
|
||||
b.add_theme_font_size_override("font_size", 28)
|
||||
parent.add_child(b)
|
||||
return b
|
||||
Loading…
Add table
Add a link
Reference in a new issue