- Server: Add SkyboxType + 6 CubeUrl fields to SkyboxDefinition entity - Server: EF migration AddSkyboxCubemapType - Server: GetSkyboxConfigResponse now returns array of all active skyboxes - Admin: SkyboxManagerPage supports Panoramic/AnimatedPanorama/Cubemap types, 6 face URL fields for cubemap, and independent per-skybox active toggle - Client: ContentCache fetches + caches skyboxes; adds get_random_skybox, get_skybox_bg_url, load_texture_async, apply_scene_background helpers - Client: game_screen replaces _fetch_skybox with ContentCache-based approach; adds _load_cubemap_skybox / _apply_cubemap_images / _apply_cubemap_material - Client: 12 2D scene scripts call ContentCache.apply_scene_background(self) in _ready() to replace solid-color backgrounds with CDN skybox images 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>
134 lines
4.5 KiB
GDScript
134 lines
4.5 KiB
GDScript
extends Control
|
|
## Matchmaking screen — join ranked queue, wait for opponent, cancel.
|
|
|
|
const DECK_BTN = preload("res://scenes/common/components/DeckPickerButton.tscn")
|
|
##
|
|
## Flow:
|
|
## 1. _ready: fetch player's decks via collection.get_decks
|
|
## 2. If multiple decks, show deck picker; if one, auto-select
|
|
## 3. On deck selected: call matchmaking.join → show Searching state
|
|
## 4. On Game.match_found: navigate to GameScreen
|
|
## 5. Cancel: matchmaking.leave → back to MainScreen
|
|
|
|
@onready var status_label : Label = %StatusLabel
|
|
@onready var sub_label : Label = %SubLabel
|
|
@onready var cancel_btn : Button = %CancelBtn
|
|
@onready var deck_panel : Control = %DeckPanel
|
|
@onready var deck_list : VBoxContainer = %DeckList
|
|
@onready var search_panel : Control = %SearchPanel
|
|
@onready var elapsed_label : Label = %ElapsedLabel
|
|
|
|
var _selected_deck_id : String = ""
|
|
var _search_timer : float = 0.0
|
|
var _searching : bool = false
|
|
|
|
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
|
|
|
func _ready() -> void:
|
|
ContentCache.apply_scene_background(self)
|
|
cancel_btn.pressed.connect(_on_cancel)
|
|
Game.match_found.connect(_on_match_found)
|
|
_show_deck_panel()
|
|
_fetch_decks()
|
|
|
|
|
|
func _exit_tree() -> void:
|
|
if Game.match_found.is_connected(_on_match_found):
|
|
Game.match_found.disconnect(_on_match_found)
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
if _searching:
|
|
_search_timer += delta
|
|
var secs := int(_search_timer)
|
|
elapsed_label.text = "Searching… %02d:%02d" % [secs / 60, secs % 60]
|
|
|
|
# ── Deck fetch ────────────────────────────────────────────────────────────────
|
|
|
|
func _fetch_decks() -> void:
|
|
status_label.text = "Loading decks…"
|
|
Network.request("collection.get_decks", {},
|
|
_on_decks_response,
|
|
func(_c: String, _m: String) -> void:
|
|
status_label.text = "Could not load decks."
|
|
sub_label.text = "Check your connection and try again."
|
|
)
|
|
|
|
|
|
func _on_decks_response(_type: String, payload: Variant) -> void:
|
|
var decks : Array = (payload as Dictionary).get("decks", [])
|
|
|
|
if decks.is_empty():
|
|
status_label.text = "No decks found."
|
|
sub_label.text = "Build a deck in the Collection first."
|
|
cancel_btn.text = "Back"
|
|
return
|
|
|
|
for c in deck_list.get_children():
|
|
c.queue_free()
|
|
|
|
if decks.size() == 1:
|
|
_selected_deck_id = str(decks[0].get("id", ""))
|
|
_join_queue()
|
|
return
|
|
|
|
# Show deck picker.
|
|
status_label.text = "Choose a deck"
|
|
sub_label.text = ""
|
|
for deck: Dictionary in decks:
|
|
var btn := DECK_BTN.instantiate()
|
|
btn.picked.connect(func(id: String) -> void:
|
|
_selected_deck_id = id
|
|
_join_queue())
|
|
deck_list.add_child(btn)
|
|
btn.setup(
|
|
str(deck.get("id", "")),
|
|
str(deck.get("name", "Unnamed")),
|
|
int(deck.get("cardCount", 0))
|
|
)
|
|
|
|
# ── Queue actions ─────────────────────────────────────────────────────────────
|
|
|
|
func _join_queue() -> void:
|
|
_show_search_panel()
|
|
status_label.text = "Finding a match…"
|
|
sub_label.text = ""
|
|
_search_timer = 0.0
|
|
_searching = true
|
|
|
|
Network.request("matchmaking.join",
|
|
{ "deckId": _selected_deck_id },
|
|
func(_t: String, _p: Variant) -> void: pass,
|
|
func(_c: String, _m: String) -> void:
|
|
_searching = false
|
|
status_label.text = "Failed to join queue."
|
|
)
|
|
|
|
|
|
func _on_cancel() -> void:
|
|
if _searching:
|
|
Network.request("matchmaking.leave", {},
|
|
func(_t: String, _p: Variant) -> void: pass,
|
|
func(_c: String, _m: String) -> void: pass)
|
|
_searching = false
|
|
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")
|
|
|
|
|
|
func _on_match_found(_sid: String, opponent_name: String, _rank: int) -> void:
|
|
_searching = false
|
|
status_label.text = "Match found!"
|
|
sub_label.text = "Opponent: %s" % opponent_name
|
|
await get_tree().create_timer(0.8).timeout
|
|
get_tree().change_scene_to_file("res://scenes/game/GameScreen.tscn")
|
|
|
|
# ── Panel helpers ─────────────────────────────────────────────────────────────
|
|
|
|
func _show_deck_panel() -> void:
|
|
deck_panel.visible = true
|
|
search_panel.visible = false
|
|
|
|
|
|
func _show_search_panel() -> void:
|
|
deck_panel.visible = false
|
|
search_panel.visible = true
|