diff --git a/Client/origin-client/icons/affinity_air.svg b/Client/origin-client/icons/affinity_air.svg
new file mode 100644
index 0000000..8066b98
--- /dev/null
+++ b/Client/origin-client/icons/affinity_air.svg
@@ -0,0 +1,6 @@
+
diff --git a/Client/origin-client/icons/affinity_dark.svg b/Client/origin-client/icons/affinity_dark.svg
new file mode 100644
index 0000000..821b11e
--- /dev/null
+++ b/Client/origin-client/icons/affinity_dark.svg
@@ -0,0 +1,3 @@
+
diff --git a/Client/origin-client/icons/affinity_earth.svg b/Client/origin-client/icons/affinity_earth.svg
new file mode 100644
index 0000000..70defcd
--- /dev/null
+++ b/Client/origin-client/icons/affinity_earth.svg
@@ -0,0 +1,3 @@
+
diff --git a/Client/origin-client/icons/affinity_fire.svg b/Client/origin-client/icons/affinity_fire.svg
new file mode 100644
index 0000000..f228ed9
--- /dev/null
+++ b/Client/origin-client/icons/affinity_fire.svg
@@ -0,0 +1,4 @@
+
diff --git a/Client/origin-client/icons/affinity_light.svg b/Client/origin-client/icons/affinity_light.svg
new file mode 100644
index 0000000..e031d9f
--- /dev/null
+++ b/Client/origin-client/icons/affinity_light.svg
@@ -0,0 +1,11 @@
+
diff --git a/Client/origin-client/icons/affinity_lightning.svg b/Client/origin-client/icons/affinity_lightning.svg
new file mode 100644
index 0000000..9f126a0
--- /dev/null
+++ b/Client/origin-client/icons/affinity_lightning.svg
@@ -0,0 +1,3 @@
+
diff --git a/Client/origin-client/icons/affinity_water.svg b/Client/origin-client/icons/affinity_water.svg
new file mode 100644
index 0000000..ddf839c
--- /dev/null
+++ b/Client/origin-client/icons/affinity_water.svg
@@ -0,0 +1,3 @@
+
diff --git a/Client/origin-client/scenes/collection/collection_screen.gd b/Client/origin-client/scenes/collection/collection_screen.gd
index b1264cc..f85cb2d 100644
--- a/Client/origin-client/scenes/collection/collection_screen.gd
+++ b/Client/origin-client/scenes/collection/collection_screen.gd
@@ -6,15 +6,19 @@ extends VBoxContainer
## If not syncing, triggers a silent background sync to pick up any new cards
## added since last session.
+const CARD_DETAIL_POPUP := preload("res://scenes/collection/components/CardDetailPopup.tscn")
+
# ── Node references ───────────────────────────────────────────────────────────
-@onready var back_btn : Button = %BackBtn
-@onready var sync_label : Label = %SyncLabel
-@onready var cards_tab_btn : Button = %CardsTabBtn
-@onready var decks_tab_btn : Button = %DecksTabBtn
+@onready var back_btn : Button = %BackBtn
+@onready var sync_label : Label = %SyncLabel
+@onready var cards_tab_btn : Button = %CardsTabBtn
+@onready var decks_tab_btn : Button = %DecksTabBtn
@onready var cards_view : VBoxContainer = %CardsView
@onready var decks_view : VBoxContainer = %DecksView
+var _card_popup: Control = null
+
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
@@ -22,6 +26,11 @@ func _ready() -> void:
cards_tab_btn.pressed.connect(func(): _show_tab(0))
decks_tab_btn.pressed.connect(func(): _show_tab(1))
+ # Add popup to the viewport root so it overlays above the VBoxContainer.
+ _card_popup = CARD_DETAIL_POPUP.instantiate()
+ get_tree().get_root().add_child(_card_popup)
+ cards_view.card_selected.connect(_on_card_selected)
+
_show_tab(0)
_setup_sync()
@@ -31,6 +40,15 @@ func _exit_tree() -> void:
ContentCache.sync_complete.disconnect(_on_sync_done)
if ContentCache.sync_failed.is_connected(_on_sync_done_or_failed):
ContentCache.sync_failed.disconnect(_on_sync_done_or_failed)
+ if _card_popup != null and is_instance_valid(_card_popup):
+ _card_popup.queue_free()
+ _card_popup = null
+
+# ── Card detail ───────────────────────────────────────────────────────────────
+
+func _on_card_selected(dto: Dictionary, def: Dictionary) -> void:
+ if _card_popup != null and is_instance_valid(_card_popup):
+ _card_popup.show_card(dto, def)
# ── Tab switching ─────────────────────────────────────────────────────────────
diff --git a/Client/origin-client/scenes/collection/components/CardDetailPopup.tscn b/Client/origin-client/scenes/collection/components/CardDetailPopup.tscn
new file mode 100644
index 0000000..97b2eab
--- /dev/null
+++ b/Client/origin-client/scenes/collection/components/CardDetailPopup.tscn
@@ -0,0 +1,148 @@
+[gd_scene load_steps=2 format=3]
+
+[ext_resource type="Script" path="res://scenes/collection/components/card_detail_popup.gd" id="1_cdp"]
+
+[node name="CardDetailPopup" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+mouse_filter = 0
+visible = false
+script = ExtResource("1_cdp")
+
+[node name="Overlay" type="ColorRect" parent="."]
+unique_name_in_owner = true
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+color = Color(0.0, 0.0, 0.0, 0.72)
+mouse_filter = 0
+
+[node name="Center" type="CenterContainer" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+mouse_filter = 2
+
+[node name="Panel" type="PanelContainer" parent="Center"]
+layout_mode = 2
+custom_minimum_size = Vector2(310, 0)
+
+[node name="Scroll" type="ScrollContainer" parent="Center/Panel"]
+layout_mode = 2
+custom_minimum_size = Vector2(0, 0)
+horizontal_scroll_mode = 0
+
+[node name="Inner" type="MarginContainer" parent="Center/Panel/Scroll"]
+layout_mode = 2
+size_flags_horizontal = 3
+theme_override_constants/margin_left = 14
+theme_override_constants/margin_top = 14
+theme_override_constants/margin_right = 14
+theme_override_constants/margin_bottom = 14
+
+[node name="VBox" type="VBoxContainer" parent="Center/Panel/Scroll/Inner"]
+layout_mode = 2
+theme_override_constants/separation = 10
+
+[node name="HeaderRow" type="HBoxContainer" parent="Center/Panel/Scroll/Inner/VBox"]
+layout_mode = 2
+theme_override_constants/separation = 8
+
+[node name="AffinityIcon" type="TextureRect" parent="Center/Panel/Scroll/Inner/VBox/HeaderRow"]
+unique_name_in_owner = true
+layout_mode = 2
+custom_minimum_size = Vector2(28, 28)
+expand_mode = 1
+stretch_mode = 5
+
+[node name="NameLabel" type="Label" parent="Center/Panel/Scroll/Inner/VBox/HeaderRow"]
+unique_name_in_owner = true
+layout_mode = 2
+size_flags_horizontal = 3
+text = "Card Name"
+vertical_alignment = 1
+theme_override_font_sizes/font_size = 18
+
+[node name="FoilBadge" type="Label" parent="Center/Panel/Scroll/Inner/VBox/HeaderRow"]
+unique_name_in_owner = true
+layout_mode = 2
+text = "✦ Foil"
+visible = false
+modulate = Color(0.95, 0.85, 0.30, 1.0)
+vertical_alignment = 1
+theme_override_font_sizes/font_size = 12
+
+[node name="CloseBtn" type="Button" parent="Center/Panel/Scroll/Inner/VBox/HeaderRow"]
+unique_name_in_owner = true
+layout_mode = 2
+custom_minimum_size = Vector2(32, 32)
+text = "✕"
+theme_override_font_sizes/font_size = 16
+
+[node name="TagRow" type="HBoxContainer" parent="Center/Panel/Scroll/Inner/VBox"]
+layout_mode = 2
+theme_override_constants/separation = 8
+
+[node name="TypeLabel" type="Label" parent="Center/Panel/Scroll/Inner/VBox/TagRow"]
+unique_name_in_owner = true
+layout_mode = 2
+text = ""
+modulate = Color(0.70, 0.70, 0.80, 1.0)
+theme_override_font_sizes/font_size = 13
+
+[node name="TagFill" type="Control" parent="Center/Panel/Scroll/Inner/VBox/TagRow"]
+layout_mode = 2
+size_flags_horizontal = 3
+
+[node name="AffinityLabel" type="Label" parent="Center/Panel/Scroll/Inner/VBox/TagRow"]
+unique_name_in_owner = true
+layout_mode = 2
+text = ""
+theme_override_font_sizes/font_size = 13
+
+[node name="TagFill2" type="Control" parent="Center/Panel/Scroll/Inner/VBox/TagRow"]
+layout_mode = 2
+size_flags_horizontal = 3
+
+[node name="RarityLabel" type="Label" parent="Center/Panel/Scroll/Inner/VBox/TagRow"]
+unique_name_in_owner = true
+layout_mode = 2
+text = ""
+theme_override_font_sizes/font_size = 13
+
+[node name="StatsSep" type="HSeparator" parent="Center/Panel/Scroll/Inner/VBox"]
+layout_mode = 2
+
+[node name="StatsGrid" type="GridContainer" parent="Center/Panel/Scroll/Inner/VBox"]
+unique_name_in_owner = true
+layout_mode = 2
+columns = 4
+theme_override_constants/h_separation = 8
+theme_override_constants/v_separation = 6
+
+[node name="AbilitiesSep" type="HSeparator" parent="Center/Panel/Scroll/Inner/VBox"]
+unique_name_in_owner = true
+layout_mode = 2
+visible = false
+
+[node name="AbilitiesTitle" type="Label" parent="Center/Panel/Scroll/Inner/VBox"]
+unique_name_in_owner = true
+layout_mode = 2
+text = "Abilities"
+visible = false
+theme_override_font_sizes/font_size = 14
+
+[node name="AbilitiesList" type="VBoxContainer" parent="Center/Panel/Scroll/Inner/VBox"]
+unique_name_in_owner = true
+layout_mode = 2
+theme_override_constants/separation = 6
diff --git a/Client/origin-client/scenes/collection/components/CardWidget.tscn b/Client/origin-client/scenes/collection/components/CardWidget.tscn
index 8553a38..6b6c731 100644
--- a/Client/origin-client/scenes/collection/components/CardWidget.tscn
+++ b/Client/origin-client/scenes/collection/components/CardWidget.tscn
@@ -62,7 +62,7 @@ grow_horizontal = 2
grow_vertical = 2
color = Color(0.18, 0.18, 0.24, 1.0)
-[node name="ArtSymbol" type="Label" parent="Margin/VBox/ArtArea"]
+[node name="ArtSymbol" type="TextureRect" parent="Margin/VBox/ArtArea"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
@@ -70,10 +70,9 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
-text = "◇"
-horizontal_alignment = 1
-vertical_alignment = 1
-theme_override_font_sizes/font_size = 28
+expand_mode = 1
+stretch_mode = 5
+modulate = Color(1, 1, 1, 0.85)
[node name="NameLabel" type="Label" parent="Margin/VBox"]
unique_name_in_owner = true
diff --git a/Client/origin-client/scenes/collection/components/card_detail_popup.gd b/Client/origin-client/scenes/collection/components/card_detail_popup.gd
new file mode 100644
index 0000000..70ae852
--- /dev/null
+++ b/Client/origin-client/scenes/collection/components/card_detail_popup.gd
@@ -0,0 +1,159 @@
+extends Control
+## Full-screen card detail overlay.
+##
+## Call show_card(dto, def) to populate and show.
+## Closes when the user taps the ✕ button or the semi-transparent background.
+##
+## Added to the viewport root at runtime by collection_screen.gd so it renders
+## above the VBoxContainer layout regardless of scene structure.
+
+const _CardWidget = preload("res://scenes/collection/components/card_widget.gd")
+
+const RARITY_COLOR := {
+ "Common": Color(0.67, 0.67, 0.67),
+ "Uncommon": Color(0.27, 0.85, 0.27),
+ "Rare": Color(0.27, 0.53, 1.00),
+ "Epic": Color(0.67, 0.27, 1.00),
+ "Legendary": Color(1.00, 0.67, 0.13),
+}
+
+# ── Node refs ─────────────────────────────────────────────────────────────────
+
+@onready var overlay : ColorRect = %Overlay
+@onready var affinity_icon : TextureRect = %AffinityIcon
+@onready var name_label : Label = %NameLabel
+@onready var foil_badge : Label = %FoilBadge
+@onready var close_btn : Button = %CloseBtn
+@onready var type_label : Label = %TypeLabel
+@onready var affinity_label : Label = %AffinityLabel
+@onready var rarity_label : Label = %RarityLabel
+@onready var stats_grid : GridContainer = %StatsGrid
+@onready var abilities_sep : HSeparator = %AbilitiesSep
+@onready var abilities_title: Label = %AbilitiesTitle
+@onready var abilities_list : VBoxContainer = %AbilitiesList
+
+# ── Lifecycle ─────────────────────────────────────────────────────────────────
+
+func _ready() -> void:
+ overlay.gui_input.connect(_on_overlay_input)
+ close_btn.pressed.connect(hide)
+
+# ── Public API ────────────────────────────────────────────────────────────────
+
+func show_card(dto: Dictionary, def: Dictionary) -> void:
+ var affinity := str(dto.get("affinity", ""))
+ var rarity := str(dto.get("rarity", ""))
+ var card_type := str(dto.get("cardType", ""))
+ var is_foil := bool(dto.get("isFoil", false))
+
+ # Header
+ name_label.text = str(dto.get("name", "Unknown"))
+ affinity_icon.texture = _CardWidget.AFFINITY_ICONS.get(affinity, null)
+ affinity_icon.modulate = _CardWidget.AFFINITY_BORDER.get(affinity, Color.WHITE)
+ foil_badge.visible = is_foil
+
+ # Tags
+ type_label.text = card_type
+ affinity_label.text = affinity
+ affinity_label.modulate = _CardWidget.AFFINITY_BORDER.get(affinity, Color.WHITE)
+ rarity_label.text = rarity
+ rarity_label.modulate = RARITY_COLOR.get(rarity, Color(0.67, 0.67, 0.67))
+
+ # Stats grid
+ _populate_stats(def)
+
+ # Abilities
+ _populate_abilities(def)
+
+ show()
+
+
+# ── Private ───────────────────────────────────────────────────────────────────
+
+func _populate_stats(def: Dictionary) -> void:
+ for child in stats_grid.get_children():
+ child.queue_free()
+
+ var sp : Variant = def.get("spCost", null)
+ var st : Variant = def.get("stCost", null)
+ var dmg : Variant = def.get("damage", null)
+ var hp : Variant = def.get("maxHealth", null)
+ var dfs : Variant = def.get("maxDefense", null)
+ var mov : Variant = def.get("movementPoints", null)
+
+ _add_stat("Spirit", "◆ %s" % (str(sp) if sp != null else "—"))
+ if st != null and int(st) > 0:
+ _add_stat("Stamina", "⚡ %s" % str(st))
+ else:
+ _add_stat("Stamina", "—")
+ _add_stat("Damage", "⚔ %s" % (str(dmg) if dmg != null else "—"))
+ _add_stat("Health", "♥ %s" % (str(hp) if hp != null else "—"))
+ _add_stat("Defense", "▲ %s" % (str(dfs) if dfs != null else "—"))
+ _add_stat("Move", str(mov) if mov != null else "—")
+
+
+func _add_stat(label_text: String, value_text: String) -> void:
+ var lbl := Label.new()
+ lbl.text = label_text
+ lbl.modulate = Color(0.65, 0.65, 0.72)
+ lbl.theme_override_font_sizes["font_size"] = 12
+
+ var val := Label.new()
+ val.text = value_text
+ val.theme_override_font_sizes["font_size"] = 13
+
+ stats_grid.add_child(lbl)
+ stats_grid.add_child(val)
+
+
+func _populate_abilities(def: Dictionary) -> void:
+ for child in abilities_list.get_children():
+ child.queue_free()
+
+ var json_str := str(def.get("abilitiesJson", ""))
+ if json_str.is_empty() or json_str == "[]":
+ abilities_sep.visible = false
+ abilities_title.visible = false
+ return
+
+ var parsed: Variant = JSON.parse_string(json_str)
+ if typeof(parsed) != TYPE_ARRAY or (parsed as Array).is_empty():
+ abilities_sep.visible = false
+ abilities_title.visible = false
+ return
+
+ abilities_sep.visible = true
+ abilities_title.visible = true
+
+ for ab in parsed as Array:
+ if typeof(ab) != TYPE_DICTIONARY:
+ continue
+ var d := ab as Dictionary
+ var name_ := str(d.get("name", d.get("Name", "")))
+ var desc := str(d.get("description", d.get("Description", "")))
+
+ var row := VBoxContainer.new()
+ row.theme_override_constants["separation"] = 2
+
+ var name_lbl := Label.new()
+ name_lbl.text = "[%s]" % name_
+ name_lbl.theme_override_font_sizes["font_size"] = 13
+ name_lbl.modulate = Color(0.90, 0.80, 0.50)
+ row.add_child(name_lbl)
+
+ if not desc.is_empty():
+ var desc_lbl := Label.new()
+ desc_lbl.text = desc
+ desc_lbl.theme_override_font_sizes["font_size"] = 12
+ desc_lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
+ desc_lbl.modulate = Color(0.80, 0.80, 0.85)
+ row.add_child(desc_lbl)
+
+ abilities_list.add_child(row)
+
+
+func _on_overlay_input(event: InputEvent) -> void:
+ if event is InputEventMouseButton and event.pressed:
+ hide()
+ elif event is InputEventScreenTouch and event.pressed:
+ hide()
diff --git a/Client/origin-client/scenes/collection/components/card_widget.gd b/Client/origin-client/scenes/collection/components/card_widget.gd
index 5371f48..c3462c7 100644
--- a/Client/origin-client/scenes/collection/components/card_widget.gd
+++ b/Client/origin-client/scenes/collection/components/card_widget.gd
@@ -30,9 +30,14 @@ const AFFINITY_BG := {
"Light": Color(0.47, 0.38, 0.04),
}
-const AFFINITY_SYMBOL := {
- "Fire": "🔥", "Water": "💧", "Earth": "⛰",
- "Air": "💨", "Lightning": "⚡", "Dark": "✦", "Light": "★",
+const AFFINITY_ICONS := {
+ "Fire": preload("res://icons/affinity_fire.svg"),
+ "Water": preload("res://icons/affinity_water.svg"),
+ "Earth": preload("res://icons/affinity_earth.svg"),
+ "Air": preload("res://icons/affinity_air.svg"),
+ "Lightning": preload("res://icons/affinity_lightning.svg"),
+ "Dark": preload("res://icons/affinity_dark.svg"),
+ "Light": preload("res://icons/affinity_light.svg"),
}
const RARITY_COLOR := {
@@ -53,8 +58,8 @@ signal card_pressed(definition_id: String)
@onready var sp_label : Label = %SpLabel
@onready var st_label : Label = %StLabel
@onready var foil_label : Label = %FoilLabel
-@onready var art_rect : ColorRect = %ArtRect
-@onready var art_symbol : Label = %ArtSymbol
+@onready var art_rect : ColorRect = %ArtRect
+@onready var art_symbol : TextureRect = %ArtSymbol
@onready var name_label : Label = %NameLabel
@onready var type_label : Label = %TypeLabel
@onready var rarity_label : Label = %RarityLabel
@@ -79,8 +84,8 @@ func setup(dto: Dictionary, def: Dictionary = {}) -> void:
_apply_style()
- art_rect.color = AFFINITY_BG.get(_affinity, Color(0.18, 0.18, 0.24))
- art_symbol.text = AFFINITY_SYMBOL.get(_affinity, "◇")
+ art_rect.color = AFFINITY_BG.get(_affinity, Color(0.18, 0.18, 0.24))
+ art_symbol.texture = AFFINITY_ICONS.get(_affinity, null)
foil_label.visible = is_foil
name_label.text = str(dto.get("name", "—"))
diff --git a/Client/origin-client/scenes/collection/views/cars_view.gd b/Client/origin-client/scenes/collection/views/cars_view.gd
index baa96bd..b4e7284 100644
--- a/Client/origin-client/scenes/collection/views/cars_view.gd
+++ b/Client/origin-client/scenes/collection/views/cars_view.gd
@@ -30,8 +30,8 @@ var _loading : bool = false
var _search_timer : float = 0.0
const _SEARCH_DEBOUNCE := 0.4
-# Signals emitted to parent when a card is tapped (for future deck-editor use)
-signal card_selected(player_card_id: String, definition_id: String)
+# Emitted when the user taps a card — parent uses this to show the detail popup.
+signal card_selected(dto: Dictionary, def: Dictionary)
# ── Lifecycle ─────────────────────────────────────────────────────────────────
@@ -136,8 +136,8 @@ func _on_cards_response(payload: Variant, page: int) -> void:
var def := ContentCache.get_definition(str(dto.get("cardDefinitionId", "")))
var widget = CARD_WIDGET.instantiate() as PanelContainer
widget.setup(dto, def)
- widget.card_pressed.connect(func(def_id: String):
- card_selected.emit(str(dto.get("playerCardId", "")), def_id))
+ widget.card_pressed.connect(func(_def_id: String):
+ card_selected.emit(dto, def))
card_grid.add_child(widget)
if cards.is_empty() and page == 1:
diff --git a/Client/origin-client/scenes/login/LoginScreen.tscn b/Client/origin-client/scenes/login/LoginScreen.tscn
index 9366b65..24f8797 100644
--- a/Client/origin-client/scenes/login/LoginScreen.tscn
+++ b/Client/origin-client/scenes/login/LoginScreen.tscn
@@ -92,6 +92,12 @@ placeholder_text = "••••••••"
secret = true
theme_override_font_sizes/font_size = 15
+[node name="RememberMe" type="CheckBox" parent="Center/Panel/Margin/VBox/Tabs/Login"]
+unique_name_in_owner = true
+layout_mode = 2
+text = "Remember me"
+theme_override_font_sizes/font_size = 13
+
[node name="LoginSpacer" type="Control" parent="Center/Panel/Margin/VBox/Tabs/Login"]
layout_mode = 2
custom_minimum_size = Vector2(0, 4)
diff --git a/Client/origin-client/scenes/login/login_screen.gd b/Client/origin-client/scenes/login/login_screen.gd
index 6d369ae..5a1b762 100644
--- a/Client/origin-client/scenes/login/login_screen.gd
+++ b/Client/origin-client/scenes/login/login_screen.gd
@@ -9,12 +9,16 @@ extends Control
## On success: transitions to InitScreen (which runs version check + content sync,
## then proceeds to MainScreen).
## On failure: shows an error message and re-enables the form.
+##
+## Remember Me: saves email + password encrypted with AES-256-CBC to
+## user://creds.dat. Cleared when the user unchecks the box and logs in.
# ── Node references (unique names set in the .tscn) ──────────────────────────
-@onready var email_input : LineEdit = %EmailInput
-@onready var password_input : LineEdit = %PasswordInput
-@onready var login_btn : Button = %LoginBtn
+@onready var email_input : LineEdit = %EmailInput
+@onready var password_input : LineEdit = %PasswordInput
+@onready var remember_me : CheckBox = %RememberMe
+@onready var login_btn : Button = %LoginBtn
@onready var reg_email_input : LineEdit = %RegEmailInput
@onready var reg_password_input : LineEdit = %RegPasswordInput
@@ -23,6 +27,28 @@ extends Control
@onready var status_label : Label = %StatusLabel
+# ── Credential encryption ─────────────────────────────────────────────────────
+# AES-256-CBC, 32-byte key embedded and XOR-obfuscated across two halves.
+
+const _CREDS_PATH := "user://creds.dat"
+
+# Key halves — XOR'd together at runtime so the plaintext key is never a
+# contiguous literal in the binary. Both halves must be exactly 16 bytes.
+const _KEY_A := PackedByteArray([
+ 0x7A, 0x4D, 0x9F, 0x2C, 0xB8, 0x61, 0xE3, 0x5A,
+ 0x0F, 0xC7, 0x94, 0x3B, 0xD6, 0x2E, 0x81, 0xF5,
+])
+const _KEY_B := PackedByteArray([
+ 0x4C, 0xA9, 0x73, 0x1E, 0x5B, 0xD8, 0x06, 0x92,
+ 0xE7, 0x3F, 0xC4, 0x6A, 0x17, 0x85, 0xB0, 0x2D,
+])
+
+# ── State ─────────────────────────────────────────────────────────────────────
+
+var _was_manual_login := false
+var _pending_email := ""
+var _pending_pass := ""
+
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
@@ -41,6 +67,13 @@ func _ready() -> void:
password_input.text_submitted.connect(func(_t): _on_login_pressed())
reg_name_input.text_submitted.connect(func(_t): _on_register_pressed())
+ # Pre-fill email/password if saved credentials exist.
+ var creds := _load_creds()
+ if creds.size() == 2:
+ email_input.text = creds[0]
+ password_input.text = creds[1]
+ remember_me.button_pressed = true
+
# Show connection / session-resume status on first open.
if not Auth.session_token.is_empty():
_set_status("Resuming session…", false)
@@ -63,6 +96,9 @@ func _on_login_pressed() -> void:
if email.is_empty() or pass_.is_empty():
_set_status("Please enter your email and password.", true)
return
+ _was_manual_login = true
+ _pending_email = email
+ _pending_pass = pass_
_set_status("Signing in…", false)
_set_enabled(false)
Auth.login(email, pass_)
@@ -82,10 +118,17 @@ func _on_register_pressed() -> void:
# ── Auth signal handlers ──────────────────────────────────────────────────────
func _on_auth_success(_user_id: String, _display_name: String) -> void:
+ if _was_manual_login:
+ if remember_me.button_pressed:
+ _save_creds(_pending_email, _pending_pass)
+ else:
+ _clear_creds()
+ _was_manual_login = false
_go_to_main()
func _on_auth_failed(error_code: String, message: String) -> void:
+ _was_manual_login = false
if error_code == "DISCONNECTED":
_set_status("Connection lost. Retrying…", false)
else:
@@ -127,3 +170,77 @@ func _friendly_error(code: String, message: String) -> String:
_:
return message if not message.is_empty() \
else "Something went wrong (%s)." % code
+
+# ── Credential storage (AES-256-CBC) ─────────────────────────────────────────
+
+func _build_key() -> PackedByteArray:
+ var key := PackedByteArray()
+ key.resize(32)
+ for i in 16:
+ key[i] = _KEY_A[i] ^ (i * 0x11)
+ key[i + 16] = _KEY_B[i] ^ (i * 0x11)
+ return key
+
+
+func _save_creds(email: String, password: String) -> void:
+ var plain := (email + "\n" + password).to_utf8_buffer()
+ # PKCS#7 padding to 16-byte block boundary.
+ var pad := 16 - (plain.size() % 16)
+ for _i in pad:
+ plain.append(pad)
+
+ var iv := Crypto.new().generate_random_bytes(16)
+ var key := _build_key()
+ var aes := AESContext.new()
+ if aes.start(AESContext.MODE_CBC_ENCRYPT, key, iv) != OK:
+ push_warning("LoginScreen: AES encrypt start failed")
+ return
+ var cipher := aes.update(plain)
+ aes.finish()
+
+ var f := FileAccess.open(_CREDS_PATH, FileAccess.WRITE)
+ if f == null:
+ push_warning("LoginScreen: cannot write credentials file")
+ return
+ f.store_buffer(iv)
+ f.store_buffer(cipher)
+
+
+func _load_creds() -> Array:
+ if not FileAccess.file_exists(_CREDS_PATH):
+ return []
+ var f := FileAccess.open(_CREDS_PATH, FileAccess.READ)
+ if f == null:
+ return []
+ var data := f.get_buffer(f.get_length())
+ if data.size() < 32: # 16 IV + at least one 16-byte block
+ return []
+
+ var iv := data.slice(0, 16)
+ var cipher := data.slice(16)
+ var key := _build_key()
+ var aes := AESContext.new()
+ if aes.start(AESContext.MODE_CBC_DECRYPT, key, iv) != OK:
+ push_warning("LoginScreen: AES decrypt start failed")
+ return []
+ var plain := aes.update(cipher)
+ aes.finish()
+
+ # Strip PKCS#7 padding.
+ if plain.size() == 0:
+ return []
+ var pad_len := plain[plain.size() - 1]
+ if pad_len < 1 or pad_len > 16 or pad_len > plain.size():
+ return []
+ plain = plain.slice(0, plain.size() - pad_len)
+
+ var text := plain.get_string_from_utf8()
+ var parts := text.split("\n", false)
+ if parts.size() != 2:
+ return []
+ return [parts[0], parts[1]]
+
+
+func _clear_creds() -> void:
+ if FileAccess.file_exists(_CREDS_PATH):
+ DirAccess.remove_absolute(ProjectSettings.globalize_path(_CREDS_PATH))