Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
a8088d0964
|
|||
|
d548663222
|
|||
|
3056e38cf2
|
|||
|
bcc8a91015
|
|||
|
3a80abd28c
|
|||
|
261d4a8985
|
|||
|
d5e2601cb9
|
|||
|
96090090fa
|
|||
|
79a4a5e07b
|
|||
|
1abe2ac064
|
|||
|
b37db5231e
|
|||
|
09b18a07bf
|
|||
|
ec797297e0
|
|||
|
b48a826052
|
|||
|
845e58f98f
|
2945
Assets/Scenes/ChatroomMenu.unity
Normal file
2945
Assets/Scenes/ChatroomMenu.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/ChatroomMenu.unity.meta
Normal file
7
Assets/Scenes/ChatroomMenu.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d51f8ef1f7d4f01a8416e468a7ed278
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2057,142 +2057,6 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1097153681}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1221390703
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1221390704}
|
||||
- component: {fileID: 1221390706}
|
||||
- component: {fileID: 1221390705}
|
||||
m_Layer: 5
|
||||
m_Name: Text (TMP)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1221390704
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1221390703}
|
||||
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: 2038556860}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: -21.5}
|
||||
m_SizeDelta: {x: 200, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1221390705
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1221390703}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: Coming 1.5.1
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 4fd546dd0900395408d2de20f5025882, type: 2}
|
||||
m_sharedMaterial: {fileID: -1476194838487357290, guid: 4fd546dd0900395408d2de20f5025882, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4278255615
|
||||
m_fontColor: {r: 1, g: 1, b: 0, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 16
|
||||
m_fontSizeBase: 16
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 512
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 0
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!222 &1221390706
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1221390703}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1263503579
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4360,7 +4224,6 @@ RectTransform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1657120008}
|
||||
- {fileID: 1221390704}
|
||||
m_Father: {fileID: 1266243668}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
@@ -4420,7 +4283,7 @@ MonoBehaviour:
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 0
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 2038556863}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -49,6 +49,9 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
dataForm.AddField("totalUltraBerries", PlayerPrefs.GetString("TotalUltraBerries", "0"));
|
||||
dataForm.AddField("totalSpeedyBerries", PlayerPrefs.GetString("TotalSpeedyBerries", "0"));
|
||||
dataForm.AddField("totalAttempts", PlayerPrefs.GetString("TotalAttempts", "0"));
|
||||
dataForm.AddField("birdR", PlayerPrefs.GetString("BirdColor", "255;255;255").Split(';')[0]);
|
||||
dataForm.AddField("birdG", PlayerPrefs.GetString("BirdColor", "255;255;255").Split(';')[1]);
|
||||
dataForm.AddField("birdB", PlayerPrefs.GetString("BirdColor", "255;255;255").Split(';')[2]);
|
||||
using UnityWebRequest request = UnityWebRequest.Post(SensitiveInfo.SERVER_DATABASE_PREFIX + "saveAccount.php", dataForm.GetWWWForm());
|
||||
request.SetRequestHeader("Requester", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
@@ -130,6 +133,7 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
PlayerPrefs.SetString("TotalUltraBerries", split[7]);
|
||||
PlayerPrefs.SetString("TotalSpeedyBerries", split[8]);
|
||||
PlayerPrefs.SetString("TotalAttempts", split[9]);
|
||||
PlayerPrefs.SetString("BirdColor", $"{split[10]};{split[11]};{split[12]}");
|
||||
AccountHandler.UpdateStatusText(loggedInText, "Loaded account data", Color.green);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -83,6 +83,7 @@ public class AccountLogin : MonoBehaviour
|
||||
PlayerPrefs.SetString("TotalUltraBerries", array[10]);
|
||||
PlayerPrefs.SetString("TotalSpeedyBerries", array[11]);
|
||||
PlayerPrefs.SetString("TotalAttempts", array[12]);
|
||||
PlayerPrefs.SetString("BirdColor", $"{array[13]};{array[14]};{array[15]}");
|
||||
AccountHandler.instance.SwitchPanel(0);
|
||||
AccountHandler.UpdateStatusText(loginPanelStatusText, "", Color.red);
|
||||
}
|
||||
|
||||
@@ -59,9 +59,17 @@ public class AccountRefreshLogin : MonoBehaviour
|
||||
{
|
||||
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Incorrect username or password", Color.red);
|
||||
}
|
||||
else if (response == "1")
|
||||
else if (response.Split(":")[0] == "1")
|
||||
{
|
||||
string[] array = response.Split(':');
|
||||
string session = array[1];
|
||||
string userName = array[2];
|
||||
int userId = int.Parse(array[3]);
|
||||
PlayerPrefs.SetString("gameSession", session);
|
||||
PlayerPrefs.SetString("userName", userName);
|
||||
PlayerPrefs.SetInt("userId", userId);
|
||||
AccountHandler.instance.SwitchPanel(0);
|
||||
AccountHandler.UpdateStatusText(refreshLoginStatusText, "", Color.red);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
235
Assets/Scripts/ChatroomMenu.cs
Normal file
235
Assets/Scripts/ChatroomMenu.cs
Normal file
@@ -0,0 +1,235 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ChatroomMenu : MonoBehaviour
|
||||
{
|
||||
public TMP_Text statusText;
|
||||
public Button backButton;
|
||||
public Button sendButton;
|
||||
public TMP_InputField messageInputField;
|
||||
public GameObject content;
|
||||
public GameObject sampleObject;
|
||||
private string statusMessage;
|
||||
private Coroutine statusRoutine;
|
||||
private Coroutine refreshLoopRoutine;
|
||||
|
||||
void Start()
|
||||
{
|
||||
backButton.onClick.AddListener(async () => await SceneManager.LoadSceneAsync("MainMenu"));
|
||||
sendButton.onClick.AddListener(async () => await HandleMessageSubmit());
|
||||
messageInputField.textComponent.textWrappingMode = TextWrappingModes.Normal;
|
||||
messageInputField.onSubmit.AddListener(async (_) => await HandleMessageSubmit());
|
||||
refreshLoopRoutine = StartCoroutine(Loop());
|
||||
}
|
||||
|
||||
IEnumerator Loop() {
|
||||
while (true) {
|
||||
Refresh();
|
||||
yield return new WaitForSeconds(3f);
|
||||
}
|
||||
}
|
||||
|
||||
async Task HandleMessageSubmit()
|
||||
{
|
||||
var text = messageInputField.text.Clone() as string;
|
||||
messageInputField.text = string.Empty;
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EncryptedWWWForm dataForm = new();
|
||||
dataForm.AddField("content", text);
|
||||
dataForm.AddField("gameSession", PlayerPrefs.GetString("gameSession", ""));
|
||||
using UnityWebRequest request = UnityWebRequest.Post(SensitiveInfo.SERVER_DATABASE_PREFIX + "sendChatroomMessage.php", dataForm.GetWWWForm());
|
||||
request.SetRequestHeader("Requester", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY);
|
||||
switch (response)
|
||||
{
|
||||
case "-999":
|
||||
ShowStatus("Server error while fetching data");
|
||||
break;
|
||||
case "-998":
|
||||
ShowStatus("Client version too outdated to access servers");
|
||||
break;
|
||||
case "-997":
|
||||
ShowStatus("Encryption/decryption issues");
|
||||
break;
|
||||
case "-1":
|
||||
ShowStatus("Authentication error.");
|
||||
break;
|
||||
case "1":
|
||||
StopCoroutine(refreshLoopRoutine);
|
||||
refreshLoopRoutine = StartCoroutine(Loop());
|
||||
content.transform.localPosition = new Vector2(0f, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ShowStatus(string content)
|
||||
{
|
||||
statusMessage = content;
|
||||
if (statusRoutine != null) StopCoroutine(statusRoutine);
|
||||
statusRoutine = StartCoroutine(StatusRoutine());
|
||||
}
|
||||
|
||||
IEnumerator StatusRoutine()
|
||||
{
|
||||
statusText.gameObject.SetActive(true);
|
||||
statusText.text = statusMessage;
|
||||
statusText.color = new Color(statusText.color.r, statusText.color.g, statusText.color.b, 0f);
|
||||
|
||||
float t = 0f;
|
||||
while (t < 0.5f)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
float a = t / 0.5f;
|
||||
statusText.color = new Color(statusText.color.r, statusText.color.g, statusText.color.b, a);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(2f);
|
||||
|
||||
t = 0f;
|
||||
while (t < 0.5f)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
float a = 1f - (t / 0.5f);
|
||||
statusText.color = new Color(statusText.color.r, statusText.color.g, statusText.color.b, a);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
statusText.gameObject.SetActive(false);
|
||||
statusText.text = "";
|
||||
statusRoutine = null;
|
||||
}
|
||||
|
||||
async void Refresh()
|
||||
{
|
||||
using UnityWebRequest request = UnityWebRequest.Get(SensitiveInfo.SERVER_DATABASE_PREFIX + "getChatroomMessages.php");
|
||||
request.SetRequestHeader("Requester", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("Failed to fetch chatroom messages: " + request.error);
|
||||
return;
|
||||
}
|
||||
string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY);
|
||||
var shouldClear = true;
|
||||
switch (response)
|
||||
{
|
||||
case "-999":
|
||||
ShowStatus("Server error while fetching data");
|
||||
break;
|
||||
case "-998":
|
||||
ShowStatus("Client version too outdated to access servers");
|
||||
break;
|
||||
case "-997":
|
||||
ShowStatus("Encryption/decryption issues");
|
||||
break;
|
||||
case "-1":
|
||||
ShowStatus("Authentication error.");
|
||||
break;
|
||||
default:
|
||||
var split = response.Split(':');
|
||||
if (split[0] == "1")
|
||||
{
|
||||
shouldClear = false;
|
||||
foreach (var row in split[1].Split("|"))
|
||||
{
|
||||
var rowSplit = row.Split(';');
|
||||
var id = rowSplit[0];
|
||||
var username = Encoding.UTF8.GetString(Convert.FromBase64String(rowSplit[1]));
|
||||
var chatContent = Encoding.UTF8.GetString(Convert.FromBase64String(rowSplit[2]));
|
||||
var icon = rowSplit[3];
|
||||
var overlay = rowSplit[4];
|
||||
var uid = rowSplit[5];
|
||||
var birdR = rowSplit[6];
|
||||
var birdG = rowSplit[7];
|
||||
var birdB = rowSplit[8];
|
||||
|
||||
if (content.transform.Find("ChatroomRow_" + id) != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (content.transform.childCount > 50)
|
||||
{
|
||||
var firstChild = content.transform.GetChild(0);
|
||||
Destroy(firstChild.gameObject);
|
||||
}
|
||||
|
||||
var rowInfo = Instantiate(sampleObject, content.transform);
|
||||
var usernameText = rowInfo.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||
var playerIcon = usernameText.transform.GetChild(0).GetComponent<Image>();
|
||||
var playerOverlayIcon = playerIcon.transform.GetChild(0).GetComponent<Image>();
|
||||
var messageText = rowInfo.transform.GetChild(1).GetComponent<TMP_Text>();
|
||||
|
||||
usernameText.text = username;
|
||||
messageText.text = chatContent;
|
||||
playerIcon.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + icon);
|
||||
if (icon == "1")
|
||||
{
|
||||
playerIcon.sprite = Tools.GetIconForUser(int.Parse(uid));
|
||||
}
|
||||
playerOverlayIcon.sprite = Resources.Load<Sprite>("Icons/Overlays/overlay_" + overlay);
|
||||
if (overlay == "0")
|
||||
{
|
||||
playerOverlayIcon.gameObject.SetActive(false);
|
||||
}
|
||||
else if (overlay == "8")
|
||||
{
|
||||
playerOverlayIcon.transform.localPosition = new Vector2(-16.56f, 14.81f);
|
||||
}
|
||||
else if (overlay == "11")
|
||||
{
|
||||
playerOverlayIcon.transform.localPosition = new Vector2(-14.74451f, 20.39122f);
|
||||
}
|
||||
else if (overlay == "13")
|
||||
{
|
||||
playerOverlayIcon.transform.localPosition = new Vector2(-16.54019f, 14.70365f);
|
||||
}
|
||||
try
|
||||
{
|
||||
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
|
||||
} catch (Exception)
|
||||
{
|
||||
playerIcon.color = Color.white;
|
||||
}
|
||||
rowInfo.name = "ChatroomRow_" + id;
|
||||
rowInfo.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowStatus("Error fetching messages.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (shouldClear)
|
||||
{
|
||||
foreach (Transform item in content.transform)
|
||||
{
|
||||
if (item.gameObject.activeSelf)
|
||||
{
|
||||
Destroy(item.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ChatroomMenu.cs.meta
Normal file
2
Assets/Scripts/ChatroomMenu.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dbd2b8269756e018b7c71d0e878242c
|
||||
@@ -42,6 +42,26 @@ public class GamePlayer : MonoBehaviour
|
||||
|
||||
void Awake()
|
||||
{
|
||||
var backgroundColor = PlayerPrefs.GetString("BackgroundColor", "58;58;58").Split(";");
|
||||
var birdColor = PlayerPrefs.GetString("BirdColor", "255;255;255").Split(";");
|
||||
try
|
||||
{
|
||||
Camera.main.backgroundColor = new Color(
|
||||
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
|
||||
);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogError("Invalid BackgroundColor format");
|
||||
}
|
||||
|
||||
lastMoveTime = Time.time;
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
|
||||
instance = this;
|
||||
|
||||
62
Assets/Scripts/IconsMenuBirdColorPanel.cs
Normal file
62
Assets/Scripts/IconsMenuBirdColorPanel.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class IconsMenuBirdColorPanel : MonoBehaviour
|
||||
{
|
||||
public Slider rSlider;
|
||||
public Slider gSlider;
|
||||
public Slider bSlider;
|
||||
public TMP_InputField hexValue;
|
||||
public Image previewImage;
|
||||
public Button resetButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
var birdColor = PlayerPrefs.GetString("BirdColor", "255;255;255").Split(";");
|
||||
try
|
||||
{
|
||||
rSlider.value = int.Parse(birdColor[0]);
|
||||
gSlider.value = int.Parse(birdColor[1]);
|
||||
bSlider.value = int.Parse(birdColor[2]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogError("Invalid BirdColor format");
|
||||
rSlider.value = 255; gSlider.value = 255; bSlider.value = 255;
|
||||
}
|
||||
SlidersChanged();
|
||||
|
||||
rSlider.onValueChanged.AddListener(_ => SlidersChanged());
|
||||
gSlider.onValueChanged.AddListener(_ => SlidersChanged());
|
||||
bSlider.onValueChanged.AddListener(_ => SlidersChanged());
|
||||
|
||||
hexValue.onValueChanged.AddListener(value =>
|
||||
{
|
||||
var v = value.StartsWith("#") ? value[1..] : value;
|
||||
if (v.Length == 6 && ColorUtility.TryParseHtmlString("#" + v, out var col))
|
||||
{
|
||||
rSlider.SetValueWithoutNotify(col.r * 255f);
|
||||
gSlider.SetValueWithoutNotify(col.g * 255f);
|
||||
bSlider.SetValueWithoutNotify(col.b * 255f);
|
||||
previewImage.color = col;
|
||||
PlayerPrefs.SetString("BirdColor", $"{(int)(col.r * 255)};{(int)(col.g * 255)};{(int)(col.b * 255)}");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
});
|
||||
|
||||
resetButton.onClick.AddListener(() =>
|
||||
{
|
||||
hexValue.text = "#FFFFFF";
|
||||
});
|
||||
}
|
||||
|
||||
void SlidersChanged()
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/IconsMenuBirdColorPanel.cs.meta
Normal file
2
Assets/Scripts/IconsMenuBirdColorPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2570aea461bc94f28157a7cc7d381ef
|
||||
@@ -9,37 +9,40 @@ using UnityEngine.UI;
|
||||
public class LeaderboardsMenu : MonoBehaviour
|
||||
{
|
||||
public TMP_Text statusText;
|
||||
public Button backButton;
|
||||
public Button refreshButton;
|
||||
|
||||
public GameObject selectionPanel;
|
||||
public Button selectionScoreButton;
|
||||
public Button selectionBerryButton;
|
||||
public Button selectionBackButton;
|
||||
|
||||
public GameObject scorePanel;
|
||||
public GameObject scoreContent;
|
||||
public Button scoreBackButton;
|
||||
public Button scoreRefreshButton;
|
||||
public GameObject scoreSampleObject;
|
||||
|
||||
public GameObject berryPanel;
|
||||
public GameObject berryContent;
|
||||
public TMP_Dropdown berryShowTypeDropdown;
|
||||
public Button berryBackButton;
|
||||
public Button berryRefreshButton;
|
||||
public GameObject berrySampleObject;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
selectionScoreButton.onClick.AddListener(() => SwitchMenu(1));
|
||||
selectionBerryButton.onClick.AddListener(() => SwitchMenu(2));
|
||||
selectionBackButton.onClick.AddListener(async () => await SceneManager.LoadSceneAsync("MainMenu"));
|
||||
|
||||
scoreBackButton.onClick.AddListener(() => SwitchMenu(0));
|
||||
scoreRefreshButton.onClick.AddListener(() => GetTopPlayersScore());
|
||||
|
||||
berryShowTypeDropdown.onValueChanged.AddListener(value => GetTopPlayersBerry(value));
|
||||
berryBackButton.onClick.AddListener(() => SwitchMenu(0));
|
||||
berryRefreshButton.onClick.AddListener(() => GetTopPlayersBerry(berryShowTypeDropdown.value));
|
||||
|
||||
|
||||
backButton.onClick.AddListener(async () =>
|
||||
{
|
||||
if (selectionPanel.activeSelf) await SceneManager.LoadSceneAsync("MainMenu");
|
||||
else if (scorePanel.activeSelf || berryPanel.activeSelf) SwitchMenu(0);
|
||||
});
|
||||
refreshButton.onClick.AddListener(() =>
|
||||
{
|
||||
if (scorePanel.activeSelf) GetTopPlayersScore();
|
||||
else if (berryPanel.activeSelf) GetTopPlayersBerry(berryShowTypeDropdown.value);
|
||||
});
|
||||
}
|
||||
|
||||
void SwitchMenu(int menu) {
|
||||
@@ -62,17 +65,22 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
switch (menu)
|
||||
{
|
||||
case 0:
|
||||
refreshButton.gameObject.SetActive(false);
|
||||
selectionPanel.SetActive(true);
|
||||
scorePanel.SetActive(false);
|
||||
berryPanel.SetActive(false);
|
||||
break;
|
||||
case 1:
|
||||
refreshButton.transform.localPosition = new Vector2(-402.5f, -282.33f);
|
||||
refreshButton.gameObject.SetActive(true);
|
||||
GetTopPlayersScore();
|
||||
selectionPanel.SetActive(false);
|
||||
scorePanel.SetActive(true);
|
||||
berryPanel.SetActive(false);
|
||||
break;
|
||||
case 2:
|
||||
refreshButton.transform.localPosition = new Vector2(402.5f, 282.33f);
|
||||
refreshButton.gameObject.SetActive(true);
|
||||
berryShowTypeDropdown.value = 0;
|
||||
GetTopPlayersBerry(0);
|
||||
selectionPanel.SetActive(false);
|
||||
@@ -84,8 +92,8 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
|
||||
async void GetTopPlayersScore()
|
||||
{
|
||||
scoreBackButton.interactable = false;
|
||||
scoreRefreshButton.interactable = false;
|
||||
backButton.interactable = false;
|
||||
refreshButton.interactable = false;
|
||||
foreach (Transform item in scoreContent.transform)
|
||||
{
|
||||
if (item.gameObject.activeSelf)
|
||||
@@ -133,6 +141,9 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
var icon = split[2];
|
||||
var overlay = split[3];
|
||||
var uid = split[4];
|
||||
var birdR = split[5];
|
||||
var birdG = split[6];
|
||||
var birdB = split[7];
|
||||
|
||||
var entryInfo = Instantiate(scoreSampleObject, scoreContent.transform);
|
||||
var usernameText = entryInfo.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||
@@ -164,6 +175,13 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
{
|
||||
playerOverlayIcon.transform.localPosition = new Vector2(-16.54019f, 14.70365f);
|
||||
}
|
||||
try
|
||||
{
|
||||
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
|
||||
} catch (Exception)
|
||||
{
|
||||
playerIcon.color = Color.white;
|
||||
}
|
||||
entryInfo.SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -172,15 +190,15 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
{
|
||||
UpdateStatus(true, "Failed to fetch leaderboard stats");
|
||||
}
|
||||
scoreBackButton.interactable = true;
|
||||
scoreRefreshButton.interactable = true;
|
||||
backButton.interactable = true;
|
||||
refreshButton.interactable = true;
|
||||
}
|
||||
|
||||
async void GetTopPlayersBerry(int showAmount)
|
||||
{
|
||||
berryShowTypeDropdown.interactable = false;
|
||||
berryBackButton.interactable = false;
|
||||
berryRefreshButton.interactable = false;
|
||||
backButton.interactable = false;
|
||||
refreshButton.interactable = false;
|
||||
foreach (Transform item in berryContent.transform)
|
||||
{
|
||||
if (item.gameObject.activeSelf)
|
||||
@@ -229,6 +247,9 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
var icon = split[2];
|
||||
var overlay = split[3];
|
||||
var uid = split[4];
|
||||
var birdR = split[5];
|
||||
var birdG = split[6];
|
||||
var birdB = split[7];
|
||||
|
||||
var entryInfo = Instantiate(berrySampleObject, berryContent.transform);
|
||||
var usernameText = entryInfo.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||
@@ -260,6 +281,13 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
{
|
||||
playerOverlayIcon.transform.localPosition = new Vector2(-16.54019f, 14.70365f);
|
||||
}
|
||||
try
|
||||
{
|
||||
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
|
||||
} catch (Exception)
|
||||
{
|
||||
playerIcon.color = Color.white;
|
||||
}
|
||||
entryInfo.SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -269,8 +297,8 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
UpdateStatus(true, "Failed to fetch leaderboard stats");
|
||||
}
|
||||
berryShowTypeDropdown.interactable = true;
|
||||
berryBackButton.interactable = true;
|
||||
berryRefreshButton.interactable = true;
|
||||
backButton.interactable = true;
|
||||
refreshButton.interactable = true;
|
||||
}
|
||||
|
||||
private void UpdateStatus(bool enabled, string message = "")
|
||||
|
||||
62
Assets/Scripts/SettingsMenuBgColorPanel.cs
Normal file
62
Assets/Scripts/SettingsMenuBgColorPanel.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SettingsMenuBgColorPanel : MonoBehaviour
|
||||
{
|
||||
public Slider rSlider;
|
||||
public Slider gSlider;
|
||||
public Slider bSlider;
|
||||
public TMP_InputField hexValue;
|
||||
public Image previewImage;
|
||||
public Button resetButton;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
var backgroundColor = PlayerPrefs.GetString("BackgroundColor", "58;58;58").Split(";");
|
||||
try
|
||||
{
|
||||
rSlider.value = int.Parse(backgroundColor[0]);
|
||||
gSlider.value = int.Parse(backgroundColor[1]);
|
||||
bSlider.value = int.Parse(backgroundColor[2]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogError("Invalid BackgroundColor format");
|
||||
rSlider.value = 58; gSlider.value = 58; bSlider.value = 58;
|
||||
}
|
||||
SlidersChanged();
|
||||
|
||||
rSlider.onValueChanged.AddListener(_ => SlidersChanged());
|
||||
gSlider.onValueChanged.AddListener(_ => SlidersChanged());
|
||||
bSlider.onValueChanged.AddListener(_ => SlidersChanged());
|
||||
|
||||
hexValue.onValueChanged.AddListener(value =>
|
||||
{
|
||||
var v = value.StartsWith("#") ? value[1..] : value;
|
||||
if (v.Length == 6 && ColorUtility.TryParseHtmlString("#" + v, out var col))
|
||||
{
|
||||
rSlider.SetValueWithoutNotify(col.r * 255f);
|
||||
gSlider.SetValueWithoutNotify(col.g * 255f);
|
||||
bSlider.SetValueWithoutNotify(col.b * 255f);
|
||||
previewImage.color = col;
|
||||
PlayerPrefs.SetString("BackgroundColor", $"{(int)(col.r * 255)};{(int)(col.g * 255)};{(int)(col.b * 255)}");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
});
|
||||
|
||||
resetButton.onClick.AddListener(() =>
|
||||
{
|
||||
hexValue.text = "#3A3A3A";
|
||||
});
|
||||
}
|
||||
|
||||
void SlidersChanged()
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/SettingsMenuBgColorPanel.cs.meta
Normal file
2
Assets/Scripts/SettingsMenuBgColorPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 851d6819986698659a53cdf0cb057649
|
||||
@@ -14,6 +14,9 @@ EditorBuildSettings:
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/AccountMenu.unity
|
||||
guid: 61d560f45a39646489a33d9e871b5336
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/ChatroomMenu.unity
|
||||
guid: 6d51f8ef1f7d4f01a8416e468a7ed278
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/GamePlayer.unity
|
||||
guid: 8d9f90781cae8d24c8560dbca7ed6f42
|
||||
|
||||
@@ -140,7 +140,7 @@ PlayerSettings:
|
||||
loadStoreDebugModeEnabled: 0
|
||||
visionOSBundleVersion: 1.0
|
||||
tvOSBundleVersion: 1.0
|
||||
bundleVersion: 1.5.0
|
||||
bundleVersion: 1.5.1
|
||||
preloadedAssets:
|
||||
- {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
metroInputSource: 0
|
||||
|
||||
Reference in New Issue
Block a user