Fix null-session prompt, stale ready state, spectator UI, and admin cancel
- init_screen.gd: handle null sessionId from game.get_active_session.ack properly — str(null)="<null>" which passed the is_empty() check causing every player to see "active game in progress (null phase)" on login - CustomLobby.gd: call clear_state() at the start of create() and join() so that i_am_ready/partner_ready are reset between lobbies — fixes players appearing instantly ready when entering a new lobby after a previous game - game_screen.gd: in _setup_spectator_ui(), hide _settings_btn (prevents accessing the Concede button) and add a programmatic "Leave" button that calls Game.stop_spectating() and navigates back to FreePlayScreen - CustomLobbiesPage.razor: add Cancel button (admin) for Open/Full lobbies; directly sets Status=Cancelled and refreshes the list Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -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 ───────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user