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:
@@ -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)
|
||||||
@@ -22,6 +22,7 @@ ContentCache="*res://autoloads/ContentCache.gd"
|
|||||||
Auth="*res://autoloads/Auth.gd"
|
Auth="*res://autoloads/Auth.gd"
|
||||||
CollectionCache="*res://autoloads/CollectionCache.gd"
|
CollectionCache="*res://autoloads/CollectionCache.gd"
|
||||||
Chat="*res://autoloads/Chat.gd"
|
Chat="*res://autoloads/Chat.gd"
|
||||||
|
Settings="*res://autoloads/Settings.gd"
|
||||||
|
|
||||||
[display]
|
[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="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"]
|
[node name="MainScreen" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
@@ -122,6 +123,55 @@ custom_minimum_size = Vector2(0, 52)
|
|||||||
text = "Find Match"
|
text = "Find Match"
|
||||||
theme_override_font_sizes/font_size = 15
|
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"]
|
[node name="BottomBar" type="HBoxContainer" parent="Layout"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
custom_minimum_size = Vector2(0, 56)
|
custom_minimum_size = Vector2(0, 56)
|
||||||
@@ -137,3 +187,8 @@ unique_name_in_owner = true
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Sign Out"
|
text = "Sign Out"
|
||||||
theme_override_font_sizes/font_size = 14
|
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
|
extends Control
|
||||||
## Main hub screen — shown after successful authentication.
|
## 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
|
## Session expiry is handled centrally by Auth.gd, which calls logout() and
|
||||||
## navigates to LoginScreen when auth.hello is rejected on reconnect.
|
## navigates to LoginScreen when auth.hello is rejected on reconnect.
|
||||||
|
|
||||||
@onready var welcome_label : Label = %WelcomeLabel
|
@onready var welcome_label : Label = %WelcomeLabel
|
||||||
@onready var status_label : Label = %StatusLabel
|
@onready var status_label : Label = %StatusLabel
|
||||||
@onready var logout_btn : Button = %LogoutBtn
|
@onready var logout_btn : Button = %LogoutBtn
|
||||||
@onready var collection_btn : Button = %CollectionBtn
|
@onready var collection_btn : Button = %CollectionBtn
|
||||||
@onready var bazaar_btn : Button = %BazaarBtn
|
@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 ─────────────────────────────────────────────────────────────────
|
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -20,11 +22,27 @@ func _ready() -> void:
|
|||||||
|
|
||||||
Network.connected.connect(_update_status)
|
Network.connected.connect(_update_status)
|
||||||
Network.disconnected.connect(_update_status)
|
Network.disconnected.connect(_update_status)
|
||||||
|
_update_status()
|
||||||
|
|
||||||
logout_btn.pressed.connect(_on_logout_pressed)
|
logout_btn.pressed.connect(_on_logout_pressed)
|
||||||
|
|
||||||
collection_btn.pressed.connect(func():
|
collection_btn.pressed.connect(func():
|
||||||
get_tree().change_scene_to_file("res://scenes/collection/CollectionScreen.tscn"))
|
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:
|
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")
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<Project Path="src/SOR.Networking.WebSocket/SOR.Networking.WebSocket.csproj" />
|
<Project Path="src/SOR.Networking.WebSocket/SOR.Networking.WebSocket.csproj" />
|
||||||
<Project Path="src/SOR.Shared.Proto/SOR.Shared.Proto.csproj" />
|
<Project Path="src/SOR.Shared.Proto/SOR.Shared.Proto.csproj" />
|
||||||
<Project Path="src/SOR.Shared/SOR.Shared.csproj" />
|
<Project Path="src/SOR.Shared/SOR.Shared.csproj" />
|
||||||
|
<Project Path="src/SOR.Support/SOR.Support.csproj" />
|
||||||
<Project Path="src/SOR.Versioning/SOR.Versioning.csproj" />
|
<Project Path="src/SOR.Versioning/SOR.Versioning.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
</Solution>
|
</Solution>
|
||||||
|
|||||||
@@ -107,6 +107,18 @@
|
|||||||
<i class="bi bi-hdd-network me-2"></i>CDN Browser
|
<i class="bi bi-hdd-network me-2"></i>CDN Browser
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<NavLink class="nav-link text-white" href="/support/bug-reports" Match="NavLinkMatch.All">
|
||||||
|
<i class="bi bi-bug me-2"></i>Support
|
||||||
|
</NavLink>
|
||||||
|
<ul class="nav nav-pills flex-column gap-1 ps-3 mt-1">
|
||||||
|
<li class="nav-item">
|
||||||
|
<NavLink class="nav-link text-white-50 py-1" href="/support/bug-reports">
|
||||||
|
<i class="bi bi-exclamation-triangle me-2"></i>Bug Reports
|
||||||
|
</NavLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<NavLink class="nav-link text-white" href="/feature-flags">
|
<NavLink class="nav-link text-white" href="/feature-flags">
|
||||||
<i class="bi bi-toggles me-2"></i>Feature Flags
|
<i class="bi bi-toggles me-2"></i>Feature Flags
|
||||||
|
|||||||
@@ -0,0 +1,193 @@
|
|||||||
|
@page "/support/bug-reports/{Id:guid}"
|
||||||
|
@using Microsoft.AspNetCore.Identity
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using SOR.Database.Contexts
|
||||||
|
@using SOR.Database.Entities.Chat
|
||||||
|
@using SOR.Database.Entities.Identity
|
||||||
|
@using SOR.Database.Entities.Support
|
||||||
|
@inject SupportDbContext SupportDb
|
||||||
|
@inject ChatDbContext ChatDb
|
||||||
|
@inject UserManager<Account> UserManager
|
||||||
|
@inject AuthenticationStateProvider AuthState
|
||||||
|
@inject NavigationManager Nav
|
||||||
|
|
||||||
|
<PageTitle>Bug Report — SOR Admin</PageTitle>
|
||||||
|
|
||||||
|
@if (_report is null)
|
||||||
|
{
|
||||||
|
<p class="text-muted">Loading…</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="d-flex align-items-center gap-3 mb-4">
|
||||||
|
<a href="/support/bug-reports" class="btn btn-sm btn-outline-secondary">← Back</a>
|
||||||
|
<h4 class="mb-0">@_report.Title</h4>
|
||||||
|
<span class="badge @StatusBadge(_report.Status)">@_report.Status</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row g-4">
|
||||||
|
<!-- Left: report details -->
|
||||||
|
<div class="col-lg-8">
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<dl class="row mb-0">
|
||||||
|
<dt class="col-sm-3">Submitter</dt>
|
||||||
|
<dd class="col-sm-9">@_report.SubmitterDisplayName <span class="text-muted small">(@_report.SubmitterAccountId)</span></dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-3">Category</dt>
|
||||||
|
<dd class="col-sm-9">@_report.Category</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-3">Submitted</dt>
|
||||||
|
<dd class="col-sm-9">@_report.CreatedAt.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss")</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header fw-semibold">Description</div>
|
||||||
|
<div class="card-body" style="white-space:pre-wrap">@_report.Description</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (!string.IsNullOrWhiteSpace(_report.StepsToReproduce))
|
||||||
|
{
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header fw-semibold">Steps to Reproduce</div>
|
||||||
|
<div class="card-body" style="white-space:pre-wrap">@_report.StepsToReproduce</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- Responses thread -->
|
||||||
|
<h5 class="mt-4">Responses (@_report.Responses.Count)</h5>
|
||||||
|
@foreach (var resp in _report.Responses.OrderBy(r => r.CreatedAt))
|
||||||
|
{
|
||||||
|
<div class="card mb-2 border-primary">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="d-flex justify-content-between mb-1">
|
||||||
|
<strong>@resp.AdminDisplayName</strong>
|
||||||
|
<span class="text-muted small">@resp.CreatedAt.LocalDateTime.ToString("yyyy-MM-dd HH:mm")</span>
|
||||||
|
</div>
|
||||||
|
<div style="white-space:pre-wrap">@resp.Content</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- Reply form -->
|
||||||
|
<div class="card mt-3">
|
||||||
|
<div class="card-header fw-semibold">Reply to submitter</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<textarea class="form-control mb-2" rows="4" placeholder="Your response…"
|
||||||
|
@bind="_replyText"></textarea>
|
||||||
|
@if (!string.IsNullOrWhiteSpace(_replyError))
|
||||||
|
{
|
||||||
|
<p class="text-danger small">@_replyError</p>
|
||||||
|
}
|
||||||
|
<button class="btn btn-primary" @onclick="SubmitReplyAsync" disabled="@_replying">
|
||||||
|
@(_replying ? "Sending…" : "Send Reply")
|
||||||
|
</button>
|
||||||
|
<span class="text-muted small ms-2">The player will receive a notification in-game.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Right: status management -->
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header fw-semibold">Status</div>
|
||||||
|
<div class="card-body d-flex flex-column gap-2">
|
||||||
|
@foreach (var s in new[] { "Open", "InProgress", "Resolved", "Closed" })
|
||||||
|
{
|
||||||
|
<button class="btn btn-sm @(s == _report.Status ? StatusBadge(s) + " text-white" : "btn-outline-secondary")"
|
||||||
|
@onclick="() => SetStatusAsync(s)">
|
||||||
|
@s
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public Guid Id { get; set; }
|
||||||
|
|
||||||
|
private BugReport? _report;
|
||||||
|
private string _replyText = "";
|
||||||
|
private string _replyError = "";
|
||||||
|
private bool _replying = false;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_report = await SupportDb.BugReports
|
||||||
|
.Include(r => r.Responses)
|
||||||
|
.FirstOrDefaultAsync(r => r.Id == Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SubmitReplyAsync()
|
||||||
|
{
|
||||||
|
if (_report is null) return;
|
||||||
|
if (string.IsNullOrWhiteSpace(_replyText))
|
||||||
|
{
|
||||||
|
_replyError = "Response cannot be empty.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_replying = true;
|
||||||
|
_replyError = "";
|
||||||
|
|
||||||
|
var authState = await AuthState.GetAuthenticationStateAsync();
|
||||||
|
var adminUser = await UserManager.GetUserAsync(authState.User);
|
||||||
|
|
||||||
|
var response = new BugReportResponse
|
||||||
|
{
|
||||||
|
BugReportId = _report.Id,
|
||||||
|
AdminAccountId = adminUser?.Id ?? Guid.Empty,
|
||||||
|
AdminDisplayName = adminUser?.DisplayName ?? adminUser?.UserName ?? "Admin",
|
||||||
|
Content = _replyText.Trim(),
|
||||||
|
CreatedAt = DateTimeOffset.UtcNow,
|
||||||
|
};
|
||||||
|
SupportDb.BugReportResponses.Add(response);
|
||||||
|
|
||||||
|
// Update report status to InProgress if it was Open
|
||||||
|
if (_report.Status == "Open")
|
||||||
|
_report.Status = "InProgress";
|
||||||
|
_report.UpdatedAt = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
|
await SupportDb.SaveChangesAsync();
|
||||||
|
|
||||||
|
// Notify the submitter via the Chat notification system
|
||||||
|
ChatDb.Notifications.Add(new Notification
|
||||||
|
{
|
||||||
|
RecipientAccountId = _report.SubmitterAccountId,
|
||||||
|
NotificationType = "admin_response",
|
||||||
|
Title = "Response to your bug report",
|
||||||
|
Body = $"An admin has responded to your bug report: \"{_report.Title}\"",
|
||||||
|
PayloadJson = System.Text.Json.JsonSerializer.Serialize(new
|
||||||
|
{
|
||||||
|
bugReportId = _report.Id,
|
||||||
|
preview = _replyText.Trim()[..Math.Min(_replyText.Trim().Length, 200)],
|
||||||
|
}),
|
||||||
|
CreatedAt = DateTimeOffset.UtcNow,
|
||||||
|
});
|
||||||
|
await ChatDb.SaveChangesAsync();
|
||||||
|
|
||||||
|
_replyText = "";
|
||||||
|
_replying = false;
|
||||||
|
_report.Responses.Add(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SetStatusAsync(string status)
|
||||||
|
{
|
||||||
|
if (_report is null || _report.Status == status) return;
|
||||||
|
_report.Status = status;
|
||||||
|
_report.UpdatedAt = DateTimeOffset.UtcNow;
|
||||||
|
await SupportDb.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string StatusBadge(string status) => status switch
|
||||||
|
{
|
||||||
|
"Open" => "bg-danger",
|
||||||
|
"InProgress" => "bg-warning text-dark",
|
||||||
|
"Resolved" => "bg-success",
|
||||||
|
"Closed" => "bg-secondary",
|
||||||
|
_ => "bg-secondary",
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
@page "/support/bug-reports"
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using SOR.Database.Contexts
|
||||||
|
@using SOR.Database.Entities.Support
|
||||||
|
@inject SupportDbContext SupportDb
|
||||||
|
|
||||||
|
<PageTitle>Bug Reports — SOR Admin</PageTitle>
|
||||||
|
|
||||||
|
<div class="d-flex align-items-center gap-3 mb-4">
|
||||||
|
<h3 class="mb-0">Bug Reports</h3>
|
||||||
|
<span class="badge bg-secondary">@_total</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2 mb-3">
|
||||||
|
@foreach (var status in _statuses)
|
||||||
|
{
|
||||||
|
<button class="btn btn-sm @(status == _filter ? "btn-primary" : "btn-outline-secondary")"
|
||||||
|
@onclick="() => SetFilter(status)">
|
||||||
|
@status
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (_loading)
|
||||||
|
{
|
||||||
|
<p class="text-muted">Loading…</p>
|
||||||
|
}
|
||||||
|
else if (_reports.Count == 0)
|
||||||
|
{
|
||||||
|
<p class="text-muted">No bug reports found.</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<table class="table table-sm table-hover align-middle">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Category</th>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Submitter</th>
|
||||||
|
<th>Submitted</th>
|
||||||
|
<th>Responses</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var r in _reports)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td><span class="badge @StatusBadge(r.Status)">@r.Status</span></td>
|
||||||
|
<td><span class="text-muted small">@r.Category</span></td>
|
||||||
|
<td>@r.Title</td>
|
||||||
|
<td class="text-muted small">@r.SubmitterDisplayName</td>
|
||||||
|
<td class="text-muted small">@r.CreatedAt.LocalDateTime.ToString("yyyy-MM-dd HH:mm")</td>
|
||||||
|
<td class="text-center">@r.Responses.Count</td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-sm btn-outline-primary" href="/support/bug-reports/@r.Id">View</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2 align-items-center mt-3">
|
||||||
|
<button class="btn btn-sm btn-outline-secondary" @onclick="PrevPage" disabled="@(_page == 0)">← Prev</button>
|
||||||
|
<span class="text-muted small">Page @(_page + 1) of @_pageCount</span>
|
||||||
|
<button class="btn btn-sm btn-outline-secondary" @onclick="NextPage" disabled="@(_page >= _pageCount - 1)">Next →</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private static readonly string[] _statuses = ["All", "Open", "InProgress", "Resolved", "Closed"];
|
||||||
|
private const int PageSize = 25;
|
||||||
|
|
||||||
|
private List<BugReport> _reports = [];
|
||||||
|
private int _total = 0;
|
||||||
|
private int _page = 0;
|
||||||
|
private int _pageCount = 1;
|
||||||
|
private bool _loading = true;
|
||||||
|
private string _filter = "All";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync() => await LoadAsync();
|
||||||
|
|
||||||
|
private async Task LoadAsync()
|
||||||
|
{
|
||||||
|
_loading = true;
|
||||||
|
var query = SupportDb.BugReports
|
||||||
|
.Include(r => r.Responses)
|
||||||
|
.AsQueryable();
|
||||||
|
|
||||||
|
if (_filter != "All")
|
||||||
|
query = query.Where(r => r.Status == _filter);
|
||||||
|
|
||||||
|
_total = await query.CountAsync();
|
||||||
|
_pageCount = Math.Max(1, (int)Math.Ceiling(_total / (double)PageSize));
|
||||||
|
_page = Math.Clamp(_page, 0, _pageCount - 1);
|
||||||
|
|
||||||
|
_reports = await query
|
||||||
|
.OrderByDescending(r => r.CreatedAt)
|
||||||
|
.Skip(_page * PageSize)
|
||||||
|
.Take(PageSize)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
_loading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SetFilter(string s) { _filter = s; _page = 0; await LoadAsync(); }
|
||||||
|
private async Task PrevPage() { _page--; await LoadAsync(); }
|
||||||
|
private async Task NextPage() { _page++; await LoadAsync(); }
|
||||||
|
|
||||||
|
private static string StatusBadge(string status) => status switch
|
||||||
|
{
|
||||||
|
"Open" => "bg-danger",
|
||||||
|
"InProgress" => "bg-warning text-dark",
|
||||||
|
"Resolved" => "bg-success",
|
||||||
|
"Closed" => "bg-secondary",
|
||||||
|
_ => "bg-secondary",
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -92,6 +92,7 @@ builder.Services.AddCollectionDatabase(builder.Configuration);
|
|||||||
builder.Services.AddBazaarDatabase(builder.Configuration);
|
builder.Services.AddBazaarDatabase(builder.Configuration);
|
||||||
builder.Services.AddChatDatabase(builder.Configuration);
|
builder.Services.AddChatDatabase(builder.Configuration);
|
||||||
builder.Services.AddGameDatabase(builder.Configuration);
|
builder.Services.AddGameDatabase(builder.Configuration);
|
||||||
|
builder.Services.AddSupportDatabase(builder.Configuration);
|
||||||
|
|
||||||
// ── HTTP pipeline ─────────────────────────────────────────────────────────
|
// ── HTTP pipeline ─────────────────────────────────────────────────────────
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
@@ -164,6 +165,7 @@ static async Task MigrateAllAsync(WebApplication app)
|
|||||||
await sp.GetRequiredService<BazaarDbContext>().Database.MigrateAsync();
|
await sp.GetRequiredService<BazaarDbContext>().Database.MigrateAsync();
|
||||||
await sp.GetRequiredService<ChatDbContext>().Database.MigrateAsync();
|
await sp.GetRequiredService<ChatDbContext>().Database.MigrateAsync();
|
||||||
await sp.GetRequiredService<GameDbContext>().Database.MigrateAsync();
|
await sp.GetRequiredService<GameDbContext>().Database.MigrateAsync();
|
||||||
|
await sp.GetRequiredService<SupportDbContext>().Database.MigrateAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async Task SeedAsync(WebApplication app)
|
static async Task SeedAsync(WebApplication app)
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
namespace SOR.Database.Contexts;
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SOR.Database.Entities.Support;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EF Core DbContext for the support schema (bug reports).
|
||||||
|
///
|
||||||
|
/// Schema: "support"
|
||||||
|
/// Run migrations:
|
||||||
|
/// dotnet ef migrations add InitialCreate
|
||||||
|
/// --context SupportDbContext
|
||||||
|
/// --project src/SOR.Database
|
||||||
|
/// --startup-project src/SOR.Admin
|
||||||
|
/// --output-dir Migrations/Support
|
||||||
|
/// </summary>
|
||||||
|
public sealed class SupportDbContext : DbContext
|
||||||
|
{
|
||||||
|
public SupportDbContext(DbContextOptions<SupportDbContext> options)
|
||||||
|
: base(options) { }
|
||||||
|
|
||||||
|
public DbSet<BugReport> BugReports => Set<BugReport>();
|
||||||
|
public DbSet<BugReportResponse> BugReportResponses => Set<BugReportResponse>();
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
|
{
|
||||||
|
builder.HasDefaultSchema("support");
|
||||||
|
|
||||||
|
builder.Entity<BugReport>(e =>
|
||||||
|
{
|
||||||
|
e.ToTable("bug_reports");
|
||||||
|
e.HasKey(b => b.Id);
|
||||||
|
e.HasIndex(b => b.SubmitterAccountId);
|
||||||
|
e.HasIndex(b => b.Status);
|
||||||
|
e.HasIndex(b => b.CreatedAt);
|
||||||
|
e.HasMany(b => b.Responses)
|
||||||
|
.WithOne(r => r.BugReport)
|
||||||
|
.HasForeignKey(r => r.BugReportId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Entity<BugReportResponse>(e =>
|
||||||
|
{
|
||||||
|
e.ToTable("bug_report_responses");
|
||||||
|
e.HasKey(r => r.Id);
|
||||||
|
e.HasIndex(r => r.BugReportId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -101,3 +101,15 @@ public sealed class GameDbContextFactory
|
|||||||
return new GameDbContext(opts);
|
return new GameDbContext(opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class SupportDbContextFactory
|
||||||
|
: IDesignTimeDbContextFactory<SupportDbContext>
|
||||||
|
{
|
||||||
|
public SupportDbContext CreateDbContext(string[] args)
|
||||||
|
{
|
||||||
|
var opts = new DbContextOptionsBuilder<SupportDbContext>()
|
||||||
|
.UseNpgsql(DesignTimeHelper.ResolveConnectionString("Support"))
|
||||||
|
.Options;
|
||||||
|
return new SupportDbContext(opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
namespace SOR.Database.Entities.Support;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A bug report submitted by a player from the in-game bug report dialog.
|
||||||
|
/// Admin staff can respond via the admin panel; responses create a Notification
|
||||||
|
/// of type "admin_response" so the player sees them in their in-game mailbox.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class BugReport
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; } = Guid.NewGuid();
|
||||||
|
|
||||||
|
/// <summary>Cross-schema: identity.accounts.Id of the submitter.</summary>
|
||||||
|
public Guid SubmitterAccountId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Snapshot of the display name at submission time.</summary>
|
||||||
|
public string SubmitterDisplayName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>Category chosen by the player: "gameplay", "ui", "account", "performance", "other".</summary>
|
||||||
|
public string Category { get; set; } = "other";
|
||||||
|
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public string Description { get; set; } = string.Empty;
|
||||||
|
public string? StepsToReproduce { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Workflow status: "Open", "InProgress", "Resolved", "Closed".</summary>
|
||||||
|
public string Status { get; set; } = "Open";
|
||||||
|
|
||||||
|
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||||
|
public DateTimeOffset? UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
public ICollection<BugReportResponse> Responses { get; set; } = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
namespace SOR.Database.Entities.Support;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An admin staff response to a player bug report.
|
||||||
|
/// Creating a response also triggers a Notification (chat schema) to the submitter.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class BugReportResponse
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; } = Guid.NewGuid();
|
||||||
|
|
||||||
|
public Guid BugReportId { get; set; }
|
||||||
|
public BugReport BugReport { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>Cross-schema: identity.accounts.Id of the admin who responded.</summary>
|
||||||
|
public Guid AdminAccountId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Snapshot of the admin's display name at response time.</summary>
|
||||||
|
public string AdminDisplayName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Content { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||||
|
}
|
||||||
+126
@@ -0,0 +1,126 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using SOR.Database.Contexts;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SOR.Database.Migrations.Support
|
||||||
|
{
|
||||||
|
[DbContext(typeof(SupportDbContext))]
|
||||||
|
[Migration("20260307011156_AddSupport")]
|
||||||
|
partial class AddSupport
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasDefaultSchema("support")
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.0")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Support.BugReport", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Category")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Status")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("StepsToReproduce")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SubmitterAccountId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("SubmitterDisplayName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CreatedAt");
|
||||||
|
|
||||||
|
b.HasIndex("Status");
|
||||||
|
|
||||||
|
b.HasIndex("SubmitterAccountId");
|
||||||
|
|
||||||
|
b.ToTable("bug_reports", "support");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Support.BugReportResponse", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("AdminAccountId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("AdminDisplayName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("BugReportId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Content")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("BugReportId");
|
||||||
|
|
||||||
|
b.ToTable("bug_report_responses", "support");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Support.BugReportResponse", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SOR.Database.Entities.Support.BugReport", "BugReport")
|
||||||
|
.WithMany("Responses")
|
||||||
|
.HasForeignKey("BugReportId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("BugReport");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Support.BugReport", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Responses");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SOR.Database.Migrations.Support
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddSupport : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.EnsureSchema(
|
||||||
|
name: "support");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "bug_reports",
|
||||||
|
schema: "support",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
SubmitterAccountId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
SubmitterDisplayName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Category = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Title = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Description = table.Column<string>(type: "text", nullable: false),
|
||||||
|
StepsToReproduce = table.Column<string>(type: "text", nullable: true),
|
||||||
|
Status = table.Column<string>(type: "text", nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_bug_reports", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "bug_report_responses",
|
||||||
|
schema: "support",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
BugReportId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
AdminAccountId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
AdminDisplayName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Content = table.Column<string>(type: "text", nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_bug_report_responses", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_bug_report_responses_bug_reports_BugReportId",
|
||||||
|
column: x => x.BugReportId,
|
||||||
|
principalSchema: "support",
|
||||||
|
principalTable: "bug_reports",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_bug_report_responses_BugReportId",
|
||||||
|
schema: "support",
|
||||||
|
table: "bug_report_responses",
|
||||||
|
column: "BugReportId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_bug_reports_CreatedAt",
|
||||||
|
schema: "support",
|
||||||
|
table: "bug_reports",
|
||||||
|
column: "CreatedAt");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_bug_reports_Status",
|
||||||
|
schema: "support",
|
||||||
|
table: "bug_reports",
|
||||||
|
column: "Status");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_bug_reports_SubmitterAccountId",
|
||||||
|
schema: "support",
|
||||||
|
table: "bug_reports",
|
||||||
|
column: "SubmitterAccountId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "bug_report_responses",
|
||||||
|
schema: "support");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "bug_reports",
|
||||||
|
schema: "support");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using SOR.Database.Contexts;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SOR.Database.Migrations.Support
|
||||||
|
{
|
||||||
|
[DbContext(typeof(SupportDbContext))]
|
||||||
|
partial class SupportDbContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasDefaultSchema("support")
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.0")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Support.BugReport", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Category")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Status")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("StepsToReproduce")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SubmitterAccountId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("SubmitterDisplayName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CreatedAt");
|
||||||
|
|
||||||
|
b.HasIndex("Status");
|
||||||
|
|
||||||
|
b.HasIndex("SubmitterAccountId");
|
||||||
|
|
||||||
|
b.ToTable("bug_reports", "support");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Support.BugReportResponse", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("AdminAccountId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("AdminDisplayName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("BugReportId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Content")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("BugReportId");
|
||||||
|
|
||||||
|
b.ToTable("bug_report_responses", "support");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Support.BugReportResponse", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SOR.Database.Entities.Support.BugReport", "BugReport")
|
||||||
|
.WithMany("Responses")
|
||||||
|
.HasForeignKey("BugReportId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("BugReport");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Support.BugReport", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Responses");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -72,6 +72,15 @@ public static class ServiceRegistration
|
|||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddSupportDatabase(
|
||||||
|
this IServiceCollection services,
|
||||||
|
IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddDbContext<SupportDbContext>(opts =>
|
||||||
|
opts.UseNpgsql(Resolve(configuration, "Support")));
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
private static string Resolve(IConfiguration configuration, string contextName)
|
private static string Resolve(IConfiguration configuration, string contextName)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ using SOR.Content;
|
|||||||
using SOR.Game;
|
using SOR.Game;
|
||||||
using SOR.Gateway;
|
using SOR.Gateway;
|
||||||
using SOR.Matchmaking;
|
using SOR.Matchmaking;
|
||||||
|
using SOR.Support;
|
||||||
using SOR.Versioning;
|
using SOR.Versioning;
|
||||||
using SOR.Networking.Nats;
|
using SOR.Networking.Nats;
|
||||||
using SOR.Networking.Redis;
|
using SOR.Networking.Redis;
|
||||||
@@ -168,10 +169,7 @@ if (IsEnabled("content")) builder.Services.AddContentService(builder.Configur
|
|||||||
if (IsEnabled("versioning")) builder.Services.AddVersioningService(builder.Configuration);
|
if (IsEnabled("versioning")) builder.Services.AddVersioningService(builder.Configuration);
|
||||||
if (IsEnabled("matchmaking")) builder.Services.AddMatchmakingService(builder.Configuration);
|
if (IsEnabled("matchmaking")) builder.Services.AddMatchmakingService(builder.Configuration);
|
||||||
if (IsEnabled("game")) builder.Services.AddGameService(builder.Configuration);
|
if (IsEnabled("game")) builder.Services.AddGameService(builder.Configuration);
|
||||||
|
if (IsEnabled("support")) builder.Services.AddSupportService(builder.Configuration);
|
||||||
// TODO: Uncomment as each service is implemented:
|
|
||||||
// if (IsEnabled("leaderboard")) builder.Services.AddLeaderboardService(builder.Configuration);
|
|
||||||
// if (IsEnabled("admin")) builder.Services.AddAdminService(builder.Configuration);
|
|
||||||
|
|
||||||
// ── BUILD ─────────────────────────────────────────────────────────────────────
|
// ── BUILD ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -43,5 +43,6 @@
|
|||||||
<ProjectReference Include="..\SOR.Versioning\SOR.Versioning.csproj" />
|
<ProjectReference Include="..\SOR.Versioning\SOR.Versioning.csproj" />
|
||||||
<ProjectReference Include="..\SOR.Matchmaking\SOR.Matchmaking.csproj" />
|
<ProjectReference Include="..\SOR.Matchmaking\SOR.Matchmaking.csproj" />
|
||||||
<ProjectReference Include="..\SOR.Game\SOR.Game.csproj" />
|
<ProjectReference Include="..\SOR.Game\SOR.Game.csproj" />
|
||||||
|
<ProjectReference Include="..\SOR.Support\SOR.Support.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
namespace SOR.Support.Handlers;
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SOR.Database.Contexts;
|
||||||
|
using SOR.Networking.Abstractions.Messaging;
|
||||||
|
using SOR.Networking.Abstractions.Transport;
|
||||||
|
using SOR.Shared.Networking;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// account.get_profile — returns the caller's own account profile.
|
||||||
|
/// Used by the Account Management screen: display name, OP balance, rank score.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class GetAccountProfileHandler : IMessageHandler
|
||||||
|
{
|
||||||
|
private readonly SorIdentityDbContext _identityDb;
|
||||||
|
|
||||||
|
public GetAccountProfileHandler(SorIdentityDbContext identityDb)
|
||||||
|
{
|
||||||
|
_identityDb = identityDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string MessageType => "account.get_profile";
|
||||||
|
|
||||||
|
public async Task<IServerMessage?> HandleAsync(
|
||||||
|
IClientMessage message,
|
||||||
|
AuthenticatedConnection connection,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var accountId = Guid.Parse(connection.UserId);
|
||||||
|
|
||||||
|
var account = await _identityDb.Users
|
||||||
|
.Where(a => a.Id == accountId)
|
||||||
|
.Select(a => new { a.Id, a.DisplayName, a.OriginPoints, a.RankScore })
|
||||||
|
.FirstOrDefaultAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (account is null)
|
||||||
|
return ServerMessage.Error(message.Seq, "NOT_FOUND", "Account not found.");
|
||||||
|
|
||||||
|
return ServerMessage.Reply("account.get_profile.ack", message.Seq,
|
||||||
|
new GetAccountProfileResponse(
|
||||||
|
AccountId: account.Id,
|
||||||
|
DisplayName: account.DisplayName ?? connection.DisplayName,
|
||||||
|
OriginPoints: account.OriginPoints,
|
||||||
|
RankScore: account.RankScore));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
namespace SOR.Support.Handlers;
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SOR.Database.Contexts;
|
||||||
|
using SOR.Networking.Abstractions.Messaging;
|
||||||
|
using SOR.Networking.Abstractions.Transport;
|
||||||
|
using SOR.Shared.Networking;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// leaderboard.get — returns paginated ranked leaderboard entries.
|
||||||
|
/// Ranked by RankScore descending. Includes the caller's own entry
|
||||||
|
/// so the client can highlight their position.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class GetLeaderboardHandler : IMessageHandler
|
||||||
|
{
|
||||||
|
private readonly IMessageSerializer _serializer;
|
||||||
|
private readonly SorIdentityDbContext _identityDb;
|
||||||
|
|
||||||
|
private const int MaxPageSize = 100;
|
||||||
|
|
||||||
|
public GetLeaderboardHandler(
|
||||||
|
IMessageSerializer serializer,
|
||||||
|
SorIdentityDbContext identityDb)
|
||||||
|
{
|
||||||
|
_serializer = serializer;
|
||||||
|
_identityDb = identityDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string MessageType => "leaderboard.get";
|
||||||
|
|
||||||
|
public async Task<IServerMessage?> HandleAsync(
|
||||||
|
IClientMessage message,
|
||||||
|
AuthenticatedConnection connection,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var req = _serializer.DeserializePayload<GetLeaderboardRequest>(message.Payload);
|
||||||
|
var page = Math.Max(0, req.Page);
|
||||||
|
var pageSize = Math.Clamp(req.PageSize, 1, MaxPageSize);
|
||||||
|
var skip = page * pageSize;
|
||||||
|
|
||||||
|
var total = await _identityDb.Users.CountAsync(cancellationToken);
|
||||||
|
|
||||||
|
var entries = await _identityDb.Users
|
||||||
|
.OrderByDescending(a => a.RankScore)
|
||||||
|
.Skip(skip)
|
||||||
|
.Take(pageSize)
|
||||||
|
.Select(a => new { a.Id, a.DisplayName, a.RankScore })
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
var dtos = entries
|
||||||
|
.Select((e, i) => new LeaderboardEntryDto(
|
||||||
|
Rank: skip + i + 1,
|
||||||
|
AccountId: e.Id,
|
||||||
|
DisplayName: e.DisplayName ?? e.Id.ToString(),
|
||||||
|
RankScore: e.RankScore))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return ServerMessage.Reply("leaderboard.get.ack", message.Seq,
|
||||||
|
new GetLeaderboardResponse(dtos, total, page, pageSize));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
namespace SOR.Support.Handlers;
|
||||||
|
|
||||||
|
using SOR.Database.Contexts;
|
||||||
|
using SOR.Database.Entities.Support;
|
||||||
|
using SOR.Networking.Abstractions.Messaging;
|
||||||
|
using SOR.Networking.Abstractions.Transport;
|
||||||
|
using SOR.Shared.Networking;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// support.submit_bug_report — persists a player bug report.
|
||||||
|
/// The player's display name is snapshotted from the connection.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class SubmitBugReportHandler : IMessageHandler
|
||||||
|
{
|
||||||
|
private readonly IMessageSerializer _serializer;
|
||||||
|
private readonly SupportDbContext _supportDb;
|
||||||
|
|
||||||
|
public SubmitBugReportHandler(
|
||||||
|
IMessageSerializer serializer,
|
||||||
|
SupportDbContext supportDb)
|
||||||
|
{
|
||||||
|
_serializer = serializer;
|
||||||
|
_supportDb = supportDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string MessageType => "support.submit_bug_report";
|
||||||
|
|
||||||
|
public async Task<IServerMessage?> HandleAsync(
|
||||||
|
IClientMessage message,
|
||||||
|
AuthenticatedConnection connection,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var req = _serializer.DeserializePayload<SubmitBugReportRequest>(message.Payload);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(req.Title) || string.IsNullOrWhiteSpace(req.Description))
|
||||||
|
return ServerMessage.Error(message.Seq, "INVALID_PAYLOAD", "Title and description are required.");
|
||||||
|
|
||||||
|
var accountId = Guid.Parse(connection.UserId);
|
||||||
|
|
||||||
|
var report = new BugReport
|
||||||
|
{
|
||||||
|
SubmitterAccountId = accountId,
|
||||||
|
SubmitterDisplayName = connection.DisplayName,
|
||||||
|
Category = string.IsNullOrWhiteSpace(req.Category) ? "other" : req.Category,
|
||||||
|
Title = req.Title.Trim()[..Math.Min(req.Title.Trim().Length, 200)],
|
||||||
|
Description = req.Description.Trim()[..Math.Min(req.Description.Trim().Length, 5000)],
|
||||||
|
StepsToReproduce = req.StepsToReproduce?.Trim(),
|
||||||
|
Status = "Open",
|
||||||
|
CreatedAt = DateTimeOffset.UtcNow,
|
||||||
|
};
|
||||||
|
|
||||||
|
_supportDb.BugReports.Add(report);
|
||||||
|
await _supportDb.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
return ServerMessage.Reply("support.submit_bug_report.ack", message.Seq,
|
||||||
|
new SubmitBugReportResponse(report.Id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<AssemblyName>SOR.Support</AssemblyName>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||||
|
<ProjectReference Include="..\SOR.Database\SOR.Database.csproj" />
|
||||||
|
<ProjectReference Include="..\SOR.Networking.Abstractions\SOR.Networking.Abstractions.csproj" />
|
||||||
|
<ProjectReference Include="..\SOR.Shared\SOR.Shared.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
namespace SOR.Support;
|
||||||
|
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using SOR.Database;
|
||||||
|
using SOR.Networking.Abstractions.Messaging;
|
||||||
|
using SOR.Support.Handlers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers all Support service components into the DI container.
|
||||||
|
/// Called from SOR.Host/Program.cs when ENABLED_SERVICES includes "support".
|
||||||
|
/// </summary>
|
||||||
|
public static class ServiceRegistration
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddSupportService(
|
||||||
|
this IServiceCollection services,
|
||||||
|
IConfiguration configuration)
|
||||||
|
{
|
||||||
|
// Database contexts the support service needs.
|
||||||
|
services.AddSupportDatabase(configuration);
|
||||||
|
services.AddIdentityDatabase(configuration);
|
||||||
|
|
||||||
|
// Message handlers — one per message type, Transient lifetime.
|
||||||
|
services.AddTransient<IMessageHandler, SubmitBugReportHandler>();
|
||||||
|
services.AddTransient<IMessageHandler, GetLeaderboardHandler>();
|
||||||
|
services.AddTransient<IMessageHandler, GetAccountProfileHandler>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
namespace SOR.Support;
|
||||||
|
|
||||||
|
// ── Request types (client → server) ──────────────────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>Submit a bug report from in-game.</summary>
|
||||||
|
public sealed record SubmitBugReportRequest(
|
||||||
|
string Category,
|
||||||
|
string Title,
|
||||||
|
string Description,
|
||||||
|
string? StepsToReproduce = null);
|
||||||
|
|
||||||
|
/// <summary>Fetch the ranked leaderboard (paginated).</summary>
|
||||||
|
public sealed record GetLeaderboardRequest(
|
||||||
|
int Page = 0,
|
||||||
|
int PageSize = 50);
|
||||||
|
|
||||||
|
/// <summary>Fetch the caller's own account profile.</summary>
|
||||||
|
public sealed record GetAccountProfileRequest; // identity from connection
|
||||||
|
|
||||||
|
// ── Response types (server → client) ─────────────────────────────────────────
|
||||||
|
|
||||||
|
public sealed record SubmitBugReportResponse(Guid ReportId);
|
||||||
|
|
||||||
|
public sealed record GetLeaderboardResponse(
|
||||||
|
IEnumerable<LeaderboardEntryDto> Entries,
|
||||||
|
int TotalCount,
|
||||||
|
int Page,
|
||||||
|
int PageSize);
|
||||||
|
|
||||||
|
public sealed record GetAccountProfileResponse(
|
||||||
|
Guid AccountId,
|
||||||
|
string DisplayName,
|
||||||
|
int OriginPoints,
|
||||||
|
int RankScore);
|
||||||
|
|
||||||
|
// ── DTOs ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
public sealed record LeaderboardEntryDto(
|
||||||
|
int Rank,
|
||||||
|
Guid AccountId,
|
||||||
|
string DisplayName,
|
||||||
|
int RankScore);
|
||||||
Reference in New Issue
Block a user