diff --git a/Client/origin-client/autoloads/Chat.gd b/Client/origin-client/autoloads/Chat.gd index a8686ec..7470d91 100644 --- a/Client/origin-client/autoloads/Chat.gd +++ b/Client/origin-client/autoloads/Chat.gd @@ -65,6 +65,8 @@ var notifications: Array = [] var _overlay: CanvasLayer = null var _message_poll_timer: Timer = null var _message_poll_in_flight: Dictionary = {} +var _bubble_visible_requested := false +var _bubble_host: Control = null const MESSAGE_POLL_INTERVAL_SEC := 0.2 @@ -86,8 +88,13 @@ func _add_overlay() -> void: return _overlay = scene.instantiate() as CanvasLayer # Chat UI should only be visible for authenticated users. - _overlay.visible = false + if _overlay.has_method("set_overlay_visible"): + _overlay.call("set_overlay_visible", _bubble_visible_requested) + else: + _overlay.visible = _bubble_visible_requested get_tree().get_root().add_child(_overlay) + if _overlay.has_method("set_bubble_host"): + _overlay.call("set_bubble_host", _bubble_host) # ── Auth hooks ──────────────────────────────────────────────────────────────── @@ -104,13 +111,30 @@ func _on_auth_success(_uid: String, _dn: String) -> void: ## Show or hide the chat bubble overlay. Call from scenes that want chat ## (e.g. MainScreen._ready / _exit_tree). func set_bubble_visible(v: bool) -> void: + _bubble_visible_requested = v if is_instance_valid(_overlay): - _overlay.visible = v + if _overlay.has_method("set_overlay_visible"): + _overlay.call("set_overlay_visible", v) + else: + _overlay.visible = v + + +func set_bubble_host(host: Control) -> void: + _bubble_host = host + if is_instance_valid(_overlay) and _overlay.has_method("set_bubble_host"): + _overlay.call("set_bubble_host", host) func _clear_state() -> void: + _bubble_visible_requested = false + _bubble_host = null if is_instance_valid(_overlay): - _overlay.visible = false + if _overlay.has_method("set_overlay_visible"): + _overlay.call("set_overlay_visible", false) + else: + _overlay.visible = false + if _overlay.has_method("set_bubble_host"): + _overlay.call("set_bubble_host", null) _stop_message_polling() channels = [] messages = {} diff --git a/Client/origin-client/autoloads/HighlightConfig.gd b/Client/origin-client/autoloads/HighlightConfig.gd index e1e8bd5..7f0ce23 100644 --- a/Client/origin-client/autoloads/HighlightConfig.gd +++ b/Client/origin-client/autoloads/HighlightConfig.gd @@ -15,6 +15,7 @@ extends Node ## get_color() when get_texture() returns null. signal loaded +signal texture_loaded(type: String) const CACHE_PATH := "user://highlight_config.json" const REQUEST_TYPE := "content.get_highlight_config" @@ -30,6 +31,7 @@ const DEFAULT_HEX : Dictionary = { ## Whether the server config has been loaded (or the cache has been used). var is_ready : bool = false +var _fetch_in_flight : bool = false # ── Internal state ───────────────────────────────────────────────────────────── @@ -50,7 +52,11 @@ var _pending_fetches : Dictionary = {} func _ready() -> void: _load_cache() - _fetch_from_server() + _prefetch_known_textures() + Auth.auth_success.connect(_on_auth_success) + Network.connected.connect(_on_network_connected) + if not Auth.user_id.is_empty(): + _fetch_from_server() # ── Public API ───────────────────────────────────────────────────────────────── @@ -58,6 +64,8 @@ func _ready() -> void: ## Returns the loaded Texture2D for this highlight type, or null if not yet loaded. ## Starts loading the texture on first call if not already in progress. func get_texture(type: String) -> Texture2D: + if not is_ready: + _fetch_from_server() var key := type.to_lower() if _textures.has(key): return _textures[key] @@ -70,6 +78,8 @@ func get_texture(type: String) -> Texture2D: ## Returns the fallback Color for this highlight type. func get_color(type: String) -> Color: + if not is_ready: + _fetch_from_server() var key := type.to_lower() var cfg := _effective_config(key) var hex : String = cfg.get("fallbackHex", DEFAULT_HEX.get(key, "#FFFFFF66")) @@ -118,20 +128,29 @@ func _effective_config(key: String) -> Dictionary: func _fetch_from_server() -> void: + if _fetch_in_flight: + return + if not Network.is_online(): + return + if Auth.user_id.is_empty(): + return + _fetch_in_flight = true Network.request( REQUEST_TYPE, {}, func(_type: String, resp: Variant) -> void: + _fetch_in_flight = false _on_server_response(resp), - func(_code: String, _msg: String) -> void: - # Use cached config if available; set is_ready anyway. - is_ready = true - loaded.emit() + func(code: String, msg: String) -> void: + _fetch_in_flight = false + if code not in ["DISCONNECTED", "AUTH_REQUIRED"]: + push_warning("HighlightConfig: config fetch failed - %s %s" % [code, msg]) ) func _on_server_response(resp: Variant) -> void: var configs : Array = (resp as Dictionary).get("configs", []) + _server_configs.clear() for entry : Dictionary in configs: var key : String = str(entry.get("highlightType", "")).to_lower() if key.is_empty(): @@ -144,34 +163,51 @@ func _on_server_response(resp: Variant) -> void: "fallbackHex": str(entry.get("fallbackHex", DEFAULT_HEX.get(key, "#FFFFFF66"))), } _save_cache() + _prefetch_known_textures() is_ready = true loaded.emit() +func _on_auth_success(_user_id: String, _display_name: String) -> void: + _fetch_from_server() + + +func _on_network_connected() -> void: + if not Auth.user_id.is_empty(): + _fetch_from_server() + + func _start_texture_load(key: String, cfg: Dictionary) -> void: if _pending_fetches.has(key): return - _pending_fetches[key] = true - var url : String = cfg.get("cdnPath", "") + var url := _normalize_url(str(cfg.get("cdnPath", ""))) if url.is_empty(): return + _pending_fetches[key] = true var http := HTTPRequest.new() add_child(http) http.request_completed.connect( - func(result: int, _code: int, _headers: PackedStringArray, body: PackedByteArray) -> void: + func(result: int, code: int, _headers: PackedStringArray, body: PackedByteArray) -> void: http.queue_free() _pending_fetches.erase(key) - if result != HTTPRequest.RESULT_SUCCESS or body.is_empty(): + if result != HTTPRequest.RESULT_SUCCESS or code != 200 or body.is_empty(): + push_warning("HighlightConfig: failed to download %s (result=%d http=%d url=%s)" % [key, result, code, url]) return var img := Image.new() - if img.load_png_from_buffer(body) != OK: - if img.load_webp_from_buffer(body) != OK: - return + var err := _load_image_from_body(img, url, body) + if err != OK: + push_warning("HighlightConfig: failed to decode %s from %s" % [key, url]) + return var tex := ImageTexture.create_from_image(img) _textures[key] = tex + texture_loaded.emit(key) ) - http.request(url) + var err := http.request(url) + if err != OK: + _pending_fetches.erase(key) + http.queue_free() + push_warning("HighlightConfig: request start failed for %s (err=%d url=%s)" % [key, err, url]) func _parse_hex(hex: String) -> Color: @@ -202,8 +238,39 @@ func _load_cache() -> void: func _save_cache() -> void: + DirAccess.make_dir_recursive_absolute("user://") var f := FileAccess.open(CACHE_PATH, FileAccess.WRITE) if f == null: return f.store_string(JSON.stringify(_server_configs)) f.close() + + +func _prefetch_known_textures() -> void: + for key in _server_configs.keys(): + var cfg := _effective_config(str(key)) + if not cfg.is_empty(): + _start_texture_load(str(key), cfg) + for key in _overrides.keys(): + var cfg := _effective_config(str(key)) + if not cfg.is_empty(): + _start_texture_load(str(key), cfg) + + +func _normalize_url(url: String) -> String: + return url.strip_edges().replace(" ", "%20") + + +func _load_image_from_body(img: Image, url: String, body: PackedByteArray) -> Error: + var ext := url.split("?")[0].get_extension().to_lower() + if ext in ["jpg", "jpeg"]: + return img.load_jpg_from_buffer(body) + if ext == "webp": + return img.load_webp_from_buffer(body) + var png_err := img.load_png_from_buffer(body) + if png_err == OK: + return OK + var webp_err := img.load_webp_from_buffer(body) + if webp_err == OK: + return OK + return img.load_jpg_from_buffer(body) diff --git a/Client/origin-client/autoloads/Music.gd b/Client/origin-client/autoloads/Music.gd index bd0e273..c4cd14d 100644 --- a/Client/origin-client/autoloads/Music.gd +++ b/Client/origin-client/autoloads/Music.gd @@ -1,153 +1,295 @@ extends Node -## Music autoload — fetches BGM config from the server and plays context-appropriate tracks. +## Music autoload - fetches BGM config from the server and plays context-appropriate tracks. ## -## Usage: -## Music.play_context("Game") # start/crossfade to the Game context track -## Music.play_context("Lobby") # switch to Lobby context -## Music.stop() # fade out and stop +## Scene routing: +## - GameScreen -> Game +## - FreePlay / LobbyRoom -> Lobby +## - Everything else -> Menu ## ## Volume and mute are controlled via Settings.music_volume / Settings.music_muted. -## This node streams audio via an AudioStreamPlayer on the "Music" bus. +## This node streams audio via AudioStreamPlayers on the "Music" bus. -const CROSSFADE_DURATION := 1.2 # seconds -const CONTEXT_AUDIO_MSG := "content.get_audio_config" +const CROSSFADE_DURATION := 1.2 +const CONTEXT_AUDIO_MSG := "content.get_audio_config" -## _tracks[context] = Array of { "name": String, "url": String } -var _tracks : Dictionary = {} -var _current_context: String = "" -var _player_a : AudioStreamPlayer -var _player_b : AudioStreamPlayer -var _active_player : AudioStreamPlayer # the one currently audible +const CONTEXT_MENU := "Menu" +const CONTEXT_LOBBY := "Lobby" +const CONTEXT_GAME := "Game" + +const LOBBY_SCENES := { + "res://scenes/free_play/FreePlayScreen.tscn": true, + "res://scenes/free_play/LobbyRoomScreen.tscn": true, +} + +const GAME_SCENES := { + "res://scenes/game/GameScreen.tscn": true, +} + +var _tracks: Dictionary = {} +var _stream_cache: Dictionary = {} +var _current_context: String = "" +var _current_url: String = "" +var _desired_context: String = "" +var _last_scene_path: String = "" +var _config_loaded: bool = false +var _request_serial: int = 0 + +var _player_a: AudioStreamPlayer +var _player_b: AudioStreamPlayer +var _active_player: AudioStreamPlayer +var _fade_tween: Tween = null -# ── Lifecycle ───────────────────────────────────────────────────────────────── func _ready() -> void: _player_a = _make_player() _player_b = _make_player() _active_player = _player_a - # Fetch BGM config once at startup (connection must be established by then). - # Scenes that start music will typically call play_context after login. + Auth.auth_success.connect(_on_auth_success) + Auth.session_expired.connect(_on_session_expired) + Settings.settings_changed.connect(_sync_player_volumes) + + set_process(true) + + +func _process(_delta: float) -> void: + var scene := get_tree().current_scene + if scene == null: + return + + var scene_path := scene.scene_file_path + if scene_path == _last_scene_path: + return + + _last_scene_path = scene_path + var next_context := _context_for_scene(scene_path) + if next_context.is_empty(): + stop() + else: + play_context(next_context) + func _make_player() -> AudioStreamPlayer: - var p := AudioStreamPlayer.new() - p.bus = Settings.BUS_MUSIC - p.volume_db = linear_to_db(Settings.music_volume) if not Settings.music_muted else -80.0 - add_child(p) - return p + var player := AudioStreamPlayer.new() + player.bus = Settings.BUS_MUSIC + player.volume_db = _target_volume_db() + add_child(player) + return player -# ── Public API ───────────────────────────────────────────────────────────────── -## Fetch the BGM track list from the server. -## Call this once after the player is authenticated and connected. func fetch_config() -> void: Network.request(CONTEXT_AUDIO_MSG, {}, func(_type: String, resp: Variant) -> void: - var d := resp as Dictionary - if not d.has("tracks"): - return + var data := resp as Dictionary _tracks.clear() - for t: Dictionary in d.get("tracks", []): - var ctx : String = str(t.get("context", "")) - if ctx.is_empty(): + for entry: Dictionary in data.get("tracks", []): + var context := str(entry.get("context", "")).strip_edges() + var url := str(entry.get("trackCdnUrl", "")).strip_edges() + if context.is_empty() or url.is_empty(): continue - if not _tracks.has(ctx): - _tracks[ctx] = [] - _tracks[ctx].append({ - "name": str(t.get("trackName", "")), - "url": str(t.get("trackCdnUrl", "")), - }), + if not _tracks.has(context): + _tracks[context] = [] + _tracks[context].append({ + "name": str(entry.get("trackName", "")), + "url": url, + }) + + _config_loaded = true + _apply_desired_context(), func(code: String, msg: String) -> void: - push_warning("Music: fetch_config failed — %s: %s" % [code, msg])) + _config_loaded = false + push_warning("Music: fetch_config failed - %s: %s" % [code, msg])) -## Start playing a track for the given context. -## Crossfades from the currently playing track. No-ops if already on this context. -func play_context(ctx: String) -> void: - if ctx == _current_context: + +func play_context(context: String) -> void: + _desired_context = context + _apply_desired_context() + + +func stop() -> void: + _desired_context = "" + _current_context = "" + _current_url = "" + _request_serial += 1 + _stop_inactive_player() + _fade_out(_active_player) + + +func _apply_desired_context() -> void: + if _desired_context.is_empty(): + return + if not _config_loaded: + return + if _desired_context == _current_context and not _current_url.is_empty() and _active_player.playing: + _sync_player_volumes() return - _current_context = ctx - var list : Array = _tracks.get(ctx, []) - if list.is_empty(): + var options: Array = _tracks.get(_desired_context, []) + if options.is_empty(): stop() return - var entry : Dictionary = list[randi() % list.size()] - var url : String = str(entry.get("url", "")) + var entry: Dictionary = options[randi() % options.size()] + var url := str(entry.get("url", "")) if url.is_empty(): + stop() + return + if url == _current_url and _active_player.playing: + _current_context = _desired_context + _sync_player_volumes() return - _crossfade_to(url) + _request_serial += 1 + var serial := _request_serial + _crossfade_to(url, _desired_context, serial) -## Stop music with a short fade-out. -func stop() -> void: - _current_context = "" - _fade_out(_active_player) -# ── Internal ────────────────────────────────────────────────────────────────── - -func _crossfade_to(url: String) -> void: - var next : AudioStreamPlayer = _player_b if _active_player == _player_a else _player_a - - # Load stream from URL (Godot's ResourceLoader supports http URLs if configured, - # otherwise fall back to local path for bundled tracks). +func _crossfade_to(url: String, context: String, serial: int) -> void: + var next: AudioStreamPlayer = _player_b if _active_player == _player_a else _player_a var stream := await _load_stream(url) + if serial != _request_serial: + return if stream == null: return - next.stream = stream + if _fade_tween != null: + _fade_tween.kill() + _fade_tween = null + + next.stream = stream next.volume_db = -80.0 next.play() - var tween := create_tween().set_parallel(true) - tween.tween_property(next, "volume_db", - linear_to_db(Settings.music_volume) if not Settings.music_muted else -80.0, - CROSSFADE_DURATION) - tween.tween_property(_active_player, "volume_db", -80.0, CROSSFADE_DURATION) - await tween.finished + _fade_tween = create_tween().set_parallel(true) + _fade_tween.tween_property(next, "volume_db", _target_volume_db(), CROSSFADE_DURATION) + _fade_tween.tween_property(_active_player, "volume_db", -80.0, CROSSFADE_DURATION) + await _fade_tween.finished + + if serial != _request_serial: + return _active_player.stop() _active_player = next + _current_context = context + _current_url = url + _fade_tween = null + _stop_inactive_player() + _sync_player_volumes() + func _fade_out(player: AudioStreamPlayer) -> void: - if not player.playing: + if player == null or not player.playing: return - var tween := create_tween() - tween.tween_property(player, "volume_db", -80.0, CROSSFADE_DURATION) - await tween.finished - player.stop() + + if _fade_tween != null: + _fade_tween.kill() + _fade_tween = null + + _fade_tween = create_tween() + _fade_tween.tween_property(player, "volume_db", -80.0, CROSSFADE_DURATION) + await _fade_tween.finished + if player == _active_player and _request_serial >= 0: + player.stop() + player.stream = null + _fade_tween = null + + +func _stop_inactive_player() -> void: + var inactive: AudioStreamPlayer = _player_b if _active_player == _player_a else _player_a + inactive.stop() + inactive.stream = null + inactive.volume_db = -80.0 + + +func _sync_player_volumes() -> void: + var target_db := _target_volume_db() + if _fade_tween != null: + if _active_player.playing: + _active_player.volume_db = target_db + return + + if _active_player.playing: + _active_player.volume_db = target_db + var inactive: AudioStreamPlayer = _player_b if _active_player == _player_a else _player_a + if not inactive.playing: + inactive.volume_db = -80.0 + + +func _target_volume_db() -> float: + if Settings.music_muted or Settings.music_volume <= 0.0: + return -80.0 + return linear_to_db(Settings.music_volume) + + +func _context_for_scene(scene_path: String) -> String: + if scene_path.is_empty(): + return "" + if GAME_SCENES.has(scene_path): + return CONTEXT_GAME + if LOBBY_SCENES.has(scene_path): + return CONTEXT_LOBBY + return CONTEXT_MENU + + +func _on_auth_success(_user_id: String, _display_name: String) -> void: + fetch_config() + + +func _on_session_expired() -> void: + _tracks.clear() + _stream_cache.clear() + _config_loaded = false + _last_scene_path = "" + stop() + func _load_stream(url: String) -> AudioStream: - # If it looks like a local resource path, load directly. - if url.begins_with("res://") or url.begins_with("user://"): - return load(url) as AudioStream + if _stream_cache.has(url): + return _stream_cache[url] as AudioStream - # For CDN URLs: use HTTPRequest to download and create stream from bytes. - # This is an async download approach compatible with Godot 4. + var stream: AudioStream = null + if url.begins_with("res://") or url.begins_with("user://"): + stream = load(url) as AudioStream + else: + stream = await _load_remote_stream(url) + + if stream != null: + _stream_cache[url] = stream + return stream + + +func _load_remote_stream(url: String) -> AudioStream: + var request_url := _normalize_remote_url(url) var http := HTTPRequest.new() add_child(http) - http.request(url) - var result : Array = await http.request_completed + var err := http.request(request_url) + if err != OK: + http.queue_free() + push_warning("Music: request failed for %s (err %d)" % [request_url, err]) + return null + + var result: Array = await http.request_completed http.queue_free() - var response_code : int = result[1] - var body : PackedByteArray = result[3] + var response_code: int = int(result[1]) + var body: PackedByteArray = result[3] if response_code != 200 or body.is_empty(): push_warning("Music: failed to download %s (HTTP %d)" % [url, response_code]) return null - # Determine format from URL extension and create appropriate stream. var ext := url.get_extension().to_lower() if ext == "ogg": return AudioStreamOggVorbis.load_from_buffer(body) - elif ext in ["mp3"]: - var stream := AudioStreamMP3.new() - stream.data = body - return stream - elif ext == "wav": - # WAV loading from bytes is not directly supported; warn and return null. - push_warning("Music: WAV from URL not supported. Use OGG or MP3.") - return null + if ext == "mp3": + var mp3 := AudioStreamMP3.new() + mp3.data = body + return mp3 + if ext == "wav": + return AudioStreamWAV.load_from_buffer(body) - push_warning("Music: unknown audio format '%s'" % ext) + push_warning("Music: unsupported format '%s'" % ext) return null + + +func _normalize_remote_url(url: String) -> String: + return url.replace(" ", "%20") diff --git a/Client/origin-client/autoloads/SFX.gd b/Client/origin-client/autoloads/SFX.gd index 82ba290..32ca8ca 100644 --- a/Client/origin-client/autoloads/SFX.gd +++ b/Client/origin-client/autoloads/SFX.gd @@ -1,73 +1,92 @@ extends Node -## SFX autoload — fire-and-forget sound effects from CDN URLs. +## SFX autoload - fire-and-forget sound effects from local assets or CDN URLs. ## ## Usage: -## SFX.play("https://cdn.sor.gg/sfx/attack.ogg") # fire-and-forget +## SFX.play("https://cdn.example.com/sfx/attack.wav") ## ## Volume and mute are applied globally through the "SFX" AudioServer bus ## (managed by Settings.sfx_volume / Settings.sfx_muted). ## Downloaded streams are cached in memory for the session so each URL ## only hits the network once. -const POOL_SIZE := 8 # max simultaneous SFX +const POOL_SIZE := 8 -var _pool : Array[AudioStreamPlayer] = [] -var _cache : Dictionary = {} # url → AudioStream +var _pool: Array[AudioStreamPlayer] = [] +var _cache: Dictionary = {} +var _in_flight: Dictionary = {} -# ── Lifecycle ───────────────────────────────────────────────────────────────── func _ready() -> void: for _i in POOL_SIZE: - var p := AudioStreamPlayer.new() - p.bus = Settings.BUS_SFX - add_child(p) - _pool.append(p) + var player := AudioStreamPlayer.new() + player.bus = Settings.BUS_SFX + add_child(player) + _pool.append(player) -# ── Public API ──────────────────────────────────────────────────────────────── -## Play [param url] asynchronously (fire-and-forget). -## No-ops if url is empty or the download fails. func play(url: String) -> void: - if url.is_empty(): + url = url.strip_edges() + if not _is_supported_url(url): return _play_async(url) -# ── Internal ────────────────────────────────────────────────────────────────── + +func prime(url: String) -> void: + url = url.strip_edges() + if not _is_supported_url(url): + return + if _cache.has(url) or _in_flight.has(url): + return + _prime_async(url) + func _play_async(url: String) -> void: - var stream : AudioStream = _cache.get(url, null) + var stream: AudioStream = _cache.get(url, null) if stream == null: - stream = await _load_stream(url) + if _in_flight.has(url): + await _in_flight[url] + stream = _cache.get(url, null) + else: + stream = await _load_and_cache(url) if stream == null: return - _cache[url] = stream var player := _get_free_player() player.stream = stream player.play() +func _prime_async(url: String) -> void: + await _load_and_cache(url) + + func _get_free_player() -> AudioStreamPlayer: - for p : AudioStreamPlayer in _pool: - if not p.playing: - return p - # All slots busy — steal the oldest (index 0, round-robin would be nicer - # but overkill for 8-slot game SFX). + for player: AudioStreamPlayer in _pool: + if not player.playing: + return player return _pool[0] func _load_stream(url: String) -> AudioStream: if url.begins_with("res://") or url.begins_with("user://"): return load(url) as AudioStream + if not (url.begins_with("http://") or url.begins_with("https://")): + return null + var request_url := _normalize_remote_url(url) var http := HTTPRequest.new() add_child(http) - http.request(url) - var result : Array = await http.request_completed + var err := http.request(request_url) + if err != OK: + http.queue_free() + push_warning("SFX: request failed for %s (err %d)" % [request_url, err]) + return null + + var result: Array = await http.request_completed http.queue_free() - var response_code : int = result[1] - var body : PackedByteArray = result[3] + var response_code: int = int(result[1]) + var body: PackedByteArray = result[3] if response_code != 200 or body.is_empty(): push_warning("SFX: failed to download %s (HTTP %d)" % [url, response_code]) return null @@ -75,10 +94,39 @@ func _load_stream(url: String) -> AudioStream: var ext := url.get_extension().to_lower() if ext == "ogg": return AudioStreamOggVorbis.load_from_buffer(body) - elif ext == "mp3": - var s := AudioStreamMP3.new() - s.data = body - return s + if ext == "mp3": + var mp3 := AudioStreamMP3.new() + mp3.data = body + return mp3 + if ext == "wav": + return AudioStreamWAV.load_from_buffer(body) - push_warning("SFX: unsupported format '%s' — use OGG or MP3." % ext) + push_warning("SFX: unsupported format '%s' - use OGG, MP3, or WAV." % ext) return null + + +func _normalize_remote_url(url: String) -> String: + return url.replace(" ", "%20") + + +func _is_supported_url(url: String) -> bool: + if url.is_empty() or url == "null": + return false + return url.begins_with("http://") or url.begins_with("https://") \ + or url.begins_with("res://") or url.begins_with("user://") + + +func _load_and_cache(url: String) -> AudioStream: + if _cache.has(url): + return _cache[url] as AudioStream + if _in_flight.has(url): + while _in_flight.has(url): + await get_tree().process_frame + return _cache.get(url, null) as AudioStream + + _in_flight[url] = true + var stream := await _load_stream(url) + _in_flight.erase(url) + if stream != null: + _cache[url] = stream + return stream diff --git a/Client/origin-client/scenes/chat/chat_overlay.gd b/Client/origin-client/scenes/chat/chat_overlay.gd index cf30f9e..89cb441 100644 --- a/Client/origin-client/scenes/chat/chat_overlay.gd +++ b/Client/origin-client/scenes/chat/chat_overlay.gd @@ -72,6 +72,11 @@ var _current_tab : Tab = Tab.GLOBAL var _active_channel : String = "" # channel_id used by the input bar var _active_dm : String = "" # channel_id of the open DM conversation +const _BUBBLE_DEFAULT_LEFT := -58.0 +const _BUBBLE_DEFAULT_TOP := -219.0 +const _BUBBLE_DEFAULT_RIGHT := 2.0 +const _BUBBLE_DEFAULT_BOTTOM := -159.0 + var _nicknames : Dictionary = {} # account_id → custom display name var _muted : Dictionary = {} # account_id → true @@ -109,6 +114,45 @@ func _ready() -> void: _show_tab(Tab.GLOBAL) +func set_overlay_visible(v: bool) -> void: + visible = v + var bubble := get_node_or_null("ChatBubble") as Control + if is_instance_valid(bubble): + bubble.visible = v + if not v: + var panel := get_node_or_null("ChatPanel") as Control + if is_instance_valid(panel): + panel.visible = false + + +func set_bubble_host(host: Control) -> void: + var bubble := get_node_or_null("ChatBubble") as Control + if not is_instance_valid(bubble): + return + + var target: Node = self + if is_instance_valid(host): + target = host + + if bubble.get_parent() != target: + bubble.reparent(target) + + if target == self: + bubble.set_anchors_preset(Control.PRESET_BOTTOM_RIGHT) + bubble.offset_left = _BUBBLE_DEFAULT_LEFT + bubble.offset_top = _BUBBLE_DEFAULT_TOP + bubble.offset_right = _BUBBLE_DEFAULT_RIGHT + bubble.offset_bottom = _BUBBLE_DEFAULT_BOTTOM + bubble.custom_minimum_size = Vector2.ZERO + else: + bubble.set_anchors_preset(Control.PRESET_FULL_RECT) + bubble.offset_left = 0.0 + bubble.offset_top = 0.0 + bubble.offset_right = 0.0 + bubble.offset_bottom = 0.0 + bubble.custom_minimum_size = Vector2(0, 36) + + func _connect_chat_signals() -> void: Chat.channels_updated.connect(_on_channels_updated) Chat.message_received.connect(_on_message_received) diff --git a/Client/origin-client/scenes/game/GameScreen.tscn b/Client/origin-client/scenes/game/GameScreen.tscn index 0eb01e8..fcd2bb1 100644 --- a/Client/origin-client/scenes/game/GameScreen.tscn +++ b/Client/origin-client/scenes/game/GameScreen.tscn @@ -1,14 +1,34 @@ -[gd_scene load_steps=7 format=3 uid="uid://b17evi1hw4dqu"] +[gd_scene load_steps=18 format=3 uid="uid://b17evi1hw4dqu"] [ext_resource type="Script" uid="uid://b8x84lb58h6gx" path="res://scenes/game/game_screen.gd" id="1_gscr"] [ext_resource type="Texture2D" uid="uid://dvmripj4jux0b" path="res://icons/SP-Symbol-White.png" id="2_056su"] [ext_resource type="PackedScene" path="res://scenes/game/InGameSettings.tscn" id="2_igs"] [ext_resource type="Texture2D" uid="uid://csvmdo2kwnh7c" path="res://icons/ST-Symbol-White.png" id="3_wukpb"] +[ext_resource type="Texture2D" uid="uid://beyeu0y34m3v4" path="res://ui/icons/Deck Icon.png" id="4_ld7sk"] +[ext_resource type="Texture2D" uid="uid://c65s8sn4p7s37" path="res://ui/icons/Discard Icon.png" id="5_pryjh"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_wukpb"] [sub_resource type="Theme" id="Theme_056su"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ld7sk"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_xjmfi"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_pryjh"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_pnc6c"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_2dkum"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_7me7j"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_msfbn"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ld7sk"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8asym"] + [node name="GameScreen" type="Node3D"] script = ExtResource("1_gscr") @@ -133,6 +153,8 @@ offset_left = -18.987999 offset_top = -22.968002 offset_right = 19.012001 offset_bottom = 23.031998 +tooltip_text = "Spirit Points" +mouse_filter = 1 theme_override_colors/font_color = Color(0.012617188, 0.012617188, 0.012617188, 1) theme_override_font_sizes/font_size = 33 text = "88" @@ -161,24 +183,184 @@ offset_left = -20.0 offset_top = -20.472002 offset_right = 22.0 offset_bottom = 25.527998 +tooltip_text = "Sacrifice Tokens" +mouse_filter = 1 theme_override_colors/font_color = Color(0.06469653, 0.06469653, 0.06469653, 1) theme_override_font_sizes/font_size = 33 text = "88" horizontal_alignment = 1 vertical_alignment = 1 +[node name="ActionRail" type="PanelContainer" parent="HUD"] +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -276.0 +offset_top = -241.0 +offset_right = -84.0 +offset_bottom = -77.0 +theme_override_styles/panel = SubResource("StyleBoxFlat_ld7sk") + +[node name="RailMargin" type="MarginContainer" parent="HUD/ActionRail"] +layout_mode = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 8 + +[node name="RailHBox" type="HBoxContainer" parent="HUD/ActionRail/RailMargin"] +layout_mode = 2 +theme_override_constants/separation = 12 + +[node name="Deck-Discard Panel Container" type="Control" parent="HUD/ActionRail/RailMargin/RailHBox"] +custom_minimum_size = Vector2(76, 0) +layout_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="HUD/ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +alignment = 2 + +[node name="TextureRect" type="TextureRect" parent="HUD/ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer"] +self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216) +texture_filter = 5 +custom_minimum_size = Vector2(1.78, 76) +layout_mode = 2 +theme = SubResource("Theme_056su") +texture = ExtResource("4_ld7sk") +expand_mode = 1 + +[node name="DeckLabel" type="Label" parent="HUD/ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer/TextureRect"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.507 +anchor_top = 0.40789473 +anchor_right = 0.507 +anchor_bottom = 0.40789473 +offset_left = -22.532001 +offset_top = -36.0 +offset_right = 22.467999 +offset_bottom = 10.0 +grow_horizontal = 2 +grow_vertical = 2 +tooltip_text = "Cards in Deck" +mouse_filter = 1 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 33 +text = "88" +horizontal_alignment = 1 +vertical_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="TextureRect2" type="TextureRect" parent="HUD/ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer"] +self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216) +texture_filter = 5 +custom_minimum_size = Vector2(1.78, 76) +layout_mode = 2 +theme = SubResource("Theme_056su") +expand_mode = 1 + +[node name="DiscardBtn" type="Button" parent="HUD/ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer/TextureRect2"] +unique_name_in_owner = true +layout_mode = 0 +offset_left = -4.000001 +offset_top = -5.000001 +offset_right = 568.0 +offset_bottom = 275.0 +scale = Vector2(0.14754085, 0.23068035) +tooltip_text = "View Discard" +theme_override_colors/icon_normal_color = Color(0.18431373, 0.49411765, 0.47843137, 1) +theme_override_colors/icon_focus_color = Color(0.18431373, 0.49411765, 0.47843137, 1) +theme_override_colors/icon_pressed_color = Color(0.35976923, 0.7944459, 0.77106035, 1) +theme_override_colors/icon_hover_color = Color(0.18431373, 0.49411765, 0.47843137, 1) +theme_override_colors/icon_hover_pressed_color = Color(0.18431373, 0.49411765, 0.47843137, 1) +theme_override_font_sizes/font_size = 12 +theme_override_icons/icon = ExtResource("5_pryjh") +theme_override_styles/normal = SubResource("StyleBoxEmpty_xjmfi") +theme_override_styles/pressed = SubResource("StyleBoxEmpty_pryjh") +theme_override_styles/hover = SubResource("StyleBoxEmpty_pnc6c") +theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_2dkum") +theme_override_styles/disabled = SubResource("StyleBoxEmpty_7me7j") +theme_override_styles/focus = SubResource("StyleBoxEmpty_msfbn") + +[node name="DiscardLabel" type="Label" parent="HUD/ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer/TextureRect2"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.5 +anchor_top = 0.32200003 +anchor_right = 0.5 +anchor_bottom = 0.32200003 +offset_left = -20.0 +offset_top = -31.472002 +offset_right = 22.0 +offset_bottom = 14.527998 +theme_override_colors/font_color = Color(0.06469653, 0.06469653, 0.06469653, 1) +theme_override_font_sizes/font_size = 33 +text = "88" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Controls" type="Control" parent="HUD/ActionRail/RailMargin/RailHBox"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="RightVBox" type="VBoxContainer" parent="HUD/ActionRail/RailMargin/RailHBox/Controls"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/separation = 6 + +[node name="EndTurnBtn" type="Button" parent="HUD/ActionRail/RailMargin/RailHBox/Controls/RightVBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 36) +layout_mode = 2 +theme_override_font_sizes/font_size = 13 +text = "End Turn" + +[node name="DrawBtn" type="Button" parent="HUD/ActionRail/RailMargin/RailHBox/Controls/RightVBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 36) +layout_mode = 2 +theme_override_font_sizes/font_size = 13 +text = "Draw Card" + +[node name="SettingsBtn" type="Button" parent="HUD/ActionRail/RailMargin/RailHBox/Controls/RightVBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 36) +layout_mode = 2 +theme_override_font_sizes/font_size = 12 +text = "Settings" + +[node name="ChatBubbleHost" type="Control" parent="HUD/ActionRail/RailMargin/RailHBox/Controls/RightVBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 36) +layout_mode = 2 + [node name="HandArea" type="PanelContainer" parent="HUD"] anchors_preset = -1 anchor_top = 1.0 anchor_right = 0.75 anchor_bottom = 1.0 offset_top = -250.0 +theme_override_styles/panel = SubResource("StyleBoxEmpty_ld7sk") [node name="HandScroll" type="ScrollContainer" parent="HUD/HandArea"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 +theme_override_styles/panel = SubResource("StyleBoxEmpty_8asym") vertical_scroll_mode = 0 [node name="HandCards" type="HBoxContainer" parent="HUD/HandArea/HandScroll"] @@ -188,6 +370,7 @@ size_flags_vertical = 4 theme_override_constants/separation = 6 [node name="RightPanel" type="PanelContainer" parent="HUD"] +visible = false anchors_preset = -1 anchor_left = 0.75 anchor_top = 1.0 @@ -199,49 +382,6 @@ offset_right = -1.0 offset_bottom = 9.0 scale = Vector2(1, 0.96000004) -[node name="RightMargin" type="MarginContainer" parent="HUD/RightPanel"] -layout_mode = 2 -theme_override_constants/margin_left = 10 -theme_override_constants/margin_top = 8 -theme_override_constants/margin_right = 10 -theme_override_constants/margin_bottom = 8 - -[node name="RightVBox" type="VBoxContainer" parent="HUD/RightPanel/RightMargin"] -layout_mode = 2 -theme_override_constants/separation = 6 - -[node name="DeckLabel" type="Label" parent="HUD/RightPanel/RightMargin/RightVBox"] -unique_name_in_owner = true -layout_mode = 2 -theme_override_font_sizes/font_size = 12 -text = "Deck: 0" - -[node name="DiscardBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"] -unique_name_in_owner = true -layout_mode = 2 -theme_override_font_sizes/font_size = 12 -text = "View Discard" - -[node name="DrawBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 36) -layout_mode = 2 -theme_override_font_sizes/font_size = 13 -text = "Draw Card" - -[node name="EndTurnBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 36) -layout_mode = 2 -theme_override_font_sizes/font_size = 13 -text = "End Turn" - -[node name="SettingsBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"] -unique_name_in_owner = true -layout_mode = 2 -theme_override_font_sizes/font_size = 12 -text = "Settings" - [node name="TileDrawerToggleBtn" type="Button" parent="HUD"] unique_name_in_owner = true custom_minimum_size = Vector2(36, 48) diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index da7d0cd..906f5c3 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -50,9 +50,11 @@ enum Mode { @onready var _st_lbl : Label = %StLabel @onready var _deck_lbl : Label = %DeckLabel @onready var _discard_btn : Button = %DiscardBtn +@onready var _discard_lbl : Label = %DiscardLabel @onready var _draw_btn : Button = %DrawBtn @onready var _end_turn_btn : Button = %EndTurnBtn @onready var _settings_btn : Button = %SettingsBtn +@onready var _chat_bubble_host : Control = %ChatBubbleHost @onready var _tile_drawer_toggle_btn : Button = %TileDrawerToggleBtn @onready var _in_game_settings: PanelContainer = %InGameSettings @onready var _ctx_popup : PanelContainer = %ContextPopup @@ -105,7 +107,6 @@ const AFFINITY_COLORS : Dictionary = { } const _CARD_WIDGET_SCENE := preload("res://scenes/collection/components/CardWidget.tscn") -const _CHAT_OVERLAY_SCENE := preload("res://scenes/chat/ChatOverlay.tscn") const HI_GREEN := Color(0.20, 0.90, 0.20, 0.40) const HI_RED := Color(1.00, 0.25, 0.25, 0.50) @@ -270,6 +271,14 @@ var _hovered_coord : Vector2i = Vector2i(-1, -1) ## The MeshInstance3D of the unit currently receiving a hover-glow override. var _hovered_unit_mesh : MeshInstance3D = null +const UNIT_SFX_KEYS := [ + "moveSoundUrl", + "attackSoundUrl", + "damagedSoundUrl", + "deathSoundUrl", + "blockedSoundUrl", +] + ## Animation name aliases: maps the canonical lower-case action to fallback track names. ## The AnimationPlayer track list is matched case-insensitively against each entry. const ANIM_ALIASES : Dictionary = { @@ -306,10 +315,11 @@ func _ready() -> void: Settings.settings_changed.connect(_sync_cam_ctrl_panel) _create_tile_drawer() Game.triggered_target_request.connect(_on_triggered_target_request) + HighlightConfig.texture_loaded.connect(_on_highlight_texture_loaded) # Chat overlay — add to viewport root so it renders above everything. - var _chat_overlay := _CHAT_OVERLAY_SCENE.instantiate() - get_tree().get_root().add_child(_chat_overlay) + Chat.set_bubble_visible(true) + Chat.set_bubble_host(_chat_bubble_host) Game.state_updated.connect(_on_state_updated) Game.game_over.connect(_on_game_over) @@ -372,11 +382,8 @@ func _exit_tree() -> void: func(_t: String, _r: Variant) -> void: pass, func(_c: String, _m: String) -> void: pass) _clear_stars() - # Remove chat overlay added to the viewport root. - var root := get_tree().get_root() - for child in root.get_children(): - if child.name == "ChatOverlay": - child.queue_free() + Chat.set_bubble_host(null) + Chat.set_bubble_visible(false) func _setup_spectator_ui() -> void: @@ -1615,6 +1622,7 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) if def_id.is_empty(): return var def := ContentCache.get_definition(def_id) + _prime_unit_sfx(def) var model_asset := _find_model3d_asset(def) var model_url := str(model_asset.get("cdnUrl", "")) var model_etag := str(model_asset.get("contentETag", "")) @@ -1969,6 +1977,15 @@ func _sfx_for_unit(iid: String, sfx_key: String) -> String: return str(def.get(sfx_key, "")) +func _prime_unit_sfx(def: Dictionary) -> void: + if def.is_empty(): + return + for sfx_key: String in UNIT_SFX_KEYS: + var url := str(def.get(sfx_key, "")).strip_edges() + if not url.is_empty(): + SFX.prime(url) + + ## Returns true if the AnimationPlayer's current track is an "attack" animation. func _is_attack_track(full_name: String) -> bool: var s := full_name.get_slice("/", full_name.get_slice_count("/") - 1) @@ -2508,6 +2525,27 @@ func _place_highlight_quad(quad: MeshInstance3D, x: int, y: int, col: Color, tex mat.albedo_texture = texture quad.visible = true + +func _on_highlight_texture_loaded(_type: String) -> void: + match _mode: + Mode.UNIT_SELECTED: + if not _sel_unit_id.is_empty(): + _select_unit(_sel_unit_id) + Mode.CARD_FROM_HAND, Mode.TERRAMORPHA_SELECT: + var sel_card := _find_hand_card(_sel_card_id) + if not sel_card.is_empty(): + _clear_highlights() + _highlight_tiles(_valid_play_tiles(sel_card), "movement") + Mode.PLACEMENT: + _clear_highlights() + _highlight_tiles(_valid_placement_tiles(), "movement") + _: + pass + + if _hovered_coord.x >= 0: + _hovered_coord = Vector2i(-1, -1) + _update_hover(get_viewport().get_mouse_position()) + # ── Valid target computation ────────────────────────────────────────────────── func _valid_play_tiles(card: Dictionary) -> Array: @@ -2895,7 +2933,7 @@ func _tile_drawer_section_title(title: String, expanded: bool) -> String: ## as _create_tile_drawer_section ("root", "header", "content", "title") plus "scroll" ## and a mutable "count" entry used to keep the header label up-to-date. func _create_scrollable_section(parent: VBoxContainer, title: String) -> Dictionary: - var section := VBoxContainer.new() + var section : VBoxContainer = VBoxContainer.new() section.layout_mode = 2 section.add_theme_constant_override("separation", 4) parent.add_child(section) @@ -2916,7 +2954,7 @@ func _create_scrollable_section(parent: VBoxContainer, title: String) -> Diction scroll.visible = false section.add_child(scroll) - var content := VBoxContainer.new() + var content : VBoxContainer = VBoxContainer.new() content.layout_mode = 2 content.size_flags_horizontal = Control.SIZE_EXPAND_FILL content.add_theme_constant_override("separation", 2) @@ -3000,6 +3038,21 @@ func _set_tile_drawer_lines(section: Dictionary, labels: Array, lines: Array, lbl.tooltip_text = "" +## Clears a scrollable effects section and resets its cached header/toggle state so +## the next inspected tile does not inherit a stale count or expanded body. +func _clear_effects_section(section: Dictionary, labels: Array) -> void: + _set_tile_drawer_lines(section, labels, []) + section["count"] = 0 + var header: Button = section.get("header") as Button + if is_instance_valid(header): + header.button_pressed = false + header.text = _tile_drawer_section_title(str(section.get("title", "Active Effects")), false) + var scroll: ScrollContainer = section.get("scroll") as ScrollContainer + if is_instance_valid(scroll): + scroll.visible = false + scroll.scroll_vertical = 0 + + func _find_unit_owner_account_id(unit_id: String) -> String: if unit_id.is_empty(): return "" @@ -3089,10 +3142,10 @@ func _set_tile_drawer_content(tile: Dictionary) -> void: _set_tile_drawer_lines(_tile_drawer_token_section, _tile_drawer_token_labels, []) _set_tile_drawer_lines(_tile_drawer_arch_section, _tile_drawer_arch_labels, []) _set_tile_drawer_lines(_tile_drawer_ruin_section, _tile_drawer_ruin_labels, []) - _set_tile_drawer_lines(_tile_drawer_spirit_effects_section, _tile_drawer_spirit_effects_labels, []) - _set_tile_drawer_lines(_tile_drawer_token_effects_section, _tile_drawer_token_effects_labels, []) - _set_tile_drawer_lines(_tile_drawer_arch_effects_section, _tile_drawer_arch_effects_labels, []) - _set_tile_drawer_lines(_tile_drawer_ruin_effects_section, _tile_drawer_ruin_effects_labels, []) + _clear_effects_section(_tile_drawer_spirit_effects_section, _tile_drawer_spirit_effects_labels) + _clear_effects_section(_tile_drawer_token_effects_section, _tile_drawer_token_effects_labels) + _clear_effects_section(_tile_drawer_arch_effects_section, _tile_drawer_arch_effects_labels) + _clear_effects_section(_tile_drawer_ruin_effects_section, _tile_drawer_ruin_effects_labels) return var coord : Dictionary = tile.get("coord", {}) @@ -3128,7 +3181,7 @@ func _set_tile_drawer_content(tile: Dictionary) -> void: _set_effects_section(occ_id, _tile_drawer_spirit_effects_section, _tile_drawer_spirit_effects_labels) else: _set_tile_drawer_lines(_tile_drawer_spirit_section, _tile_drawer_spirit_labels, []) - _set_tile_drawer_lines(_tile_drawer_spirit_effects_section, _tile_drawer_spirit_effects_labels, []) + _clear_effects_section(_tile_drawer_spirit_effects_section, _tile_drawer_spirit_effects_labels) if not occ_id.is_empty() and occ_id != "null" and occ_type == "SpiritToken": var token_owner_id: String = occ_owner_id if not occ_owner_id.is_empty() else _find_unit_owner_account_id(occ_id) @@ -3139,7 +3192,7 @@ func _set_tile_drawer_content(tile: Dictionary) -> void: _set_effects_section(occ_id, _tile_drawer_token_effects_section, _tile_drawer_token_effects_labels) else: _set_tile_drawer_lines(_tile_drawer_token_section, _tile_drawer_token_labels, []) - _set_tile_drawer_lines(_tile_drawer_token_effects_section, _tile_drawer_token_effects_labels, []) + _clear_effects_section(_tile_drawer_token_effects_section, _tile_drawer_token_effects_labels) if not occ_id.is_empty() and occ_id != "null" and occ_type == "ArchSpirit": var arch_owner_id: String = occ_owner_id if not occ_owner_id.is_empty() else _find_unit_owner_account_id(occ_id) @@ -3150,7 +3203,7 @@ func _set_tile_drawer_content(tile: Dictionary) -> void: _set_effects_section(occ_id, _tile_drawer_arch_effects_section, _tile_drawer_arch_effects_labels) else: _set_tile_drawer_lines(_tile_drawer_arch_section, _tile_drawer_arch_labels, []) - _set_tile_drawer_lines(_tile_drawer_arch_effects_section, _tile_drawer_arch_effects_labels, []) + _clear_effects_section(_tile_drawer_arch_effects_section, _tile_drawer_arch_effects_labels) if ruin_id_value != null and not ruin_id.is_empty() and ruin_id != "null": var ruin_lines : Array = ["Ruin: %s" % ruin_id, "Owner: %s" % Game.get_display_name(ruin_owner_id)] @@ -3159,7 +3212,7 @@ func _set_tile_drawer_content(tile: Dictionary) -> void: _set_effects_section(ruin_id, _tile_drawer_ruin_effects_section, _tile_drawer_ruin_effects_labels) else: _set_tile_drawer_lines(_tile_drawer_ruin_section, _tile_drawer_ruin_labels, []) - _set_tile_drawer_lines(_tile_drawer_ruin_effects_section, _tile_drawer_ruin_effects_labels, []) + _clear_effects_section(_tile_drawer_ruin_effects_section, _tile_drawer_ruin_effects_labels) ## Populates [param section] (a scrollable effects section) with effects targeting @@ -3336,6 +3389,8 @@ func _handle_board_click(mouse_pos: Vector2) -> void: _add_highlight(nx, ny, "movement") Mode.UNIT_SELECTED: + if coord.x >= 0: + _set_tile_drawer_content(Game.get_tile(coord.x, coord.y)) # Occupied tile with no direct unit-mesh hit → redirect to the occupant. if unit_id.is_empty() and coord.x >= 0: var _t2 := Game.get_tile(coord.x, coord.y) @@ -3445,7 +3500,7 @@ func _set_mode(new_mode: Mode) -> void: _mode = new_mode _terra_targets = [] _terra_count = 0 - if new_mode != Mode.NONE: + if new_mode != Mode.NONE and new_mode != Mode.UNIT_SELECTED: _close_tile_drawer() if new_mode == Mode.NONE: _sel_card_id = "" @@ -4455,7 +4510,7 @@ func _update_hud(state: Dictionary) -> void: var is_mine : bool = (not _is_spectating) and Game.is_my_turn() var my : Dictionary = Game.get_my_player() var opp : Dictionary = Game.get_opponent() - + print("[MY]", my) _phase_lbl.text = "Phase: %s" % phase if _is_spectating: var active_id : String = str(state.get("activePlayerAccountId", "")) @@ -4467,7 +4522,12 @@ func _update_hud(state: Dictionary) -> void: _sp_lbl.text = "%d" % int(my.get("currentSp", 0)) _st_lbl.text = "%d" % int(my.get("currentSt", 0)) - _deck_lbl.text = "Deck: %d" % int(my.get("deckCount", 0)) + _deck_lbl.text = "%d" % int(my.get("deckCount", 0)) + var discard = Game.get_my_player().get("discard", []) + var discCount : int = discard.size() + if (discCount <= 0): + discCount = 0 + _discard_lbl.text = "%d" % discCount _opp_name_lbl.text = Game.get_display_name(str(opp.get("accountId", ""))) _opp_hand_lbl.text = "Hand: %d" % int(opp.get("handCount", 0)) diff --git a/Client/origin-client/ui/icons/Deck Icon.png b/Client/origin-client/ui/icons/Deck Icon.png new file mode 100644 index 0000000..08f6839 Binary files /dev/null and b/Client/origin-client/ui/icons/Deck Icon.png differ diff --git a/Client/origin-client/ui/icons/Deck Icon.png.import b/Client/origin-client/ui/icons/Deck Icon.png.import new file mode 100644 index 0000000..c7ea925 --- /dev/null +++ b/Client/origin-client/ui/icons/Deck Icon.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://beyeu0y34m3v4" +path="res://.godot/imported/Deck Icon.png-fd8fa9aaea3a9d41b868698f599a3e2d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icons/Deck Icon.png" +dest_files=["res://.godot/imported/Deck Icon.png-fd8fa9aaea3a9d41b868698f599a3e2d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Client/origin-client/ui/icons/Discard Icon.png b/Client/origin-client/ui/icons/Discard Icon.png new file mode 100644 index 0000000..09ffe57 Binary files /dev/null and b/Client/origin-client/ui/icons/Discard Icon.png differ diff --git a/Client/origin-client/ui/icons/Discard Icon.png.import b/Client/origin-client/ui/icons/Discard Icon.png.import new file mode 100644 index 0000000..bb69222 --- /dev/null +++ b/Client/origin-client/ui/icons/Discard Icon.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c65s8sn4p7s37" +path="res://.godot/imported/Discard Icon.png-276358daed93b73e42f51f0fd3f0b0a3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icons/Discard Icon.png" +dest_files=["res://.godot/imported/Discard Icon.png-276358daed93b73e42f51f0fd3f0b0a3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Client/origin-client/ui/icons/Floating Text Background.png b/Client/origin-client/ui/icons/Floating Text Background.png new file mode 100644 index 0000000..8ef0958 Binary files /dev/null and b/Client/origin-client/ui/icons/Floating Text Background.png differ diff --git a/Client/origin-client/ui/icons/Floating Text Background.png.import b/Client/origin-client/ui/icons/Floating Text Background.png.import new file mode 100644 index 0000000..8762143 --- /dev/null +++ b/Client/origin-client/ui/icons/Floating Text Background.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bcb4f2b31d4qd" +path="res://.godot/imported/Floating Text Background.png-cbab2aeddeba039fec9ddf1debe76855.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icons/Floating Text Background.png" +dest_files=["res://.godot/imported/Floating Text Background.png-cbab2aeddeba039fec9ddf1debe76855.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Click.png b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Click.png new file mode 100644 index 0000000..2d8e87f Binary files /dev/null and b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Click.png differ diff --git a/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Click.png.import b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Click.png.import new file mode 100644 index 0000000..38dd8f1 --- /dev/null +++ b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Click.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://psjb7swm36jx" +path="res://.godot/imported/Green_Gem_Arrow_Button_Click.png-43021ae417de33085030c07fac8ee7e2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icons/Green_Gem_Arrow_Button_Click.png" +dest_files=["res://.godot/imported/Green_Gem_Arrow_Button_Click.png-43021ae417de33085030c07fac8ee7e2.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Hover.png b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Hover.png new file mode 100644 index 0000000..24aeeb0 Binary files /dev/null and b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Hover.png differ diff --git a/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Hover.png.import b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Hover.png.import new file mode 100644 index 0000000..a374a5c --- /dev/null +++ b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Hover.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cqaooikr7dreh" +path="res://.godot/imported/Green_Gem_Arrow_Button_Hover.png-478556098212f07c9dec11668367df01.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icons/Green_Gem_Arrow_Button_Hover.png" +dest_files=["res://.godot/imported/Green_Gem_Arrow_Button_Hover.png-478556098212f07c9dec11668367df01.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Regular.png b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Regular.png new file mode 100644 index 0000000..a35946c Binary files /dev/null and b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Regular.png differ diff --git a/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Regular.png.import b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Regular.png.import new file mode 100644 index 0000000..f3a039a --- /dev/null +++ b/Client/origin-client/ui/icons/Green_Gem_Arrow_Button_Regular.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cmak04unvfmbt" +path="res://.godot/imported/Green_Gem_Arrow_Button_Regular.png-840bc60d57fb09e319105ca86afb8c2f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icons/Green_Gem_Arrow_Button_Regular.png" +dest_files=["res://.godot/imported/Green_Gem_Arrow_Button_Regular.png-840bc60d57fb09e319105ca86afb8c2f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Client/origin-client/ui/icons/Hand Icon.png b/Client/origin-client/ui/icons/Hand Icon.png new file mode 100644 index 0000000..e553ef2 Binary files /dev/null and b/Client/origin-client/ui/icons/Hand Icon.png differ diff --git a/Client/origin-client/ui/icons/Hand Icon.png.import b/Client/origin-client/ui/icons/Hand Icon.png.import new file mode 100644 index 0000000..64e5cbf --- /dev/null +++ b/Client/origin-client/ui/icons/Hand Icon.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bwgtejjr5gwi4" +path="res://.godot/imported/Hand Icon.png-d155e144eba3eb2772b11f262a288b9f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icons/Hand Icon.png" +dest_files=["res://.godot/imported/Hand Icon.png-d155e144eba3eb2772b11f262a288b9f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Client/origin-client/ui/icons/Rounded-9-slice.png b/Client/origin-client/ui/icons/Rounded-9-slice.png new file mode 100644 index 0000000..c421975 Binary files /dev/null and b/Client/origin-client/ui/icons/Rounded-9-slice.png differ diff --git a/Client/origin-client/ui/icons/Rounded-9-slice.png.import b/Client/origin-client/ui/icons/Rounded-9-slice.png.import new file mode 100644 index 0000000..567e138 --- /dev/null +++ b/Client/origin-client/ui/icons/Rounded-9-slice.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dq5rhakstom8c" +path="res://.godot/imported/Rounded-9-slice.png-6f986cf872ff5d8e5aea173530672e81.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icons/Rounded-9-slice.png" +dest_files=["res://.godot/imported/Rounded-9-slice.png-6f986cf872ff5d8e5aea173530672e81.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Client/origin-client/ui/icons/SeekPng.com_white-png_237011.png b/Client/origin-client/ui/icons/SeekPng.com_white-png_237011.png new file mode 100644 index 0000000..36143fd Binary files /dev/null and b/Client/origin-client/ui/icons/SeekPng.com_white-png_237011.png differ diff --git a/Client/origin-client/ui/icons/SeekPng.com_white-png_237011.png.import b/Client/origin-client/ui/icons/SeekPng.com_white-png_237011.png.import new file mode 100644 index 0000000..5858d6b --- /dev/null +++ b/Client/origin-client/ui/icons/SeekPng.com_white-png_237011.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bfgp0yc4d6ftt" +path="res://.godot/imported/SeekPng.com_white-png_237011.png-05a85fc9f04b81f3c0cec091cdf3b5a2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/icons/SeekPng.com_white-png_237011.png" +dest_files=["res://.godot/imported/SeekPng.com_white-png_237011.png-05a85fc9f04b81f3c0cec091cdf3b5a2.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Client/origin-client/ui/icons/bubble.tres b/Client/origin-client/ui/icons/bubble.tres new file mode 100644 index 0000000..bf1e96e --- /dev/null +++ b/Client/origin-client/ui/icons/bubble.tres @@ -0,0 +1,6 @@ +[gd_resource type="StyleBoxTexture" load_steps=2 format=3 uid="uid://db4iu21ce6fdb"] + +[ext_resource type="Texture2D" uid="uid://bcb4f2b31d4qd" path="res://ui/icons/Floating Text Background.png" id="1_7mpm3"] + +[resource] +texture = ExtResource("1_7mpm3")