Tell the user why they can't send requests on self-built instance

This commit is contained in:
2025-06-30 14:38:45 -07:00
parent 68e61a9370
commit 0347dac2d8
23 changed files with 338 additions and 36 deletions

View File

@@ -61,6 +61,9 @@ public class AccountChangePassword : MonoBehaviour
case "-997":
AccountHandler.UpdateStatusText(changePasswordStatusText, "Encryption/decryption issues", Color.red);
break;
case "-996":
AccountHandler.UpdateStatusText(changePasswordStatusText, "Can't send requests on self-built instance", Color.red);
break;
case "-1":
AccountHandler.UpdateStatusText(changePasswordStatusText, "New Password is too short or too long", Color.red);
break;
@@ -88,4 +91,4 @@ public class AccountChangePassword : MonoBehaviour
AccountHandler.UpdateStatusText(changePasswordStatusText, "Unknown server response " + response, Color.red);
}
}
}
}

View File

@@ -53,6 +53,9 @@ public class AccountChangeUsername : MonoBehaviour
case "-997":
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Encryption/decryption issues", Color.red);
break;
case "-996":
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Can't send requests on self-built instance", Color.red);
break;
case "1":
PlayerPrefs.SetString("userName", changeUsernameNewUsernameInput.text);
AccountHandler.instance.SwitchPanel(0);
@@ -73,4 +76,4 @@ public class AccountChangeUsername : MonoBehaviour
break;
}
}
}
}

View File

@@ -23,7 +23,8 @@ public class AccountLoggedIn : MonoBehaviour
loggedInSaveButton.onClick.AddListener(() => SaveAccount());
loggedInLoadButton.onClick.AddListener(() => LoadAccount());
loggedInRefreshLoginButton.onClick.AddListener(() => AccountHandler.instance.SwitchPanel(6));
loggedInLogoutButton.onClick.AddListener(() => {
loggedInLogoutButton.onClick.AddListener(() =>
{
accountLoggedOut.clearValues = true;
AccountHandler.instance.SwitchPanel(1);
});
@@ -81,6 +82,9 @@ public class AccountLoggedIn : MonoBehaviour
case "-997":
AccountHandler.UpdateStatusText(loggedInText, "Encryption/decryption issues", Color.red);
break;
case "-996":
AccountHandler.UpdateStatusText(loggedInText, "Can't send requests on self-built instance", Color.red);
break;
case "1":
AccountHandler.UpdateStatusText(loggedInText, "Synced account", Color.green);
break;
@@ -124,6 +128,9 @@ public class AccountLoggedIn : MonoBehaviour
case "-997":
AccountHandler.UpdateStatusText(loggedInText, "Encryption/decryption issues", Color.red);
break;
case "-996":
AccountHandler.UpdateStatusText(loggedInText, "Can't send requests on self-built instance", Color.red);
break;
case "-1":
AccountHandler.UpdateStatusText(loggedInText, "Failed to find info about your user (refresh login?)", Color.red);
break;
@@ -153,4 +160,4 @@ public class AccountLoggedIn : MonoBehaviour
loggedInLoadButton.interactable = true;
loggedInSaveButton.interactable = true;
}
}
}

View File

@@ -37,4 +37,4 @@ public class AccountLoggedOut : MonoBehaviour
clearValues = false;
}
}
}
}

View File

@@ -58,6 +58,11 @@ public class AccountLogin : MonoBehaviour
AccountHandler.UpdateStatusText(loginPanelStatusText, "Encryption/decryption issues", Color.red);
return;
}
else if (response == "-996")
{
AccountHandler.UpdateStatusText(loginPanelStatusText, "Can't send requests on self-built instance", Color.red);
return;
}
else if (response == "-1")
{
AccountHandler.UpdateStatusText(loginPanelStatusText, "Incorrect username or password", Color.red);
@@ -93,4 +98,4 @@ public class AccountLogin : MonoBehaviour
AccountHandler.UpdateStatusText(loginPanelStatusText, "Unknown server response", Color.red);
}
}
}
}

View File

@@ -55,6 +55,11 @@ public class AccountRefreshLogin : MonoBehaviour
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Encryption/decryption issues", Color.red);
return;
}
else if (response == "-996")
{
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Can't send requests on self-built instance", Color.red);
return;
}
else if (response == "-1")
{
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Incorrect username or password", Color.red);
@@ -76,4 +81,4 @@ public class AccountRefreshLogin : MonoBehaviour
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Unknown server response", Color.red);
}
}
}
}

View File

@@ -75,6 +75,9 @@ public class AccountRegister : MonoBehaviour
case "-997":
AccountHandler.UpdateStatusText(registerPanelStatusText, "Encryption/decryption issues", Color.red);
break;
case "-996":
AccountHandler.UpdateStatusText(registerPanelStatusText, "Can't send requests on self-built instance", Color.red);
break;
case "1":
AccountHandler.instance.SwitchPanel(2);
break;
@@ -95,4 +98,4 @@ public class AccountRegister : MonoBehaviour
break;
}
}
}
}

