mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
feat: display backend ranked profile
This commit is contained in:
@@ -8,6 +8,7 @@ const RECOVERY_POLL_SECONDS := 2.0
|
||||
@onready var playlist_dropdown: OptionButton = %PlaylistDropdown
|
||||
@onready var status_label: Label = %StatusLabel
|
||||
@onready var detail_label: Label = %DetailLabel
|
||||
@onready var ranked_profile_label: Label = %RankedProfileLabel
|
||||
@onready var queue_button: Button = %QueueButton
|
||||
@onready var cancel_button: Button = %CancelButton
|
||||
@onready var accept_button: Button = %AcceptButton
|
||||
@@ -24,9 +25,11 @@ func _ready() -> void:
|
||||
playlist_dropdown.set_item_metadata(0, "casual")
|
||||
playlist_dropdown.add_item("Ranked")
|
||||
playlist_dropdown.set_item_metadata(1, "ranked")
|
||||
playlist_dropdown.item_selected.connect(_on_playlist_selected)
|
||||
ControlPlaneClient.state.changed.connect(_on_state_changed)
|
||||
ControlPlaneClient.request_failed.connect(_on_request_failed)
|
||||
ControlPlaneClient.request_succeeded.connect(_on_request_succeeded)
|
||||
_refresh_ranked_profile()
|
||||
_render(ControlPlaneClient.state.snapshot())
|
||||
|
||||
|
||||
@@ -81,6 +84,20 @@ func _on_decline_pressed() -> void:
|
||||
_on_local_error("Could not decline proposal: %s" % error_string(err))
|
||||
|
||||
|
||||
func _on_playlist_selected(_index: int) -> void:
|
||||
_refresh_ranked_profile()
|
||||
|
||||
|
||||
func _refresh_ranked_profile() -> void:
|
||||
var ranked := String(playlist_dropdown.get_selected_metadata()) == "ranked"
|
||||
ranked_profile_label.visible = ranked
|
||||
if not ranked:
|
||||
return
|
||||
var err := ControlPlaneClient.fetch_ranked_profile()
|
||||
if err != OK and err != ERR_BUSY:
|
||||
ranked_profile_label.text = "Ranked profile unavailable: %s" % error_string(err)
|
||||
|
||||
|
||||
func _on_back_pressed() -> void:
|
||||
if ControlPlaneClient.state.can_cancel():
|
||||
status_label.text = "Cancel the active search before leaving"
|
||||
@@ -93,11 +110,13 @@ func _on_state_changed(snapshot: Dictionary) -> void:
|
||||
|
||||
|
||||
func _on_request_succeeded(_operation: String, _payload: Dictionary) -> void:
|
||||
ranked_profile_label.text = ControlPlaneClient.ranked_profile.display_text()
|
||||
_render(ControlPlaneClient.state.snapshot())
|
||||
|
||||
|
||||
func _on_request_failed(_operation: String, _http_code: int, detail: String) -> void:
|
||||
detail_label.text = detail
|
||||
ranked_profile_label.text = ControlPlaneClient.ranked_profile.display_text()
|
||||
_render(ControlPlaneClient.state.snapshot())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user