Add possible error codes to the leaderboards menu
This commit is contained in:
@@ -2933,7 +2933,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
content: {fileID: 1097357904}
|
content: {fileID: 1097357904}
|
||||||
showAmount: {fileID: 1889805704}
|
showAmountDropdown: {fileID: 1889805704}
|
||||||
statusText: {fileID: 992753025}
|
statusText: {fileID: 992753025}
|
||||||
backButton: {fileID: 376603725}
|
backButton: {fileID: 376603725}
|
||||||
refreshButton: {fileID: 102792769}
|
refreshButton: {fileID: 102792769}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using UnityEngine.UI;
|
|||||||
public class LeaderboardsMenu : MonoBehaviour
|
public class LeaderboardsMenu : MonoBehaviour
|
||||||
{
|
{
|
||||||
public GameObject content;
|
public GameObject content;
|
||||||
public TMP_Dropdown showAmount;
|
public TMP_Dropdown showAmountDropdown;
|
||||||
public TMP_Text statusText;
|
public TMP_Text statusText;
|
||||||
public Button backButton;
|
public Button backButton;
|
||||||
public Button refreshButton;
|
public Button refreshButton;
|
||||||
@@ -18,7 +18,7 @@ public class LeaderboardsMenu : MonoBehaviour
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
GetTopPlayers(0);
|
GetTopPlayers(0);
|
||||||
showAmount.onValueChanged.AddListener(value =>
|
showAmountDropdown.onValueChanged.AddListener(value =>
|
||||||
{
|
{
|
||||||
GetTopPlayers(value);
|
GetTopPlayers(value);
|
||||||
});
|
});
|
||||||
@@ -28,13 +28,14 @@ public class LeaderboardsMenu : MonoBehaviour
|
|||||||
});
|
});
|
||||||
refreshButton.onClick.AddListener(() =>
|
refreshButton.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
GetTopPlayers(showAmount.value);
|
GetTopPlayers(showAmountDropdown.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async void GetTopPlayers(int showAmount)
|
async void GetTopPlayers(int showAmount)
|
||||||
{
|
{
|
||||||
refreshButton.interactable = false;
|
refreshButton.interactable = false;
|
||||||
|
showAmountDropdown.interactable = false;
|
||||||
foreach (Transform item in content.transform)
|
foreach (Transform item in content.transform)
|
||||||
{
|
{
|
||||||
if (item.gameObject.activeSelf)
|
if (item.gameObject.activeSelf)
|
||||||
@@ -53,6 +54,16 @@ public class LeaderboardsMenu : MonoBehaviour
|
|||||||
{
|
{
|
||||||
UpdateStatus(false);
|
UpdateStatus(false);
|
||||||
string response = request.downloadHandler.text;
|
string response = request.downloadHandler.text;
|
||||||
|
if (response == "-999")
|
||||||
|
{
|
||||||
|
UpdateStatus(true, "Server error while fetching data");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (response == "-998")
|
||||||
|
{
|
||||||
|
UpdateStatus(true, "Client version too outdated to access servers");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var splitResponse = response.Split(';');
|
var splitResponse = response.Split(';');
|
||||||
for (int i = 0; i < splitResponse.Length; i++)
|
for (int i = 0; i < splitResponse.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -102,6 +113,7 @@ public class LeaderboardsMenu : MonoBehaviour
|
|||||||
UpdateStatus(true, "Failed to fetch leaderboard stats");
|
UpdateStatus(true, "Failed to fetch leaderboard stats");
|
||||||
}
|
}
|
||||||
refreshButton.interactable = true;
|
refreshButton.interactable = true;
|
||||||
|
showAmountDropdown.interactable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStatus(bool enabled, string message = "")
|
private void UpdateStatus(bool enabled, string message = "")
|
||||||
|
|||||||
Reference in New Issue
Block a user