From b60480798f2f6312dafe1299de9db266a9381d08 Mon Sep 17 00:00:00 2001 From: coder-bot Date: Fri, 21 Aug 2026 00:43:45 +0000 Subject: [PATCH] WIP checkpoint: PC2: Wire "Enter World" from the browse list to the playable level --- scripts/player.gd | 8 +++----- scripts/world_list.gd | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/player.gd b/scripts/player.gd index ff37c6e..402767a 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -79,13 +79,11 @@ func _unhandled_input(event: InputEvent) -> void: _update_input_direction(key) elif not key.pressed: _clear_input_direction(key) - # Release the mouse so the player can get back to a menu/cursor. + # Escape exits the level back to the world browse list, mirroring + # the Back button pattern already used in world_list.gd/main_menu.gd. if key.pressed and key.keycode == KEY_ESCAPE: Input.mouse_mode = Input.MOUSE_MODE_VISIBLE - elif event is InputEventMouseButton and event.pressed: - # Clicking back into the viewport re-captures the mouse. - if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE and DisplayServer.get_name() != "headless": - Input.mouse_mode = Input.MOUSE_MODE_CAPTURED + get_tree().change_scene_to_file("res://scenes/world_list.tscn") elif event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED: _handle_mouse_look(event as InputEventMouseMotion) diff --git a/scripts/world_list.gd b/scripts/world_list.gd index 44f2cb1..7e7b5b0 100644 --- a/scripts/world_list.gd +++ b/scripts/world_list.gd @@ -135,8 +135,23 @@ func _create_world_card(world_dict: Dictionary) -> Control: meta_label.add_theme_font_size_override("font_size", 12) meta_label.add_theme_color_override("font_color", Color(0.5, 0.5, 0.5, 1.0)) + # PC2: the only thing a world actually loads into right now is the one + # shared playable test level (scenes/game.tscn) -- there's no per-world + # content yet, so "Enter" doesn't need the world's id for anything. + # Real per-world level loading is a later concern once worlds actually + # have their own content to load. + var enter_button := Button.new() + enter_button.text = "Enter World" + enter_button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN + enter_button.pressed.connect(_on_enter_world_pressed) + card.add_child(name_label) card.add_child(desc_label) card.add_child(meta_label) + card.add_child(enter_button) return panel + + +func _on_enter_world_pressed() -> void: + get_tree().change_scene_to_file("res://scenes/game.tscn")