/// <summary> /// Displays the leaderboards UI. /// </summary> /// <param name="windowRect">The bounding rect of the window.</param> public static void OnGUI(Rect windowRect) { if (LumosSocialGUI.currentUser == null) { LumosSocialGUI.statusMessage = "You must login before viewing leaderboards."; LumosSocialGUI.DrawLoginButton(); return; } if (LumosSocial.leaderboards == null) { LumosSocialGUI.statusMessage = "Loading leaderboards..."; if (!LumosSocialGUI.inProgress) { LumosSocial.LoadLeaderboardDescriptions(success => { LumosSocialGUI.statusMessage = null; }); LumosSocialGUI.inProgress = true; } return; } if (LumosSocial.leaderboards.Length > 0) { foreach (var leaderboard in LumosSocial.leaderboards) { if (leaderboard.loading) { GUILayout.Label("Loading..."); GUI.enabled = false; } if (GUILayout.Button(leaderboard.title)) { currentLeaderboard = leaderboard as LumosLeaderboard; LumosSocialGUI.ShowWindow(LumosGUIWindow.Scores); if (currentLeaderboard.scores == null) { Social.LoadScores(currentLeaderboard.id, null); } } GUI.enabled = true; } LumosSocialGUI.DrawDivider(); } }
/// <summary> /// Displays the achievements UI. /// </summary> /// <param name="windowRect">The bounding rect of the window.</param> public static void OnGUI(Rect windowRect) { if (LumosSocialGUI.currentUser == null) { LumosSocialGUI.statusMessage = "You must login before viewing your achievements."; LumosSocialGUI.DrawLoginButton(); return; } // Load achievements if necessary. if (achievementDescriptions == null) { LumosSocialGUI.statusMessage = "Loading achievements..."; if (!LumosSocialGUI.inProgress) { LumosSocialGUI.inProgress = true; Social.LoadAchievements(null); Social.LoadAchievementDescriptions( descriptions => { LumosSocialGUI.inProgress = false; achievementDescriptions = descriptions; LumosSocialGUI.statusMessage = null; }); } return; } scrollPos = GUILayout.BeginScrollView(scrollPos); foreach (var description in achievementDescriptions) { // Skip achievements the user isn't supposed to see. if (description.hidden && !LumosSocial.HasAchievement(description.id)) { continue; } GUI.enabled = !LumosSocial.HasAchievement(description.id); GUILayout.BeginHorizontal(GUI.skin.box); var icon = GetIcon(description); if (icon != null) { GUILayout.Label(icon); } GUILayout.BeginVertical(); GUILayout.Label(description.title); if (LumosSocial.HasAchievement(description.id)) { GUILayout.Label(description.achievedDescription); } else { GUILayout.Label(description.unachievedDescription); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); LumosSocialGUI.DrawDivider(); } GUILayout.EndScrollView(); }
/// <summary> /// Displays the profile UI. /// </summary> /// <param name="windowRect">The bounding rect of the window.</param> public static void OnGUI(Rect windowRect) { if (LumosSocialGUI.currentUser == null) { LumosSocialGUI.statusMessage = "You must login before viewing your profile."; LumosSocialGUI.DrawLoginButton(); return; } GUILayout.BeginHorizontal(); var avatar = GetAvatar(); if (avatar != null) { GUILayout.Label(GetAvatar(), GUILayout.MaxWidth(LumosSocialGUI.avatarSize), GUILayout.MaxHeight(LumosSocialGUI.avatarSize)); } GUILayout.BeginVertical(); GUILayout.Label(LumosSocialGUI.currentUser.userID); GUILayout.Label(LumosSocialGUI.currentUser.email); GUILayout.EndVertical(); GUILayout.BeginVertical(); if (GUILayout.Button(achievementsLabel)) { Social.ShowAchievementsUI(); } if (GUILayout.Button(leaderboardsLabel)) { Social.ShowLeaderboardUI(); } if (GUILayout.Button(settingsLabel)) { LumosSocialGUI.ShowWindow(LumosGUIWindow.Settings); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); LumosSocialGUI.DrawDivider(); GUILayout.BeginHorizontal(); // Other info. if (LumosSocialGUI.currentUser.other != null) { GUILayout.BeginVertical(); GUILayout.Label("Other"); otherScrollPos = GUILayout.BeginScrollView(otherScrollPos); foreach (var other in LumosSocialGUI.currentUser.other) { GUILayout.BeginHorizontal(); GUILayout.Label(other.Key); GUILayout.Label(other.Value.ToString()); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); } // Friends list. GUILayout.BeginVertical(); GUILayout.Label("Friends"); friendsScrollPos = GUILayout.BeginScrollView(friendsScrollPos); GUILayout.BeginHorizontal(); friendToAdd = GUILayout.TextField(friendToAdd); if (GUILayout.Button("Send Friend Request")) { if (friendToAdd.Length > 0) { LumosSocialGUI.currentUser.SendFriendRequest(friendToAdd, success => { if (success) { LumosSocialGUI.statusMessage = "Friend request sent."; } else { LumosSocialGUI.statusMessage = "There was a problem processing the friend request. Please try again."; } }); } } GUILayout.EndHorizontal(); if (LumosSocialGUI.currentUser.friendRequests != null) { foreach (var request in LumosSocialGUI.currentUser.friendRequests) { GUILayout.BeginHorizontal(); GUILayout.Label(request.id); if (GUILayout.Button("Accept", GUILayout.ExpandWidth(false))) { LumosSocialGUI.currentUser.AcceptFriendRequest(request.id, success => { if (success) { LumosSocialGUI.statusMessage = "Friend request accepted."; } else { LumosSocialGUI.statusMessage = "There was a problem accepting the friend request. Please try again."; } }); } if (GUILayout.Button("Decline", GUILayout.ExpandWidth(false))) { LumosSocialGUI.currentUser.DeclineFriendRequest(request.id, success => { if (success) { LumosSocialGUI.statusMessage = "Friend request declined."; } else { LumosSocialGUI.statusMessage = "There was a problem declining the friend request. Please try again."; } }); } GUILayout.EndHorizontal(); } } if (LumosSocialGUI.currentUser.friends != null) { foreach (var friend in LumosSocialGUI.currentUser.friends) { GUILayout.BeginHorizontal(); GUILayout.Label(friend.id); if (GUILayout.Button("Remove")) { LumosSocialGUI.currentUser.RemoveFriend(friend.id, success => { if (success) { LumosSocialGUI.statusMessage = "Friend removed."; } else { LumosSocialGUI.statusMessage = "There was a problem removing this friend. Please try again."; } }); } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); GUILayout.EndVertical(); LumosSocialGUI.DrawDivider(); // Scores. GUILayout.BeginVertical(); GUILayout.Label("High Scores"); scoresScrollPos = GUILayout.BeginScrollView(scoresScrollPos); if (LumosSocialGUI.currentUser.scores != null) { foreach (var score in LumosSocialGUI.currentUser.scores) { GUILayout.Label(score.leaderboardID); GUILayout.BeginHorizontal(); GUILayout.Label(score.value.ToString()); GUILayout.EndHorizontal(); LumosSocialGUI.DrawDivider(); } } GUILayout.EndScrollView(); GUILayout.EndVertical(); LumosSocialGUI.DrawDivider(); GUILayout.EndHorizontal(); }
/// <summary> /// Displays the settings UI. /// </summary> /// <param name="windowRect">The bounding rect of the window.</param> public static void OnGUI(Rect windowRect) { if (LumosSocialGUI.currentUser == null) { LumosSocialGUI.statusMessage = "You must login before viewing your settings."; LumosSocialGUI.DrawLoginButton(); return; } var halfWidth = windowRect.width / 2; scrollPos = GUILayout.BeginScrollView(scrollPos); // Name field. GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(nameLabel); name = GUILayout.TextField(name, GUILayout.Width(halfWidth)); GUILayout.EndHorizontal(); // Current Password field. GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(currentPasswordLabel); currentPassword = GUILayout.PasswordField(currentPassword, '*', GUILayout.Width(halfWidth)); GUILayout.EndHorizontal(); // New Password field. GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(passwordLabel); password = GUILayout.PasswordField(password, '*', GUILayout.Width(halfWidth)); GUILayout.EndHorizontal(); // New Password confirmation field. GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(confirmPasswordLabel); passwordConfirmation = GUILayout.PasswordField(passwordConfirmation, '*', GUILayout.Width(halfWidth)); GUILayout.EndHorizontal(); // Email address field. GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(emailLabel); email = GUILayout.TextField(email, GUILayout.Width(halfWidth)); GUILayout.EndHorizontal(); if (LumosSocialGUI.currentUser.other != null) { if (other == null) { other = new Dictionary <string, object>(LumosSocialGUI.currentUser.other); } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(otherLabel); GUILayout.BeginVertical(GUILayout.Width(halfWidth)); foreach (var entry in other) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(entry.Key); other[entry.Key] = GUILayout.TextField(entry.Value as string, GUILayout.Width(halfWidth)); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } // Submit button. GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(updateLabel, GUILayout.Width(halfWidth))) { SaveSettings(); } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); }