Update Audio
This commit is contained in:
@@ -10,6 +10,11 @@ namespace Hallucinate.UI
|
||||
private Label _rank;
|
||||
private ProgressBar _winRateBar;
|
||||
private Label _winRateText;
|
||||
private Button _logoutBtn;
|
||||
|
||||
// Future authentication schema placeholders
|
||||
private string _googleIdPlaceholder = "";
|
||||
private string _avatarUrlPlaceholder = "";
|
||||
|
||||
public override void Initialize(VisualElement uxmlRoot, UIManager manager)
|
||||
{
|
||||
@@ -19,19 +24,60 @@ namespace Hallucinate.UI
|
||||
_rank = root.Q<Label>("Rank");
|
||||
_winRateBar = root.Q<ProgressBar>("WinRateBar");
|
||||
_winRateText = root.Q<Label>("WinRateText");
|
||||
_logoutBtn = root.Q<Button>("LogoutBtn");
|
||||
|
||||
root.Q<Button>("BackBtn").clicked += async () => await uiManager.Pop();
|
||||
|
||||
|
||||
if (_logoutBtn != null)
|
||||
{
|
||||
_logoutBtn.clicked += Logout;
|
||||
}
|
||||
|
||||
LoadProfileData();
|
||||
}
|
||||
|
||||
public override async Task PlayTransitionIn()
|
||||
{
|
||||
LoadProfileData(); // Refresh data every time we show the profile
|
||||
await base.PlayTransitionIn();
|
||||
}
|
||||
|
||||
private void LoadProfileData()
|
||||
{
|
||||
// Dummy data for now
|
||||
_username.text = "GamerPro_2026";
|
||||
// Load saved username or fallback
|
||||
string savedName = PlayerPrefs.GetString("Username", "Unknown Player");
|
||||
_username.text = savedName.ToUpper();
|
||||
|
||||
// Future schema mockup (Google Sign-In)
|
||||
_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%";
|
||||
}
|
||||
|
||||
private async void Logout()
|
||||
{
|
||||
// Clear local save data
|
||||
PlayerPrefs.DeleteKey("Username");
|
||||
PlayerPrefs.DeleteKey("GoogleID");
|
||||
PlayerPrefs.DeleteKey("AvatarURL");
|
||||
PlayerPrefs.Save();
|
||||
|
||||
Debug.Log("[Profile] User logged out.");
|
||||
|
||||
// Disconnect from network if currently running
|
||||
var runner = Object.FindFirstObjectByType<Fusion.NetworkRunner>();
|
||||
if (runner != null && runner.IsRunning)
|
||||
{
|
||||
await runner.Shutdown();
|
||||
}
|
||||
|
||||
// Redirect to Login Screen
|
||||
await uiManager.Push<LoginController>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user