update map gen
This commit is contained in:
@@ -2,12 +2,16 @@ using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Hallucinate.Game;
|
||||
using Hallucinate.UI;
|
||||
|
||||
namespace Hallucinate.UI
|
||||
{
|
||||
public class ProfileController : BaseUIController
|
||||
{
|
||||
private Label _username;
|
||||
private Label _rank;
|
||||
private Label _eloLabel;
|
||||
private ProgressBar _winRateBar;
|
||||
private Label _winRateText;
|
||||
private Button _logoutBtn;
|
||||
@@ -22,6 +26,7 @@ namespace Hallucinate.UI
|
||||
|
||||
_username = root.Q<Label>("Username");
|
||||
_rank = root.Q<Label>("Rank");
|
||||
_eloLabel = root.Q<Label>("EloLabel");
|
||||
_winRateBar = root.Q<ProgressBar>("WinRateBar");
|
||||
_winRateText = root.Q<Label>("WinRateText");
|
||||
_logoutBtn = root.Q<Button>("LogoutBtn");
|
||||
@@ -67,11 +72,11 @@ namespace Hallucinate.UI
|
||||
|
||||
public override async Task PlayTransitionIn()
|
||||
{
|
||||
LoadProfileData(); // Refresh data every time we show the profile
|
||||
await LoadProfileData(); // Refresh data every time we show the profile
|
||||
await base.PlayTransitionIn();
|
||||
}
|
||||
|
||||
private void LoadProfileData()
|
||||
private async Task LoadProfileData()
|
||||
{
|
||||
// Load saved username or fallback
|
||||
string savedName = PlayerPrefs.GetString("Username", "Unknown Player");
|
||||
@@ -81,10 +86,27 @@ namespace Hallucinate.UI
|
||||
_googleIdPlaceholder = PlayerPrefs.GetString("GoogleID", "NOT_LINKED");
|
||||
_avatarUrlPlaceholder = PlayerPrefs.GetString("AvatarURL", "");
|
||||
|
||||
// Mock progression data for now
|
||||
_rank.text = "DIAMOND II";
|
||||
_winRateBar.value = 72;
|
||||
_winRateText.text = "72%";
|
||||
// Fetch real Elo data
|
||||
var eloData = await FirebaseService.GetPlayerData(savedName);
|
||||
|
||||
if (_eloLabel != null) _eloLabel.text = eloData.Rating.ToString();
|
||||
|
||||
if (_rank != null)
|
||||
{
|
||||
_rank.text = EloSystem.GetRank(eloData.Rating).ToUpper();
|
||||
if (ColorUtility.TryParseHtmlString(EloSystem.GetRankColor(eloData.Rating), out Color rankColor))
|
||||
{
|
||||
_rank.style.color = rankColor;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate Win Rate from GamesPlayed (requires adding wins to schema, but for now we use mock/partial)
|
||||
if (eloData.GamesPlayed > 0)
|
||||
{
|
||||
// Note: To show a real winrate, we'd need to store 'Wins' in PlayerEloData.
|
||||
// For now, keeping the mock or setting a placeholder.
|
||||
_winRateText.text = "CALCULATING...";
|
||||
}
|
||||
}
|
||||
|
||||
private async void Logout()
|
||||
|
||||
Reference in New Issue
Block a user