Reformat code
This commit is contained in:
77 files changed
+1041
-2187
No files matched your search
@@ -4,16 +4,14 @@ using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AccountChangePassword : MonoBehaviour
|
||||
{
|
||||
public class AccountChangePassword : MonoBehaviour {
|
||||
[SerializeField] private TMP_Text changePasswordStatusText;
|
||||
[SerializeField] private TMP_InputField changePasswordNewPasswordInput;
|
||||
[SerializeField] private TMP_InputField changePasswordRetypeNewPasswordInput;
|
||||
[SerializeField] private Button changePasswordBackButton;
|
||||
[SerializeField] private Button changePasswordSubmitButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
void Awake() {
|
||||
changePasswordNewPasswordInput.onSelect.AddListener((_) => changePasswordNewPasswordInput.caretPosition = changePasswordNewPasswordInput.text.Length);
|
||||
changePasswordRetypeNewPasswordInput.onSelect.AddListener((_) => changePasswordRetypeNewPasswordInput.caretPosition = changePasswordRetypeNewPasswordInput.text.Length);
|
||||
|
||||
@@ -21,17 +19,14 @@ public class AccountChangePassword : MonoBehaviour
|
||||
changePasswordSubmitButton.onClick.AddListener(() => ChangePassword());
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
void OnEnable() {
|
||||
changePasswordNewPasswordInput.text = "";
|
||||
changePasswordRetypeNewPasswordInput.text = "";
|
||||
changePasswordStatusText.text = "";
|
||||
}
|
||||
|
||||
async void ChangePassword()
|
||||
{
|
||||
if (changePasswordNewPasswordInput.text != changePasswordRetypeNewPasswordInput.text)
|
||||
{
|
||||
async void ChangePassword() {
|
||||
if (changePasswordNewPasswordInput.text != changePasswordRetypeNewPasswordInput.text) {
|
||||
Tools.UpdateStatusText(changePasswordStatusText, "Passwords do not match", Color.red);
|
||||
return;
|
||||
}
|
||||
@@ -45,22 +40,18 @@ public class AccountChangePassword : MonoBehaviour
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.downloadHandler.text == null)
|
||||
{
|
||||
if (request.downloadHandler.text == null) {
|
||||
changePasswordBackButton.interactable = true;
|
||||
changePasswordSubmitButton.interactable = true;
|
||||
Tools.UpdateStatusText(changePasswordStatusText, "Failed to make HTTP request", Color.red);
|
||||
return;
|
||||
}
|
||||
var jsonResponse = JObject.Parse(request.downloadHandler.text);
|
||||
if ((bool)jsonResponse["success"])
|
||||
{
|
||||
if ((bool)jsonResponse["success"]) {
|
||||
BazookaManager.Instance.SetAccountSession((string)jsonResponse["data"]);
|
||||
AccountHandler.instance.SwitchPanel(0);
|
||||
Tools.UpdateStatusText(AccountHandler.instance.accountLoggedIn.loggedInText, "Password changed successfully", Color.green);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Tools.UpdateStatusText(changePasswordStatusText, (string)jsonResponse["message"], Color.red);
|
||||
}
|
||||
changePasswordBackButton.interactable = true;
|
||||
|
||||
@@ -4,29 +4,25 @@ using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AccountChangeUsername : MonoBehaviour
|
||||
{
|
||||
public class AccountChangeUsername : MonoBehaviour {
|
||||
[SerializeField] private TMP_Text changeUsernameStatusText;
|
||||
[SerializeField] private TMP_InputField changeUsernameNewUsernameInput;
|
||||
[SerializeField] private Button changeUsernameBackButton;
|
||||
[SerializeField] private Button changeUsernameSubmitButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
void Awake() {
|
||||
changeUsernameNewUsernameInput.onSelect.AddListener((_) => changeUsernameNewUsernameInput.caretPosition = changeUsernameNewUsernameInput.text.Length);
|
||||
|
||||
changeUsernameBackButton.onClick.AddListener(() => AccountHandler.instance.SwitchPanel(0));
|
||||
changeUsernameSubmitButton.onClick.AddListener(() => ChangeUsername());
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
void OnEnable() {
|
||||
changeUsernameNewUsernameInput.text = "";
|
||||
changeUsernameStatusText.text = "";
|
||||
}
|
||||
|
||||
async void ChangeUsername()
|
||||
{
|
||||
async void ChangeUsername() {
|
||||
changeUsernameBackButton.interactable = false;
|
||||
changeUsernameSubmitButton.interactable = false;
|
||||
WWWForm dataForm = new();
|
||||
@@ -37,23 +33,19 @@ public class AccountChangeUsername : MonoBehaviour
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.downloadHandler.text == null)
|
||||
{
|
||||
if (request.downloadHandler.text == null) {
|
||||
changeUsernameBackButton.interactable = true;
|
||||
changeUsernameSubmitButton.interactable = true;
|
||||
Tools.UpdateStatusText(changeUsernameStatusText, "Failed to make HTTP request", Color.red);
|
||||
return;
|
||||
}
|
||||
var jsonResponse = JObject.Parse(request.downloadHandler.text);
|
||||
if ((bool)jsonResponse["success"])
|
||||
{
|
||||
if ((bool)jsonResponse["success"]) {
|
||||
BazookaManager.Instance.SetAccountName(changeUsernameNewUsernameInput.text);
|
||||
BazookaManager.Instance.SetAccountSession((string)jsonResponse["data"]);
|
||||
AccountHandler.instance.SwitchPanel(0);
|
||||
Tools.UpdateStatusText(AccountHandler.instance.accountLoggedIn.loggedInText, "Username changed successfully", Color.green);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Tools.UpdateStatusText(changeUsernameStatusText, (string)jsonResponse["message"], Color.red);
|
||||
}
|
||||
changeUsernameBackButton.interactable = true;
|
||||
|
||||
@@ -4,8 +4,7 @@ using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AccountForgotDetails : MonoBehaviour
|
||||
{
|
||||
public class AccountForgotDetails : MonoBehaviour {
|
||||
[SerializeField] internal TMP_Text forgotDetailsTitleText;
|
||||
[SerializeField] private TMP_Text forgotDetailsStatusText;
|
||||
[SerializeField] private TMP_InputField forgotDetailsEmailInput;
|
||||
@@ -14,13 +13,11 @@ public class AccountForgotDetails : MonoBehaviour
|
||||
[SerializeField] internal Button forgotDetailsSubmitButton;
|
||||
internal int mode = 0;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
void Awake() {
|
||||
forgotDetailsEmailInput.onSelect.AddListener((_) => forgotDetailsEmailInput.caretPosition = forgotDetailsEmailInput.text.Length);
|
||||
forgotDetailsVerifyCodeInput.onSelect.AddListener((_) => forgotDetailsVerifyCodeInput.caretPosition = forgotDetailsVerifyCodeInput.text.Length);
|
||||
|
||||
forgotDetailsBackButton.onClick.AddListener(() =>
|
||||
{
|
||||
forgotDetailsBackButton.onClick.AddListener(() => {
|
||||
forgotDetailsBackButton.interactable = false;
|
||||
forgotDetailsSubmitButton.interactable = false;
|
||||
mode = 0;
|
||||
@@ -31,14 +28,12 @@ public class AccountForgotDetails : MonoBehaviour
|
||||
forgotDetailsSubmitButton.onClick.AddListener(() => ForgotDetails());
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
void OnEnable() {
|
||||
forgotDetailsEmailInput.text = "";
|
||||
forgotDetailsVerifyCodeInput.text = "";
|
||||
}
|
||||
|
||||
async void ForgotDetails()
|
||||
{
|
||||
async void ForgotDetails() {
|
||||
forgotDetailsBackButton.interactable = false;
|
||||
forgotDetailsSubmitButton.interactable = false;
|
||||
WWWForm dataForm = new();
|
||||
@@ -50,8 +45,7 @@ public class AccountForgotDetails : MonoBehaviour
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.downloadHandler.text == null)
|
||||
{
|
||||
if (request.downloadHandler.text == null) {
|
||||
forgotDetailsBackButton.interactable = true;
|
||||
forgotDetailsSubmitButton.interactable = true;
|
||||
Tools.UpdateStatusText(forgotDetailsStatusText, "Failed to make HTTP request", Color.red);
|
||||
|
||||
@@ -2,8 +2,7 @@ using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class AccountHandler : MonoBehaviour
|
||||
{
|
||||
public class AccountHandler : MonoBehaviour {
|
||||
public static AccountHandler instance;
|
||||
public AccountLoggedIn accountLoggedIn;
|
||||
[SerializeField] private AccountLoggedOut accountLoggedOut;
|
||||
@@ -14,27 +13,20 @@ public class AccountHandler : MonoBehaviour
|
||||
[SerializeField] private AccountRefreshLogin accountRefreshLogin;
|
||||
[SerializeField] internal AccountForgotDetails accountForgotDetails;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
void Awake() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (BazookaManager.Instance.GetAccountID() != null && BazookaManager.Instance.GetAccountName() != null && BazookaManager.Instance.GetAccountSession() != null)
|
||||
{
|
||||
void Start() {
|
||||
if (BazookaManager.Instance.GetAccountID() != null && BazookaManager.Instance.GetAccountName() != null && BazookaManager.Instance.GetAccountSession() != null) {
|
||||
SwitchPanel(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
SwitchPanel(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchPanel(int panel)
|
||||
{
|
||||
switch (panel)
|
||||
{
|
||||
public void SwitchPanel(int panel) {
|
||||
switch (panel) {
|
||||
case 0:
|
||||
accountLoggedIn.gameObject.SetActive(true);
|
||||
accountLoggedOut.gameObject.SetActive(false);
|
||||
@@ -119,10 +111,8 @@ public class AccountHandler : MonoBehaviour
|
||||
foreach (CustomColorObject customColorObject in FindObjectsByType<CustomColorObject>(FindObjectsSortMode.None)) customColorObject.SetColor();
|
||||
}
|
||||
|
||||
async void Update()
|
||||
{
|
||||
if (Keyboard.current.escapeKey.wasPressedThisFrame)
|
||||
{
|
||||
async void Update() {
|
||||
if (Keyboard.current.escapeKey.wasPressedThisFrame) {
|
||||
if (accountChangePassword.gameObject.activeSelf || accountChangeUsername.gameObject.activeSelf || accountRefreshLogin.gameObject.activeSelf) SwitchPanel(0);
|
||||
else if (accountLogin.gameObject.activeSelf || accountRegister.gameObject.activeSelf) SwitchPanel(1);
|
||||
else if (accountForgotDetails.gameObject.activeSelf) accountForgotDetails.forgotDetailsBackButton.onClick.Invoke();
|
||||
|
||||
@@ -7,8 +7,7 @@ using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AccountLoggedIn : MonoBehaviour
|
||||
{
|
||||
public class AccountLoggedIn : MonoBehaviour {
|
||||
public TMP_Text loggedInText;
|
||||
[SerializeField] private AccountLoggedOut accountLoggedOut;
|
||||
[SerializeField] private Button loggedInChangeUsernameButton;
|
||||
@@ -19,30 +18,26 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
[SerializeField] private Button loggedInLogoutButton;
|
||||
[SerializeField] private Button loggedInBackButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
void Awake() {
|
||||
loggedInChangeUsernameButton.onClick.AddListener(() => AccountHandler.instance.SwitchPanel(4));
|
||||
loggedInChangePasswordButton.onClick.AddListener(() => AccountHandler.instance.SwitchPanel(5));
|
||||
loggedInSaveButton.onClick.AddListener(() => SaveAccount());
|
||||
loggedInLoadButton.onClick.AddListener(() => LoadAccount());
|
||||
loggedInRefreshLoginButton.onClick.AddListener(() => AccountHandler.instance.SwitchPanel(6));
|
||||
loggedInLogoutButton.onClick.AddListener(() =>
|
||||
{
|
||||
loggedInLogoutButton.onClick.AddListener(() => {
|
||||
BazookaManager.Instance.ResetSave();
|
||||
AccountHandler.instance.SwitchPanel(1);
|
||||
});
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
void OnEnable() {
|
||||
loggedInSaveButton.interactable = true;
|
||||
loggedInLoadButton.interactable = true;
|
||||
var textColor = BazookaManager.Instance.GetColorSettingText();
|
||||
Tools.UpdateStatusText(loggedInText, "Logged in as: " + BazookaManager.Instance.GetAccountName(), new Color(int.Parse(textColor[0].ToString()) / 255f, int.Parse(textColor[1].ToString()) / 255f, int.Parse(textColor[2].ToString()) / 255f));
|
||||
}
|
||||
|
||||
async void SaveAccount()
|
||||
{
|
||||
async void SaveAccount() {
|
||||
loggedInChangeUsernameButton.interactable = false;
|
||||
loggedInChangePasswordButton.interactable = false;
|
||||
loggedInSaveButton.interactable = false;
|
||||
@@ -58,8 +53,7 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.downloadHandler.text == null)
|
||||
{
|
||||
if (request.downloadHandler.text == null) {
|
||||
loggedInChangeUsernameButton.interactable = true;
|
||||
loggedInChangePasswordButton.interactable = true;
|
||||
loggedInSaveButton.interactable = true;
|
||||
@@ -81,8 +75,7 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
loggedInBackButton.interactable = true;
|
||||
}
|
||||
|
||||
async void LoadAccount()
|
||||
{
|
||||
async void LoadAccount() {
|
||||
loggedInChangeUsernameButton.interactable = false;
|
||||
loggedInChangePasswordButton.interactable = false;
|
||||
loggedInSaveButton.interactable = false;
|
||||
@@ -96,8 +89,7 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.downloadHandler.text == null)
|
||||
{
|
||||
if (request.downloadHandler.text == null) {
|
||||
loggedInChangeUsernameButton.interactable = true;
|
||||
loggedInChangePasswordButton.interactable = true;
|
||||
loggedInSaveButton.interactable = true;
|
||||
@@ -109,18 +101,14 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
var jsonResponse = JObject.Parse(request.downloadHandler.text);
|
||||
if ((bool)jsonResponse["success"])
|
||||
{
|
||||
if ((bool)jsonResponse["success"]) {
|
||||
BazookaManager.Instance.saveFile = JObject.FromObject(jsonResponse["data"]);
|
||||
if (!Application.isMobilePlatform)
|
||||
{
|
||||
if (!Application.isMobilePlatform) {
|
||||
var width = Display.main.systemWidth;
|
||||
var height = Display.main.systemHeight;
|
||||
Screen.SetResolution(width, height, BazookaManager.Instance.GetSettingFullScreen());
|
||||
QualitySettings.vSyncCount = BazookaManager.Instance.GetSettingVsync() ? 1 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Application.targetFrameRate = 360;
|
||||
QualitySettings.vSyncCount = 0;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AccountLoggedOut : MonoBehaviour
|
||||
{
|
||||
public class AccountLoggedOut : MonoBehaviour {
|
||||
[SerializeField] private Button loggedOutLoginButton;
|
||||
[SerializeField] private Button loggedOutRegisterButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
void Awake() {
|
||||
loggedOutLoginButton.onClick.AddListener(() => AccountHandler.instance.SwitchPanel(2));
|
||||
loggedOutRegisterButton.onClick.AddListener(() => AccountHandler.instance.SwitchPanel(3));
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AccountLogin : MonoBehaviour
|
||||
{
|
||||
public class AccountLogin : MonoBehaviour {
|
||||
[SerializeField] private TMP_Text loginPanelStatusText;
|
||||
[SerializeField] private TMP_InputField loginUsernameInput;
|
||||
[SerializeField] private TMP_InputField loginPasswordInput;
|
||||
@@ -15,23 +14,20 @@ public class AccountLogin : MonoBehaviour
|
||||
[SerializeField] private Button loginBackButton;
|
||||
[SerializeField] private Button loginSubmitButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
void Awake() {
|
||||
loginUsernameInput.onSelect.AddListener((_) => loginUsernameInput.caretPosition = loginUsernameInput.text.Length);
|
||||
loginPasswordInput.onSelect.AddListener((_) => loginPasswordInput.caretPosition = loginPasswordInput.text.Length);
|
||||
|
||||
loginBackButton.onClick.AddListener(() => AccountHandler.instance.SwitchPanel(1));
|
||||
loginSubmitButton.onClick.AddListener(() => SubmitLogin());
|
||||
forgotUsernameButton.onClick.AddListener(() =>
|
||||
{
|
||||
forgotUsernameButton.onClick.AddListener(() => {
|
||||
AccountHandler.instance.SwitchPanel(7);
|
||||
AccountHandler.instance.accountForgotDetails.mode = 0;
|
||||
AccountHandler.instance.accountForgotDetails.forgotDetailsTitleText.text = "Forgot username";
|
||||
AccountHandler.instance.accountForgotDetails.forgotDetailsBackButton.interactable = true;
|
||||
AccountHandler.instance.accountForgotDetails.forgotDetailsSubmitButton.interactable = true;
|
||||
});
|
||||
forgotPasswordButton.onClick.AddListener(() =>
|
||||
{
|
||||
forgotPasswordButton.onClick.AddListener(() => {
|
||||
AccountHandler.instance.SwitchPanel(7);
|
||||
AccountHandler.instance.accountForgotDetails.mode = 1;
|
||||
AccountHandler.instance.accountForgotDetails.forgotDetailsTitleText.text = "Forgot password";
|
||||
@@ -40,19 +36,16 @@ public class AccountLogin : MonoBehaviour
|
||||
});
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
void OnEnable() {
|
||||
loginUsernameInput.text = "";
|
||||
loginPasswordInput.text = "";
|
||||
loginPanelStatusText.text = "";
|
||||
}
|
||||
|
||||
async void SubmitLogin()
|
||||
{
|
||||
async void SubmitLogin() {
|
||||
loginBackButton.interactable = false;
|
||||
loginSubmitButton.interactable = false;
|
||||
if (loginUsernameInput.text == string.Empty || loginPasswordInput.text == string.Empty)
|
||||
{
|
||||
if (loginUsernameInput.text == string.Empty || loginPasswordInput.text == string.Empty) {
|
||||
Tools.UpdateStatusText(loginPanelStatusText, "All input fields must be filled", Color.red);
|
||||
return;
|
||||
}
|
||||
@@ -64,24 +57,20 @@ public class AccountLogin : MonoBehaviour
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.downloadHandler.text == null)
|
||||
{
|
||||
if (request.downloadHandler.text == null) {
|
||||
loginBackButton.interactable = true;
|
||||
loginSubmitButton.interactable = true;
|
||||
Tools.UpdateStatusText(loginPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
return;
|
||||
}
|
||||
var jsonResponse = JObject.Parse(request.downloadHandler.text);
|
||||
if ((bool)jsonResponse["success"])
|
||||
{
|
||||
if ((bool)jsonResponse["success"]) {
|
||||
BazookaManager.Instance.SetAccountSession((string)jsonResponse["data"]["session"]);
|
||||
BazookaManager.Instance.SetAccountName((string)jsonResponse["data"]["username"]);
|
||||
BazookaManager.Instance.SetAccountID(BigInteger.Parse((string)jsonResponse["data"]["id"]));
|
||||
AccountHandler.instance.SwitchPanel(0);
|
||||
Tools.UpdateStatusText(loginPanelStatusText, "", Color.red);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Tools.UpdateStatusText(loginPanelStatusText, (string)jsonResponse["message"], Color.red);
|
||||
}
|
||||
loginBackButton.interactable = true;
|
||||
|
||||
@@ -5,16 +5,14 @@ using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AccountRefreshLogin : MonoBehaviour
|
||||
{
|
||||
public class AccountRefreshLogin : MonoBehaviour {
|
||||
[SerializeField] private TMP_Text refreshLoginStatusText;
|
||||
[SerializeField] private TMP_InputField refreshLoginUsernameInput;
|
||||
[SerializeField] private TMP_InputField refreshLoginPasswordInput;
|
||||
[SerializeField] private Button refreshLoginBackButton;
|
||||
[SerializeField] private Button refreshLoginSubmitButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
void Awake() {
|
||||
refreshLoginUsernameInput.onSelect.AddListener((_) => refreshLoginUsernameInput.caretPosition = refreshLoginUsernameInput.text.Length);
|
||||
refreshLoginPasswordInput.onSelect.AddListener((_) => refreshLoginPasswordInput.caretPosition = refreshLoginPasswordInput.text.Length);
|
||||
|
||||
@@ -22,14 +20,12 @@ public class AccountRefreshLogin : MonoBehaviour
|
||||
refreshLoginSubmitButton.onClick.AddListener(() => RefreshLogin());
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
void OnEnable() {
|
||||
refreshLoginUsernameInput.text = "";
|
||||
refreshLoginPasswordInput.text = "";
|
||||
}
|
||||
|
||||
async void RefreshLogin()
|
||||
{
|
||||
async void RefreshLogin() {
|
||||
refreshLoginBackButton.interactable = false;
|
||||
refreshLoginSubmitButton.interactable = false;
|
||||
WWWForm dataForm = new();
|
||||
@@ -40,24 +36,20 @@ public class AccountRefreshLogin : MonoBehaviour
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.downloadHandler.text == null)
|
||||
{
|
||||
if (request.downloadHandler.text == null) {
|
||||
refreshLoginBackButton.interactable = true;
|
||||
refreshLoginSubmitButton.interactable = true;
|
||||
Tools.UpdateStatusText(refreshLoginStatusText, "Failed to make HTTP request", Color.red);
|
||||
return;
|
||||
}
|
||||
var jsonResponse = JObject.Parse(request.downloadHandler.text);
|
||||
if ((bool)jsonResponse["success"])
|
||||
{
|
||||
if ((bool)jsonResponse["success"]) {
|
||||
BazookaManager.Instance.SetAccountSession((string)jsonResponse["data"]["session"]);
|
||||
BazookaManager.Instance.SetAccountName((string)jsonResponse["data"]["username"]);
|
||||
BazookaManager.Instance.SetAccountID(BigInteger.Parse((string)jsonResponse["data"]["id"]));
|
||||
AccountHandler.instance.SwitchPanel(0);
|
||||
Tools.UpdateStatusText(refreshLoginStatusText, "", Color.red);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Tools.UpdateStatusText(refreshLoginStatusText, (string)jsonResponse["message"], Color.red);
|
||||
}
|
||||
refreshLoginBackButton.interactable = true;
|
||||
|
||||
@@ -4,8 +4,7 @@ using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AccountRegister : MonoBehaviour
|
||||
{
|
||||
public class AccountRegister : MonoBehaviour {
|
||||
[SerializeField] private TMP_Text registerPanelStatusText;
|
||||
[SerializeField] private TMP_InputField registerUsernameInput;
|
||||
[SerializeField] private TMP_InputField registerEmailInput;
|
||||
@@ -16,8 +15,7 @@ public class AccountRegister : MonoBehaviour
|
||||
[SerializeField] private Button registerBackButton;
|
||||
[SerializeField] private Button registerSubmitButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
void Awake() {
|
||||
registerUsernameInput.onSelect.AddListener((_) => registerUsernameInput.caretPosition = registerUsernameInput.text.Length);
|
||||
registerEmailInput.onSelect.AddListener((_) => registerEmailInput.caretPosition = registerEmailInput.text.Length);
|
||||
registerRetypeEmailInput.onSelect.AddListener((_) => registerRetypeEmailInput.caretPosition = registerRetypeEmailInput.text.Length);
|
||||
@@ -29,8 +27,7 @@ public class AccountRegister : MonoBehaviour
|
||||
registerSubmitButton.onClick.AddListener(() => SubmitRegister());
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
void OnEnable() {
|
||||
registerUsernameInput.text = "";
|
||||
registerEmailInput.text = "";
|
||||
registerRetypeEmailInput.text = "";
|
||||
@@ -40,8 +37,7 @@ public class AccountRegister : MonoBehaviour
|
||||
registerPanelStatusText.text = "";
|
||||
}
|
||||
|
||||
async void SubmitRegister()
|
||||
{
|
||||
async void SubmitRegister() {
|
||||
if (
|
||||
registerUsernameInput.text == string.Empty ||
|
||||
registerEmailInput.text == string.Empty ||
|
||||
@@ -49,18 +45,15 @@ public class AccountRegister : MonoBehaviour
|
||||
registerPasswordInput.text == string.Empty ||
|
||||
registerRetypePasswordInput.text == string.Empty ||
|
||||
registerVerifyCodeInput.text == string.Empty
|
||||
)
|
||||
{
|
||||
) {
|
||||
Tools.UpdateStatusText(registerPanelStatusText, "All input fields must be filled", Color.red);
|
||||
return;
|
||||
}
|
||||
if (registerEmailInput.text != registerRetypeEmailInput.text)
|
||||
{
|
||||
if (registerEmailInput.text != registerRetypeEmailInput.text) {
|
||||
Tools.UpdateStatusText(registerPanelStatusText, "Emails don't match", Color.red);
|
||||
return;
|
||||
}
|
||||
if (registerPasswordInput.text != registerRetypePasswordInput.text)
|
||||
{
|
||||
if (registerPasswordInput.text != registerRetypePasswordInput.text) {
|
||||
Tools.UpdateStatusText(registerPanelStatusText, "Passwords don't match", Color.red);
|
||||
return;
|
||||
}
|
||||
@@ -77,20 +70,16 @@ public class AccountRegister : MonoBehaviour
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.downloadHandler.text == null)
|
||||
{
|
||||
if (request.downloadHandler.text == null) {
|
||||
registerBackButton.interactable = true;
|
||||
registerSubmitButton.interactable = true;
|
||||
Tools.UpdateStatusText(registerPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
return;
|
||||
}
|
||||
var jsonResponse = JObject.Parse(request.downloadHandler.text);
|
||||
if ((bool)jsonResponse["success"])
|
||||
{
|
||||
if ((bool)jsonResponse["success"]) {
|
||||
AccountHandler.instance.SwitchPanel(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Tools.UpdateStatusText(registerPanelStatusText, (string)jsonResponse["message"], Color.red);
|
||||
}
|
||||
registerBackButton.interactable = true;
|
||||
|
||||
Reference in new issue
Block a user