From 396507ef4fc53c39909cec7f266d8afb1faeb07e Mon Sep 17 00:00:00 2001 From: adtpdn Date: Mon, 22 Jun 2026 17:22:31 +0800 Subject: [PATCH] Fix UI panel overlaps and admin RPC parsing - Prevent overlap in FragmentCraftPanel by using PanelContainer and Layout Mode 2 - Fix missing Admin Panel data by correctly parsing JSON payload in _rpc helper - Auto-resolve 'social_global' chatroom ID for Admin Panel queries - Untrack .claude and .agent from repository --- .agent/rules/read-before-think.md | 6 - .claude/settings.local.json | 11 -- .gitignore | 1 + scenes/ui/fragment_craft_panel.tscn | 248 +++++++--------------------- scripts/ui/admin_panel.gd | 64 ++++++- 5 files changed, 116 insertions(+), 214 deletions(-) delete mode 100644 .agent/rules/read-before-think.md delete mode 100644 .claude/settings.local.json diff --git a/.agent/rules/read-before-think.md b/.agent/rules/read-before-think.md deleted file mode 100644 index 0b67e32..0000000 --- a/.agent/rules/read-before-think.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -trigger: always_on ---- - -Make sure you check whole files before editing. -Ensure .tscn, .tres, .res related checked. \ No newline at end of file diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index 8b4ec60..0000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(sort -t'\"' -k2 -n)", - "WebFetch(domain:github.com)", - "WebFetch(domain:raw.githubusercontent.com)", - "Bash(claude mcp *)" - ] - }, - "prefersReducedMotion": true -} diff --git a/.gitignore b/.gitignore index e55c03c..2e20ce6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ build/ /android/ .tmp .vscode/settings.json +.claude/ diff --git a/scenes/ui/fragment_craft_panel.tscn b/scenes/ui/fragment_craft_panel.tscn index d875ad0..a616fe4 100644 --- a/scenes/ui/fragment_craft_panel.tscn +++ b/scenes/ui/fragment_craft_panel.tscn @@ -1,41 +1,10 @@ -[gd_scene format=3 uid="uid://frag_craft_panel_001"] +[gd_scene format=3 uid="uid://gfybn8mjd6ek"] -[ext_resource type="Script" path="res://scripts/ui/fragment_craft_panel.gd" id="1"] +[ext_resource type="Script" uid="uid://cnenx8f7cftrs" path="res://scripts/ui/fragment_craft_panel.gd" id="1"] [ext_resource type="Theme" uid="uid://cxab3xxy00" path="res://assets/themes/GUI_Tekton.tres" id="2"] [ext_resource type="FontFile" uid="uid://xnjx058n4tsw" path="res://assets/fonts/Nougat-ExtraBlack.ttf" id="3_font"] [ext_resource type="Texture2D" uid="uid://jqvv6s55mlsk" path="res://assets/graphics/gui/BG.png" id="4_bg"] -[ext_resource type="Texture2D" uid="uid://b5pp08fke7ptd" path="res://assets/graphics/gui/lobby/gold.png" id="5_common"] -[ext_resource type="Texture2D" uid="uid://d0ouvm3x8h42c" path="res://assets/graphics/gui/lobby/star.png" id="6_uncommon"] -[ext_resource type="Texture2D" uid="uid://d0ouvm3x8h42c" path="res://assets/graphics/gui/lobby/star.png" id="7_rare"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_OuterPanel"] -content_margin_left = 4.0 -content_margin_top = 4.0 -content_margin_right = 4.0 -content_margin_bottom = 4.0 -bg_color = Color(0.14117648, 0.16862746, 0.19215687, 1) -corner_radius_top_left = 12 -corner_radius_top_right = 12 -corner_radius_bottom_right = 12 -corner_radius_bottom_left = 12 -shadow_color = Color(0, 0, 0, 0.3529412) -shadow_size = 4 -shadow_offset = Vector2(-2, 2) - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_InnerDark"] -bg_color = Color(0.1, 0.1, 0.1, 1) -corner_radius_top_left = 6 -corner_radius_top_right = 6 -corner_radius_bottom_right = 6 -corner_radius_bottom_left = 6 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gd4oi"] -bg_color = Color(0, 0, 0, 0.48235294) -border_color = Color(0.92941177, 0.91764706, 0.8862745, 1) -corner_radius_top_left = 3 -corner_radius_top_right = 3 -corner_radius_bottom_right = 3 -corner_radius_bottom_left = 3 +[ext_resource type="Texture2D" uid="uid://c5s8dr6nbws5r" path="res://assets/graphics/gui/banner/fragment.png" id="5_lx1s2"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tab_inactive"] content_margin_left = 16.0 @@ -59,7 +28,15 @@ corner_radius_top_right = 8 corner_radius_bottom_right = 8 corner_radius_bottom_left = 8 -[node name="FragmentCraftPanel" type="Control"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gd4oi"] +bg_color = Color(0, 0, 0, 0.48235294) +border_color = Color(0.92941177, 0.91764706, 0.8862745, 1) +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 + +[node name="FragmentCraftPanel" type="Control" unique_id=1697578241] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -69,7 +46,7 @@ grow_vertical = 2 theme = ExtResource("2") script = ExtResource("1") -[node name="Background" type="ColorRect" parent="."] +[node name="Background" type="ColorRect" parent="." unique_id=1888772967] visible = false layout_mode = 1 anchors_preset = 15 @@ -79,7 +56,7 @@ grow_horizontal = 2 grow_vertical = 2 color = Color(0.0627451, 0.0745098, 0.101961, 1) -[node name="BackgroundTexture" type="TextureRect" parent="."] +[node name="BackgroundTexture" type="TextureRect" parent="." unique_id=1072386194] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -89,7 +66,7 @@ grow_vertical = 2 texture = ExtResource("4_bg") expand_mode = 2 -[node name="MainMargin" type="MarginContainer" parent="."] +[node name="MainMargin" type="MarginContainer" parent="." unique_id=1990716398] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -101,161 +78,65 @@ theme_override_constants/margin_top = 20 theme_override_constants/margin_right = 30 theme_override_constants/margin_bottom = 20 -[node name="MainVBox" type="VBoxContainer" parent="MainMargin"] +[node name="MainVBox" type="VBoxContainer" parent="MainMargin" unique_id=549090365] layout_mode = 2 theme_override_constants/separation = 14 -[node name="TopBar" type="HBoxContainer" parent="MainMargin/MainVBox"] +[node name="TopBar" type="HBoxContainer" parent="MainMargin/MainVBox" unique_id=219751484] layout_mode = 2 theme_override_constants/separation = 12 -[node name="BackBtn" type="Button" parent="MainMargin/MainVBox/TopBar"] +[node name="BackBtn" type="Button" parent="MainMargin/MainVBox/TopBar" unique_id=813523635] unique_name_in_owner = true custom_minimum_size = Vector2(44, 44) layout_mode = 2 theme_override_fonts/font = ExtResource("3_font") theme_override_font_sizes/font_size = 22 theme_override_styles/normal = SubResource("StyleBoxFlat_tab_inactive") -theme_override_styles/hover = SubResource("StyleBoxFlat_tab_inactive") theme_override_styles/pressed = SubResource("StyleBoxFlat_tab_active") +theme_override_styles/hover = SubResource("StyleBoxFlat_tab_inactive") text = "←" -[node name="TitleLabel" type="Label" parent="MainMargin/MainVBox/TopBar"] +[node name="TitleLabel" type="Label" parent="MainMargin/MainVBox/TopBar" unique_id=840628337] layout_mode = 2 size_flags_horizontal = 3 -theme_override_colors/font_color = Color(0.4, 1.0, 0.7, 1) +theme_override_colors/font_color = Color(0.4, 1, 0.7, 1) theme_override_fonts/font = ExtResource("3_font") theme_override_font_sizes/font_size = 24 text = "Fragment Craft" -[node name="FragRow" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar"] +[node name="FragBalanceRow" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar" unique_id=796220915] layout_mode = 2 size_flags_horizontal = 3 -theme_override_constants/separation = 8 +theme_override_constants/separation = 6 alignment = 2 -[node name="CommonPanel" type="PanelContainer" parent="MainMargin/MainVBox/TopBar/FragRow"] -custom_minimum_size = Vector2(80, 0) -layout_mode = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_InnerDark") - -[node name="Margin" type="MarginContainer" parent="MainMargin/MainVBox/TopBar/FragRow/CommonPanel"] -layout_mode = 2 -theme_override_constants/margin_left = 6 -theme_override_constants/margin_top = 4 -theme_override_constants/margin_right = 6 -theme_override_constants/margin_bottom = 4 - -[node name="HBox" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar/FragRow/CommonPanel/Margin"] -layout_mode = 2 -theme_override_constants/separation = 4 - -[node name="Icon" type="Label" parent="MainMargin/MainVBox/TopBar/FragRow/CommonPanel/Margin/HBox"] -layout_mode = 2 -text = "⬜" - -[node name="CommonLabel" type="Label" parent="MainMargin/MainVBox/TopBar/FragRow/CommonPanel/Margin/HBox"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 3 -theme_override_fonts/font = ExtResource("3_font") -theme_override_font_sizes/font_size = 13 -text = "0" -horizontal_alignment = 2 - -[node name="UncommonPanel" type="PanelContainer" parent="MainMargin/MainVBox/TopBar/FragRow"] -custom_minimum_size = Vector2(80, 0) -layout_mode = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_InnerDark") - -[node name="Margin" type="MarginContainer" parent="MainMargin/MainVBox/TopBar/FragRow/UncommonPanel"] -layout_mode = 2 -theme_override_constants/margin_left = 6 -theme_override_constants/margin_top = 4 -theme_override_constants/margin_right = 6 -theme_override_constants/margin_bottom = 4 - -[node name="HBox" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar/FragRow/UncommonPanel/Margin"] -layout_mode = 2 -theme_override_constants/separation = 4 - -[node name="Icon" type="Label" parent="MainMargin/MainVBox/TopBar/FragRow/UncommonPanel/Margin/HBox"] -layout_mode = 2 -text = "🟩" - -[node name="UncommonLabel" type="Label" parent="MainMargin/MainVBox/TopBar/FragRow/UncommonPanel/Margin/HBox"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 3 -theme_override_fonts/font = ExtResource("3_font") -theme_override_font_sizes/font_size = 13 -text = "0" -horizontal_alignment = 2 - -[node name="RarePanel" type="PanelContainer" parent="MainMargin/MainVBox/TopBar/FragRow"] -custom_minimum_size = Vector2(80, 0) -layout_mode = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_InnerDark") - -[node name="Margin" type="MarginContainer" parent="MainMargin/MainVBox/TopBar/FragRow/RarePanel"] -layout_mode = 2 -theme_override_constants/margin_left = 6 -theme_override_constants/margin_top = 4 -theme_override_constants/margin_right = 6 -theme_override_constants/margin_bottom = 4 - -[node name="HBox" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar/FragRow/RarePanel/Margin"] -layout_mode = 2 -theme_override_constants/separation = 4 - -[node name="Icon" type="Label" parent="MainMargin/MainVBox/TopBar/FragRow/RarePanel/Margin/HBox"] -layout_mode = 2 -text = "🟦" - -[node name="RareLabel" type="Label" parent="MainMargin/MainVBox/TopBar/FragRow/RarePanel/Margin/HBox"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 3 -theme_override_fonts/font = ExtResource("3_font") -theme_override_font_sizes/font_size = 13 -text = "0" -horizontal_alignment = 2 - -[node name="FragBalanceRow" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar"] -visible = false -layout_mode = 2 -theme_override_constants/separation = 6 - +[node name="CommonPanel" type="PanelContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow" unique_id=1764739158] custom_minimum_size = Vector2(70, 30) layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_gd4oi") -[node name="MarginContainer" type="MarginContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/CommonPanel"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/margin_left = 3 +[node name="MarginContainer" type="MarginContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/CommonPanel" unique_id=854646513] +layout_mode = 2 +theme_override_constants/margin_left = 10 theme_override_constants/margin_top = 3 -theme_override_constants/margin_right = 6 +theme_override_constants/margin_right = 10 theme_override_constants/margin_bottom = 3 -[node name="HBoxContainer" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/CommonPanel/MarginContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/CommonPanel/MarginContainer" unique_id=58481962] layout_mode = 2 -[node name="TextureRect" type="TextureRect" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/CommonPanel/MarginContainer/HBoxContainer"] -unique_name_in_owner = true +[node name="TextureRect" type="TextureRect" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/CommonPanel/MarginContainer/HBoxContainer" unique_id=25966478] +modulate = Color(1, 1, 0, 1) custom_minimum_size = Vector2(20, 20) layout_mode = 2 size_flags_horizontal = 0 size_flags_vertical = 4 -texture = ExtResource("5_common") +texture = ExtResource("5_lx1s2") expand_mode = 1 stretch_mode = 5 -[node name="CommonLabel" type="Label" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/CommonPanel/MarginContainer/HBoxContainer"] +[node name="CommonLabel" type="Label" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/CommonPanel/MarginContainer/HBoxContainer" unique_id=708193996] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 @@ -264,37 +145,32 @@ theme_override_font_sizes/font_size = 14 text = "0" horizontal_alignment = 2 -[node name="UncommonPanel" type="Panel" parent="MainMargin/MainVBox/TopBar/FragBalanceRow"] +[node name="UncommonPanel" type="PanelContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow" unique_id=1543411590] custom_minimum_size = Vector2(70, 30) layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_gd4oi") -[node name="MarginContainer" type="MarginContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/UncommonPanel"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/margin_left = 3 +[node name="MarginContainer" type="MarginContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/UncommonPanel" unique_id=2087797147] +layout_mode = 2 +theme_override_constants/margin_left = 10 theme_override_constants/margin_top = 3 -theme_override_constants/margin_right = 6 +theme_override_constants/margin_right = 10 theme_override_constants/margin_bottom = 3 -[node name="HBoxContainer" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/UncommonPanel/MarginContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/UncommonPanel/MarginContainer" unique_id=116980182] layout_mode = 2 -[node name="TextureRect" type="TextureRect" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/UncommonPanel/MarginContainer/HBoxContainer"] -unique_name_in_owner = true +[node name="TextureRect" type="TextureRect" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/UncommonPanel/MarginContainer/HBoxContainer" unique_id=536779590] +modulate = Color(0.7869837, 0, 1, 1) custom_minimum_size = Vector2(20, 20) layout_mode = 2 size_flags_horizontal = 0 size_flags_vertical = 4 -texture = ExtResource("6_uncommon") +texture = ExtResource("5_lx1s2") expand_mode = 1 stretch_mode = 5 -[node name="UncommonLabel" type="Label" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/UncommonPanel/MarginContainer/HBoxContainer"] +[node name="UncommonLabel" type="Label" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/UncommonPanel/MarginContainer/HBoxContainer" unique_id=67246805] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 @@ -303,37 +179,32 @@ theme_override_font_sizes/font_size = 14 text = "0" horizontal_alignment = 2 -[node name="RarePanel" type="Panel" parent="MainMargin/MainVBox/TopBar/FragBalanceRow"] +[node name="RarePanel" type="PanelContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow" unique_id=217749753] custom_minimum_size = Vector2(70, 30) layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_gd4oi") -[node name="MarginContainer" type="MarginContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/RarePanel"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/margin_left = 3 +[node name="MarginContainer" type="MarginContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/RarePanel" unique_id=44717054] +layout_mode = 2 +theme_override_constants/margin_left = 10 theme_override_constants/margin_top = 3 -theme_override_constants/margin_right = 6 +theme_override_constants/margin_right = 10 theme_override_constants/margin_bottom = 3 -[node name="HBoxContainer" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/RarePanel/MarginContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/RarePanel/MarginContainer" unique_id=1311460266] layout_mode = 2 -[node name="TextureRect" type="TextureRect" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/RarePanel/MarginContainer/HBoxContainer"] -unique_name_in_owner = true +[node name="TextureRect" type="TextureRect" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/RarePanel/MarginContainer/HBoxContainer" unique_id=1983313869] +modulate = Color(0.13335153, 1, 0.2400937, 1) custom_minimum_size = Vector2(20, 20) layout_mode = 2 size_flags_horizontal = 0 size_flags_vertical = 4 -texture = ExtResource("7_rare") +texture = ExtResource("5_lx1s2") expand_mode = 1 stretch_mode = 5 -[node name="RareLabel" type="Label" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/RarePanel/MarginContainer/HBoxContainer"] +[node name="RareLabel" type="Label" parent="MainMargin/MainVBox/TopBar/FragBalanceRow/RarePanel/MarginContainer/HBoxContainer" unique_id=93911456] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 @@ -342,29 +213,28 @@ theme_override_font_sizes/font_size = 14 text = "0" horizontal_alignment = 2 -[node name="SubTitle" type="Label" parent="MainMargin/MainVBox"] +[node name="SubTitle" type="Label" parent="MainMargin/MainVBox" unique_id=1597486392] layout_mode = 2 -theme_override_colors/font_color = Color(1.0, 1.0, 1.0, 1) +theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 13 text = "Collect Common, Uncommon, and Rare fragments from gacha pulls to craft exclusive skins." -[node name="HSep" type="HSeparator" parent="MainMargin/MainVBox"] +[node name="HSep" type="HSeparator" parent="MainMargin/MainVBox" unique_id=430267490] layout_mode = 2 -[node name="ScrollContainer" type="ScrollContainer" parent="MainMargin/MainVBox"] +[node name="ScrollContainer" type="ScrollContainer" parent="MainMargin/MainVBox" unique_id=1354459173] layout_mode = 2 size_flags_vertical = 3 horizontal_scroll_mode = 0 -[node name="RecipeList" type="VBoxContainer" parent="MainMargin/MainVBox/ScrollContainer"] +[node name="RecipeList" type="VBoxContainer" parent="MainMargin/MainVBox/ScrollContainer" unique_id=896986292] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 theme_override_constants/separation = 10 -[node name="StatusLabel" type="Label" parent="MainMargin/MainVBox"] +[node name="StatusLabel" type="Label" parent="MainMargin/MainVBox" unique_id=2017604675] unique_name_in_owner = true layout_mode = 2 theme_override_font_sizes/font_size = 14 horizontal_alignment = 1 -text = "" diff --git a/scripts/ui/admin_panel.gd b/scripts/ui/admin_panel.gd index 5527e73..9e595c3 100644 --- a/scripts/ui/admin_panel.gd +++ b/scripts/ui/admin_panel.gd @@ -301,7 +301,15 @@ func _rpc(rpc_name: String, payload: Dictionary) -> Dictionary: var err: String = str(result.get("message", "Unknown error")) _set_status(err, CLR_STATUS_ERR) return {"error": err} - return result.get("data", {}) + + var payload_str: String = result.get("payload", "{}") + if payload_str.is_empty(): + payload_str = "{}" + + var parsed = JSON.parse_string(payload_str) + if typeof(parsed) == TYPE_DICTIONARY: + return parsed + return {} func _set_status(msg: String, color: Color = CLR_DIM) -> void: status_label.text = msg @@ -1264,12 +1272,30 @@ func _on_wipe_chat() -> void: confirm.popup_centered() confirm.confirmed.connect(func(): chat_status_label.text = "Wiping chat..." + + var target_channel_id = "" var lobby = get_tree().get_first_node_in_group("Lobby") - if lobby and lobby.has_method("admin_wipe_chat"): - lobby.admin_wipe_chat() + if lobby and lobby.get("chat") and lobby.chat.get("_chat_channel"): + target_channel_id = lobby.chat._chat_channel.id + + if target_channel_id.is_empty(): + chat_status_label.text = "Error: Not connected to global chat." + confirm.queue_free() + return + + var payload = JSON.stringify({"channel_id": target_channel_id}) + var result = await BackendService.admin_clear_global_chat(payload) + + if result.get("success", false): chat_status_label.text = "Chat wiped!" + if lobby.has_method("admin_wipe_chat"): + # Just update UI locally + lobby.chat._chat_messages.clear() + lobby.chat._refresh_chat_display() + lobby.chat._inject_local_message("[SYSTEM] : Global chat cleared by admin.") else: - chat_status_label.text = "Lobby not found — cannot wipe." + chat_status_label.text = "Wipe failed: " + str(result.get("message", "")) + confirm.queue_free() ) @@ -1286,12 +1312,24 @@ func _on_purge_old_chat() -> void: confirm.popup_centered() confirm.confirmed.connect(func(): chat_status_label.text = "Purging old messages..." + + var target_channel_id = "" var lobby = get_tree().get_first_node_in_group("Lobby") - if lobby and lobby.has_method("admin_purge_chat"): - var deleted: int = await lobby.admin_purge_chat(max_age) - chat_status_label.text = "Purged %d old messages." % deleted + if lobby and lobby.get("chat") and lobby.chat.get("_chat_channel"): + target_channel_id = lobby.chat._chat_channel.id + + if target_channel_id.is_empty(): + chat_status_label.text = "Error: Not connected to global chat." + confirm.queue_free() + return + + var result = await BackendService.admin_purge_old_messages(target_channel_id, max_age) + if result.has("error"): + chat_status_label.text = "Purge failed: " + str(result.get("error", "")) else: - chat_status_label.text = "Lobby not found — cannot purge." + var deleted: int = result.get("deleted", 0) + chat_status_label.text = "Purged %d old messages." % deleted + confirm.queue_free() ) @@ -1317,6 +1355,16 @@ func _on_load_chat_messages() -> void: _set_status("Enter a Channel ID first.", CLR_STATUS_ERR) return + # Auto-resolve "social_global" to the actual Nakama Channel ID if the admin is in the lobby + if channel_id == "social_global": + var lobby = get_tree().get_first_node_in_group("Lobby") + if lobby and lobby.get("chat") and lobby.chat.get("_chat_channel"): + channel_id = lobby.chat._chat_channel.id + chat_channel_id_edit.text = channel_id # Update UI so admin sees the real ID + else: + _set_status("Cannot resolve social_global. Join chat first.", CLR_STATUS_ERR) + return + _chat_channel_id = channel_id _chat_cursor = "" _chat_messages_data.clear()