Standardize programmatic UI to scene-based instantiation (Phases 1-5)
Convert all screens that built UI nodes in GDScript into proper .tscn
scene files. Each component gets its own scene; parent screens use
preload + instantiate; data flows through setup() methods; actions use
signals. Eliminates ~1000 lines of boilerplate node-creation code.
Phase 1 — Simple row components (6 new scenes):
LeaderboardRow, NotificationRow, StarterDeckCard, DeckPickerButton,
StatRow, AbilityRow
Modifies: leaderboard_screen, account_screen, starter_deck_screen,
matchmaking_screen, card_detail_popup (GridContainer→VBox)
Phase 2 — Lobby browser rows (2 new scenes):
LobbyBrowserRow (signal join_requested), ActiveGameRow (signal spectate_requested)
Modifies: free_play_screen
Phase 3 — RulesEditorDialog (1 new scene):
Replaces 150+ line _open_rules_editor() in lobby_room_screen with
4-line instantiate pattern; signal confirmed(overrides)
Phase 4 — DeckEditorPanel.tscn:
Moves split-pane deck editor into scene file; removes _setup_ui(),
_make_left_pane(), _make_right_pane(); switches to @onready refs;
DecksView.tscn updated to instance the scene
Phase 5 — ChatOverlay.tscn:
Fully populates ChatPanel with header, 7 tab buttons, 7 content panes
(FriendsPane/PresencePane/GlobalPane/LobbyPane/GamePane/PartyPane/DmsPane),
and InputBar; removes _build_panel() and all _make_*/_build_*_tab()
functions from chat_overlay.gd; replaces with @onready refs and
_ready() wiring from scene children
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
extends Control
|
||||
## Account Management screen.
|
||||
|
||||
const NOTIF_ROW = preload("res://scenes/account/components/NotificationRow.tscn")
|
||||
## Shows the player's own profile (display name, OP, rank score)
|
||||
## and a mailbox tab with admin responses to bug reports.
|
||||
|
||||
@@ -67,44 +69,15 @@ func _on_notifications_ok(p: Variant) -> void:
|
||||
|
||||
for n in notifs:
|
||||
var nd := n as Dictionary
|
||||
var row := _make_notification_row(nd)
|
||||
var row := NOTIF_ROW.instantiate()
|
||||
row.setup(
|
||||
nd.get("title", "Notification"),
|
||||
nd.get("body", ""),
|
||||
nd.get("readAt", null) == null
|
||||
)
|
||||
mailbox_list.add_child(row)
|
||||
|
||||
|
||||
func _make_notification_row(n: Dictionary) -> PanelContainer:
|
||||
var panel := PanelContainer.new()
|
||||
panel.custom_minimum_size = Vector2(0, 72)
|
||||
|
||||
var margin := MarginContainer.new()
|
||||
margin.add_theme_constant_override("margin_left", 12)
|
||||
margin.add_theme_constant_override("margin_right", 12)
|
||||
margin.add_theme_constant_override("margin_top", 8)
|
||||
margin.add_theme_constant_override("margin_bottom", 8)
|
||||
panel.add_child(margin)
|
||||
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 4)
|
||||
margin.add_child(vbox)
|
||||
|
||||
var title_lbl := Label.new()
|
||||
title_lbl.text = n.get("title", "Notification")
|
||||
title_lbl.add_theme_font_size_override("font_size", 13)
|
||||
vbox.add_child(title_lbl)
|
||||
|
||||
var body_lbl := Label.new()
|
||||
body_lbl.text = n.get("body", "")
|
||||
body_lbl.add_theme_font_size_override("font_size", 11)
|
||||
body_lbl.modulate = Color(0.7, 0.7, 0.75)
|
||||
body_lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
vbox.add_child(body_lbl)
|
||||
|
||||
var is_unread : bool = n.get("readAt", null) == null
|
||||
if is_unread:
|
||||
title_lbl.modulate = Color(0.95, 0.85, 0.30)
|
||||
|
||||
return panel
|
||||
|
||||
|
||||
# ── Navigation ────────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_back() -> void:
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/account/components/notification_row.gd" id="1_nr"]
|
||||
|
||||
[node name="NotificationRow" type="PanelContainer"]
|
||||
custom_minimum_size = Vector2(0, 72)
|
||||
script = ExtResource("1_nr")
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="Margin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="Margin/VBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="BodyLabel" type="Label" parent="Margin/VBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
autowrap_mode = 2
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
theme_override_font_sizes/font_size = 11
|
||||
@@ -0,0 +1,12 @@
|
||||
extends PanelContainer
|
||||
## Single mailbox notification row.
|
||||
|
||||
@onready var title_label : Label = %TitleLabel
|
||||
@onready var body_label : Label = %BodyLabel
|
||||
|
||||
|
||||
func setup(title: String, body: String, is_unread: bool) -> void:
|
||||
title_label.text = title
|
||||
body_label.text = body
|
||||
if is_unread:
|
||||
title_label.modulate = Color(0.95, 0.85, 0.30)
|
||||
@@ -49,3 +49,459 @@ offset_right = -16.0
|
||||
offset_bottom = -84.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="RootVBox" type="VBoxContainer" parent="ChatPanel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="Header" type="MarginContainer" parent="ChatPanel/RootVBox"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="HeaderInner" type="HBoxContainer" parent="ChatPanel/RootVBox/Header"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="ChatPanel/RootVBox/Header/HeaderInner"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Chat"
|
||||
theme_override_font_sizes/font_size = 15
|
||||
|
||||
[node name="CloseBtn" type="Button" parent="ChatPanel/RootVBox/Header/HeaderInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
flat = true
|
||||
text = "✕"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
|
||||
[node name="HeaderSep" type="HSeparator" parent="ChatPanel/RootVBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TabBar" type="HBoxContainer" parent="ChatPanel/RootVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 28)
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="FriendsTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Friends"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="PresenceTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Presence"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="GlobalTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Global"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="LobbyTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Lobby"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="GameTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Game"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="PartyTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Party"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="DmsTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "DMs"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="TabSep" type="HSeparator" parent="ChatPanel/RootVBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ContentArea" type="Control" parent="ChatPanel/RootVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="FriendsPane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="RequestsSection" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/FriendsPane"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="ReqMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/FriendsPane/RequestsSection"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_bottom = 2
|
||||
|
||||
[node name="ReqHeader" type="Label" parent="ChatPanel/RootVBox/ContentArea/FriendsPane/RequestsSection/ReqMargin"]
|
||||
layout_mode = 2
|
||||
text = "FRIEND REQUESTS"
|
||||
modulate = Color(0.52, 0.52, 0.58, 1)
|
||||
theme_override_font_sizes/font_size = 10
|
||||
|
||||
[node name="RequestsList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/FriendsPane/RequestsSection"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="ReqSep" type="HSeparator" parent="ChatPanel/RootVBox/ContentArea/FriendsPane/RequestsSection"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="FriendsScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/FriendsPane"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="FriendsList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/FriendsPane/FriendsScroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="PresencePane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="StatusMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/PresencePane"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="StatusHBox" type="HBoxContainer" parent="ChatPanel/RootVBox/ContentArea/PresencePane/StatusMargin"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="StatusLabel" type="Label" parent="ChatPanel/RootVBox/ContentArea/PresencePane/StatusMargin/StatusHBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "My Status:"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="PresenceOption" type="OptionButton" parent="ChatPanel/RootVBox/ContentArea/PresencePane/StatusMargin/StatusHBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="PresenceSep" type="HSeparator" parent="ChatPanel/RootVBox/ContentArea/PresencePane"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PresenceHeaderMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/PresencePane"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_bottom = 2
|
||||
|
||||
[node name="PresenceHeaderLabel" type="Label" parent="ChatPanel/RootVBox/ContentArea/PresencePane/PresenceHeaderMargin"]
|
||||
layout_mode = 2
|
||||
text = "FRIENDS PRESENCE"
|
||||
modulate = Color(0.52, 0.52, 0.58, 1)
|
||||
theme_override_font_sizes/font_size = 10
|
||||
|
||||
[node name="PresenceScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/PresencePane"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="PresenceList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/PresencePane/PresenceScroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="GlobalPane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="GlobalScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/GlobalPane"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="GlobalMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/GlobalPane/GlobalScroll"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="GlobalList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/GlobalPane/GlobalScroll/GlobalMargin"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="LobbyPane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="LobbyScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/LobbyPane"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="LobbyMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/LobbyPane/LobbyScroll"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="LobbyList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/LobbyPane/LobbyScroll/LobbyMargin"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="GamePane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="GameScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/GamePane"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="GameMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/GamePane/GameScroll"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="GameList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/GamePane/GameScroll/GameMargin"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="PartyPane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="PartyActionBar" type="HBoxContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="PartyActionMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="PartyActionInner" type="HBoxContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar/PartyActionMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="PartyNameLabel" type="Label" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar/PartyActionMargin/PartyActionInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Party"
|
||||
modulate = Color(0.42, 1.0, 0.58, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="RenameBtn" type="Button" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar/PartyActionMargin/PartyActionInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
flat = true
|
||||
text = "Rename"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="LeaveBtn" type="Button" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar/PartyActionMargin/PartyActionInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
flat = true
|
||||
text = "Leave"
|
||||
modulate = Color(1.0, 0.38, 0.38, 1)
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="PartyActionSep" type="HSeparator" parent="ChatPanel/RootVBox/ContentArea/PartyPane"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PartyScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="PartyMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyScroll"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="PartyList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyScroll/PartyMargin"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="DmsPane" type="HBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="DmConvArea" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(110, 0)
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="DmConvScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane/DmConvArea"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="DmConvList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane/DmConvArea/DmConvScroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="DmVSep" type="VSeparator" parent="ChatPanel/RootVBox/ContentArea/DmsPane"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DmMsgArea" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="DmMsgScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane/DmMsgArea"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="DmMsgMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane/DmMsgArea/DmMsgScroll"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="DmMsgList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane/DmMsgArea/DmMsgScroll/DmMsgMargin"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="InputSep" type="HSeparator" parent="ChatPanel/RootVBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="InputBar" type="HBoxContainer" parent="ChatPanel/RootVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="InputMargin" type="MarginContainer" parent="ChatPanel/RootVBox/InputBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="InputInner" type="HBoxContainer" parent="ChatPanel/RootVBox/InputBar/InputMargin"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="MessageInput" type="LineEdit" parent="ChatPanel/RootVBox/InputBar/InputMargin/InputInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Type a message..."
|
||||
max_length = 500
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="SendBtn" type="Button" parent="ChatPanel/RootVBox/InputBar/InputMargin/InputInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(52, 0)
|
||||
text = "Send"
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
extends CanvasLayer
|
||||
## Chat overlay — persists across all scenes as a child of the viewport root.
|
||||
##
|
||||
## Structure (built programmatically in _build_panel):
|
||||
## Structure (defined in ChatOverlay.tscn):
|
||||
## ChatBubble (Button, bottom-right) — toggles the panel
|
||||
## ChatPanel (PanelContainer)
|
||||
## VBox
|
||||
## RootVBox
|
||||
## Header — title + close button
|
||||
## TabBar — Friends | Presence | Global | Lobby | Game | DMs
|
||||
## ContentArea — one VBox per tab, only active one is visible
|
||||
## TabBar — Friends | Presence | Global | Lobby | Game | Party | DMs
|
||||
## ContentArea — one pane per tab, only active one is visible
|
||||
## InputBar — LineEdit + Send (hidden on Friends/Presence tabs)
|
||||
##
|
||||
## Message row format: [HH:MM] [source] SenderName: message text
|
||||
@@ -45,31 +45,29 @@ const SOURCE_COLORS := {
|
||||
@onready var _badge : Label = $ChatBubble/BadgeLabel
|
||||
@onready var _panel : PanelContainer = $ChatPanel
|
||||
|
||||
# ── Built programmatically ────────────────────────────────────────────────────
|
||||
@onready var _input_bar : HBoxContainer = %InputBar
|
||||
@onready var _message_input : LineEdit = %MessageInput
|
||||
|
||||
# Per-tab content refs
|
||||
@onready var _friends_list : VBoxContainer = %FriendsList
|
||||
@onready var _requests_section : VBoxContainer = %RequestsSection
|
||||
@onready var _requests_list : VBoxContainer = %RequestsList
|
||||
@onready var _presence_list : VBoxContainer = %PresenceList
|
||||
@onready var _presence_option : OptionButton = %PresenceOption
|
||||
@onready var _global_list : VBoxContainer = %GlobalList
|
||||
@onready var _lobby_list : VBoxContainer = %LobbyList
|
||||
@onready var _game_list : VBoxContainer = %GameList
|
||||
@onready var _dm_conv_list : VBoxContainer = %DmConvList
|
||||
@onready var _dm_msg_list : VBoxContainer = %DmMsgList
|
||||
@onready var _party_msg_list : VBoxContainer = %PartyList
|
||||
@onready var _party_action_bar : HBoxContainer = %PartyActionBar
|
||||
@onready var _party_name_lbl : Label = %PartyNameLabel
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
var _tab_buttons : Array[Button] = []
|
||||
var _content_nodes : Array[Control] = [] # one entry per Tab enum value
|
||||
|
||||
var _input_bar : HBoxContainer = null
|
||||
var _message_input : LineEdit = null
|
||||
var _send_button : Button = null
|
||||
|
||||
# Per-tab content refs
|
||||
var _friends_list : VBoxContainer = null
|
||||
var _requests_section : Control = null
|
||||
var _requests_list : VBoxContainer = null
|
||||
var _presence_list : VBoxContainer = null
|
||||
var _presence_option : OptionButton = null
|
||||
var _global_list : VBoxContainer = null
|
||||
var _lobby_list : VBoxContainer = null
|
||||
var _game_list : VBoxContainer = null
|
||||
var _dm_conv_list : VBoxContainer = null
|
||||
var _dm_msg_list : VBoxContainer = null
|
||||
var _party_msg_list : VBoxContainer = null
|
||||
var _party_action_bar : HBoxContainer = null
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
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
|
||||
@@ -80,10 +78,35 @@ var _muted : Dictionary = {} # account_id → true
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
_build_panel()
|
||||
# Populate tab button array from scene TabBar children (order matches Tab enum).
|
||||
for btn in %TabBar.get_children():
|
||||
_tab_buttons.append(btn as Button)
|
||||
for i in _tab_buttons.size():
|
||||
var idx := i
|
||||
_tab_buttons[i].pressed.connect(func() -> void: _show_tab(idx as Tab))
|
||||
|
||||
# Populate content pane array from scene ContentArea children (order matches Tab enum).
|
||||
for pane in %ContentArea.get_children():
|
||||
_content_nodes.append(pane as Control)
|
||||
|
||||
# Wire scene node signals.
|
||||
%CloseBtn.pressed.connect(func() -> void: _panel.visible = false)
|
||||
%RenameBtn.pressed.connect(_on_party_rename_pressed)
|
||||
%LeaveBtn.pressed.connect(_on_party_leave_pressed)
|
||||
%SendBtn.pressed.connect(_send_current_input)
|
||||
_message_input.text_submitted.connect(func(_text: String) -> void: _send_current_input())
|
||||
|
||||
# Populate presence option items.
|
||||
_presence_option.add_item("● Online", 0)
|
||||
_presence_option.add_item("◐ Away", 1)
|
||||
_presence_option.add_item("○ Offline", 2)
|
||||
_presence_option.selected = 0
|
||||
_presence_option.item_selected.connect(_on_own_presence_changed)
|
||||
|
||||
_style_bubble()
|
||||
_connect_chat_signals()
|
||||
_bubble.pressed.connect(_toggle_panel)
|
||||
_show_tab(Tab.GLOBAL)
|
||||
|
||||
|
||||
func _connect_chat_signals() -> void:
|
||||
@@ -119,123 +142,6 @@ func _style_bubble() -> void:
|
||||
badge_style.corner_radius_bottom_right = 6
|
||||
_badge.add_theme_stylebox_override("normal", badge_style)
|
||||
|
||||
# ── Build panel ───────────────────────────────────────────────────────────────
|
||||
|
||||
func _build_panel() -> void:
|
||||
var root_vbox := VBoxContainer.new()
|
||||
root_vbox.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
root_vbox.add_theme_constant_override("separation", 0)
|
||||
_panel.add_child(root_vbox)
|
||||
|
||||
root_vbox.add_child(_make_header())
|
||||
root_vbox.add_child(_make_tab_bar())
|
||||
root_vbox.add_child(_make_separator())
|
||||
|
||||
# Content area — child controls fill it; only one is visible at a time.
|
||||
var content_area := Control.new()
|
||||
content_area.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
root_vbox.add_child(content_area)
|
||||
|
||||
for i in TAB_LABELS.size():
|
||||
var tab_node := _build_tab_content(i as Tab)
|
||||
tab_node.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
tab_node.visible = false
|
||||
content_area.add_child(tab_node)
|
||||
_content_nodes.append(tab_node)
|
||||
|
||||
root_vbox.add_child(_make_separator())
|
||||
root_vbox.add_child(_make_input_bar())
|
||||
|
||||
_show_tab(Tab.GLOBAL)
|
||||
|
||||
|
||||
func _make_separator() -> HSeparator:
|
||||
return HSeparator.new()
|
||||
|
||||
|
||||
func _make_header() -> Control:
|
||||
var margin := MarginContainer.new()
|
||||
margin.add_theme_constant_override("margin_left", 12)
|
||||
margin.add_theme_constant_override("margin_right", 8)
|
||||
margin.add_theme_constant_override("margin_top", 6)
|
||||
margin.add_theme_constant_override("margin_bottom", 6)
|
||||
|
||||
var hbox := HBoxContainer.new()
|
||||
hbox.add_theme_constant_override("separation", 8)
|
||||
hbox.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
margin.add_child(hbox)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "Chat"
|
||||
title.add_theme_font_size_override("font_size", 15)
|
||||
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
hbox.add_child(title)
|
||||
|
||||
var close_btn := Button.new()
|
||||
close_btn.text = "✕"
|
||||
close_btn.flat = true
|
||||
close_btn.add_theme_font_size_override("font_size", 14)
|
||||
close_btn.pressed.connect(func() -> void: _panel.visible = false)
|
||||
hbox.add_child(close_btn)
|
||||
|
||||
return margin
|
||||
|
||||
|
||||
func _make_tab_bar() -> Control:
|
||||
var hbox := HBoxContainer.new()
|
||||
hbox.add_theme_constant_override("separation", 0)
|
||||
hbox.custom_minimum_size = Vector2(0, 28)
|
||||
|
||||
for i in TAB_LABELS.size():
|
||||
var btn := Button.new()
|
||||
btn.text = TAB_LABELS[i]
|
||||
btn.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
btn.flat = true
|
||||
btn.add_theme_font_size_override("font_size", 11)
|
||||
var idx := i
|
||||
btn.pressed.connect(func() -> void: _show_tab(idx as Tab))
|
||||
_tab_buttons.append(btn)
|
||||
hbox.add_child(btn)
|
||||
|
||||
return hbox
|
||||
|
||||
|
||||
func _make_input_bar() -> Control:
|
||||
_input_bar = HBoxContainer.new()
|
||||
_input_bar.add_theme_constant_override("separation", 0)
|
||||
_input_bar.visible = false
|
||||
|
||||
var margin := MarginContainer.new()
|
||||
margin.add_theme_constant_override("margin_left", 8)
|
||||
margin.add_theme_constant_override("margin_right", 8)
|
||||
margin.add_theme_constant_override("margin_top", 6)
|
||||
margin.add_theme_constant_override("margin_bottom", 6)
|
||||
margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_input_bar.add_child(margin)
|
||||
|
||||
var inner := HBoxContainer.new()
|
||||
inner.add_theme_constant_override("separation", 6)
|
||||
inner.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
margin.add_child(inner)
|
||||
|
||||
_message_input = LineEdit.new()
|
||||
_message_input.placeholder_text = "Type a message..."
|
||||
_message_input.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_message_input.add_theme_font_size_override("font_size", 13)
|
||||
_message_input.max_length = 500
|
||||
_message_input.text_submitted.connect(func(_text: String) -> void:
|
||||
_send_current_input())
|
||||
inner.add_child(_message_input)
|
||||
|
||||
_send_button = Button.new()
|
||||
_send_button.text = "Send"
|
||||
_send_button.custom_minimum_size = Vector2(52, 0)
|
||||
_send_button.add_theme_font_size_override("font_size", 12)
|
||||
_send_button.pressed.connect(_send_current_input)
|
||||
inner.add_child(_send_button)
|
||||
|
||||
return _input_bar
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not _panel.visible or not _input_bar.visible:
|
||||
@@ -248,267 +154,6 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
and (key.keycode == KEY_ENTER or key.keycode == KEY_KP_ENTER):
|
||||
_send_current_input()
|
||||
get_viewport().set_input_as_handled()
|
||||
# ── Tab builders ──────────────────────────────────────────────────────────────
|
||||
|
||||
func _build_tab_content(tab: Tab) -> Control:
|
||||
match tab:
|
||||
Tab.FRIENDS: return _build_friends_tab()
|
||||
Tab.PRESENCE: return _build_presence_tab()
|
||||
Tab.GLOBAL: return _build_channel_tab(Tab.GLOBAL)
|
||||
Tab.LOBBY: return _build_channel_tab(Tab.LOBBY)
|
||||
Tab.GAME: return _build_channel_tab(Tab.GAME)
|
||||
Tab.PARTY: return _build_party_tab()
|
||||
Tab.DMS: return _build_dms_tab()
|
||||
return Control.new()
|
||||
|
||||
|
||||
func _build_friends_tab() -> Control:
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 0)
|
||||
|
||||
# ── Pending requests (hidden when empty) ──────────────────────────────────
|
||||
_requests_section = VBoxContainer.new()
|
||||
_requests_section.visible = false
|
||||
vbox.add_child(_requests_section)
|
||||
|
||||
var req_margin := MarginContainer.new()
|
||||
req_margin.add_theme_constant_override("margin_left", 10)
|
||||
req_margin.add_theme_constant_override("margin_top", 6)
|
||||
req_margin.add_theme_constant_override("margin_bottom", 2)
|
||||
_requests_section.add_child(req_margin)
|
||||
|
||||
var req_header := Label.new()
|
||||
req_header.text = "FRIEND REQUESTS"
|
||||
req_header.add_theme_color_override("font_color", MUTED_COLOR)
|
||||
req_header.add_theme_font_size_override("font_size", 10)
|
||||
req_margin.add_child(req_header)
|
||||
|
||||
_requests_list = VBoxContainer.new()
|
||||
_requests_list.add_theme_constant_override("separation", 0)
|
||||
_requests_section.add_child(_requests_list)
|
||||
|
||||
_requests_section.add_child(_make_separator())
|
||||
|
||||
# ── Friends scroll ────────────────────────────────────────────────────────
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
vbox.add_child(scroll)
|
||||
|
||||
_friends_list = VBoxContainer.new()
|
||||
_friends_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_friends_list.add_theme_constant_override("separation", 0)
|
||||
scroll.add_child(_friends_list)
|
||||
|
||||
return vbox
|
||||
|
||||
|
||||
func _build_presence_tab() -> Control:
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 0)
|
||||
|
||||
# ── Own status selector ───────────────────────────────────────────────────
|
||||
var sm := MarginContainer.new()
|
||||
sm.add_theme_constant_override("margin_left", 12)
|
||||
sm.add_theme_constant_override("margin_right", 12)
|
||||
sm.add_theme_constant_override("margin_top", 8)
|
||||
sm.add_theme_constant_override("margin_bottom", 8)
|
||||
vbox.add_child(sm)
|
||||
|
||||
var shbox := HBoxContainer.new()
|
||||
shbox.add_theme_constant_override("separation", 8)
|
||||
shbox.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
sm.add_child(shbox)
|
||||
|
||||
var slbl := Label.new()
|
||||
slbl.text = "My Status:"
|
||||
slbl.add_theme_font_size_override("font_size", 13)
|
||||
slbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
shbox.add_child(slbl)
|
||||
|
||||
_presence_option = OptionButton.new()
|
||||
_presence_option.add_item("● Online", 0)
|
||||
_presence_option.add_item("◐ Away", 1)
|
||||
_presence_option.add_item("○ Offline", 2)
|
||||
_presence_option.selected = 0
|
||||
_presence_option.add_theme_font_size_override("font_size", 12)
|
||||
_presence_option.item_selected.connect(_on_own_presence_changed)
|
||||
shbox.add_child(_presence_option)
|
||||
|
||||
vbox.add_child(_make_separator())
|
||||
|
||||
# ── Online friends list ───────────────────────────────────────────────────
|
||||
var lm := MarginContainer.new()
|
||||
lm.add_theme_constant_override("margin_left", 10)
|
||||
lm.add_theme_constant_override("margin_top", 6)
|
||||
lm.add_theme_constant_override("margin_bottom", 2)
|
||||
vbox.add_child(lm)
|
||||
|
||||
var llbl := Label.new()
|
||||
llbl.text = "FRIENDS PRESENCE"
|
||||
llbl.add_theme_color_override("font_color", MUTED_COLOR)
|
||||
llbl.add_theme_font_size_override("font_size", 10)
|
||||
lm.add_child(llbl)
|
||||
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
vbox.add_child(scroll)
|
||||
|
||||
_presence_list = VBoxContainer.new()
|
||||
_presence_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_presence_list.add_theme_constant_override("separation", 0)
|
||||
scroll.add_child(_presence_list)
|
||||
|
||||
return vbox
|
||||
|
||||
|
||||
func _build_channel_tab(tab: Tab) -> Control:
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 0)
|
||||
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
vbox.add_child(scroll)
|
||||
|
||||
var outer_margin := MarginContainer.new()
|
||||
outer_margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
outer_margin.add_theme_constant_override("margin_left", 8)
|
||||
outer_margin.add_theme_constant_override("margin_right", 8)
|
||||
outer_margin.add_theme_constant_override("margin_top", 4)
|
||||
outer_margin.add_theme_constant_override("margin_bottom", 4)
|
||||
scroll.add_child(outer_margin)
|
||||
|
||||
var msg_list := VBoxContainer.new()
|
||||
msg_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
msg_list.add_theme_constant_override("separation", 2)
|
||||
outer_margin.add_child(msg_list)
|
||||
|
||||
match tab:
|
||||
Tab.GLOBAL: _global_list = msg_list
|
||||
Tab.LOBBY: _lobby_list = msg_list
|
||||
Tab.GAME: _game_list = msg_list
|
||||
|
||||
return vbox
|
||||
|
||||
|
||||
func _build_dms_tab() -> Control:
|
||||
var hbox := HBoxContainer.new()
|
||||
hbox.add_theme_constant_override("separation", 0)
|
||||
|
||||
# ── Left: conversation list ───────────────────────────────────────────────
|
||||
var left_vbox := VBoxContainer.new()
|
||||
left_vbox.custom_minimum_size = Vector2(110, 0)
|
||||
left_vbox.add_theme_constant_override("separation", 0)
|
||||
hbox.add_child(left_vbox)
|
||||
|
||||
var conv_scroll := ScrollContainer.new()
|
||||
conv_scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
conv_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
left_vbox.add_child(conv_scroll)
|
||||
|
||||
_dm_conv_list = VBoxContainer.new()
|
||||
_dm_conv_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_dm_conv_list.add_theme_constant_override("separation", 0)
|
||||
conv_scroll.add_child(_dm_conv_list)
|
||||
|
||||
# ── Vertical divider ──────────────────────────────────────────────────────
|
||||
hbox.add_child(VSeparator.new())
|
||||
|
||||
# ── Right: message area ───────────────────────────────────────────────────
|
||||
var right_vbox := VBoxContainer.new()
|
||||
right_vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
right_vbox.add_theme_constant_override("separation", 0)
|
||||
hbox.add_child(right_vbox)
|
||||
|
||||
var msg_scroll := ScrollContainer.new()
|
||||
msg_scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
msg_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
right_vbox.add_child(msg_scroll)
|
||||
|
||||
var msg_margin := MarginContainer.new()
|
||||
msg_margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
msg_margin.add_theme_constant_override("margin_left", 8)
|
||||
msg_margin.add_theme_constant_override("margin_right", 8)
|
||||
msg_margin.add_theme_constant_override("margin_top", 4)
|
||||
msg_margin.add_theme_constant_override("margin_bottom", 4)
|
||||
msg_scroll.add_child(msg_margin)
|
||||
|
||||
_dm_msg_list = VBoxContainer.new()
|
||||
_dm_msg_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_dm_msg_list.add_theme_constant_override("separation", 2)
|
||||
msg_margin.add_child(_dm_msg_list)
|
||||
|
||||
return hbox
|
||||
|
||||
func _build_party_tab() -> Control:
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 0)
|
||||
|
||||
# ── Action bar (Leave / Invite) ───────────────────────────────────────────
|
||||
_party_action_bar = HBoxContainer.new()
|
||||
_party_action_bar.add_theme_constant_override("separation", 4)
|
||||
_party_action_bar.visible = false
|
||||
|
||||
var abm := MarginContainer.new()
|
||||
abm.add_theme_constant_override("margin_left", 8)
|
||||
abm.add_theme_constant_override("margin_right", 8)
|
||||
abm.add_theme_constant_override("margin_top", 4)
|
||||
abm.add_theme_constant_override("margin_bottom", 4)
|
||||
abm.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_party_action_bar.add_child(abm)
|
||||
|
||||
var ab_inner := HBoxContainer.new()
|
||||
ab_inner.add_theme_constant_override("separation", 6)
|
||||
abm.add_child(ab_inner)
|
||||
|
||||
var party_name_lbl := Label.new()
|
||||
party_name_lbl.name = "PartyNameLabel"
|
||||
party_name_lbl.text = "Party"
|
||||
party_name_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
party_name_lbl.add_theme_font_size_override("font_size", 12)
|
||||
party_name_lbl.add_theme_color_override("font_color", SOURCE_COLORS["party"])
|
||||
ab_inner.add_child(party_name_lbl)
|
||||
|
||||
var rename_btn := Button.new()
|
||||
rename_btn.text = "Rename"
|
||||
rename_btn.add_theme_font_size_override("font_size", 11)
|
||||
rename_btn.flat = true
|
||||
rename_btn.pressed.connect(_on_party_rename_pressed)
|
||||
ab_inner.add_child(rename_btn)
|
||||
|
||||
var leave_btn := Button.new()
|
||||
leave_btn.text = "Leave"
|
||||
leave_btn.add_theme_color_override("font_color", DANGER_COLOR)
|
||||
leave_btn.add_theme_font_size_override("font_size", 11)
|
||||
leave_btn.flat = true
|
||||
leave_btn.pressed.connect(_on_party_leave_pressed)
|
||||
ab_inner.add_child(leave_btn)
|
||||
|
||||
vbox.add_child(_party_action_bar)
|
||||
vbox.add_child(_make_separator())
|
||||
|
||||
# ── Message area ──────────────────────────────────────────────────────────
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
vbox.add_child(scroll)
|
||||
|
||||
var outer_margin := MarginContainer.new()
|
||||
outer_margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
outer_margin.add_theme_constant_override("margin_left", 8)
|
||||
outer_margin.add_theme_constant_override("margin_right", 8)
|
||||
outer_margin.add_theme_constant_override("margin_top", 4)
|
||||
outer_margin.add_theme_constant_override("margin_bottom", 4)
|
||||
scroll.add_child(outer_margin)
|
||||
|
||||
_party_msg_list = VBoxContainer.new()
|
||||
_party_msg_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_party_msg_list.add_theme_constant_override("separation", 2)
|
||||
outer_margin.add_child(_party_msg_list)
|
||||
|
||||
return vbox
|
||||
|
||||
# ── Tab switching ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -736,7 +381,6 @@ func _refresh_presence() -> void:
|
||||
status_lbl.text = status
|
||||
status_lbl.add_theme_color_override("font_color", _presence_color(status))
|
||||
status_lbl.add_theme_font_size_override("font_size", 10)
|
||||
row.add_child(status_lbl)
|
||||
|
||||
var rm := MarginContainer.new()
|
||||
rm.add_theme_constant_override("margin_right", 10)
|
||||
@@ -878,12 +522,9 @@ func _refresh_party_tab() -> void:
|
||||
var party_chan := Chat.get_party_channel()
|
||||
var in_party := not party_chan.is_empty()
|
||||
|
||||
if is_instance_valid(_party_action_bar):
|
||||
_party_action_bar.visible = in_party
|
||||
if in_party:
|
||||
var name_lbl := _party_action_bar.find_child("PartyNameLabel", true, false) as Label
|
||||
if is_instance_valid(name_lbl):
|
||||
name_lbl.text = party_chan.get("name", "Party")
|
||||
_party_action_bar.visible = in_party
|
||||
if in_party:
|
||||
_party_name_lbl.text = party_chan.get("name", "Party")
|
||||
|
||||
_input_bar.visible = in_party
|
||||
if in_party:
|
||||
@@ -1297,5 +938,3 @@ func _make_section_label(text: String) -> Control:
|
||||
lbl.add_theme_font_size_override("font_size", 10)
|
||||
m.add_child(lbl)
|
||||
return m
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/ability_row.gd" id="1_ar"]
|
||||
|
||||
[node name="AbilityRow" type="VBoxContainer"]
|
||||
theme_override_constants/separation = 2
|
||||
script = ExtResource("1_ar")
|
||||
|
||||
[node name="NameLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
modulate = Color(0.90, 0.80, 0.50, 1)
|
||||
|
||||
[node name="DescLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
autowrap_mode = 2
|
||||
modulate = Color(0.80, 0.80, 0.85, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
@@ -117,12 +117,10 @@ theme_override_font_sizes/font_size = 13
|
||||
[node name="StatsSep" type="HSeparator" parent="Center/Panel/Scroll/Inner/VBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="StatsGrid" type="GridContainer" parent="Center/Panel/Scroll/Inner/VBox"]
|
||||
[node name="StatsGrid" type="VBoxContainer" parent="Center/Panel/Scroll/Inner/VBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_constants/h_separation = 8
|
||||
theme_override_constants/v_separation = 6
|
||||
columns = 4
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="AbilitiesSep" type="HSeparator" parent="Center/Panel/Scroll/Inner/VBox"]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/deck_editor_panel.gd" id="1_dep"]
|
||||
|
||||
[node name="DeckEditorPanel" type="VBoxContainer"]
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 0
|
||||
script = ExtResource("1_dep")
|
||||
|
||||
[node name="TopPanel" type="PanelContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TopMargin" type="MarginContainer" parent="TopPanel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="TopBar" type="HBoxContainer" parent="TopPanel/TopMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="BackBtn" type="Button" parent="TopPanel/TopMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(80, 32)
|
||||
text = "◄ Back"
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="TopPanel/TopMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Editing deck"
|
||||
text_overrun_behavior = 3
|
||||
theme_override_font_sizes/font_size = 15
|
||||
|
||||
[node name="CountLabel" type="Label" parent="TopPanel/TopMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "0 / 40"
|
||||
modulate = Color(0.75, 0.75, 0.8, 1)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="Split" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="Left" type="VBoxContainer" parent="Split"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="LeftMargin" type="MarginContainer" parent="Split/Left"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="LeftInner" type="VBoxContainer" parent="Split/Left/LeftMargin"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="LeftHeader" type="Label" parent="Split/Left/LeftMargin/LeftInner"]
|
||||
layout_mode = 2
|
||||
text = "Deck Contents"
|
||||
modulate = Color(0.8, 0.8, 0.85, 1)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="DeckLoadingLabel" type="Label" parent="Split/Left/LeftMargin/LeftInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
text = "Loading…"
|
||||
modulate = Color(0.65, 0.65, 0.7, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="DeckScroll" type="ScrollContainer" parent="Split/Left/LeftMargin/LeftInner"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="DeckCardList" type="VBoxContainer" parent="Split/Left/LeftMargin/LeftInner/DeckScroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="VSep" type="VSeparator" parent="Split"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Right" type="VBoxContainer" parent="Split"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="RightMargin" type="MarginContainer" parent="Split/Right"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="RightInner" type="VBoxContainer" parent="Split/Right/RightMargin"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="RightHeader" type="Label" parent="Split/Right/RightMargin/RightInner"]
|
||||
layout_mode = 2
|
||||
text = "Add Cards"
|
||||
modulate = Color(0.8, 0.8, 0.85, 1)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="SearchBar" type="HBoxContainer" parent="Split/Right/RightMargin/RightInner"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="SearchInput" type="LineEdit" parent="Split/Right/RightMargin/RightInner/SearchBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 30)
|
||||
placeholder_text = "Search…"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="TypeOption" type="OptionButton" parent="Split/Right/RightMargin/RightInner/SearchBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(110, 30)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="CollLoadingLabel" type="Label" parent="Split/Right/RightMargin/RightInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
text = "Loading…"
|
||||
modulate = Color(0.65, 0.65, 0.7, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="CollScroll" type="ScrollContainer" parent="Split/Right/RightMargin/RightInner"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="CollList" type="VBoxContainer" parent="Split/Right/RightMargin/RightInner/CollScroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="LoadMoreBtn" type="Button" parent="Split/Right/RightMargin/RightInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
text = "Load More"
|
||||
@@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/stat_row.gd" id="1_sr"]
|
||||
|
||||
[node name="StatRow" type="HBoxContainer"]
|
||||
theme_override_constants/separation = 8
|
||||
script = ExtResource("1_sr")
|
||||
|
||||
[node name="KeyLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(72, 0)
|
||||
modulate = Color(0.65, 0.65, 0.72, 1)
|
||||
|
||||
[node name="ValueLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
@@ -0,0 +1,11 @@
|
||||
extends VBoxContainer
|
||||
## Single ability row used in CardDetailPopup.
|
||||
|
||||
@onready var name_label : Label = %NameLabel
|
||||
@onready var desc_label : Label = %DescLabel
|
||||
|
||||
|
||||
func setup(ability_name: String, description: String) -> void:
|
||||
name_label.text = "[%s]" % ability_name
|
||||
desc_label.text = description
|
||||
desc_label.visible = not description.is_empty()
|
||||
@@ -8,6 +8,8 @@ extends Control
|
||||
## above the VBoxContainer layout regardless of scene structure.
|
||||
|
||||
const _CardWidget = preload("res://scenes/collection/components/card_widget.gd")
|
||||
const _StatRow = preload("res://scenes/collection/components/StatRow.tscn")
|
||||
const _AbilityRow = preload("res://scenes/collection/components/AbilityRow.tscn")
|
||||
|
||||
const RARITY_COLOR := {
|
||||
"Common": Color(0.67, 0.67, 0.67),
|
||||
@@ -27,7 +29,7 @@ const RARITY_COLOR := {
|
||||
@onready var type_label : Label = %TypeLabel
|
||||
@onready var affinity_label : Label = %AffinityLabel
|
||||
@onready var rarity_label : Label = %RarityLabel
|
||||
@onready var stats_grid : GridContainer = %StatsGrid
|
||||
@onready var stats_grid : VBoxContainer = %StatsGrid
|
||||
@onready var abilities_sep : HSeparator = %AbilitiesSep
|
||||
@onready var abilities_title: Label = %AbilitiesTitle
|
||||
@onready var abilities_list : VBoxContainer = %AbilitiesList
|
||||
@@ -81,29 +83,18 @@ func _populate_stats(def: Dictionary) -> void:
|
||||
var dfs : Variant = def.get("maxDefense", null)
|
||||
var mov : Variant = def.get("movementPoints", null)
|
||||
|
||||
_add_stat("Spirit", "◆ %s" % (str(sp) if sp != null else "—"))
|
||||
if st != null and int(st) > 0:
|
||||
_add_stat("Stamina", "⚡ %s" % str(st))
|
||||
else:
|
||||
_add_stat("Stamina", "—")
|
||||
_add_stat("Damage", "⚔ %s" % (str(dmg) if dmg != null else "—"))
|
||||
_add_stat("Health", "♥ %s" % (str(hp) if hp != null else "—"))
|
||||
_add_stat("Defense", "▲ %s" % (str(dfs) if dfs != null else "—"))
|
||||
_add_stat("Move", str(mov) if mov != null else "—")
|
||||
_add_stat("Spirit", "◆ %s" % (str(sp) if sp != null else "—"))
|
||||
_add_stat("Stamina", "⚡ %s" % str(st) if (st != null and int(st) > 0) else "—")
|
||||
_add_stat("Damage", "⚔ %s" % (str(dmg) if dmg != null else "—"))
|
||||
_add_stat("Health", "♥ %s" % (str(hp) if hp != null else "—"))
|
||||
_add_stat("Defense", "▲ %s" % (str(dfs) if dfs != null else "—"))
|
||||
_add_stat("Move", str(mov) if mov != null else "—")
|
||||
|
||||
|
||||
func _add_stat(label_text: String, value_text: String) -> void:
|
||||
var lbl := Label.new()
|
||||
lbl.text = label_text
|
||||
lbl.modulate = Color(0.65, 0.65, 0.72)
|
||||
#lbl.theme_override_font_sizes["font_size"] = 12
|
||||
|
||||
var val := Label.new()
|
||||
val.text = value_text
|
||||
#val.theme_override_font_sizes["font_size"] = 13
|
||||
|
||||
stats_grid.add_child(lbl)
|
||||
stats_grid.add_child(val)
|
||||
func _add_stat(key: String, value: String) -> void:
|
||||
var row := _StatRow.instantiate()
|
||||
row.setup(key, value)
|
||||
stats_grid.add_child(row)
|
||||
|
||||
|
||||
func _populate_abilities(def: Dictionary) -> void:
|
||||
@@ -128,27 +119,12 @@ func _populate_abilities(def: Dictionary) -> void:
|
||||
for ab in parsed as Array:
|
||||
if typeof(ab) != TYPE_DICTIONARY:
|
||||
continue
|
||||
var d := ab as Dictionary
|
||||
var d := ab as Dictionary
|
||||
var name_ := str(d.get("name", d.get("Name", "")))
|
||||
var desc := str(d.get("description", d.get("Description", "")))
|
||||
|
||||
var row := VBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 2)
|
||||
|
||||
var name_lbl := Label.new()
|
||||
name_lbl.text = "[%s]" % name_
|
||||
name_lbl.add_theme_font_size_override("font_size", 13)
|
||||
name_lbl.modulate = Color(0.90, 0.80, 0.50)
|
||||
row.add_child(name_lbl)
|
||||
|
||||
if not desc.is_empty():
|
||||
var desc_lbl := Label.new()
|
||||
desc_lbl.text = desc
|
||||
desc_lbl.add_theme_font_size_override("font_size", 12)
|
||||
desc_lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
desc_lbl.modulate = Color(0.80, 0.80, 0.85)
|
||||
row.add_child(desc_lbl)
|
||||
|
||||
var row := _AbilityRow.instantiate()
|
||||
row.setup(name_, desc)
|
||||
abilities_list.add_child(row)
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
extends VBoxContainer
|
||||
## Deck editor panel — add/remove cards from an existing deck.
|
||||
##
|
||||
## The entire UI is built programmatically in _setup_ui() so no separate
|
||||
## .tscn is needed. Embed this script on a VBoxContainer node in DecksView.
|
||||
##
|
||||
## Usage:
|
||||
## call open_deck(deck_id, deck_name) to load a deck for editing.
|
||||
## connect back_pressed to return to the deck list.
|
||||
@@ -12,17 +9,17 @@ signal back_pressed()
|
||||
|
||||
const PAGE_SIZE := 100
|
||||
|
||||
# ── Node refs (created in _setup_ui) ─────────────────────────────────────────
|
||||
# ── Node refs ─────────────────────────────────────────────────────────────────
|
||||
|
||||
var _title_lbl : Label
|
||||
var _count_lbl : Label
|
||||
var _deck_loading_lbl : Label
|
||||
var _deck_card_list : VBoxContainer
|
||||
var _search_input : LineEdit
|
||||
var _type_option : OptionButton
|
||||
var _coll_loading_lbl : Label
|
||||
var _coll_list : VBoxContainer
|
||||
var _load_more_btn : Button
|
||||
@onready var _title_lbl : Label = %TitleLabel
|
||||
@onready var _count_lbl : Label = %CountLabel
|
||||
@onready var _deck_loading_lbl : Label = %DeckLoadingLabel
|
||||
@onready var _deck_card_list : VBoxContainer = %DeckCardList
|
||||
@onready var _search_input : LineEdit = %SearchInput
|
||||
@onready var _type_option : OptionButton = %TypeOption
|
||||
@onready var _coll_loading_lbl : Label = %CollLoadingLabel
|
||||
@onready var _coll_list : VBoxContainer = %CollList
|
||||
@onready var _load_more_btn : Button = %LoadMoreBtn
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -42,7 +39,11 @@ const _DEBOUNCE := 0.4
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
_setup_ui()
|
||||
%BackBtn.pressed.connect(func(): back_pressed.emit())
|
||||
_search_input.text_changed.connect(_on_search_changed)
|
||||
_type_option.item_selected.connect(func(_i): _reload_collection())
|
||||
_load_more_btn.pressed.connect(_on_load_more)
|
||||
_populate_type_options()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@@ -52,175 +53,6 @@ func _process(delta: float) -> void:
|
||||
_search_timer = 0.0
|
||||
_reload_collection()
|
||||
|
||||
# ── UI construction ───────────────────────────────────────────────────────────
|
||||
|
||||
func _setup_ui() -> void:
|
||||
size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
add_theme_constant_override("separation", 0)
|
||||
|
||||
# Top bar
|
||||
var top_panel := PanelContainer.new()
|
||||
var top_margin := MarginContainer.new()
|
||||
top_margin.add_theme_constant_override("margin_left", 10)
|
||||
top_margin.add_theme_constant_override("margin_right", 10)
|
||||
top_margin.add_theme_constant_override("margin_top", 8)
|
||||
top_margin.add_theme_constant_override("margin_bottom", 8)
|
||||
top_panel.add_child(top_margin)
|
||||
|
||||
var top_bar := HBoxContainer.new()
|
||||
top_bar.add_theme_constant_override("separation", 8)
|
||||
top_margin.add_child(top_bar)
|
||||
|
||||
var back_btn := Button.new()
|
||||
back_btn.text = "◄ Back"
|
||||
back_btn.custom_minimum_size = Vector2(80, 32)
|
||||
back_btn.pressed.connect(func(): back_pressed.emit())
|
||||
top_bar.add_child(back_btn)
|
||||
|
||||
_title_lbl = Label.new()
|
||||
_title_lbl.text = "Editing deck"
|
||||
_title_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_title_lbl.add_theme_font_size_override("font_size", 15)
|
||||
_title_lbl.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||
top_bar.add_child(_title_lbl)
|
||||
|
||||
_count_lbl = Label.new()
|
||||
_count_lbl.text = "0 / 40"
|
||||
_count_lbl.add_theme_font_size_override("font_size", 13)
|
||||
_count_lbl.modulate = Color(0.75, 0.75, 0.8)
|
||||
top_bar.add_child(_count_lbl)
|
||||
|
||||
add_child(top_panel)
|
||||
|
||||
# Split area
|
||||
var split := HBoxContainer.new()
|
||||
split.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
split.add_theme_constant_override("separation", 0)
|
||||
|
||||
var left := _make_left_pane()
|
||||
left.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
split.add_child(left)
|
||||
|
||||
var vsep := VSeparator.new()
|
||||
split.add_child(vsep)
|
||||
|
||||
var right := _make_right_pane()
|
||||
right.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
split.add_child(right)
|
||||
|
||||
add_child(split)
|
||||
|
||||
|
||||
func _make_left_pane() -> VBoxContainer:
|
||||
var pane := VBoxContainer.new()
|
||||
pane.add_theme_constant_override("separation", 4)
|
||||
|
||||
var margin := MarginContainer.new()
|
||||
margin.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
margin.add_theme_constant_override("margin_left", 8)
|
||||
margin.add_theme_constant_override("margin_right", 8)
|
||||
margin.add_theme_constant_override("margin_top", 6)
|
||||
margin.add_theme_constant_override("margin_bottom", 6)
|
||||
pane.add_child(margin)
|
||||
|
||||
var inner := VBoxContainer.new()
|
||||
inner.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
inner.add_theme_constant_override("separation", 4)
|
||||
margin.add_child(inner)
|
||||
|
||||
var hdr := Label.new()
|
||||
hdr.text = "Deck Contents"
|
||||
hdr.add_theme_font_size_override("font_size", 13)
|
||||
hdr.modulate = Color(0.8, 0.8, 0.85)
|
||||
inner.add_child(hdr)
|
||||
|
||||
_deck_loading_lbl = Label.new()
|
||||
_deck_loading_lbl.text = "Loading…"
|
||||
_deck_loading_lbl.modulate = Color(0.65, 0.65, 0.7)
|
||||
_deck_loading_lbl.add_theme_font_size_override("font_size", 12)
|
||||
_deck_loading_lbl.visible = false
|
||||
inner.add_child(_deck_loading_lbl)
|
||||
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
inner.add_child(scroll)
|
||||
|
||||
_deck_card_list = VBoxContainer.new()
|
||||
_deck_card_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_deck_card_list.add_theme_constant_override("separation", 2)
|
||||
scroll.add_child(_deck_card_list)
|
||||
|
||||
return pane
|
||||
|
||||
|
||||
func _make_right_pane() -> VBoxContainer:
|
||||
var pane := VBoxContainer.new()
|
||||
pane.add_theme_constant_override("separation", 4)
|
||||
|
||||
var margin := MarginContainer.new()
|
||||
margin.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
margin.add_theme_constant_override("margin_left", 8)
|
||||
margin.add_theme_constant_override("margin_right", 8)
|
||||
margin.add_theme_constant_override("margin_top", 6)
|
||||
margin.add_theme_constant_override("margin_bottom", 6)
|
||||
pane.add_child(margin)
|
||||
|
||||
var inner := VBoxContainer.new()
|
||||
inner.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
inner.add_theme_constant_override("separation", 4)
|
||||
margin.add_child(inner)
|
||||
|
||||
var hdr := Label.new()
|
||||
hdr.text = "Add Cards"
|
||||
hdr.add_theme_font_size_override("font_size", 13)
|
||||
hdr.modulate = Color(0.8, 0.8, 0.85)
|
||||
inner.add_child(hdr)
|
||||
|
||||
var search_bar := HBoxContainer.new()
|
||||
search_bar.add_theme_constant_override("separation", 4)
|
||||
inner.add_child(search_bar)
|
||||
|
||||
_search_input = LineEdit.new()
|
||||
_search_input.placeholder_text = "Search…"
|
||||
_search_input.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_search_input.custom_minimum_size = Vector2(0, 30)
|
||||
_search_input.add_theme_font_size_override("font_size", 13)
|
||||
_search_input.text_changed.connect(_on_search_changed)
|
||||
search_bar.add_child(_search_input)
|
||||
|
||||
_type_option = OptionButton.new()
|
||||
_type_option.custom_minimum_size = Vector2(110, 30)
|
||||
_type_option.add_theme_font_size_override("font_size", 12)
|
||||
_type_option.item_selected.connect(func(_i): _reload_collection())
|
||||
_populate_type_options()
|
||||
search_bar.add_child(_type_option)
|
||||
|
||||
_coll_loading_lbl = Label.new()
|
||||
_coll_loading_lbl.text = "Loading…"
|
||||
_coll_loading_lbl.modulate = Color(0.65, 0.65, 0.7)
|
||||
_coll_loading_lbl.add_theme_font_size_override("font_size", 12)
|
||||
_coll_loading_lbl.visible = false
|
||||
inner.add_child(_coll_loading_lbl)
|
||||
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
inner.add_child(scroll)
|
||||
|
||||
_coll_list = VBoxContainer.new()
|
||||
_coll_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_coll_list.add_theme_constant_override("separation", 2)
|
||||
scroll.add_child(_coll_list)
|
||||
|
||||
_load_more_btn = Button.new()
|
||||
_load_more_btn.text = "Load More"
|
||||
_load_more_btn.visible = false
|
||||
_load_more_btn.pressed.connect(_on_load_more)
|
||||
inner.add_child(_load_more_btn)
|
||||
|
||||
return pane
|
||||
|
||||
|
||||
func _populate_type_options() -> void:
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
extends HBoxContainer
|
||||
## Single stat key/value row used in CardDetailPopup.
|
||||
|
||||
@onready var key_label : Label = %KeyLabel
|
||||
@onready var value_label : Label = %ValueLabel
|
||||
|
||||
|
||||
func setup(key: String, value: String) -> void:
|
||||
key_label.text = key
|
||||
value_label.text = value
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/views/decks_view.gd" id="1_dv"]
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/deck_editor_panel.gd" id="2_dep"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/collection/components/DeckEditorPanel.tscn" id="2_dep"]
|
||||
|
||||
[node name="DecksView" type="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
@@ -143,12 +143,11 @@ visible = false
|
||||
modulate = Color(0.6, 0.6, 0.65, 1.0)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
|
||||
[node name="DeckEditorPanel" type="VBoxContainer" parent="."]
|
||||
[node name="DeckEditorPanel" parent="." instance=ExtResource("2_dep")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
visible = false
|
||||
script = ExtResource("2_dep")
|
||||
|
||||
[node name="ConfirmDialog" type="ConfirmationDialog" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/common/components/deck_picker_button.gd" id="1_dpb"]
|
||||
|
||||
[node name="DeckPickerButton" type="Button"]
|
||||
script = ExtResource("1_dpb")
|
||||
@@ -0,0 +1,18 @@
|
||||
extends Button
|
||||
## Reusable deck-picker button — shows deck name + card count and emits picked(id).
|
||||
|
||||
signal picked(id: String)
|
||||
|
||||
var _id : String = ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
add_theme_font_size_override("font_size", 14)
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
pressed.connect(func(): picked.emit(_id))
|
||||
|
||||
|
||||
func setup(id: String, deck_name: String, card_count: int) -> void:
|
||||
_id = id
|
||||
text = "%s (%d cards)" % [deck_name, card_count]
|
||||
@@ -0,0 +1,27 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/free_play/components/active_game_row.gd" id="1_agr"]
|
||||
|
||||
[node name="ActiveGameRow" type="VBoxContainer"]
|
||||
script = ExtResource("1_agr")
|
||||
|
||||
[node name="Row" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 48)
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="MatchupLabel" type="Label" parent="Row"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
clip_text = true
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="SpectateBtn" type="Button" parent="Row"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(80, 0)
|
||||
text = "Spectate"
|
||||
|
||||
[node name="Sep" type="HSeparator" parent="."]
|
||||
layout_mode = 2
|
||||
@@ -0,0 +1,41 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/free_play/components/lobby_browser_row.gd" id="1_lbr"]
|
||||
|
||||
[node name="LobbyBrowserRow" type="VBoxContainer"]
|
||||
script = ExtResource("1_lbr")
|
||||
|
||||
[node name="Row" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 48)
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="PasswordIcon" type="Label" parent="Row"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "🔒"
|
||||
visible = false
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="NameLabel" type="Label" parent="Row"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
clip_text = true
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="HostLabel" type="Label" parent="Row"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
modulate = Color(0.65, 0.65, 0.7, 1)
|
||||
vertical_alignment = 1
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="JoinBtn" type="Button" parent="Row"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(70, 0)
|
||||
text = "Join"
|
||||
|
||||
[node name="Sep" type="HSeparator" parent="."]
|
||||
layout_mode = 2
|
||||
@@ -0,0 +1,65 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/free_play/components/rules_editor_dialog.gd" id="1_red"]
|
||||
|
||||
[node name="RulesEditorDialog" type="Window"]
|
||||
title = "Rules Editor"
|
||||
initial_position = 1
|
||||
size = Vector2i(480, 600)
|
||||
exclusive = true
|
||||
script = ExtResource("1_red")
|
||||
|
||||
[node name="RootVBox" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="RootVBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="FieldsMargin" type="MarginContainer" parent="RootVBox/Scroll"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="FieldsBox" type="VBoxContainer" parent="RootVBox/Scroll/FieldsMargin"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="FooterSep" type="HSeparator" parent="RootVBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="FooterMargin" type="MarginContainer" parent="RootVBox"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="BtnRow" type="HBoxContainer" parent="RootVBox/FooterMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="Spacer" type="Control" parent="RootVBox/FooterMargin/BtnRow"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="CancelBtn" type="Button" parent="RootVBox/FooterMargin/BtnRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Cancel"
|
||||
|
||||
[node name="ConfirmBtn" type="Button" parent="RootVBox/FooterMargin/BtnRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Apply"
|
||||
@@ -0,0 +1,24 @@
|
||||
extends VBoxContainer
|
||||
## Single row in the active-games list.
|
||||
|
||||
signal spectate_requested(session_id: String)
|
||||
|
||||
@onready var matchup_label : Label = %MatchupLabel
|
||||
@onready var spectate_btn : Button = %SpectateBtn
|
||||
|
||||
var _session_id : String = ""
|
||||
|
||||
|
||||
func setup(game: Dictionary) -> void:
|
||||
var host_name : String = game.get("hostDisplayName", "?")
|
||||
var guest_name : String = game.get("guestDisplayName", "?")
|
||||
var has_pw : bool = game.get("hasPassword", false)
|
||||
|
||||
_session_id = str(game.get("gameSessionId", ""))
|
||||
|
||||
matchup_label.text = "%s%s — %s vs %s" % [
|
||||
"🔒 " if has_pw else "",
|
||||
game.get("lobbyName", "?"),
|
||||
host_name, guest_name
|
||||
]
|
||||
spectate_btn.pressed.connect(func(): spectate_requested.emit(_session_id), CONNECT_ONE_SHOT)
|
||||
@@ -0,0 +1,27 @@
|
||||
extends VBoxContainer
|
||||
## Single row in the open-lobby browser.
|
||||
|
||||
signal join_requested(lobby_id: String, has_password: bool)
|
||||
|
||||
@onready var name_label : Label = %NameLabel
|
||||
@onready var host_label : Label = %HostLabel
|
||||
@onready var password_icon : Label = %PasswordIcon
|
||||
@onready var join_btn : Button = %JoinBtn
|
||||
|
||||
var _lobby_id : String = ""
|
||||
var _has_password: bool = false
|
||||
|
||||
|
||||
func setup(lobby: Dictionary, has_deck: bool) -> void:
|
||||
var has_pw : bool = lobby.get("rules", {}).get("hasPassword", false)
|
||||
var has_guest : bool = lobby.get("hasGuest", false)
|
||||
var host_name : String = lobby.get("hostDisplayName", "?")
|
||||
|
||||
_lobby_id = str(lobby.get("lobbyId", ""))
|
||||
_has_password = has_pw
|
||||
|
||||
name_label.text = lobby.get("lobbyName", "?")
|
||||
host_label.text = "Host: %s [%s]" % [host_name, "2/2" if has_guest else "1/2"]
|
||||
password_icon.visible = has_pw
|
||||
join_btn.disabled = not has_deck
|
||||
join_btn.pressed.connect(func(): join_requested.emit(_lobby_id, _has_password), CONNECT_ONE_SHOT)
|
||||
@@ -0,0 +1,128 @@
|
||||
extends Window
|
||||
## Standalone rules-editor dialog.
|
||||
##
|
||||
## Usage:
|
||||
## var dlg = RulesEditorDialog.instantiate()
|
||||
## dlg.setup(current_rules, is_host)
|
||||
## dlg.confirmed.connect(_on_rules_confirmed)
|
||||
## dlg.cancelled.connect(func(): dlg.queue_free())
|
||||
## add_child(dlg)
|
||||
## dlg.popup()
|
||||
|
||||
signal confirmed(overrides: Dictionary)
|
||||
signal cancelled
|
||||
|
||||
@onready var fields_box : VBoxContainer = %FieldsBox
|
||||
@onready var cancel_btn : Button = %CancelBtn
|
||||
@onready var confirm_btn : Button = %ConfirmBtn
|
||||
|
||||
var _controls : Dictionary = {}
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
cancel_btn.pressed.connect(func(): cancelled.emit(); queue_free())
|
||||
confirm_btn.pressed.connect(_on_confirm)
|
||||
close_requested.connect(func(): cancelled.emit(); queue_free())
|
||||
|
||||
|
||||
func setup(current_rules: Dictionary, is_host: bool) -> void:
|
||||
title = "Edit Rules" if is_host else "Suggest Rules"
|
||||
confirm_btn.text = "Apply" if is_host else "Suggest"
|
||||
_build_fields(current_rules)
|
||||
|
||||
|
||||
func _build_fields(r: Dictionary) -> void:
|
||||
_controls.clear()
|
||||
for child in fields_box.get_children():
|
||||
child.queue_free()
|
||||
|
||||
var get_i := func(k: String, d: int) -> int:
|
||||
return int(r[k]) if r.has(k) else d
|
||||
var get_b := func(k: String, d: bool) -> bool:
|
||||
return bool(r[k]) if r.has(k) else d
|
||||
|
||||
var add_int := func(label: String, key: String, min_v: int, max_v: int, def_v: int, note: String) -> void:
|
||||
var hbox := HBoxContainer.new()
|
||||
var lbl := Label.new()
|
||||
lbl.text = label
|
||||
lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
if note != "":
|
||||
lbl.tooltip_text = note
|
||||
hbox.add_child(lbl)
|
||||
var spin := SpinBox.new()
|
||||
spin.min_value = min_v
|
||||
spin.max_value = max_v
|
||||
spin.value = get_i.call(key, def_v)
|
||||
spin.custom_minimum_size = Vector2(90, 0)
|
||||
hbox.add_child(spin)
|
||||
fields_box.add_child(hbox)
|
||||
_controls[key] = spin
|
||||
|
||||
var add_bool := func(label: String, key: String, def_v: bool) -> void:
|
||||
var hbox := HBoxContainer.new()
|
||||
var lbl := Label.new()
|
||||
lbl.text = label
|
||||
lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
hbox.add_child(lbl)
|
||||
var chk := CheckBox.new()
|
||||
chk.button_pressed = get_b.call(key, def_v)
|
||||
hbox.add_child(chk)
|
||||
fields_box.add_child(hbox)
|
||||
_controls[key] = chk
|
||||
|
||||
# ── Hand & Cards ──────────────────────────────────────────────────────────
|
||||
_section("HAND & CARDS")
|
||||
add_int.call("Opening Hand Size", "openingHandSize", 1, 20, 6, "")
|
||||
add_int.call("Draw Per Turn", "drawPerTurn", 1, 10, 1, "")
|
||||
add_int.call("Hand Size Cap", "handSizeCap", 0, 20, 0, "0 = no cap")
|
||||
add_bool.call("Discard on Max Hand", "discardOnMaxHand", false)
|
||||
|
||||
# ── SP ─────────────────────────────────────────────────────────────────────
|
||||
_section("SP")
|
||||
add_int.call("SP Per Turn", "spAccumulationPerTurn", 1, 20, 3, "")
|
||||
add_bool.call("SP Has Cap", "spHasCap", false)
|
||||
add_int.call("SP Cap", "spCap", 1, 100, 10, "")
|
||||
|
||||
# ── Timers & Limits ────────────────────────────────────────────────────────
|
||||
_section("TIMERS & LIMITS")
|
||||
add_int.call("Turn Timer (s)", "turnTimerSeconds", 0, 300, 0, "0 = no timer")
|
||||
add_int.call("Time Limit (min)", "timeLimitMinutes", 0, 120, 0, "0 = no limit")
|
||||
add_int.call("Turn Limit", "turnLimit", 0, 200, 0, "0 = no limit")
|
||||
|
||||
# ── Board ──────────────────────────────────────────────────────────────────
|
||||
_section("BOARD")
|
||||
add_int.call("Board Width", "boardWidth", 3, 12, 6, "")
|
||||
add_int.call("Board Height", "boardHeight", 3, 12, 6, "")
|
||||
add_int.call("Starting Tile Affinity %","startingRandomTilePct",0, 100, 0, "% of tiles with a random basic affinity")
|
||||
|
||||
# ── Deck ───────────────────────────────────────────────────────────────────
|
||||
_section("DECK")
|
||||
add_int.call("Min Deck Size", "minDeckSize", 0, 60, 0, "0 = no limit")
|
||||
add_int.call("Max Deck Size", "maxDeckSize", 0, 120, 0, "0 = no limit")
|
||||
add_int.call("Max Arch Tier-1", "maxArchTier1", 0, 10, 0, "0 = no limit")
|
||||
|
||||
# ── Misc ───────────────────────────────────────────────────────────────────
|
||||
_section("MISC")
|
||||
add_bool.call("First Player Skips Draw","firstPlayerSkipsDraw", false)
|
||||
add_int.call("MP Buff Per Turn", "mpBuff", 0, 20, 0, "Flat MP added to each unit at turn start")
|
||||
|
||||
|
||||
func _section(title: String) -> void:
|
||||
fields_box.add_child(HSeparator.new())
|
||||
var lbl := Label.new()
|
||||
lbl.text = title
|
||||
lbl.modulate = Color(0.6, 0.6, 0.65)
|
||||
lbl.add_theme_font_size_override("font_size", 11)
|
||||
fields_box.add_child(lbl)
|
||||
|
||||
|
||||
func _on_confirm() -> void:
|
||||
var overrides := {}
|
||||
for key in _controls:
|
||||
var ctrl = _controls[key]
|
||||
if ctrl is SpinBox:
|
||||
overrides[key] = int(ctrl.value)
|
||||
elif ctrl is CheckBox:
|
||||
overrides[key] = ctrl.button_pressed
|
||||
confirmed.emit(overrides)
|
||||
queue_free()
|
||||
@@ -1,6 +1,10 @@
|
||||
extends Control
|
||||
## FreePlayScreen — browse open lobbies, active games, and create new lobbies.
|
||||
|
||||
const LOBBY_ROW = preload("res://scenes/free_play/components/LobbyBrowserRow.tscn")
|
||||
const ACTIVE_ROW = preload("res://scenes/free_play/components/ActiveGameRow.tscn")
|
||||
const DECK_BTN = preload("res://scenes/common/components/DeckPickerButton.tscn")
|
||||
|
||||
# ── Node refs ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@onready var back_btn : Button = $Layout/Header/HeaderMargin/HeaderInner/BackBtn
|
||||
@@ -126,8 +130,19 @@ func _populate_open_lobbies() -> void:
|
||||
lbl.modulate = Color(0.6, 0.6, 0.6)
|
||||
lobby_list_container.add_child(lbl)
|
||||
return
|
||||
var has_deck := not _selected_deck.is_empty()
|
||||
for lobby in _open_lobbies:
|
||||
lobby_list_container.add_child(_make_lobby_row(lobby))
|
||||
var row := LOBBY_ROW.instantiate()
|
||||
row.setup(lobby, has_deck)
|
||||
row.join_requested.connect(_on_row_join_requested)
|
||||
lobby_list_container.add_child(row)
|
||||
|
||||
|
||||
func _on_row_join_requested(lobby_id: String, _has_password: bool) -> void:
|
||||
for lobby in _open_lobbies:
|
||||
if str(lobby.get("lobbyId", "")) == lobby_id:
|
||||
_on_join_pressed(lobby)
|
||||
return
|
||||
|
||||
|
||||
func _populate_active_games() -> void:
|
||||
@@ -140,69 +155,10 @@ func _populate_active_games() -> void:
|
||||
active_list_container.add_child(lbl)
|
||||
return
|
||||
for game in _active_games:
|
||||
active_list_container.add_child(_make_active_game_row(game))
|
||||
|
||||
|
||||
func _make_lobby_row(lobby: Dictionary) -> Control:
|
||||
var row := HBoxContainer.new()
|
||||
row.custom_minimum_size = Vector2(0, 48)
|
||||
|
||||
var name_lbl := Label.new()
|
||||
var has_pw : bool = lobby.get("rules", {}).get("hasPassword", false)
|
||||
var has_guest : bool = lobby.get("hasGuest", false)
|
||||
var host_name : String = lobby.get("hostDisplayName", "?")
|
||||
name_lbl.text = "%s%s — Host: %s [%s]" % [
|
||||
"🔒 " if has_pw else "",
|
||||
lobby.get("lobbyName", "?"),
|
||||
host_name,
|
||||
"2/2" if has_guest else "1/2"
|
||||
]
|
||||
name_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
name_lbl.clip_text = true
|
||||
row.add_child(name_lbl)
|
||||
|
||||
var join_btn := Button.new()
|
||||
join_btn.text = "Join"
|
||||
join_btn.custom_minimum_size = Vector2(70, 0)
|
||||
join_btn.pressed.connect(func(): _on_join_pressed(lobby))
|
||||
row.add_child(join_btn)
|
||||
|
||||
var sep := HSeparator.new()
|
||||
var wrapper := VBoxContainer.new()
|
||||
wrapper.add_child(row)
|
||||
wrapper.add_child(sep)
|
||||
return wrapper
|
||||
|
||||
|
||||
func _make_active_game_row(game: Dictionary) -> Control:
|
||||
var row := HBoxContainer.new()
|
||||
row.custom_minimum_size = Vector2(0, 48)
|
||||
|
||||
var name_lbl := Label.new()
|
||||
var host_name : String = game.get("hostDisplayName", "?")
|
||||
var guest_name : String = game.get("guestDisplayName", "?")
|
||||
var has_pw : bool = game.get("hasPassword", false)
|
||||
name_lbl.text = "%s%s — %s vs %s" % [
|
||||
"🔒 " if has_pw else "",
|
||||
game.get("lobbyName", "?"),
|
||||
host_name, guest_name
|
||||
]
|
||||
name_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
name_lbl.clip_text = true
|
||||
row.add_child(name_lbl)
|
||||
|
||||
var spectate_btn := Button.new()
|
||||
spectate_btn.text = "Spectate"
|
||||
spectate_btn.custom_minimum_size = Vector2(80, 0)
|
||||
var session_id : String = str(game.get("gameSessionId", ""))
|
||||
spectate_btn.pressed.connect(func(): _on_spectate_pressed(session_id))
|
||||
row.add_child(spectate_btn)
|
||||
|
||||
var sep := HSeparator.new()
|
||||
var wrapper := VBoxContainer.new()
|
||||
wrapper.add_child(row)
|
||||
wrapper.add_child(sep)
|
||||
return wrapper
|
||||
var row := ACTIVE_ROW.instantiate()
|
||||
row.setup(game)
|
||||
row.spectate_requested.connect(_on_spectate_pressed)
|
||||
active_list_container.add_child(row)
|
||||
|
||||
|
||||
func _populate_create_deck_buttons() -> void:
|
||||
@@ -220,15 +176,14 @@ func _populate_create_deck_buttons() -> void:
|
||||
for i in range(_all_decks.size()):
|
||||
var deck := _all_decks[i] as Dictionary
|
||||
var did : String = str(deck.get("id", ""))
|
||||
var name : String = str(deck.get("name", "Unnamed Deck"))
|
||||
var btn := Button.new()
|
||||
btn.text = name
|
||||
btn.toggle_mode = true
|
||||
var btn := DECK_BTN.instantiate()
|
||||
btn.toggle_mode = true
|
||||
btn.button_group = _deck_btn_group
|
||||
# Auto-press first button to reflect the auto-selected deck.
|
||||
if i == 0:
|
||||
btn.button_pressed = true
|
||||
btn.pressed.connect(func(): _selected_deck = did)
|
||||
btn.setup(did, str(deck.get("name", "Unnamed Deck")), int(deck.get("cardCount", 0)))
|
||||
btn.picked.connect(func(id: String): _selected_deck = id)
|
||||
deck_select_container.add_child(btn)
|
||||
|
||||
# ── Action handlers ───────────────────────────────────────────────────────────
|
||||
@@ -260,14 +215,13 @@ func _show_join_deck_picker() -> void:
|
||||
for i in range(_all_decks.size()):
|
||||
var deck := _all_decks[i] as Dictionary
|
||||
var did : String = str(deck.get("id", ""))
|
||||
var name : String = str(deck.get("name", "Unnamed Deck"))
|
||||
var btn := Button.new()
|
||||
btn.text = name
|
||||
btn.toggle_mode = true
|
||||
var btn := DECK_BTN.instantiate()
|
||||
btn.toggle_mode = true
|
||||
btn.button_group = grp
|
||||
if _selected_deck == did or (i == 0 and _selected_deck.is_empty()):
|
||||
btn.button_pressed = true
|
||||
btn.pressed.connect(func(): _selected_deck = did)
|
||||
btn.setup(did, str(deck.get("name", "Unnamed Deck")), int(deck.get("cardCount", 0)))
|
||||
btn.picked.connect(func(id: String): _selected_deck = id)
|
||||
vbox.add_child(btn)
|
||||
|
||||
dialog.confirmed.connect(func():
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
extends Control
|
||||
## LobbyRoomScreen — lobby room where host and guest prepare before starting.
|
||||
|
||||
const RULES_DIALOG = preload("res://scenes/free_play/components/RulesEditorDialog.tscn")
|
||||
##
|
||||
## Layout:
|
||||
## VBox
|
||||
@@ -350,167 +352,20 @@ func _on_deck_picker_confirmed() -> void:
|
||||
|
||||
|
||||
func _on_edit_rules_pressed() -> void:
|
||||
_open_rules_editor()
|
||||
var dlg := RULES_DIALOG.instantiate()
|
||||
dlg.setup(_current_rules, CustomLobby.is_host)
|
||||
dlg.confirmed.connect(_on_rules_dialog_confirmed)
|
||||
add_child(dlg)
|
||||
dlg.popup_centered()
|
||||
|
||||
|
||||
## Builds and shows a modal rules editor popup.
|
||||
## Host: "Apply" commits the new overrides directly.
|
||||
## Guest: "Suggest" sends them to the host for approval.
|
||||
func _open_rules_editor() -> void:
|
||||
var is_host := CustomLobby.is_host
|
||||
var win := Window.new()
|
||||
win.title = "Edit Rules" if is_host else "Suggest Rules"
|
||||
win.initial_position = Window.WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN
|
||||
win.size = Vector2i(480, 600)
|
||||
win.exclusive = true
|
||||
|
||||
var root_vbox := VBoxContainer.new()
|
||||
root_vbox.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
root_vbox.add_theme_constant_override("separation", 0)
|
||||
win.add_child(root_vbox)
|
||||
|
||||
# Scrollable field area
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
root_vbox.add_child(scroll)
|
||||
|
||||
var inner_margin := MarginContainer.new()
|
||||
for side in ["margin_left", "margin_right", "margin_top", "margin_bottom"]:
|
||||
inner_margin.add_theme_constant_override(side, 12)
|
||||
inner_margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
scroll.add_child(inner_margin)
|
||||
|
||||
var inner := VBoxContainer.new()
|
||||
inner.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
inner.add_theme_constant_override("separation", 8)
|
||||
inner_margin.add_child(inner)
|
||||
|
||||
# Collect controls keyed by camelCase field name
|
||||
var controls : Dictionary = {}
|
||||
var r := _current_rules
|
||||
|
||||
# Value helpers — read current effective value or fall back to game default
|
||||
var get_i := func(k: String, d: int) -> int:
|
||||
return int(r[k]) if r.has(k) else d
|
||||
var get_b := func(k: String, d: bool) -> bool:
|
||||
return bool(r[k]) if r.has(k) else d
|
||||
|
||||
# Row builders
|
||||
var add_int := func(label: String, key: String, min_v: int, max_v: int, def_v: int, note: String) -> void:
|
||||
var hbox := HBoxContainer.new()
|
||||
var lbl := Label.new()
|
||||
lbl.text = label
|
||||
lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
if note != "":
|
||||
lbl.tooltip_text = note
|
||||
hbox.add_child(lbl)
|
||||
var spin := SpinBox.new()
|
||||
spin.min_value = min_v
|
||||
spin.max_value = max_v
|
||||
spin.value = get_i.call(key, def_v)
|
||||
spin.custom_minimum_size = Vector2(90, 0)
|
||||
hbox.add_child(spin)
|
||||
inner.add_child(hbox)
|
||||
controls[key] = spin
|
||||
|
||||
var add_bool := func(label: String, key: String, def_v: bool) -> void:
|
||||
var hbox := HBoxContainer.new()
|
||||
var lbl := Label.new()
|
||||
lbl.text = label
|
||||
lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
hbox.add_child(lbl)
|
||||
var chk := CheckBox.new()
|
||||
chk.button_pressed = get_b.call(key, def_v)
|
||||
hbox.add_child(chk)
|
||||
inner.add_child(hbox)
|
||||
controls[key] = chk
|
||||
|
||||
# ── Hand & Cards ──────────────────────────────────────────────────────────
|
||||
_section_label(inner, "HAND & CARDS")
|
||||
add_int.call("Opening Hand Size", "openingHandSize", 1, 20, 6, "")
|
||||
add_int.call("Draw Per Turn", "drawPerTurn", 1, 10, 1, "")
|
||||
add_int.call("Hand Size Cap", "handSizeCap", 0, 20, 0, "0 = no cap")
|
||||
add_bool.call("Discard on Max Hand", "discardOnMaxHand", false)
|
||||
|
||||
# ── SP ─────────────────────────────────────────────────────────────────────
|
||||
_section_label(inner, "SP")
|
||||
add_int.call("SP Per Turn", "spAccumulationPerTurn", 1, 20, 3, "")
|
||||
add_bool.call("SP Has Cap", "spHasCap", false)
|
||||
add_int.call("SP Cap", "spCap", 1, 100, 10, "")
|
||||
|
||||
# ── Timers & Limits ────────────────────────────────────────────────────────
|
||||
_section_label(inner, "TIMERS & LIMITS")
|
||||
add_int.call("Turn Timer (s)", "turnTimerSeconds", 0, 300, 0, "0 = no timer")
|
||||
add_int.call("Time Limit (min)", "timeLimitMinutes", 0, 120, 0, "0 = no limit")
|
||||
add_int.call("Turn Limit", "turnLimit", 0, 200, 0, "0 = no limit")
|
||||
|
||||
# ── Board ──────────────────────────────────────────────────────────────────
|
||||
_section_label(inner, "BOARD")
|
||||
add_int.call("Board Width", "boardWidth", 3, 12, 6, "")
|
||||
add_int.call("Board Height", "boardHeight", 3, 12, 6, "")
|
||||
add_int.call("Starting Tile Affinity %","startingRandomTilePct", 0, 100, 0, "% of tiles that start with a random basic affinity (0 = all void)")
|
||||
|
||||
# ── Deck ───────────────────────────────────────────────────────────────────
|
||||
_section_label(inner, "DECK")
|
||||
add_int.call("Min Deck Size", "minDeckSize", 0, 60, 0, "0 = no limit")
|
||||
add_int.call("Max Deck Size", "maxDeckSize", 0, 120, 0, "0 = no limit")
|
||||
add_int.call("Max Arch Tier-1", "maxArchTier1", 0, 10, 0, "0 = no limit")
|
||||
|
||||
# ── Misc ───────────────────────────────────────────────────────────────────
|
||||
_section_label(inner, "MISC")
|
||||
add_bool.call("First Player Skips Draw","firstPlayerSkipsDraw", false)
|
||||
add_int.call("MP Buff Per Turn", "mpBuff", 0, 20, 0, "Flat MP added to each unit at turn start")
|
||||
|
||||
# ── Footer ─────────────────────────────────────────────────────────────────
|
||||
root_vbox.add_child(HSeparator.new())
|
||||
|
||||
var footer_margin := MarginContainer.new()
|
||||
for side in ["margin_left", "margin_right", "margin_top", "margin_bottom"]:
|
||||
footer_margin.add_theme_constant_override(side, 8)
|
||||
root_vbox.add_child(footer_margin)
|
||||
|
||||
var btn_row := HBoxContainer.new()
|
||||
btn_row.add_theme_constant_override("separation", 8)
|
||||
footer_margin.add_child(btn_row)
|
||||
|
||||
var spacer := Control.new()
|
||||
spacer.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
btn_row.add_child(spacer)
|
||||
|
||||
var cancel_btn := Button.new()
|
||||
cancel_btn.text = "Cancel"
|
||||
cancel_btn.pressed.connect(func(): win.queue_free())
|
||||
btn_row.add_child(cancel_btn)
|
||||
|
||||
var confirm_btn := Button.new()
|
||||
confirm_btn.text = "Apply" if is_host else "Suggest"
|
||||
confirm_btn.pressed.connect(func():
|
||||
var overrides := {}
|
||||
for key in controls:
|
||||
var ctrl = controls[key]
|
||||
if ctrl is SpinBox:
|
||||
overrides[key] = int(ctrl.value)
|
||||
elif ctrl is CheckBox:
|
||||
overrides[key] = ctrl.button_pressed
|
||||
win.queue_free()
|
||||
if is_host:
|
||||
CustomLobby.update_rules(overrides)
|
||||
else:
|
||||
CustomLobby.suggest_rules(overrides))
|
||||
btn_row.add_child(confirm_btn)
|
||||
|
||||
add_child(win)
|
||||
win.popup()
|
||||
func _on_rules_dialog_confirmed(overrides: Dictionary) -> void:
|
||||
if CustomLobby.is_host:
|
||||
CustomLobby.update_rules(overrides)
|
||||
else:
|
||||
CustomLobby.suggest_rules(overrides)
|
||||
|
||||
|
||||
## Inserts a small section heading into an inner VBoxContainer.
|
||||
func _section_label(container: VBoxContainer, title: String) -> void:
|
||||
container.add_child(HSeparator.new())
|
||||
var lbl := Label.new()
|
||||
lbl.text = title
|
||||
lbl.modulate = Color(0.6, 0.6, 0.65)
|
||||
lbl.add_theme_font_size_override("font_size", 11)
|
||||
container.add_child(lbl)
|
||||
|
||||
|
||||
func _on_save_preset_pressed() -> void:
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/leaderboard/components/leaderboard_row.gd" id="1_lr"]
|
||||
|
||||
[node name="LeaderboardRow" type="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(0, 40)
|
||||
theme_override_constants/separation = 12
|
||||
script = ExtResource("1_lr")
|
||||
|
||||
[node name="RankLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(48, 0)
|
||||
horizontal_alignment = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
|
||||
[node name="NameLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 14
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(80, 0)
|
||||
horizontal_alignment = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
@@ -0,0 +1,16 @@
|
||||
extends HBoxContainer
|
||||
## Single leaderboard entry row.
|
||||
|
||||
@onready var rank_label : Label = %RankLabel
|
||||
@onready var name_label : Label = %NameLabel
|
||||
@onready var score_label : Label = %ScoreLabel
|
||||
|
||||
|
||||
func setup(rank: int, display_name: String, score: int, is_self: bool, is_top3: bool) -> void:
|
||||
rank_label.text = "#%d" % rank
|
||||
name_label.text = display_name
|
||||
score_label.text = str(score)
|
||||
if is_top3:
|
||||
rank_label.modulate = Color(0.95, 0.85, 0.30)
|
||||
if is_self:
|
||||
name_label.modulate = Color(0.5, 0.9, 1.0)
|
||||
@@ -1,6 +1,8 @@
|
||||
extends Control
|
||||
## Leaderboard screen — top players ranked by RankScore.
|
||||
|
||||
const ROW = preload("res://scenes/leaderboard/components/LeaderboardRow.tscn")
|
||||
|
||||
@onready var back_btn : Button = %BackBtn
|
||||
@onready var entry_list : VBoxContainer = %EntryList
|
||||
@onready var loading_lbl : Label = %LoadingLabel
|
||||
@@ -55,40 +57,16 @@ func _on_leaderboard_ok(p: Variant) -> void:
|
||||
return
|
||||
|
||||
for entry in entries:
|
||||
entry_list.add_child(_make_row(entry as Dictionary))
|
||||
|
||||
|
||||
func _make_row(e: Dictionary) -> HBoxContainer:
|
||||
var hbox := HBoxContainer.new()
|
||||
hbox.custom_minimum_size = Vector2(0, 40)
|
||||
hbox.add_theme_constant_override("separation", 12)
|
||||
|
||||
var rank_lbl := Label.new()
|
||||
rank_lbl.custom_minimum_size = Vector2(48, 0)
|
||||
rank_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
rank_lbl.text = "#%d" % int(e.get("rank", 0))
|
||||
rank_lbl.add_theme_font_size_override("font_size", 14)
|
||||
if int(e.get("rank", 99)) <= 3:
|
||||
rank_lbl.modulate = Color(0.95, 0.85, 0.30)
|
||||
hbox.add_child(rank_lbl)
|
||||
|
||||
var name_lbl := Label.new()
|
||||
name_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
name_lbl.text = e.get("displayName", "???")
|
||||
name_lbl.add_theme_font_size_override("font_size", 14)
|
||||
if e.get("accountId", "") == Auth.user_id:
|
||||
name_lbl.modulate = Color(0.5, 0.9, 1.0)
|
||||
hbox.add_child(name_lbl)
|
||||
|
||||
var score_lbl := Label.new()
|
||||
score_lbl.custom_minimum_size = Vector2(80, 0)
|
||||
score_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
score_lbl.text = str(int(e.get("rankScore", 0)))
|
||||
score_lbl.add_theme_font_size_override("font_size", 14)
|
||||
score_lbl.modulate = Color(0.7, 0.7, 0.75)
|
||||
hbox.add_child(score_lbl)
|
||||
|
||||
return hbox
|
||||
var e := entry as Dictionary
|
||||
var row := ROW.instantiate()
|
||||
row.setup(
|
||||
int(e.get("rank", 0)),
|
||||
e.get("displayName", "???"),
|
||||
int(e.get("rankScore", 0)),
|
||||
e.get("accountId", "") == Auth.user_id,
|
||||
int(e.get("rank", 99)) <= 3
|
||||
)
|
||||
entry_list.add_child(row)
|
||||
|
||||
|
||||
func _update_pagination() -> void:
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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
|
||||
@@ -73,14 +75,14 @@ func _on_decks_response(_type: String, payload: Variant) -> void:
|
||||
status_label.text = "Choose a deck"
|
||||
sub_label.text = ""
|
||||
for deck: Dictionary in decks:
|
||||
var btn := Button.new()
|
||||
btn.text = "%s (%d cards)" % [deck.get("name", "Unnamed"), int(deck.get("cardCount", 0))]
|
||||
btn.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
btn.custom_minimum_size = Vector2(0, 44)
|
||||
btn.add_theme_font_size_override("font_size", 14)
|
||||
var did := str(deck.get("id", ""))
|
||||
btn.pressed.connect(func() -> void:
|
||||
_selected_deck_id = did
|
||||
var btn := DECK_BTN.instantiate()
|
||||
btn.setup(
|
||||
str(deck.get("id", "")),
|
||||
str(deck.get("name", "Unnamed")),
|
||||
int(deck.get("cardCount", 0))
|
||||
)
|
||||
btn.picked.connect(func(id: String) -> void:
|
||||
_selected_deck_id = id
|
||||
_join_queue())
|
||||
deck_list.add_child(btn)
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/starter_deck/components/starter_deck_card.gd" id="1_sdc"]
|
||||
|
||||
[node name="StarterDeckCard" type="Button"]
|
||||
focus_mode = 1
|
||||
size_flags_horizontal = 2
|
||||
script = ExtResource("1_sdc")
|
||||
|
||||
[node name="Inner" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 5
|
||||
|
||||
[node name="NameLabel" type="Label" parent="Inner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
|
||||
[node name="SubtitleLabel" type="Label" parent="Inner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
modulate = Color(0.7, 0.7, 0.8, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
@@ -0,0 +1,46 @@
|
||||
extends Button
|
||||
## Selectable starter deck card in the deck picker screen.
|
||||
|
||||
signal selected(id: String)
|
||||
|
||||
const SEL_COLOR := Color(0.36, 0.56, 1.0, 1.0)
|
||||
const DEF_COLOR := Color(0.25, 0.25, 0.35, 1.0)
|
||||
|
||||
@onready var name_label : Label = %NameLabel
|
||||
@onready var subtitle_label : Label = %SubtitleLabel
|
||||
|
||||
var _id : String = ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pressed.connect(func(): selected.emit(_id))
|
||||
_apply_style(false)
|
||||
|
||||
|
||||
func setup(id: String, deck_name: String, subtitle: String) -> void:
|
||||
_id = id
|
||||
name_label.text = deck_name
|
||||
subtitle_label.text = subtitle
|
||||
|
||||
|
||||
func set_selected(v: bool) -> void:
|
||||
_apply_style(v)
|
||||
|
||||
|
||||
func _apply_style(sel: bool) -> void:
|
||||
var bg := Color(0.13, 0.13, 0.20, 1.0)
|
||||
var make := func(b: Color) -> StyleBoxFlat:
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = b
|
||||
s.border_color = SEL_COLOR if sel else DEF_COLOR
|
||||
s.set_border_width_all(2)
|
||||
s.set_corner_radius_all(6)
|
||||
s.content_margin_left = 14
|
||||
s.content_margin_right = 14
|
||||
s.content_margin_top = 12
|
||||
s.content_margin_bottom = 12
|
||||
return s
|
||||
add_theme_stylebox_override("normal", make.call(bg))
|
||||
add_theme_stylebox_override("hover", make.call(Color(0.20, 0.20, 0.30, 1.0)))
|
||||
add_theme_stylebox_override("pressed", make.call(bg))
|
||||
add_theme_stylebox_override("focus", make.call(bg))
|
||||
@@ -1,5 +1,7 @@
|
||||
extends Control
|
||||
## Starter deck selection screen — shown to new players immediately after auth.
|
||||
|
||||
const CARD = preload("res://scenes/starter_deck/components/StarterDeckCard.tscn")
|
||||
##
|
||||
## Flow:
|
||||
## 1. Send collection.get_starter_decks → populate deck list.
|
||||
@@ -63,79 +65,23 @@ func _populate_list(decks: Array) -> void:
|
||||
child.queue_free()
|
||||
|
||||
for deck in decks:
|
||||
var d := deck as Dictionary
|
||||
var id := d.get("id", "") as String
|
||||
deck_list.add_child(_build_card(d, id))
|
||||
|
||||
|
||||
func _build_card(d: Dictionary, id: String) -> Button:
|
||||
var btn := Button.new()
|
||||
btn.name = "Deck_%s" % id
|
||||
btn.flat = false
|
||||
btn.focus_mode = Control.FOCUS_CLICK
|
||||
btn.size_flags_horizontal = Control.SIZE_FILL
|
||||
_apply_card_style(btn, false)
|
||||
|
||||
var inner := VBoxContainer.new()
|
||||
inner.add_theme_constant_override("separation", 5)
|
||||
btn.add_child(inner)
|
||||
|
||||
# Deck name
|
||||
var name_lbl := Label.new()
|
||||
name_lbl.text = d.get("name", "Unknown Deck")
|
||||
name_lbl.add_theme_font_size_override("font_size", 16)
|
||||
inner.add_child(name_lbl)
|
||||
|
||||
# ArchSpirit · card count
|
||||
var arch : String = d.get("archSpiritName", "")
|
||||
var total : int = d.get("totalCards", 0)
|
||||
var sub_lbl := Label.new()
|
||||
sub_lbl.text = ("%s · %d cards" % [arch, total]) if not arch.is_empty() \
|
||||
else ("%d cards" % total)
|
||||
sub_lbl.modulate = Color(0.7, 0.7, 0.8)
|
||||
sub_lbl.add_theme_font_size_override("font_size", 12)
|
||||
inner.add_child(sub_lbl)
|
||||
|
||||
# Optional description
|
||||
var desc : String = d.get("description", "")
|
||||
if not desc.is_empty():
|
||||
var desc_lbl := Label.new()
|
||||
desc_lbl.text = desc
|
||||
desc_lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
desc_lbl.modulate = Color(0.65, 0.65, 0.75)
|
||||
desc_lbl.add_theme_font_size_override("font_size", 11)
|
||||
inner.add_child(desc_lbl)
|
||||
|
||||
btn.pressed.connect(func(): _select_deck(id))
|
||||
return btn
|
||||
|
||||
|
||||
func _apply_card_style(btn: Button, selected: bool,
|
||||
bg: Color = Color(0.13, 0.13, 0.20, 1.0)) -> void:
|
||||
var make := func(b: Color) -> StyleBoxFlat:
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = b
|
||||
s.border_color = SEL_COLOR if selected else DEF_COLOR
|
||||
s.set_border_width_all(2)
|
||||
s.set_corner_radius_all(6)
|
||||
s.content_margin_left = 14
|
||||
s.content_margin_right = 14
|
||||
s.content_margin_top = 12
|
||||
s.content_margin_bottom = 12
|
||||
return s
|
||||
btn.add_theme_stylebox_override("normal", make.call(bg))
|
||||
btn.add_theme_stylebox_override("hover", make.call(Color(0.20, 0.20, 0.30, 1.0)))
|
||||
btn.add_theme_stylebox_override("pressed", make.call(bg))
|
||||
btn.add_theme_stylebox_override("focus", make.call(bg))
|
||||
var d := deck as Dictionary
|
||||
var id := d.get("id", "") as String
|
||||
var arch : String = d.get("archSpiritName", "")
|
||||
var total : int = d.get("totalCards", 0)
|
||||
var sub : String = ("%s · %d cards" % [arch, total]) if not arch.is_empty() \
|
||||
else ("%d cards" % total)
|
||||
var card := CARD.instantiate()
|
||||
card.setup(id, d.get("name", "Unknown Deck"), sub)
|
||||
card.selected.connect(_select_deck)
|
||||
deck_list.add_child(card)
|
||||
|
||||
|
||||
func _select_deck(id: String) -> void:
|
||||
_selected_id = id
|
||||
for child in deck_list.get_children():
|
||||
var btn := child as Button
|
||||
if btn == null:
|
||||
continue
|
||||
_apply_card_style(btn, btn.name == ("Deck_%s" % id))
|
||||
if child.has_method("set_selected"):
|
||||
child.set_selected(child._id == id)
|
||||
confirm_btn.disabled = false
|
||||
|
||||
# ── Confirm ───────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user