Add Settings, Account, Bug Reports, and Leaderboard

Server:
- New SOR.Support project: SubmitBugReport, GetLeaderboard, GetAccountProfile handlers
- New SOR.Database support schema: BugReport + BugReportResponse entities + SupportDbContext
- EF migration: Migrations/Support/AddSupport
- Admin panel: Bug Reports list + detail pages with reply-to-submitter flow
- Admin NavMenu: Support section with Bug Reports link
- Reply creates chat.Notification (type "admin_response") for in-game mailbox

Client:
- Settings autoload (Settings.gd): music/sfx volume+mute, persisted to user://settings.cfg
- SettingsScreen: sliders + mute CheckButtons wired to Settings autoload
- AccountScreen: profile (display name, OP, rank score) + mailbox (admin_response notifications)
- LeaderboardScreen: paginated ranked player list, caller highlighted in blue
- BugReportDialog: category/title/description/steps form, submits via support.submit_bug_report
- MainScreen: new Leaderboard, Account, Settings, Report a Bug navigation buttons

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:
dingo
2026-03-06 20:14:12 -05:00
co-authored by Claude Happy
parent c4ef720570
commit a482cc5319
33 changed files with 2107 additions and 14 deletions
@@ -0,0 +1,90 @@
extends Node
## Settings autoload — persists audio volume/mute preferences.
##
## Usage from any scene:
## Settings.music_volume → float 0.0–1.0
## Settings.music_muted → bool
## Settings.sfx_volume → float 0.0–1.0
## Settings.sfx_muted → bool
##
## Changing any property automatically applies it to the AudioServer and saves.
const SAVE_PATH := "user://settings.cfg"
const SECTION := "audio"
## Audio bus names as configured in the Godot project.
const BUS_MUSIC := "Music"
const BUS_SFX := "SFX"
signal settings_changed
var music_volume : float = 1.0 :
set(v):
music_volume = clampf(v, 0.0, 1.0)
_apply_music()
_save()
settings_changed.emit()
var music_muted : bool = false :
set(v):
music_muted = v
_apply_music()
_save()
settings_changed.emit()
var sfx_volume : float = 1.0 :
set(v):
sfx_volume = clampf(v, 0.0, 1.0)
_apply_sfx()
_save()
settings_changed.emit()
var sfx_muted : bool = false :
set(v):
sfx_muted = v
_apply_sfx()
_save()
settings_changed.emit()
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
_load()
_apply_music()
_apply_sfx()
# ── Internal ──────────────────────────────────────────────────────────────────
func _apply_music() -> void:
var idx := AudioServer.get_bus_index(BUS_MUSIC)
if idx < 0:
return
AudioServer.set_bus_volume_db(idx, linear_to_db(music_volume) if not music_muted else -80.0)
AudioServer.set_bus_mute(idx, music_muted)
func _apply_sfx() -> void:
var idx := AudioServer.get_bus_index(BUS_SFX)
if idx < 0:
return
AudioServer.set_bus_volume_db(idx, linear_to_db(sfx_volume) if not sfx_muted else -80.0)
AudioServer.set_bus_mute(idx, sfx_muted)
func _load() -> void:
var cfg := ConfigFile.new()
if cfg.load(SAVE_PATH) != OK:
return
music_volume = float(cfg.get_value(SECTION, "music_volume", 1.0))
music_muted = bool(cfg.get_value(SECTION, "music_muted", false))
sfx_volume = float(cfg.get_value(SECTION, "sfx_volume", 1.0))
sfx_muted = bool(cfg.get_value(SECTION, "sfx_muted", false))
func _save() -> void:
var cfg := ConfigFile.new()
cfg.set_value(SECTION, "music_volume", music_volume)
cfg.set_value(SECTION, "music_muted", music_muted)
cfg.set_value(SECTION, "sfx_volume", sfx_volume)
cfg.set_value(SECTION, "sfx_muted", sfx_muted)
cfg.save(SAVE_PATH)
+1
View File
@@ -22,6 +22,7 @@ ContentCache="*res://autoloads/ContentCache.gd"
Auth="*res://autoloads/Auth.gd"
CollectionCache="*res://autoloads/CollectionCache.gd"
Chat="*res://autoloads/Chat.gd"
Settings="*res://autoloads/Settings.gd"
[display]
@@ -0,0 +1,139 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scenes/account/account_screen.gd" id="1_acc"]
[node name="AccountScreen" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_acc")
[node name="Background" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.094, 0.094, 0.137, 1.0)
[node name="Layout" 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="TopBar" type="MarginContainer" parent="Layout"]
layout_mode = 2
theme_override_constants/margin_left = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_top = 8
theme_override_constants/margin_bottom = 8
[node name="TopBarInner" type="HBoxContainer" parent="Layout/TopBar"]
layout_mode = 2
custom_minimum_size = Vector2(0, 40)
theme_override_constants/separation = 10
[node name="BackBtn" type="Button" parent="Layout/TopBar/TopBarInner"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(40, 40)
text = "←"
theme_override_font_sizes/font_size = 18
[node name="TitleLabel" type="Label" parent="Layout/TopBar/TopBarInner"]
layout_mode = 2
size_flags_horizontal = 3
text = "Account"
vertical_alignment = 1
theme_override_font_sizes/font_size = 18
[node name="HSep" type="HSeparator" parent="Layout"]
layout_mode = 2
[node name="Scroll" type="ScrollContainer" parent="Layout"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="Content" type="VBoxContainer" parent="Layout/Scroll"]
layout_mode = 2
size_flags_horizontal = 3
[node name="ContentMargin" type="MarginContainer" parent="Layout/Scroll/Content"]
layout_mode = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_bottom = 20
[node name="Sections" type="VBoxContainer" parent="Layout/Scroll/Content/ContentMargin"]
layout_mode = 2
theme_override_constants/separation = 24
[node name="ProfileSection" type="VBoxContainer" parent="Layout/Scroll/Content/ContentMargin/Sections"]
layout_mode = 2
theme_override_constants/separation = 8
[node name="ProfileLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/ProfileSection"]
layout_mode = 2
text = "PROFILE"
modulate = Color(0.6, 0.6, 0.65, 1.0)
theme_override_font_sizes/font_size = 11
[node name="DisplayLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/ProfileSection"]
unique_name_in_owner = true
layout_mode = 2
text = "—"
theme_override_font_sizes/font_size = 22
[node name="OpLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/ProfileSection"]
unique_name_in_owner = true
layout_mode = 2
text = "◆ — OP"
modulate = Color(0.95, 0.85, 0.30, 1.0)
theme_override_font_sizes/font_size = 15
[node name="RankLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/ProfileSection"]
unique_name_in_owner = true
layout_mode = 2
text = "Rank: —"
modulate = Color(0.7, 0.7, 0.75, 1.0)
theme_override_font_sizes/font_size = 14
[node name="MailboxSection" type="VBoxContainer" parent="Layout/Scroll/Content/ContentMargin/Sections"]
layout_mode = 2
theme_override_constants/separation = 8
[node name="MailboxLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/MailboxSection"]
layout_mode = 2
text = "MAILBOX"
modulate = Color(0.6, 0.6, 0.65, 1.0)
theme_override_font_sizes/font_size = 11
[node name="LoadingLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/MailboxSection"]
unique_name_in_owner = true
layout_mode = 2
text = "Loading…"
modulate = Color(0.7, 0.7, 0.75, 1.0)
theme_override_font_sizes/font_size = 13
[node name="EmptyLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/MailboxSection"]
unique_name_in_owner = true
layout_mode = 2
text = "No messages yet."
visible = false
modulate = Color(0.55, 0.55, 0.60, 1.0)
theme_override_font_sizes/font_size = 13
[node name="MailboxList" type="VBoxContainer" parent="Layout/Scroll/Content/ContentMargin/Sections/MailboxSection"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/separation = 6
@@ -0,0 +1,111 @@
extends Control
## Account Management screen.
## Shows the player's own profile (display name, OP, rank score)
## and a mailbox tab with admin responses to bug reports.
@onready var back_btn : Button = %BackBtn
@onready var display_label : Label = %DisplayLabel
@onready var op_label : Label = %OpLabel
@onready var rank_label : Label = %RankLabel
@onready var mailbox_list : VBoxContainer = %MailboxList
@onready var loading_label : Label = %LoadingLabel
@onready var empty_label : Label = %EmptyLabel
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
back_btn.pressed.connect(_on_back)
_load_profile()
_load_notifications()
# ── Profile ───────────────────────────────────────────────────────────────────
func _load_profile() -> void:
display_label.text = Auth.display_name
op_label.text = "◆ — OP"
rank_label.text = "Rank: —"
Network.request(
"account.get_profile",
{},
func(_type: String, p: Variant): _on_profile_ok(p),
func(_c: String, _m: String): pass
)
func _on_profile_ok(p: Variant) -> void:
var d := p as Dictionary
op_label.text = "◆ %d OP" % int(d.get("originPoints", 0))
rank_label.text = "Rank Score: %d" % int(d.get("rankScore", 1000))
# ── Notifications (mailbox) ────────────────────────────────────────────────────
func _load_notifications() -> void:
loading_label.visible = true
empty_label.visible = false
for c in mailbox_list.get_children():
c.queue_free()
Network.request(
"chat.get_notifications",
{ "unreadOnly": false },
func(_type: String, p: Variant): _on_notifications_ok(p),
func(_c: String, _m: String):
loading_label.text = "Failed to load mailbox."
)
func _on_notifications_ok(p: Variant) -> void:
loading_label.visible = false
var notifs : Array = (p as Dictionary).get("notifications", []) as Array
if notifs.is_empty():
empty_label.visible = true
return
for n in notifs:
var nd := n as Dictionary
var row := _make_notification_row(nd)
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:
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")
@@ -0,0 +1,118 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scenes/bug_report/bug_report_dialog.gd" id="1_brd"]
[node name="BugReportDialog" type="Window"]
title = "Report a Bug"
initial_position = 2
size = Vector2i(560, 520)
script = ExtResource("1_brd")
[node name="Margin" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_top = 12
theme_override_constants/margin_bottom = 12
[node name="VBox" type="VBoxContainer" parent="Margin"]
layout_mode = 2
theme_override_constants/separation = 10
[node name="CategoryRow" type="HBoxContainer" parent="Margin/VBox"]
layout_mode = 2
theme_override_constants/separation = 8
[node name="CategoryLabel" type="Label" parent="Margin/VBox/CategoryRow"]
layout_mode = 2
custom_minimum_size = Vector2(80, 0)
text = "Category"
vertical_alignment = 1
theme_override_font_sizes/font_size = 13
[node name="CategoryOption" type="OptionButton" parent="Margin/VBox/CategoryRow"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
custom_minimum_size = Vector2(0, 32)
theme_override_font_sizes/font_size = 13
[node name="TitleRow" type="HBoxContainer" parent="Margin/VBox"]
layout_mode = 2
theme_override_constants/separation = 8
[node name="TitleRowLabel" type="Label" parent="Margin/VBox/TitleRow"]
layout_mode = 2
custom_minimum_size = Vector2(80, 0)
text = "Title"
vertical_alignment = 1
theme_override_font_sizes/font_size = 13
[node name="TitleEdit" type="LineEdit" parent="Margin/VBox/TitleRow"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
custom_minimum_size = Vector2(0, 32)
placeholder_text = "Short summary of the issue"
theme_override_font_sizes/font_size = 13
[node name="DescLabel" type="Label" parent="Margin/VBox"]
layout_mode = 2
text = "Description"
theme_override_font_sizes/font_size = 13
[node name="DescEdit" type="TextEdit" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
custom_minimum_size = Vector2(0, 100)
placeholder_text = "Describe the bug in detail…"
theme_override_font_sizes/font_size = 13
[node name="StepsLabel" type="Label" parent="Margin/VBox"]
layout_mode = 2
text = "Steps to reproduce (optional)"
modulate = Color(0.7, 0.7, 0.75, 1.0)
theme_override_font_sizes/font_size = 12
[node name="StepsEdit" type="TextEdit" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
custom_minimum_size = Vector2(0, 80)
placeholder_text = "1. Open the bazaar\n2. Click Buy\n3. …"
theme_override_font_sizes/font_size = 12
[node name="StatusLabel" type="Label" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
text = ""
visible = false
theme_override_font_sizes/font_size = 13
[node name="ButtonRow" type="HBoxContainer" parent="Margin/VBox"]
layout_mode = 2
theme_override_constants/separation = 8
[node name="BtnSpacer" type="Control" parent="Margin/VBox/ButtonRow"]
layout_mode = 2
size_flags_horizontal = 3
[node name="CancelBtn" type="Button" parent="Margin/VBox/ButtonRow"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(90, 36)
text = "Cancel"
theme_override_font_sizes/font_size = 13
[node name="SubmitBtn" type="Button" parent="Margin/VBox/ButtonRow"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(120, 36)
text = "Submit Report"
theme_override_font_sizes/font_size = 13
@@ -0,0 +1,73 @@
extends Window
## Bug Report dialog — can be shown from any scene.
## Submits via support.submit_bug_report and shows success/error feedback.
@onready var category_option : OptionButton = %CategoryOption
@onready var title_edit : LineEdit = %TitleEdit
@onready var desc_edit : TextEdit = %DescEdit
@onready var steps_edit : TextEdit = %StepsEdit
@onready var submit_btn : Button = %SubmitBtn
@onready var cancel_btn : Button = %CancelBtn
@onready var status_label : Label = %StatusLabel
const CATEGORIES := ["gameplay", "ui", "account", "performance", "other"]
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
for cat in CATEGORIES:
category_option.add_item(cat.capitalize())
submit_btn.pressed.connect(_on_submit)
cancel_btn.pressed.connect(func(): hide())
close_requested.connect(func(): hide())
# ── Submit ────────────────────────────────────────────────────────────────────
func _on_submit() -> void:
var title := title_edit.text.strip_edges()
var desc := desc_edit.text.strip_edges()
if title.is_empty() or desc.is_empty():
_set_status("Title and description are required.", true)
return
submit_btn.disabled = true
_set_status("Submitting…", false)
var cat_idx := category_option.selected
var cat := CATEGORIES[cat_idx] if cat_idx >= 0 else "other"
Network.request(
"support.submit_bug_report",
{
"category": cat,
"title": title,
"description": desc,
"stepsToReproduce": steps_edit.text.strip_edges() if not steps_edit.text.is_empty() else null,
},
func(_type: String, _p: Variant): _on_success(),
func(code: String, msg: String): _on_error(code, msg)
)
func _on_success() -> void:
_set_status("Report submitted! Thank you.", false)
submit_btn.disabled = false
title_edit.text = ""
desc_edit.text = ""
steps_edit.text = ""
await get_tree().create_timer(2.0).timeout
hide()
func _on_error(code: String, msg: String) -> void:
_set_status("Error (%s): %s" % [code, msg], true)
submit_btn.disabled = false
func _set_status(text: String, is_error: bool) -> void:
status_label.text = text
status_label.modulate = Color(0.9, 0.3, 0.3) if is_error else Color(0.5, 0.9, 0.5)
status_label.visible = not text.is_empty()
@@ -0,0 +1,150 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scenes/leaderboard/leaderboard_screen.gd" id="1_lb"]
[node name="LeaderboardScreen" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_lb")
[node name="Background" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.094, 0.094, 0.137, 1.0)
[node name="Layout" 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="TopBar" type="MarginContainer" parent="Layout"]
layout_mode = 2
theme_override_constants/margin_left = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_top = 8
theme_override_constants/margin_bottom = 8
[node name="TopBarInner" type="HBoxContainer" parent="Layout/TopBar"]
layout_mode = 2
custom_minimum_size = Vector2(0, 40)
theme_override_constants/separation = 10
[node name="BackBtn" type="Button" parent="Layout/TopBar/TopBarInner"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(40, 40)
text = "←"
theme_override_font_sizes/font_size = 18
[node name="TitleLabel" type="Label" parent="Layout/TopBar/TopBarInner"]
layout_mode = 2
size_flags_horizontal = 3
text = "Leaderboard"
vertical_alignment = 1
theme_override_font_sizes/font_size = 18
[node name="HSep" type="HSeparator" parent="Layout"]
layout_mode = 2
[node name="HeaderRow" type="MarginContainer" parent="Layout"]
layout_mode = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_top = 8
theme_override_constants/margin_bottom = 4
[node name="HeaderInner" type="HBoxContainer" parent="Layout/HeaderRow"]
layout_mode = 2
theme_override_constants/separation = 12
[node name="RankHeader" type="Label" parent="Layout/HeaderRow/HeaderInner"]
layout_mode = 2
custom_minimum_size = Vector2(48, 0)
horizontal_alignment = 1
text = "Rank"
modulate = Color(0.6, 0.6, 0.65, 1.0)
theme_override_font_sizes/font_size = 11
[node name="NameHeader" type="Label" parent="Layout/HeaderRow/HeaderInner"]
layout_mode = 2
size_flags_horizontal = 3
text = "Player"
modulate = Color(0.6, 0.6, 0.65, 1.0)
theme_override_font_sizes/font_size = 11
[node name="ScoreHeader" type="Label" parent="Layout/HeaderRow/HeaderInner"]
layout_mode = 2
custom_minimum_size = Vector2(80, 0)
horizontal_alignment = 2
text = "Score"
modulate = Color(0.6, 0.6, 0.65, 1.0)
theme_override_font_sizes/font_size = 11
[node name="HSep2" type="HSeparator" parent="Layout"]
layout_mode = 2
[node name="Scroll" type="ScrollContainer" parent="Layout"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="ListMargin" type="MarginContainer" parent="Layout/Scroll"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/margin_left = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_top = 8
theme_override_constants/margin_bottom = 8
[node name="EntryList" type="VBoxContainer" parent="Layout/Scroll/ListMargin"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
[node name="LoadingLabel" type="Label" parent="Layout/Scroll/ListMargin/EntryList"]
unique_name_in_owner = true
layout_mode = 2
text = "Loading…"
modulate = Color(0.7, 0.7, 0.75, 1.0)
theme_override_font_sizes/font_size = 14
[node name="PaginationRow" type="HBoxContainer" parent="Layout"]
layout_mode = 2
custom_minimum_size = Vector2(0, 44)
alignment = 1
theme_override_constants/separation = 12
[node name="PrevBtn" type="Button" parent="Layout/PaginationRow"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(80, 34)
text = "← Prev"
theme_override_font_sizes/font_size = 13
[node name="PageLabel" type="Label" parent="Layout/PaginationRow"]
unique_name_in_owner = true
layout_mode = 2
text = "Page 1 / 1"
vertical_alignment = 1
modulate = Color(0.7, 0.7, 0.75, 1.0)
theme_override_font_sizes/font_size = 13
[node name="NextBtn" type="Button" parent="Layout/PaginationRow"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(80, 34)
text = "Next →"
theme_override_font_sizes/font_size = 13
@@ -0,0 +1,105 @@
extends Control
## Leaderboard screen — top players ranked by RankScore.
@onready var back_btn : Button = %BackBtn
@onready var entry_list : VBoxContainer = %EntryList
@onready var loading_lbl : Label = %LoadingLabel
@onready var prev_btn : Button = %PrevBtn
@onready var next_btn : Button = %NextBtn
@onready var page_label : Label = %PageLabel
const PAGE_SIZE := 25
var _page : int = 0
var _total : int = 0
var _page_count : int = 1
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
back_btn.pressed.connect(_on_back)
prev_btn.pressed.connect(func(): _go_page(_page - 1))
next_btn.pressed.connect(func(): _go_page(_page + 1))
_load_page(0)
# ── Loading ───────────────────────────────────────────────────────────────────
func _load_page(page: int) -> void:
_page = page
loading_lbl.visible = true
for c in entry_list.get_children():
c.queue_free()
Network.request(
"leaderboard.get",
{ "page": _page, "pageSize": PAGE_SIZE },
func(_type: String, p: Variant): _on_leaderboard_ok(p),
func(_c: String, _m: String):
loading_lbl.text = "Failed to load."
)
func _on_leaderboard_ok(p: Variant) -> void:
loading_lbl.visible = false
var d := p as Dictionary
var entries : Array = d.get("entries", []) as Array
_total = int(d.get("totalCount", 0))
_page_count = max(1, int(ceil(_total / float(PAGE_SIZE))))
_update_pagination()
if entries.is_empty():
loading_lbl.text = "No players yet."
loading_lbl.visible = true
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
func _update_pagination() -> void:
page_label.text = "Page %d / %d" % [_page + 1, _page_count]
prev_btn.disabled = _page <= 0
next_btn.disabled = _page >= _page_count - 1
func _go_page(p: int) -> void:
_load_page(clamp(p, 0, _page_count - 1))
func _on_back() -> void:
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")
@@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3]
[gd_scene load_steps=3 format=3]
[ext_resource type="Script" path="res://scenes/main/main_screen.gd" id="1_main"]
[ext_resource type="PackedScene" path="res://scenes/bug_report/BugReportDialog.tscn" id="2_brd"]
[node name="MainScreen" type="Control"]
layout_mode = 3
@@ -122,6 +123,55 @@ custom_minimum_size = Vector2(0, 52)
text = "Find Match"
theme_override_font_sizes/font_size = 15
[node name="SocialSection" type="Label" parent="Layout/Scroll/Content/ContentMargin/ContentInner"]
layout_mode = 2
text = "COMMUNITY"
modulate = Color(0.6, 0.6, 0.65, 1.0)
theme_override_font_sizes/font_size = 11
[node name="SocialButtons" type="VBoxContainer" parent="Layout/Scroll/Content/ContentMargin/ContentInner"]
layout_mode = 2
theme_override_constants/separation = 10
[node name="LeaderboardBtn" type="Button" parent="Layout/Scroll/Content/ContentMargin/ContentInner/SocialButtons"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(0, 52)
text = "Leaderboard"
theme_override_font_sizes/font_size = 15
[node name="AccountSection" type="Label" parent="Layout/Scroll/Content/ContentMargin/ContentInner"]
layout_mode = 2
text = "ACCOUNT"
modulate = Color(0.6, 0.6, 0.65, 1.0)
theme_override_font_sizes/font_size = 11
[node name="AccountButtons" type="VBoxContainer" parent="Layout/Scroll/Content/ContentMargin/ContentInner"]
layout_mode = 2
theme_override_constants/separation = 10
[node name="AccountBtn" type="Button" parent="Layout/Scroll/Content/ContentMargin/ContentInner/AccountButtons"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(0, 52)
text = "Account"
theme_override_font_sizes/font_size = 15
[node name="SettingsBtn" type="Button" parent="Layout/Scroll/Content/ContentMargin/ContentInner/AccountButtons"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(0, 52)
text = "Settings"
theme_override_font_sizes/font_size = 15
[node name="ReportBugBtn" type="Button" parent="Layout/Scroll/Content/ContentMargin/ContentInner/AccountButtons"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(0, 44)
text = "Report a Bug"
modulate = Color(0.85, 0.85, 0.90, 0.7)
theme_override_font_sizes/font_size = 13
[node name="BottomBar" type="HBoxContainer" parent="Layout"]
layout_mode = 2
custom_minimum_size = Vector2(0, 56)
@@ -137,3 +187,8 @@ unique_name_in_owner = true
layout_mode = 2
text = "Sign Out"
theme_override_font_sizes/font_size = 14
[node name="BugReportDialog" parent="." instance=ExtResource("2_brd")]
unique_name_in_owner = true
visible = false
@@ -1,17 +1,19 @@
extends Control
## Main hub screen — shown after successful authentication.
##
## Displays the player's display name and live connection status.
## Placeholder navigation buttons for future game features.
##
## Session expiry is handled centrally by Auth.gd, which calls logout() and
## navigates to LoginScreen when auth.hello is rejected on reconnect.
@onready var welcome_label : Label = %WelcomeLabel
@onready var status_label : Label = %StatusLabel
@onready var logout_btn : Button = %LogoutBtn
@onready var collection_btn : Button = %CollectionBtn
@onready var bazaar_btn : Button = %BazaarBtn
@onready var welcome_label : Label = %WelcomeLabel
@onready var status_label : Label = %StatusLabel
@onready var logout_btn : Button = %LogoutBtn
@onready var collection_btn : Button = %CollectionBtn
@onready var bazaar_btn : Button = %BazaarBtn
@onready var leaderboard_btn : Button = %LeaderboardBtn
@onready var account_btn : Button = %AccountBtn
@onready var settings_btn : Button = %SettingsBtn
@onready var report_bug_btn : Button = %ReportBugBtn
@onready var bug_report_dialog = %BugReportDialog
# ── Lifecycle ─────────────────────────────────────────────────────────────────
@@ -20,11 +22,27 @@ func _ready() -> void:
Network.connected.connect(_update_status)
Network.disconnected.connect(_update_status)
_update_status()
logout_btn.pressed.connect(_on_logout_pressed)
collection_btn.pressed.connect(func():
get_tree().change_scene_to_file("res://scenes/collection/CollectionScreen.tscn"))
_update_status()
bazaar_btn.pressed.connect(func():
get_tree().change_scene_to_file("res://scenes/bazaar/BazaarScreen.tscn"))
leaderboard_btn.pressed.connect(func():
get_tree().change_scene_to_file("res://scenes/leaderboard/LeaderboardScreen.tscn"))
account_btn.pressed.connect(func():
get_tree().change_scene_to_file("res://scenes/account/AccountScreen.tscn"))
settings_btn.pressed.connect(func():
get_tree().change_scene_to_file("res://scenes/settings/SettingsScreen.tscn"))
report_bug_btn.pressed.connect(func():
bug_report_dialog.popup_centered())
func _exit_tree() -> void:
@@ -0,0 +1,143 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scenes/settings/settings_screen.gd" id="1_set"]
[node name="SettingsScreen" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_set")
[node name="Background" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.094, 0.094, 0.137, 1.0)
[node name="Layout" 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="TopBar" type="MarginContainer" parent="Layout"]
layout_mode = 2
theme_override_constants/margin_left = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_top = 8
theme_override_constants/margin_bottom = 8
[node name="TopBarInner" type="HBoxContainer" parent="Layout/TopBar"]
layout_mode = 2
custom_minimum_size = Vector2(0, 40)
theme_override_constants/separation = 10
[node name="BackBtn" type="Button" parent="Layout/TopBar/TopBarInner"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(40, 40)
text = "←"
theme_override_font_sizes/font_size = 18
[node name="TitleLabel" type="Label" parent="Layout/TopBar/TopBarInner"]
layout_mode = 2
size_flags_horizontal = 3
text = "Settings"
vertical_alignment = 1
theme_override_font_sizes/font_size = 18
[node name="HSep" type="HSeparator" parent="Layout"]
layout_mode = 2
[node name="ScrollContainer" type="ScrollContainer" parent="Layout"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="Content" type="VBoxContainer" parent="Layout/ScrollContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="ContentMargin" type="MarginContainer" parent="Layout/ScrollContainer/Content"]
layout_mode = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_bottom = 20
[node name="Sections" type="VBoxContainer" parent="Layout/ScrollContainer/Content/ContentMargin"]
layout_mode = 2
theme_override_constants/separation = 24
[node name="AudioSection" type="VBoxContainer" parent="Layout/ScrollContainer/Content/ContentMargin/Sections"]
layout_mode = 2
theme_override_constants/separation = 12
[node name="AudioLabel" type="Label" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/AudioSection"]
layout_mode = 2
text = "AUDIO"
modulate = Color(0.6, 0.6, 0.65, 1.0)
theme_override_font_sizes/font_size = 11
[node name="MusicRow" type="HBoxContainer" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/AudioSection"]
layout_mode = 2
theme_override_constants/separation = 12
[node name="MusicLabel" type="Label" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/AudioSection/MusicRow"]
layout_mode = 2
custom_minimum_size = Vector2(100, 0)
text = "Music"
vertical_alignment = 1
theme_override_font_sizes/font_size = 14
[node name="MusicSlider" type="HSlider" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/AudioSection/MusicRow"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
custom_minimum_size = Vector2(0, 32)
min_value = 0.0
max_value = 1.0
step = 0.01
value = 1.0
[node name="MusicMuteBtn" type="CheckButton" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/AudioSection/MusicRow"]
unique_name_in_owner = true
layout_mode = 2
text = "Mute"
theme_override_font_sizes/font_size = 13
[node name="SfxRow" type="HBoxContainer" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/AudioSection"]
layout_mode = 2
theme_override_constants/separation = 12
[node name="SfxLabel" type="Label" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/AudioSection/SfxRow"]
layout_mode = 2
custom_minimum_size = Vector2(100, 0)
text = "SFX"
vertical_alignment = 1
theme_override_font_sizes/font_size = 14
[node name="SfxSlider" type="HSlider" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/AudioSection/SfxRow"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
custom_minimum_size = Vector2(0, 32)
min_value = 0.0
max_value = 1.0
step = 0.01
value = 1.0
[node name="SfxMuteBtn" type="CheckButton" parent="Layout/ScrollContainer/Content/ContentMargin/Sections/AudioSection/SfxRow"]
unique_name_in_owner = true
layout_mode = 2
text = "Mute"
theme_override_font_sizes/font_size = 13
@@ -0,0 +1,42 @@
extends Control
## Settings screen — audio volume and mute controls.
## Reads initial values from the Settings autoload and writes back on change.
@onready var back_btn : Button = %BackBtn
@onready var music_slider : HSlider = %MusicSlider
@onready var music_mute_btn : CheckButton = %MusicMuteBtn
@onready var sfx_slider : HSlider = %SfxSlider
@onready var sfx_mute_btn : CheckButton = %SfxMuteBtn
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
# Populate controls from current settings (no signal spam).
music_slider.set_value_no_signal(Settings.music_volume)
music_mute_btn.set_pressed_no_signal(Settings.music_muted)
sfx_slider.set_value_no_signal(Settings.sfx_volume)
sfx_mute_btn.set_pressed_no_signal(Settings.sfx_muted)
_refresh_slider_states()
back_btn.pressed.connect(_on_back)
music_slider.value_changed.connect(func(v): Settings.music_volume = v)
music_mute_btn.toggled.connect(func(on):
Settings.music_muted = on
_refresh_slider_states())
sfx_slider.value_changed.connect(func(v): Settings.sfx_volume = v)
sfx_mute_btn.toggled.connect(func(on):
Settings.sfx_muted = on
_refresh_slider_states())
# ── Helpers ───────────────────────────────────────────────────────────────────
func _refresh_slider_states() -> void:
music_slider.editable = not Settings.music_muted
sfx_slider.editable = not Settings.sfx_muted
music_slider.modulate = Color(1, 1, 1, 0.4 if Settings.music_muted else 1.0)
sfx_slider.modulate = Color(1, 1, 1, 0.4 if Settings.sfx_muted else 1.0)
func _on_back() -> void:
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")