diff --git a/game/scripts/main.gd b/game/scripts/main.gd index d62787d..f8d09bc 100644 --- a/game/scripts/main.gd +++ b/game/scripts/main.gd @@ -111,8 +111,7 @@ func _ready() -> void: showcase = Showcase.new() showcase.art = art showcase.closed.connect(close_showcase) - showcase.hide() - showcase.process_mode = Node.PROCESS_MODE_DISABLED + _hide_showcase() add_child(showcase) _show_menu("") match options.start: @@ -216,6 +215,7 @@ func _show_menu(status: String) -> void: ## Shows the world of the session and puts the figure on the spawn. func _show_world() -> void: menu.hide() + _hide_showcase() hud.show() for node: Node2D in [avatar, marker, figures]: node.show() @@ -242,9 +242,15 @@ func open_showcase() -> void: ## Goes back from the style samples to the menu. func close_showcase() -> void: + _hide_showcase() + menu.show() + + +## Hides the style samples and stops them. A world that starts while they are +## open, such as the one a joining guest receives, takes their place. +func _hide_showcase() -> void: showcase.hide() showcase.process_mode = Node.PROCESS_MODE_DISABLED - menu.show() ## Draws the playing field again after the style changed. diff --git a/game/tests/test_main.gd b/game/tests/test_main.gd index 9475375..642a12a 100644 --- a/game/tests/test_main.gd +++ b/game/tests/test_main.gd @@ -440,3 +440,15 @@ func test_the_style_samples_open_from_the_menu_and_lead_back_to_it() -> void: check(main.menu.visible, "the menu is back") check(not main.showcase.visible, "the samples are gone") _clean_up([directory]) + + +func test_a_world_that_starts_takes_the_place_of_the_style_samples() -> void: + var directory := TestFiles.temporary_dir("samples-world") + var main := _start_main(directory) + main.open_showcase() + check(main.showcase.visible, "the samples are open") + main.play(false) + check(not main.showcase.visible, "the world shows instead of the samples") + check_eq(main.showcase.process_mode, Node.PROCESS_MODE_DISABLED, "and the samples take no input") + check(not main.menu.visible, "the menu stays hidden") + _clean_up([directory])