Shelf-Made Tycoon’s main menu is not a scene
A common way to make a main menu in Godot is a scene of its own, with a Play button that changes to the game scene. Shelf-Made Tycoon, a logistics tycoon built in Flockbay, does it the other way round: the game is already running when the menu appears, and the menu is a card laid over it. This is how the project does that, from its files.
- Game
- Shelf-Made Tycoon, a logistics tycoon built in Flockbay
- Source
- The game’s own project:
scenes/boot.tscn,scripts/ui/boot.gd,scripts/ui/hud.gdandproject.godot - Engine
- Godot 4.7.2, on the Forward+ renderer
- Picture
- Rendered for this page by the project’s
tests/review_shots.gd, on Windows
The scene Godot starts is one node with a script
The project’s main scene, the one run/main_scene names in project.godot, is not the game and not a menu. It is one node with a script:
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scripts/ui/boot.gd" id="1"]
[node name="Boot" type="Node"]
script = ExtResource("1")That script puts a dark cover over the window, fades two logos in and out on it, and asks Godot to load the real game scene on another thread while they play:
var error := ResourceLoader.load_threaded_request(MAIN_SCENE, "PackedScene", false)load_threaded_request returns at once and the loading goes on in the background, so the logos keep animating instead of the window freezing on its first frame. The game scene goes into the tree under the cover and sets itself up there. The cover lifts only when the title card is ready, and until then it stops every click: the cover is a full-window ColorRect with mouse_filter set to stop.
The menu is a dim layer over the live yard
When the cover lifts, this is what is under it:

The warehouse behind the buttons is not a background picture. It is the game, running, with a translucent rectangle on top:
func show_title() -> void:
title_screen = ColorRect.new()
(title_screen as ColorRect).color = Color(0.09, 0.1, 0.12, 0.8)
title_screen.set_anchors_preset(Control.PRESET_FULL_RECT)
root.add_child(title_screen)A ColorRect at 80 per cent opacity, anchored to the full window, added to the HUD’s root. The rest of the function fills it with a CenterContainer, a VBoxContainer, the logo and the buttons. The game’s own panels (cash, clock, the board of offers) are set fully transparent while the card is up and tweened back in over a quarter of a second when it closes.
Two things follow from building the menu this way. Starting a game needs no scene change: for the standard start, the company is the yard already on screen, and Open a new warehouse only names it and begins it. And the menu always shows the game as it looks today, with no screenshot to keep up to date.
The cost is that the game has to know a menu is over it. The card’s last line is main.menu_open(true), which sets a flag in the main script. While it is set, the yard’s own keys and build tools are ignored, so a key meant for the card does nothing in the game behind it. Closing the card calls main.menu_open(false).
Which button is the main one depends on the save
The buttons are made in code, not laid out in the editor, because the list is not fixed:
var companies: Array = main.companies()
var playable: bool = companies.any(func(row): return bool(row.playable)) if not Playtest.on() else main.save_playable()
if Playtest.on() and not playable:
main.set_aside_unreadable_save()
if playable:
var go := Button.new()
go.text = tr("Back to work (last save)")
_primary(go)
go.custom_minimum_size.y = 44
go.pressed.connect(func():
close_title()
main.load_game(main.latest_company()))
buttons.add_child(go)When a saved company can be played on, the card leads with Back to work, styled as the primary button, with that company’s name, day and cash under it. When there is none, as in the frame above, that button does not exist and Open a new warehouse is the primary one instead. Load appears only when there is something to load. A returning player and a new one each get one obvious button, and it is not the same one.
The small buttons at the bottom are built by one loop over a list of label and function pairs, two to a row.
Each label goes through tr(), Godot’s translation call, so the same code draws the card in every language the game ships. Quit does not call get_tree().quit(). It calls the game’s own quit_game(), the same function the window’s close button reaches, which saves first; the save guide covers that side.
Focus is handed out once, for keyboard and gamepad
A menu built for the mouse falls apart on a gamepad or a Steam Deck unless something has focus when it opens. The title card, like the game’s other dialogs, makes one call that sorts this out:
func _focus_dialog(node: Node) -> void:
var first: Control = null
var primary: Control = null
var field: Control = null
for control in node.find_children("*", "Control", true, false):
if not (control is BaseButton or control is Slider or control is LineEdit):
continue
(control as Control).focus_mode = Control.FOCUS_ALL
_pad_keys(control)
if not (control as Control).visible or (control is BaseButton and (control as BaseButton).disabled):
continue
if first == null:
first = control
if primary == null and control.has_meta("primary"):
primary = control
if field == null and control is LineEdit:
field = control
var target := field if field != null else (primary if primary != null else first)
if target != null:
_grab.call_deferred(target)It walks every button, slider and text field in the dialog, makes each one focusable, and then gives focus to the dialog’s text field if it has one, else its primary button, else its first control. The primary button is found by the primary metadata that the styling function set on it, so the button that looks like the main one is also the one Enter presses. From there, by the project’s own comment, the arrows and the d-pad move focus in reading order, Enter and A press, and Esc and B go back.
The buttons of the in-play HUD are deliberately left out of this. The project’s comment says why: they never keep keyboard focus, so Space and the speed keys reach the game and not whichever button was clicked last.
One layout serves every window size
The card is laid out once, for a 1280x720 design size, and the project lets Godot scale it:
window/size/viewport_width=1280
window/size/viewport_height=720
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"With the canvas_items stretch mode, controls are drawn at the window’s real resolution and scaled from the design size, so text stays sharp. The expand aspect keeps the design’s proportions and gives a wider or taller window more room, with no black bars.
The picture came from a script that opens every screen
The project has a script, tests/review_shots.gd, written so translators could see every screen in their language. It loads the game scene into a SubViewport, opens each screen in turn by calling the same functions the buttons call, and saves a frame of each. We ran it in English for this page, on a copy of the project with its own user folder, as the script’s header asks, and Godot printed:
What Godot printed, after its version and renderer lines
SHOTS en 32: title, start, scenarios, company_name, howto, settings, controls, credits, first_morning, offer_card, booked_card, rail_racks, rail_grow, rail_routes, inspector, alerts, books, goals, menu, companies, world, estate, rail_yard, containers, harbour, shipping_line, district_booked, routes_open, books_late, win, fold, playtest_end
Thirty-two screens, the title card first. A menu that is one function call can be opened by a script, which is what makes a run like this possible. It shows that every screen opens and draws; it does not press the buttons, so it would not catch one wired to the wrong function.
What to take from it
- Make the main scene a small boot scene, and load the game with
ResourceLoader.load_threaded_requestbehind it. - If your game can stand behind its own menu, draw the menu over it and skip the scene change.
- Decide the primary button from the save: continue when there is one, new game when there is not.
- Give something focus when a menu opens, so a gamepad can use it.
- Set a design size and the
canvas_itemsstretch mode before laying out the first button.
To build a game this way, download Flockbay and describe it; Getting started covers the first build.