View File

@@ -0,0 +1,15 @@
using UnityEngine;
public class BouncyPanel : MonoBehaviour
{
public float frequency = 8f;
public float minSize = 1f;
public float maxSize = 1.1f;
void Update()
{
float newsize = (Mathf.Sin(Time.time * frequency) + 1f) / 2f;
var size = Mathf.Lerp(minSize, maxSize, newsize);
gameObject.transform.localScale = new(size, size, size);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9c3738bf0236e043c9bdf9972b8a7375

View File

@@ -35,8 +35,10 @@ public class ChatroomMenu : MonoBehaviour
refreshLoopRoutine = StartCoroutine(Loop());
}
IEnumerator Loop() {
while (true) {
IEnumerator Loop()
{
while (true)
{
Refresh();
yield return new WaitForSeconds(3f);
}
@@ -76,6 +78,9 @@ public class ChatroomMenu : MonoBehaviour
case "-997":
ShowStatus("Encryption/decryption issues");
break;
case "-996":
ShowStatus("Can't send requests on self-built instance");
break;
case "-1":
ShowStatus("Authentication error");
break;
@@ -150,6 +155,9 @@ public class ChatroomMenu : MonoBehaviour
case "-997":
ShowStatus("Encryption/decryption issues");
break;
case "-996":
ShowStatus("Can't send requests on self-built instance");
break;
default:
var split = response.Split(':');
if (split[0] == "1")
@@ -215,7 +223,8 @@ public class ChatroomMenu : MonoBehaviour
{
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
playerOverlayIcon.color = new Color32(byte.Parse(overlayR), byte.Parse(overlayG), byte.Parse(overlayB), 255);
} catch (Exception)
}
catch (Exception)
{
playerIcon.color = Color.white;
playerOverlayIcon.color = Color.white;

View File

@@ -1,6 +1,5 @@
using UnityEngine;
using UnityEngine.EventSystems;
using TMPro;
using UnityEngine.UI;
using System.Collections.Generic;
@@ -100,4 +99,4 @@ public class DraggableUI : MonoBehaviour, IDragHandler, IBeginDragHandler
result = Vector3.zero;
return false;
}
}
}

View File

@@ -6,8 +6,9 @@ public class EncryptedWWWForm
public void AddField(string key, string value)
{
form.AddField(SensitiveInfo.Encrypt(key, SensitiveInfo.SERVER_SEND_TRANSFER_KEY), SensitiveInfo.Encrypt(value, SensitiveInfo.SERVER_SEND_TRANSFER_KEY));
if (SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY.Trim() != string.Empty && SensitiveInfo.SERVER_SEND_TRANSFER_KEY.Trim() != string.Empty)
form.AddField(SensitiveInfo.Encrypt(key, SensitiveInfo.SERVER_SEND_TRANSFER_KEY), SensitiveInfo.Encrypt(value, SensitiveInfo.SERVER_SEND_TRANSFER_KEY));
}
public WWWForm GetWWWForm() => form;
}
}

View File

@@ -48,19 +48,19 @@ public class GamePlayer : MonoBehaviour
try
{
Camera.main.backgroundColor = new Color(
int.Parse(backgroundColor[0])/255f,
int.Parse(backgroundColor[1])/255f,
int.Parse(backgroundColor[2])/255f
int.Parse(backgroundColor[0]) / 255f,
int.Parse(backgroundColor[1]) / 255f,
int.Parse(backgroundColor[2]) / 255f
);
bird.GetComponent<SpriteRenderer>().color = new Color(
int.Parse(birdColor[0])/255f,
int.Parse(birdColor[1])/255f,
int.Parse(birdColor[2])/255f
int.Parse(birdColor[0]) / 255f,
int.Parse(birdColor[1]) / 255f,
int.Parse(birdColor[2]) / 255f
);
bird.transform.GetChild(0).GetComponent<SpriteRenderer>().color = new Color(
int.Parse(overlayColor[0])/255f,
int.Parse(overlayColor[1])/255f,
int.Parse(overlayColor[2])/255f
int.Parse(overlayColor[0]) / 255f,
int.Parse(overlayColor[1]) / 255f,
int.Parse(overlayColor[2]) / 255f
);
}
catch

View File

@@ -53,10 +53,10 @@ public class IconsMenuBirdColorPanel : MonoBehaviour
void SlidersChanged()
{
var col = new Color(rSlider.value/255f, gSlider.value/255f, bSlider.value/255f);
var col = new Color(rSlider.value / 255f, gSlider.value / 255f, bSlider.value / 255f);
previewImage.color = col;
hexValue.SetTextWithoutNotify($"#{ColorUtility.ToHtmlStringRGB(col)}");
PlayerPrefs.SetString("BirdColor", $"{(int)rSlider.value};{(int)gSlider.value};{(int)bSlider.value}");
PlayerPrefs.Save();
}
}
}

