diff --git a/Client/origin-client/autoloads/CustomLobby.gd b/Client/origin-client/autoloads/CustomLobby.gd index 20d863d..54c860b 100644 --- a/Client/origin-client/autoloads/CustomLobby.gd +++ b/Client/origin-client/autoloads/CustomLobby.gd @@ -76,6 +76,7 @@ func clear_state() -> void: func create(lobby_name: String, deck_id: String, password: String, rules_override: Dictionary, on_success: Callable = Callable(), on_error: Callable = Callable()) -> void: + clear_state() my_deck_id = deck_id var payload := { "lobbyName": lobby_name, @@ -101,6 +102,7 @@ func create(lobby_name: String, deck_id: String, password: String, func join(lid: String, deck_id: String, password: String, on_success: Callable = Callable(), on_error: Callable = Callable()) -> void: + clear_state() my_deck_id = deck_id var payload := { "lobbyId": lid, "deckId": deck_id } if password != "": diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 6006b8c..40e3de7 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -261,7 +261,7 @@ func _exit_tree() -> void: func _setup_spectator_ui() -> void: - # "SPECTATING" overlay label. + # "SPECTATING" label at top-center. var lbl := Label.new() lbl.text = "SPECTATING" lbl.modulate = Color(1.0, 0.76, 0.2) @@ -271,9 +271,21 @@ func _setup_spectator_ui() -> void: lbl.position = Vector2(0, 8) _hud.add_child(lbl) - # Hide action buttons — spectators can only watch. + # "Leave" button for spectators (top-right corner). + var leave_btn := Button.new() + leave_btn.text = "Leave" + leave_btn.set_anchors_preset(Control.PRESET_TOP_RIGHT) + leave_btn.position = Vector2(-90, 8) + leave_btn.custom_minimum_size = Vector2(80, 32) + leave_btn.pressed.connect(func() -> void: + Game.stop_spectating() + get_tree().change_scene_to_file("res://scenes/free_play/FreePlayScreen.tscn")) + _hud.add_child(leave_btn) + + # Hide action buttons and the settings panel — spectators cannot interact with the game. _draw_btn.visible = false _end_turn_btn.visible = false + _settings_btn.visible = false # ── Environment ─────────────────────────────────────────────────────────────── diff --git a/Client/origin-client/scenes/init/init_screen.gd b/Client/origin-client/scenes/init/init_screen.gd index 67f966f..99a49a6 100644 --- a/Client/origin-client/scenes/init/init_screen.gd +++ b/Client/origin-client/scenes/init/init_screen.gd @@ -127,14 +127,19 @@ func _check_active_session() -> void: func _on_active_session(payload: Variant) -> void: - var p := payload as Dictionary - var sid : String = str(p.get("sessionId", "")) - # A null or zero UUID means no active session. + var p := payload as Dictionary + var sid_raw = p.get("sessionId") # may be null when server has no active session + # Treat null or zero UUID as "no active session". + if sid_raw == null: + _go_to_main() + return + var sid : String = str(sid_raw) if sid.is_empty() or sid == "00000000-0000-0000-0000-000000000000": _go_to_main() return - var phase : String = str(p.get("phase", "unknown")) + var phase_raw = p.get("phase") + var phase : String = str(phase_raw) if phase_raw != null else "unknown" var dialog := ConfirmationDialog.new() dialog.title = "Active Game Found" dialog.dialog_text = "You have an active game in progress (%s phase).\nWould you like to rejoin?" % phase diff --git a/Server/src/SOR.Admin/Components/Pages/Game/CustomLobbiesPage.razor b/Server/src/SOR.Admin/Components/Pages/Game/CustomLobbiesPage.razor index 8897e11..2181885 100644 --- a/Server/src/SOR.Admin/Components/Pages/Game/CustomLobbiesPage.razor +++ b/Server/src/SOR.Admin/Components/Pages/Game/CustomLobbiesPage.razor @@ -73,6 +73,7 @@ else