updates
This commit is contained in:
parent
0cba7f5ee0
commit
32ed347b58
172 changed files with 5464 additions and 582 deletions
33
scenes/scene_router.gd
Normal file
33
scenes/scene_router.gd
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
class_name SceneRouter
|
||||
## Moves between the menu and a game (the project's only scene changes), carrying what the next
|
||||
## scene needs in `args`.
|
||||
|
||||
const MENU := "res://scenes/menu.tscn"
|
||||
const GAME := "res://scenes/game.tscn"
|
||||
|
||||
## What the scene being entered should start with, e.g. {game: {seed, human, style}, settings}.
|
||||
## The scene takes it with take().
|
||||
static var args := {}
|
||||
|
||||
|
||||
## Opens a game with `opts` ({seed, human, style}) and `settings`.
|
||||
static func to_game(opts: Dictionary, settings: Dictionary) -> void:
|
||||
args = {"game": opts, "settings": settings}
|
||||
_tree().change_scene_to_file.call_deferred(GAME)
|
||||
|
||||
|
||||
## Back to the menu; `screen` is "" for the title or "setup" for the new-game screen.
|
||||
static func to_menu(screen := "") -> void:
|
||||
args = {"screen": screen}
|
||||
_tree().change_scene_to_file.call_deferred(MENU)
|
||||
|
||||
|
||||
## The args left for this scene, cleared so a reload doesn't reuse them.
|
||||
static func take() -> Dictionary:
|
||||
var out := args
|
||||
args = {}
|
||||
return out
|
||||
|
||||
|
||||
static func _tree() -> SceneTree:
|
||||
return Engine.get_main_loop() as SceneTree
|
||||
Loading…
Add table
Add a link
Reference in a new issue