View File

@@ -53,10 +53,10 @@ public class IconsMenuOverlayColorPanel : MonoBehaviour
void SlidersChanged()
{
var col = new Color(rSlider.value/255f, gSlider.value/255f, bSlider.value/255f);
var col = new Color(rSlider.value / 255f, gSlider.value / 255f, bSlider.value / 255f);
previewImage.color = col;
hexValue.SetTextWithoutNotify($"#{ColorUtility.ToHtmlStringRGB(col)}");
PlayerPrefs.SetString("OverlayColor", $"{(int)rSlider.value};{(int)gSlider.value};{(int)bSlider.value}");
PlayerPrefs.Save();
}
}
}

View File

@@ -3,4 +3,4 @@ using UnityEngine;
public class IgnoreRaycast : MonoBehaviour, ICanvasRaycastFilter
{
public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera) => false;
}
}

View File

@@ -45,7 +45,8 @@ public class LeaderboardsMenu : MonoBehaviour
});
}
void SwitchMenu(int menu) {
void SwitchMenu(int menu)
{
UpdateStatus(false, "");
foreach (Transform item in scoreContent.transform)
{
@@ -125,6 +126,10 @@ public class LeaderboardsMenu : MonoBehaviour
{
UpdateStatus(true, "Encryption/decryption issues");
}
else if (response == "-996")
{
UpdateStatus(true, "Can't send requests on self-built instance");
}
else if (response == "-1")
{
UpdateStatus(true, "No entries for this leaderboard found!");
@@ -182,7 +187,8 @@ public class LeaderboardsMenu : MonoBehaviour
{
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
playerOverlayIcon.color = new Color32(byte.Parse(overlayR), byte.Parse(overlayG), byte.Parse(overlayB), 255);
} catch (Exception)
}
catch (Exception)
{
playerIcon.color = Color.white;
playerOverlayIcon.color = Color.white;
@@ -236,6 +242,10 @@ public class LeaderboardsMenu : MonoBehaviour
{
UpdateStatus(true, "Encryption/decryption issues");
}
else if (response == "-996")
{
UpdateStatus(true, "Can't send requests on self-built instance");
}
else if (response == "-1")
{
UpdateStatus(true, "No entries for this leaderboard found!");
@@ -293,7 +303,8 @@ public class LeaderboardsMenu : MonoBehaviour
{
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
playerOverlayIcon.color = new Color32(byte.Parse(overlayR), byte.Parse(overlayG), byte.Parse(overlayB), 255);
} catch (Exception)
}
catch (Exception)
{
playerIcon.color = Color.white;
playerOverlayIcon.color = Color.white;

View File

@@ -43,7 +43,8 @@ public class LoadingMenu : MonoBehaviour
SetIfNone("Setting4", 0);
Application.targetFrameRate = 360;
QualitySettings.vSyncCount = 0;
if (Application.platform == RuntimePlatform.WebGLPlayer) {
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
Screen.fullScreen = false;
}
}

View File

@@ -7,6 +7,7 @@ public class MenuScript : MonoBehaviour
public Button exitButton;
public TMP_Text updateText;
public Button updateButton;
public GameObject selfBuiltPanel;
void Awake()
{
@@ -25,5 +26,6 @@ public class MenuScript : MonoBehaviour
Application.Quit();
});
}
if (SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY.Trim() == string.Empty || SensitiveInfo.SERVER_SEND_TRANSFER_KEY.Trim() == string.Empty) selfBuiltPanel.SetActive(true);
}
}

View File

@@ -12,6 +12,7 @@ public class SensitiveInfo
public static string Encrypt(string plainText, string key)
{
if (SERVER_RECEIVE_TRANSFER_KEY.Trim() == string.Empty || SERVER_SEND_TRANSFER_KEY.Trim() == string.Empty) return null;
try
{
using Aes aes = Aes.Create();
@@ -40,6 +41,10 @@ public class SensitiveInfo
public static string Decrypt(string dataB64, string key)
{
if (SERVER_RECEIVE_TRANSFER_KEY.Trim() == string.Empty || SERVER_SEND_TRANSFER_KEY.Trim() == string.Empty)
{
return "-996";
}
try
{
var data = Convert.FromBase64String(dataB64);

View File

@@ -53,10 +53,10 @@ public class SettingsMenuBgColorPanel : MonoBehaviour
void SlidersChanged()
{
var col = new Color(rSlider.value/255f, gSlider.value/255f, bSlider.value/255f);
var col = new Color(rSlider.value / 255f, gSlider.value / 255f, bSlider.value / 255f);
previewImage.color = col;
hexValue.SetTextWithoutNotify($"#{ColorUtility.ToHtmlStringRGB(col)}");
PlayerPrefs.SetString("BackgroundColor", $"{(int)rSlider.value};{(int)gSlider.value};{(int)bSlider.value}");
PlayerPrefs.Save();
}
}
}