Client Account screen

This commit is contained in:
Chris Bell 2025-03-28 11:50:03 -05:00
parent f0d5d8469e
commit c846b56bc0
33 changed files with 1259 additions and 1 deletions

7
.gitignore vendored
View File

@ -2,4 +2,11 @@ SessionZeroBackend/.idea/
SessionZeroBackend/bin/
SessionZeroBackend/obj/
SessionZeroClient/.idea/
SessionZeroClient/.godot/
SessionZeroClient/.import/
SessionZeroClient/export.cfg
SessionZeroClient/export_credentials.cfg
pgdata/

BIN
FreeSerif.ttf Normal file

Binary file not shown.

View File

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/projectSettingsUpdater.xml
/.idea.SessionZero.iml
/contentModel.xml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1 @@
SessionZero

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings" defaultProject="true" />
</project>

View File

@ -0,0 +1,35 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://3u51jubgr63y"
path="res://.godot/imported/FreeSerif.ttf-d3f850a526ba264a81d97d5a8f33e870.fontdata"
[deps]
source_file="res://Assets/Resources/Fonts/FreeSerif.ttf"
dest_files=["res://.godot/imported/FreeSerif.ttf-d3f850a526ba264a81d97d5a8f33e870.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=4
keep_rounding_remainders=true
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bq0or760sx1ok"
path="res://.godot/imported/left-nav.png-1124519e9a4bd1a3b74c16c06636c259.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Resources/Images/Icons/left-nav.png"
dest_files=["res://.godot/imported/left-nav.png-1124519e9a4bd1a3b74c16c06636c259.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cacev5aqk6x7u"
path="res://.godot/imported/right-nav.png-117024ad57bdc49c9239bef756b351d5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Resources/Images/Icons/right-nav.png"
dest_files=["res://.godot/imported/right-nav.png-117024ad57bdc49c9239bef756b351d5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ggqgyxjb8043"
path="res://.godot/imported/bush.png-6d381c72687bf7e56168606d5af09401.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Resources/Images/bush.png"
dest_files=["res://.godot/imported/bush.png-6d381c72687bf7e56168606d5af09401.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -0,0 +1,53 @@
[gd_resource type="Theme" load_steps=7 format=3 uid="uid://bm4ftvoinmisi"]
[ext_resource type="FontFile" uid="uid://3u51jubgr63y" path="res://Assets/Resources/Fonts/FreeSerif.ttf" id="1_q88bu"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_q88bu"]
bg_color = Color(0.499313, 0.46906, 0.385154, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_h4ddc"]
bg_color = Color(0.649057, 0.616573, 0.526348, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_50ycf"]
bg_color = Color(0.649057, 0.616573, 0.526348, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_6tm00"]
bg_color = Color(0.862745, 0.843137, 0.788235, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_v7gxe"]
bg_color = Color(0.862745, 0.843137, 0.788235, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[resource]
Button/colors/font_color = Color(0, 0, 0, 1)
Button/font_sizes/font_size = 18
Button/fonts/font = ExtResource("1_q88bu")
Button/styles/disabled = SubResource("StyleBoxFlat_q88bu")
Button/styles/focus = SubResource("StyleBoxFlat_h4ddc")
Button/styles/hover = SubResource("StyleBoxFlat_50ycf")
Button/styles/normal = SubResource("StyleBoxFlat_6tm00")
Label/colors/font_color = Color(0.862745, 0.843137, 0.788235, 1)
Label/fonts/font = ExtResource("1_q88bu")
LineEdit/colors/font_color = Color(0.0768359, 0.0768358, 0.0768357, 1)
LineEdit/colors/font_placeholder_color = Color(0.252028, 0.252028, 0.252027, 0.6)
LineEdit/fonts/font = ExtResource("1_q88bu")
LineEdit/styles/normal = SubResource("StyleBoxFlat_v7gxe")

View File

@ -0,0 +1,27 @@
[gd_scene load_steps=8 format=3 uid="uid://bw7x0lo60q816"]
[ext_resource type="Texture2D" uid="uid://bq0or760sx1ok" path="res://Assets/Resources/Images/Icons/left-nav.png" id="1_kst2m"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1hlfy"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0u1w4"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0r0ug"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_45tpj"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_p5six"]
[sub_resource type="Theme" id="Theme_mmkqo"]
Button/styles/disabled = SubResource("StyleBoxEmpty_1hlfy")
Button/styles/focus = SubResource("StyleBoxEmpty_0u1w4")
Button/styles/hover = SubResource("StyleBoxEmpty_0r0ug")
Button/styles/normal = SubResource("StyleBoxEmpty_45tpj")
Button/styles/pressed = SubResource("StyleBoxEmpty_p5six")
[node name="BackButton" type="Button"]
custom_minimum_size = Vector2(30, 30)
theme = SubResource("Theme_mmkqo")
icon = ExtResource("1_kst2m")
icon_alignment = 1
expand_icon = true

View File

@ -0,0 +1,256 @@
[gd_scene load_steps=5 format=3 uid="uid://uokaq6vxbb5f"]
[ext_resource type="Theme" uid="uid://bm4ftvoinmisi" path="res://Assets/Resources/Themes/main_ui_theme.tres" id="1_rchxh"]
[ext_resource type="Texture2D" uid="uid://ggqgyxjb8043" path="res://Assets/Resources/Images/bush.png" id="2_jxtli"]
[ext_resource type="Script" uid="uid://cxvwd0kfb2l7e" path="res://Assets/Scripts/AccountScreenLogic.cs" id="2_vgvw7"]
[ext_resource type="PackedScene" uid="uid://bw7x0lo60q816" path="res://Assets/Scenes/UiElements/back_button.tscn" id="3_vgvw7"]
[node name="AccountScreen" type="Control" node_paths=PackedStringArray("SelectionScreenVboxContainer", "RegisterSelectionButton", "LoginSelectionButton", "UrlLineEdit", "RegisterScreenVboxContainer", "RegisterUsernameLineEdit", "RegisterEmailLineEdit", "RegisterPasswordLineEdit", "RegisterButton", "LoginScreenVboxContainer", "LoginUsernameLineEdit", "LoginPasswordLineEdit", "LoginButton", "AccountScreenVboxContainer", "AccountScreenGreetingLabel", "LogoutButton", "BackButton")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_rchxh")
script = ExtResource("2_vgvw7")
SelectionScreenVboxContainer = NodePath("Control/SelectionPanel")
RegisterSelectionButton = NodePath("Control/SelectionPanel/EnterRegistrationButton")
LoginSelectionButton = NodePath("Control/SelectionPanel/EnterLoginButton")
UrlLineEdit = NodePath("Control/SelectionPanel/UrlLineEdit")
RegisterScreenVboxContainer = NodePath("Control/RegisterPanel")
RegisterUsernameLineEdit = NodePath("Control/RegisterPanel/UsernameLineEdit")
RegisterEmailLineEdit = NodePath("Control/RegisterPanel/EmailLineEdit")
RegisterPasswordLineEdit = NodePath("Control/RegisterPanel/PasswordLineEdit")
RegisterButton = NodePath("Control/RegisterPanel/RegisterButton")
LoginScreenVboxContainer = NodePath("Control/LoginPanel")
LoginUsernameLineEdit = NodePath("Control/LoginPanel/UsernameLineEdit")
LoginPasswordLineEdit = NodePath("Control/LoginPanel/PasswordLineEdit")
LoginButton = NodePath("Control/LoginPanel/LoginButton")
AccountScreenVboxContainer = NodePath("Control/AccountScreen")
AccountScreenGreetingLabel = NodePath("Control/AccountScreen/Greeting")
LogoutButton = NodePath("Control/AccountScreen/LogoutButton")
BackButton = NodePath("Control/BackButtonMargin/BackButton")
[node name="Control" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="TextureRect" type="TextureRect" parent="Control"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("2_jxtli")
expand_mode = 1
[node name="ColorRect" type="ColorRect" parent="Control"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.172549, 0.223529, 0.188235, 0.878431)
[node name="LoginPanel" type="VBoxContainer" parent="Control"]
custom_minimum_size = Vector2(0, 300)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -100.0
offset_top = -49.5
offset_right = 100.0
offset_bottom = 49.5
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="Control/LoginPanel"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
theme_override_font_sizes/font_size = 28
text = "Login"
[node name="UsernameLineEdit" type="LineEdit" parent="Control/LoginPanel"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
placeholder_text = "Username"
alignment = 1
max_length = 50
[node name="PasswordLineEdit" type="LineEdit" parent="Control/LoginPanel"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
placeholder_text = "Password"
alignment = 1
secret = true
secret_character = "*"
[node name="LoginButton" type="Button" parent="Control/LoginPanel"]
custom_minimum_size = Vector2(0, 28)
layout_mode = 2
size_flags_vertical = 6
text = "Login"
[node name="RegisterPanel" type="VBoxContainer" parent="Control"]
visible = false
custom_minimum_size = Vector2(0, 300)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -100.0
offset_top = -49.5
offset_right = 100.0
offset_bottom = 49.5
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="Control/RegisterPanel"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
theme_override_font_sizes/font_size = 28
text = "Register"
[node name="UsernameLineEdit" type="LineEdit" parent="Control/RegisterPanel"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
placeholder_text = "Username"
alignment = 1
max_length = 50
[node name="EmailLineEdit" type="LineEdit" parent="Control/RegisterPanel"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
placeholder_text = "Email"
alignment = 1
max_length = 50
[node name="PasswordLineEdit" type="LineEdit" parent="Control/RegisterPanel"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
placeholder_text = "Password"
alignment = 1
secret = true
secret_character = "*"
[node name="RegisterButton" type="Button" parent="Control/RegisterPanel"]
custom_minimum_size = Vector2(0, 28)
layout_mode = 2
size_flags_vertical = 6
text = "Register"
[node name="SelectionPanel" type="VBoxContainer" parent="Control"]
visible = false
custom_minimum_size = Vector2(0, 300)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -100.0
offset_top = -49.5
offset_right = 100.0
offset_bottom = 49.5
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="Control/SelectionPanel"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
theme_override_font_sizes/font_size = 28
text = "SessionZero"
[node name="UrlLineEdit" type="LineEdit" parent="Control/SelectionPanel"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
text = "http://localhost:5161"
placeholder_text = "Server URL"
alignment = 1
max_length = 50
[node name="EnterRegistrationButton" type="Button" parent="Control/SelectionPanel"]
custom_minimum_size = Vector2(0, 28)
layout_mode = 2
size_flags_vertical = 6
text = "Register"
[node name="EnterLoginButton" type="Button" parent="Control/SelectionPanel"]
custom_minimum_size = Vector2(0, 28)
layout_mode = 2
size_flags_vertical = 6
text = "Login
"
[node name="AccountScreen" type="VBoxContainer" parent="Control"]
visible = false
custom_minimum_size = Vector2(0, 300)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -100.0
offset_top = -49.5
offset_right = 100.0
offset_bottom = 49.5
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="Control/AccountScreen"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
theme_override_font_sizes/font_size = 28
text = "SessionZero"
[node name="Greeting" type="Label" parent="Control/AccountScreen"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 2
theme_override_font_sizes/font_size = 28
text = "Welcome, {username}!"
[node name="LogoutButton" type="Button" parent="Control/AccountScreen"]
layout_mode = 2
size_flags_vertical = 2
text = "Logout"
[node name="BackButtonMargin" type="MarginContainer" parent="Control"]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
theme_override_constants/margin_left = 30
theme_override_constants/margin_top = 30
[node name="BackButton" parent="Control/BackButtonMargin" instance=ExtResource("3_vgvw7")]
visible = false
layout_mode = 2

View File

@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://bxafbn1ydfybh"]
[ext_resource type="PackedScene" uid="uid://uokaq6vxbb5f" path="res://Assets/Scenes/account-screen.tscn" id="1_l26l0"]
[ext_resource type="Script" uid="uid://cs8huxu78aaoj" path="res://Assets/Scripts/Main.cs" id="1_qplxx"]
[node name="Main" type="Node" node_paths=PackedStringArray("MainCanvasLayer")]
script = ExtResource("1_qplxx")
MainCanvasLayer = NodePath("MainCanvasLayer")
AccountScreenScene = ExtResource("1_l26l0")
[node name="MainCanvasLayer" type="CanvasLayer" parent="."]

View File

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
namespace SessionZeroClient.API;
public class ApiHandler : IApiHandler
{
private readonly HttpClient _httpClient;
public ApiHandler()
{
_httpClient = new HttpClient();
}
public async Task<string> Register(string url, string username, string email, string password)
{
var apiString = $"{url}/api/Auth/register";
var requestBody = new Dictionary<string, string>
{
{"username", username},
{"email", email},
{"password", password}
};
var jsonBody = JsonSerializer.Serialize(requestBody);
var content = new StringContent(jsonBody, System.Text.Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync(apiString, content);
if (!response.IsSuccessStatusCode)
{
throw new HttpRequestException($"Register failed: {response.StatusCode}");
}
var responseString = await response.Content.ReadAsStringAsync();
return responseString;
}
public async Task<string> Login(string url, string username, string password)
{
var apiString = $"{url}/api/Auth/login";
var requestBody = new Dictionary<string, string>
{
{"username", username},
{"password", password}
};
var jsonBody = JsonSerializer.Serialize(requestBody);
var content = new StringContent(jsonBody, System.Text.Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync(apiString, content);
if (!response.IsSuccessStatusCode)
{
throw new HttpRequestException($"Login failed: {response.StatusCode}");
}
var responseString = await response.Content.ReadAsStringAsync();
return responseString;
}
}

View File

@ -0,0 +1 @@
uid://bfve44wlimku6

View File

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace SessionZeroClient.API;
public interface IApiHandler
{
Task<string> Register(string url, string username, string email, string password);
Task<string> Login(string url, string username, string password);
}

View File

@ -0,0 +1 @@
uid://btq0nsj3b3dh3

View File

@ -0,0 +1,58 @@
using Godot;
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using SessionZeroClient.API;
namespace SessionZeroClient;
public class AccountManager(IApiHandler apiHandler)
{
public string Username { get; private set; } = "";
public string Email { get; private set; } = "";
public string Jwt { get; private set; } = "";
private IApiHandler _apiHandler = apiHandler;
public async Task<bool> Register(string url, string username, string email, string password)
{
var response = await _apiHandler.Register(url, username, email, password);
if (!string.IsNullOrEmpty(response))
{
var responseData = JsonSerializer.Deserialize<Dictionary<string, string>>(response);
if (responseData != null && responseData.ContainsKey("message") && responseData["message"] == "User registered successfully")
{
return true;
}
}
return false;
}
public async Task<bool> Login(string url, string username, string password)
{
var response = await _apiHandler.Login(url, username, password);
if (!string.IsNullOrEmpty(response))
{
var responseData = JsonSerializer.Deserialize<Dictionary<string, string>>(response);
if (responseData != null && responseData.ContainsKey("token"))
{
Jwt = responseData["token"];
Username = username;
return true;
}
}
return false;
}
public void Logout()
{
Jwt = "";
Username = "";
Email = "";
}
}

View File

@ -0,0 +1 @@
uid://sdy65tix3maw

View File

@ -0,0 +1,167 @@
using Godot;
using System;
using SessionZeroClient;
public partial class AccountScreenLogic : Node
{
[ExportGroup("UI Elements")]
// Selection Screen
[ExportSubgroup("Selection Screen")]
[Export] private VBoxContainer SelectionScreenVboxContainer { get; set; }
[Export] private Button RegisterSelectionButton { get; set; }
[Export] private Button LoginSelectionButton { get; set; }
[Export] private LineEdit UrlLineEdit { get; set; }
// Register Screen
[ExportSubgroup("Register Screen")]
[Export] private VBoxContainer RegisterScreenVboxContainer { get; set; }
[Export] private LineEdit RegisterUsernameLineEdit { get; set; }
[Export] private LineEdit RegisterEmailLineEdit { get; set; }
[Export] private LineEdit RegisterPasswordLineEdit { get; set; }
[Export] private Button RegisterButton { get; set; }
// Login Screen
[ExportSubgroup("Login Screen")]
[Export] private VBoxContainer LoginScreenVboxContainer { get; set; }
[Export] private LineEdit LoginUsernameLineEdit { get; set; }
[Export] private LineEdit LoginPasswordLineEdit { get; set; }
[Export] private Button LoginButton { get; set; }
// Account Screen
[ExportSubgroup("Account Screen")]
[Export] private VBoxContainer AccountScreenVboxContainer { get; set; }
[Export] private Label AccountScreenGreetingLabel { get; set; }
[Export] private Button LogoutButton { get; set; }
// Other
[ExportSubgroup("Other")]
[Export] Button BackButton { get; set; }
private AccountManager _accountManager;
private string _url = "";
public void Init(AccountManager accountManager)
{
_accountManager = accountManager;
SetupSignals();
InitialState();
}
private void InitialState()
{
SelectionScreenVboxContainer.Visible = true;
RegisterScreenVboxContainer.Visible = false;
LoginScreenVboxContainer.Visible = false;
AccountScreenVboxContainer.Visible = false;
BackButton.Visible = false;
}
private void RegisterState()
{
SelectionScreenVboxContainer.Visible = false;
RegisterScreenVboxContainer.Visible = true;
LoginScreenVboxContainer.Visible = false;
AccountScreenVboxContainer.Visible = false;
BackButton.Visible = true;
}
private void LoginState()
{
SelectionScreenVboxContainer.Visible = false;
RegisterScreenVboxContainer.Visible = false;
LoginScreenVboxContainer.Visible = true;
AccountScreenVboxContainer.Visible = false;
BackButton.Visible = true;
}
private void AccountSuccessState()
{
SelectionScreenVboxContainer.Visible = false;
RegisterScreenVboxContainer.Visible = false;
LoginScreenVboxContainer.Visible = false;
AccountScreenVboxContainer.Visible = true;
BackButton.Visible = false;
AccountScreenGreetingLabel.Text = $"Welcome, {_accountManager.Username}!";
}
private void SetupSignals()
{
// Selection Screen
RegisterSelectionButton.Pressed += RegisterSelectionButtonPressed;
LoginSelectionButton.Pressed += LoginSelectionButtonPressed;
// Register Screen
RegisterButton.Pressed += RegisterButtonPressed;
// Login Screen
LoginButton.Pressed += LoginButtonPressed;
// Account Screen
LogoutButton.Pressed += Logout;
// Other
BackButton.Pressed += BackButtonPressed;
}
private void RegisterSelectionButtonPressed()
{
_url = UrlLineEdit.Text; // TODO: Add validation
RegisterState();
}
private void LoginSelectionButtonPressed()
{
_url = UrlLineEdit.Text; // TODO: Add validation
LoginState();
}
private async void RegisterButtonPressed()
{
var username = RegisterUsernameLineEdit.Text;
var email = RegisterEmailLineEdit.Text;
var password = RegisterPasswordLineEdit.Text;
var success = await _accountManager.Register(_url, username, email, password);
GD.Print($"Register success: {success}");
if (success)
{
var loginSuccess = await _accountManager.Login(_url, username, password);
GD.Print($"Login success: {loginSuccess}");
if (loginSuccess)
{
AccountSuccessState();
}
}
}
private async void LoginButtonPressed()
{
var username = LoginUsernameLineEdit.Text;
var password = LoginPasswordLineEdit.Text;
var success = await _accountManager.Login(_url, username, password);
GD.Print($"Login success: {success}");
if (success)
{
AccountSuccessState();
}
}
private void Logout()
{
_accountManager.Logout();
InitialState();
}
private void BackButtonPressed()
{
InitialState();
}
}

View File

@ -0,0 +1 @@
uid://cxvwd0kfb2l7e

View File

@ -0,0 +1,37 @@
using Godot;
using System;
using SessionZeroClient.API;
namespace SessionZeroClient;
public partial class Main : Node
{
[Export] public CanvasLayer MainCanvasLayer { get; set; }
[Export] public PackedScene AccountScreenScene { get; set; }
private IApiHandler _apiHandler;
private AccountScreenLogic _accountScreenLogic;
private AccountManager _accountManager;
public override void _Ready()
{
_apiHandler = new ApiHandler();
_accountManager = new AccountManager(_apiHandler);
SetupAccountScreen();
}
private void SetupAccountScreen()
{
try
{
_accountScreenLogic = AccountScreenScene.Instantiate() as AccountScreenLogic;
_accountScreenLogic.Init(_accountManager);
MainCanvasLayer.AddChild(_accountScreenLogic);
}
catch (Exception e)
{
throw new Exception($"Error instantiating AccountScreenLogic: {e.Message}");
}
}
}

View File

@ -0,0 +1 @@
uid://cs8huxu78aaoj

View File

@ -0,0 +1,6 @@
<Project Sdk="Godot.NET.Sdk/4.4.0">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionZero", "SessionZero.csproj", "{6886D4CC-357D-42DF-A442-4A6003EE56A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
ExportDebug|Any CPU = ExportDebug|Any CPU
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6886D4CC-357D-42DF-A442-4A6003EE56A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6886D4CC-357D-42DF-A442-4A6003EE56A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6886D4CC-357D-42DF-A442-4A6003EE56A0}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{6886D4CC-357D-42DF-A442-4A6003EE56A0}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{6886D4CC-357D-42DF-A442-4A6003EE56A0}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{6886D4CC-357D-42DF-A442-4A6003EE56A0}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal

View File

@ -11,7 +11,8 @@ config_version=5
[application]
config/name="SessionZero"
config/features=PackedStringArray("4.4", "GL Compatibility")
run/main_scene="uid://bxafbn1ydfybh"
config/features=PackedStringArray("4.4", "C#", "GL Compatibility")
config/icon="res://icon.svg"
[dotnet]

376
sesh0.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 3.1 MiB

BIN
text31.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB