harvest/game/scripts/main_menu.gd
Forrest 938a4124df iOS test port: phone build switches, PerfTest overlay, Codemagic workflow
A one-day port to measure a late night on an iPhone before committing to
touch controls (docs/ios-test-port.md).

- MobilePort: on phones (the "mobile" feature) no ToonLook (standard
  materials, Mobile renderer), 3D at 0.75 resolution scale, co-op hidden,
  microphone never opened, and leaving the app pauses. `-- --mobile` and
  `-- --perf-test` turn the same switches on for desktop.
- PerfTest (the iOS preset's "perf_test" feature): frame time, physics,
  render CPU and GPU readout, a per-night summary (avg, p99, worst), and
  tap buttons for night 20/30, unlock all, next phase, and a shield.
  CampaignDebug's jumps also work in that release build.
- iOS export preset (export project only; bundle
  com.oatmealgames.harvestseason, team 823T4Q2T3U), an opaque 1024 icon,
  filled privacy purpose strings, ETC2/ASTC import, landscape both ways.
- codemagic.yaml: Godot 4.7.2 export, signing, .ipa, TestFlight upload.

Graph update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 12:59:25 -04:00

114 lines
4.4 KiB
GDScript

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; not on phones), 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())
coop_button.visible = not MobilePort.active() # no co-op on phones
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