diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-11-27 19:19:49 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-11-27 19:29:29 +0200 |
| commit | 99be84042a7796fab592d46db3704f1e0058440d (patch) | |
| tree | 4cf51082912db2d2d923df78fdd7152b00b9e9a1 | |
| parent | 0b0960c76c99e44632428cdeb116f5642181641a (diff) | |
Fix paused bug
| -rw-r--r-- | docs/index.html | 2 | ||||
| -rw-r--r-- | docs/index.pck | bin | 3820948 -> 3846888 bytes | |||
| -rw-r--r-- | docs/index.service.worker.js | 2 | ||||
| -rw-r--r-- | pause_menu.gd | 23 | ||||
| -rw-r--r-- | room_main_menu.gd | 4 | ||||
| -rw-r--r-- | tileset_kenney_platformer.tres | 2 | ||||
| -rw-r--r-- | top.gd | 12 | ||||
| -rw-r--r-- | top.tscn | 32 | ||||
| -rw-r--r-- | transition_player.gd | 7 |
9 files changed, 68 insertions, 16 deletions
diff --git a/docs/index.html b/docs/index.html index 9949cc1..26b76c3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -112,7 +112,7 @@ body { <script src="index.js"></script> <script> -const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":3820948,"index.wasm":38034280},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4,"serviceWorker":"index.service.worker.js"}; +const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":3846888,"index.wasm":38034280},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4,"serviceWorker":"index.service.worker.js"}; const GODOT_THREADS_ENABLED = false; const engine = new Engine(GODOT_CONFIG); diff --git a/docs/index.pck b/docs/index.pck Binary files differindex 16d14db..3036a52 100644 --- a/docs/index.pck +++ b/docs/index.pck diff --git a/docs/index.service.worker.js b/docs/index.service.worker.js index c4e3a3c..85bcaac 100644 --- a/docs/index.service.worker.js +++ b/docs/index.service.worker.js @@ -4,7 +4,7 @@ // Incrementing CACHE_VERSION will kick off the install event and force // previously cached resources to be updated from the network. /** @type {string} */ -const CACHE_VERSION = '1764178526|14188520319'; +const CACHE_VERSION = '1764264560|5770444584'; /** @type {string} */ const CACHE_PREFIX = 'MobileMetroidvan-sw-cache-'; const CACHE_NAME = CACHE_PREFIX + CACHE_VERSION; diff --git a/pause_menu.gd b/pause_menu.gd index e5a3129..6079519 100644 --- a/pause_menu.gd +++ b/pause_menu.gd @@ -2,9 +2,18 @@ class_name PauseMenu extends CanvasLayer var active_map_room: MapRoom +var active_page_index: int = 0 +@export var pages: Array[Node] func _ready(): deactivate() + $System/QuitButton.grab_focus.call_deferred() + $System/QuitButton.connect("pressed", _on_quit_button_pressed) + +func _process(_delta: float): + if visible and Input.is_action_just_pressed("jump"): + active_page_index = (active_page_index + 1) % pages.size() + refresh_page() func set_room_name(map_room_name: String): if active_map_room: active_map_room.unhighlight() @@ -19,9 +28,23 @@ func set_room_name(map_room_name: String): $Map.position = -pos + delta - active_map_room.size / 2 func activate(): + active_page_index = 0 visible = true + get_tree().paused = true get_tree().call_group("ui_movement", "set_visible", false) + refresh_page() func deactivate(): visible = false + get_tree().paused = false get_tree().call_group("ui_movement", "set_visible", true) + +func refresh_page(): + for i in range(pages.size()): + pages[i].visible = (active_page_index == i) + +func _on_quit_button_pressed() -> void: + if not visible: return + var top: Top = get_tree().root.get_node("Top") + top.get_transition_player().room_transition(null, "res://room_main_menu.tscn", null) + deactivate() diff --git a/room_main_menu.gd b/room_main_menu.gd index 977b24b..f9ec9d1 100644 --- a/room_main_menu.gd +++ b/room_main_menu.gd @@ -3,8 +3,8 @@ extends Node2D func _ready() -> void: $PlayButton.grab_focus.call_deferred() - $PlayButton.pressed.connect(_play_button_pressed) + $PlayButton.connect("pressed", _on_play_button_pressed) -func _play_button_pressed(): +func _on_play_button_pressed() -> void: var top: Top = get_tree().root.get_node("Top") top.game_load() diff --git a/tileset_kenney_platformer.tres b/tileset_kenney_platformer.tres index ad38ffc..b3d936d 100644 --- a/tileset_kenney_platformer.tres +++ b/tileset_kenney_platformer.tres @@ -1,6 +1,6 @@ [gd_resource type="TileSet" load_steps=4 format=3 uid="uid://0cd30n67d6k5"] -[ext_resource type="Texture2D" uid="uid://o0yy2jkyp0dy" path="res://assets.bak/kenney_1-bit-platformer-pack/Tilemap/monochrome_tilemap_transparent_packed.png" id="2_at7kb"] +[ext_resource type="Texture2D" uid="uid://o0yy2jkyp0dy" path="res://assets.untracked/kenney_1-bit-platformer-pack/Tilemap/monochrome_tilemap_transparent_packed.png" id="2_at7kb"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_0e48y"] resource_name = "solid trans" @@ -42,16 +42,14 @@ func replace_active_room(new_room: Node, on_changed: Callable): func get_pause_menu() -> PauseMenu: return $PauseMenu - + func get_transition_player() -> TransitionPlayer: return $TransitionPlayer func open_pause_menu(): - get_tree().paused = true $PauseMenu.activate() func close_pause_menu(): - get_tree().paused = false $PauseMenu.deactivate() # Save state logic @@ -70,8 +68,6 @@ func game_save(): func game_load(): save_state.load(SAVE_PATH) - $TransitionPlayer.room_transition( - null, - save_state.get_value(SAVE_SECTION, SAVE_ACTIVE_ROOM_PATH, ROOM_NEW_GAME), - save_state.get_value(SAVE_SECTION, SAVE_LAST_DOOR_NAME) - ) + var save_active_room_path = save_state.get_value(SAVE_SECTION, SAVE_ACTIVE_ROOM_PATH, ROOM_NEW_GAME) + var save_last_door_name = save_state.get_value(SAVE_SECTION, SAVE_LAST_DOOR_NAME, "DoorLeft") + $TransitionPlayer.room_transition(null, save_active_room_path, save_last_door_name) @@ -156,8 +156,9 @@ libraries = { speed_scale = 3.0 script = ExtResource("6_ch5ua") -[node name="PauseMenu" type="CanvasLayer" parent="."] +[node name="PauseMenu" type="CanvasLayer" parent="." node_paths=PackedStringArray("pages")] script = ExtResource("6_ql50d") +pages = [NodePath("Map"), NodePath("Status"), NodePath("System")] [node name="Bg" type="ColorRect" parent="PauseMenu"] offset_right = 192.0 @@ -194,6 +195,34 @@ offset_right = 79.0 offset_bottom = 65.0 metadata/_edit_use_anchors_ = true +[node name="Status" type="CanvasGroup" parent="PauseMenu"] +visible = false +scale = Vector2(0.25, 0.25) + +[node name="Label" type="Label" parent="PauseMenu/Status"] +offset_left = 320.0 +offset_top = 192.0 +offset_right = 411.0 +offset_bottom = 215.0 +text = "Status page" + +[node name="System" type="CanvasGroup" parent="PauseMenu"] +scale = Vector2(0.25, 0.25) + +[node name="QuitButton" type="Button" parent="PauseMenu/System"] +offset_left = 300.0 +offset_top = 172.0 +offset_right = 455.0 +offset_bottom = 203.0 +text = "Quit to main menu" + +[node name="AutosavedAgoText" type="Label" parent="PauseMenu/System"] +offset_left = 296.0 +offset_top = 208.0 +offset_right = 460.0 +offset_bottom = 231.0 +text = "Autosaved TODO ago" + [node name="PaletteShader" type="CanvasLayer" parent="."] layer = 10 script = ExtResource("5_ch5ua") @@ -205,3 +234,4 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 diff --git a/transition_player.gd b/transition_player.gd index b7b4918..2e0ec29 100644 --- a/transition_player.gd +++ b/transition_player.gd @@ -5,6 +5,8 @@ var _transition_room: Node var _transition_door_name: Variant # String or null func room_transition(from_door: Door, to_room_path: String, door_name: Variant): + print_debug("to_room_path: %s" % to_room_path) + var top: Top = get_tree().root.get_node("Top") # Do not transition if there is already a transition in process if _transition_room != null: @@ -23,8 +25,9 @@ func room_transition(from_door: Door, to_room_path: String, door_name: Variant): _transition_room = room.instantiate() _transition_door_name = door_name - top.game_set(Top.SAVE_ACTIVE_ROOM_PATH, to_room_path) - top.game_set(Top.SAVE_LAST_DOOR_NAME, door_name) + if to_room_path != Top.ROOM_MAIN_MENU: + top.game_set(Top.SAVE_ACTIVE_ROOM_PATH, to_room_path) + top.game_set(Top.SAVE_LAST_DOOR_NAME, door_name) func _transition_start(): var top: Top = get_tree().root.get_node("Top") |
