From 0d57d2b3a9f9ef2ac537da24132b01289ec8745e Mon Sep 17 00:00:00 2001 From: Mark Joshwel Date: Sun, 17 Nov 2024 07:29:22 +0800 Subject: [PATCH] game: basic auth --- ColourMeOKGame/Assets/Scenes/GameScene.unity | 95 ++++- ColourMeOKGame/Assets/Scripts/AccountUI.cs | 399 ++++++++++++++++++ .../Assets/Scripts/AccountUI.cs.meta | 11 + ColourMeOKGame/Assets/Scripts/Backend.cs | 304 ++++++++++--- ColourMeOKGame/Assets/Scripts/Colorimetry.cs | 6 +- ColourMeOKGame/Assets/Scripts/GameManager.cs | 28 ++ ...ColourPicker.cs => OklchColourPickerUI.cs} | 13 +- ...er.cs.meta => OklchColourPickerUI.cs.meta} | 0 ColourMeOKGame/Assets/UI/GameUI.uss | 135 +++--- ColourMeOKGame/Assets/UI/GameUI.uxml | 179 ++++++-- 10 files changed, 985 insertions(+), 185 deletions(-) create mode 100644 ColourMeOKGame/Assets/Scripts/AccountUI.cs create mode 100644 ColourMeOKGame/Assets/Scripts/AccountUI.cs.meta rename ColourMeOKGame/Assets/Scripts/{OklchColourPicker.cs => OklchColourPickerUI.cs} (94%) rename ColourMeOKGame/Assets/Scripts/{OklchColourPicker.cs.meta => OklchColourPickerUI.cs.meta} (100%) diff --git a/ColourMeOKGame/Assets/Scenes/GameScene.unity b/ColourMeOKGame/Assets/Scenes/GameScene.unity index bb52e1b..e956634 100644 --- a/ColourMeOKGame/Assets/Scenes/GameScene.unity +++ b/ColourMeOKGame/Assets/Scenes/GameScene.unity @@ -132,8 +132,10 @@ GameObject: m_Component: - component: {fileID: 133964672} - component: {fileID: 133964671} + - component: {fileID: 133964673} + - component: {fileID: 133964674} m_Layer: 5 - m_Name: UIDocument + m_Name: UI m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -151,9 +153,9 @@ MonoBehaviour: m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0} m_Name: m_EditorClassIdentifier: - m_PanelSettings: {fileID: 11400000, guid: bffa1f5b972ffbe4c93fc7ced33c800d, type: 2} + m_PanelSettings: {fileID: 11400000, guid: 507e346b0e9956149b317358e209c34b, type: 2} m_ParentUI: {fileID: 0} - sourceAsset: {fileID: 0} + sourceAsset: {fileID: 9197481963319205126, guid: 11e9bf775ad0e834fa8d7d3e80056d11, type: 3} m_SortingOrder: 0 --- !u!4 &133964672 Transform: @@ -170,6 +172,34 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &133964673 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 133964670} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7b7c3f177f7c8ac4eb4b8b61373e37b4, type: 3} + m_Name: + m_EditorClassIdentifier: + lightness: 0 + chroma: 0 + hue: 0 +--- !u!114 &133964674 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 133964670} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6149e386d290e7d4ea7ed651a5dd3551, type: 3} + m_Name: + m_EditorClassIdentifier: + state: 0 --- !u!1 &447905425 GameObject: m_ObjectHideFlags: 0 @@ -179,7 +209,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 447905427} - - component: {fileID: 447905426} m_Layer: 0 m_Name: Backend m_TagString: Untagged @@ -187,19 +216,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &447905426 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 447905425} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e377ac89b8e57264d9a53a33902d1e07, type: 3} - m_Name: - m_EditorClassIdentifier: - connected: 1 --- !u!4 &447905427 Transform: m_ObjectHideFlags: 0 @@ -401,6 +417,50 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1204483824 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1204483826} + - component: {fileID: 1204483825} + m_Layer: 0 + m_Name: Game Manager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1204483825 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1204483824} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cfc0b50e9003a0468ebdc186439c53b, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1204483826 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1204483824} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 @@ -409,3 +469,4 @@ SceneRoots: - {fileID: 705507995} - {fileID: 133964672} - {fileID: 447905427} + - {fileID: 1204483826} diff --git a/ColourMeOKGame/Assets/Scripts/AccountUI.cs b/ColourMeOKGame/Assets/Scripts/AccountUI.cs new file mode 100644 index 0000000..dcab716 --- /dev/null +++ b/ColourMeOKGame/Assets/Scripts/AccountUI.cs @@ -0,0 +1,399 @@ +using System; +using System.Net.Mail; +using UnityEngine; +using UnityEngine.Assertions; +using UnityEngine.UIElements; + +/// +/// class to handle the account view ui +/// +public class AccountUI : MonoBehaviour +{ + /// + /// state of the account view + /// + private enum State + { + UnassociatedState, // (start) + NotSignedIn, // initial + AfterContinue, // after + SignedIn // post + } + + /// + /// current state of the account view + /// + [SerializeField] private State state = State.UnassociatedState; + + /// + /// account view header text + /// + private Label _header; + + /// + /// username text field + /// + private TextField _usernameField; + + /// + /// email text field + /// + private TextField _emailField; + + /// + /// password text field + /// + private TextField _passwordField; + + /// + /// button to update the username + /// + private Button _usernameUpdateButton; + + /// + /// button to update the email + /// + private Button _emailUpdateButton; + + /// + /// button to update the password + /// + private Button _passwordUpdateButton; + + /// + /// accompanying text for the account input fields, used when an error/notice is needed + /// + private Label _accompanyingText; + + /// + /// either 'continue', 'log in', or 'sign out' button + /// (in order of 'initial', 'after', and 'post' states) + /// + private Button _primaryActionButton; + + /// + /// either 'forgot password' or 'create an account' + /// (in order of 'initial' and 'after' states, is hidden in 'post' state) + /// + private Button _secondaryActionButton; + + /// + /// function to subscribe button events to their respective functions + /// + public void OnEnable() + { + var ui = GetComponent().rootVisualElement; + + _header = ui.Q