Beispiel #1
0
    /// <summary>
    /// Displays the registration UI.
    /// </summary>
    /// <param name="windowRect">The bounding rect of the window.</param>
    public static void OnGUI(Rect windowRect)
    {
        var halfWidth = windowRect.width / 2;

        GUI.enabled = !LumosSocialGUI.inProgress;

        // Username field.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(usernameLabel);
        username = GUILayout.TextField(username, GUILayout.Width(halfWidth));
        GUILayout.EndHorizontal();

        // Email address field.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(emailLabel);
        email = GUILayout.TextField(email, GUILayout.Width(halfWidth));
        GUILayout.EndHorizontal();

        // Password field.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(passwordLabel);
        password = GUILayout.PasswordField(password, '\u2022', GUILayout.Width(halfWidth));
        GUILayout.EndHorizontal();

        // Password confirmation field.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(confirmPasswordLabel);
        passwordConfirmation = GUILayout.PasswordField(passwordConfirmation, '\u2022', GUILayout.Width(halfWidth));
        GUILayout.EndHorizontal();

        // Submit button.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button(registerLabel, GUILayout.Width(halfWidth)))
        {
            RegisterNewUser();
        }
        GUILayout.EndHorizontal();

        LumosSocialGUI.DrawDivider();

        // Login button.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button(loginLabel, GUILayout.Width(halfWidth)))
        {
            LumosSocialGUI.ShowWindow(LumosGUIWindow.Login);
        }
        GUILayout.EndHorizontal();
    }
Beispiel #2
0
    /// <summary>
    /// Displays the login UI.
    /// </summary>
    /// <param name="windowRect">The bounding rect of the window.</param>
    public static void OnGUI(Rect windowRect)
    {
        var halfWidth = windowRect.width / 2;

        GUI.enabled = !LumosSocialGUI.inProgress;

        // Username field.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(usernameLabel);
        username = GUILayout.TextField(username, GUILayout.Width(halfWidth));
        GUILayout.EndHorizontal();

        // Password field.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(passwordLabel);
        password = GUILayout.PasswordField(password, '\u2022', GUILayout.Width(halfWidth));
        GUILayout.EndHorizontal();

        // Submit button.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button(loginLabel, GUILayout.Width(halfWidth)))
        {
            SubmitLoginCredentials();
        }
        GUILayout.EndHorizontal();

        LumosSocialGUI.DrawDivider();

        // Forgot password button.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button(forgotPasswordLabel, GUILayout.Width(halfWidth)))
        {
            LumosSocialGUI.ShowWindow(LumosGUIWindow.ResetPassword);
        }
        GUILayout.EndHorizontal();

        // Register new account button.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button(registerLabel, GUILayout.Width(halfWidth)))
        {
            LumosSocialGUI.ShowWindow(LumosGUIWindow.Registration);
            return;
        }
        GUILayout.EndHorizontal();
    }
Beispiel #3
0
    /// <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 password reset UI.
    /// </summary>
    /// <param name="windowRect">The bounding rect of the window.</param>
    public static void OnGUI(Rect windowRect)
    {
        var halfWidth = windowRect.width / 2;

        if (GUILayout.Button(backLabel, GUILayout.ExpandWidth(false)))
        {
            LumosSocialGUI.ShowWindow(LumosGUIWindow.Login);
        }

        LumosSocialGUI.DrawDivider();

        // Username field.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(usernameLabel);
        username = GUILayout.TextField(username, GUILayout.Width(halfWidth));
        GUILayout.EndHorizontal();

        // Submit button.
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button(resetLabel, GUILayout.Width(halfWidth)))
        {
            LumosSocial.ResetPassword(username,
                                      success => {
                if (success)
                {
                    LumosSocialGUI.statusMessage = "An email has been sent to confirm your password reset.";
                }
                else
                {
                    LumosSocialGUI.statusMessage = "There was a problem resetting your password. Please try again.";
                }
            });
        }
        GUILayout.EndHorizontal();
    }
Beispiel #5
0
    void DisplayMenu()
    {
        if (Social.localUser == null || !Social.localUser.authenticated)
        {
            if (GUILayout.Button("Login/Register"))
            {
                LumosSocialGUI.ShowWindow(LumosGUIWindow.Login);
            }
        }
        else
        {
            if (GUILayout.Button("Achievements"))
            {
                LumosSocialGUI.ShowWindow(LumosGUIWindow.Achievements);
            }

            if (GUILayout.Button("Leaderboards"))
            {
                LumosSocialGUI.ShowWindow(LumosGUIWindow.Leaderboards);
            }

            if (GUILayout.Button("Profile"))
            {
                LumosSocialGUI.ShowWindow(LumosGUIWindow.Profile);
            }

            if (GUILayout.Button("Settings"))
            {
                LumosSocialGUI.ShowWindow(LumosGUIWindow.Settings);
            }

            if (GUILayout.Button("Close"))
            {
                currentUI = UI.None;
            }
        }
    }
Beispiel #6
0
 // Shows the leaderboard UI.
 public void ShowLeaderboardUI()
 {
     LumosSocialGUI.ShowWindow(LumosGUIWindow.Leaderboards);
 }
Beispiel #7
0
    /// <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();
    }
Beispiel #8
0
 // Use this for initialization
 void Start()
 {
     LumosSocialGUI.ShowWindow(LumosGUIWindow.Login);
 }
Beispiel #9
0
    /// <summary>
    /// Displays the scores UI.
    /// </summary>
    /// <param name="windowRect">The bounding rect of the window.</param>
    public static void OnGUI(Rect windowRect)
    {
        if (LumosLeaderboardsGUI.currentLeaderboard == null)
        {
            return;
        }

        if (LumosLeaderboardsGUI.currentLeaderboard.scores == null)
        {
            GUILayout.Label("Loading scores...");
            return;
        }

        if (GUILayout.Button("Leaderboards List", GUILayout.ExpandWidth(false)))
        {
            LumosSocialGUI.ShowWindow(LumosGUIWindow.Leaderboards);
        }

        LumosSocialGUI.DrawDivider();

        // Title
        GUILayout.Label(LumosLeaderboardsGUI.currentLeaderboard.title);

        LumosSocialGUI.DrawDivider();

        // Friend Scores
        if (LumosLeaderboardsGUI.currentLeaderboard.friendScores != null)
        {
            DisplayScoreLabel("Friends");
            GUILayout.BeginVertical(GUI.skin.box);
            friendScoresScrollPos = GUILayout.BeginScrollView(friendScoresScrollPos);
            DisplayScoreData(LumosLeaderboardsGUI.currentLeaderboard.friendScores);
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
        }

        // All Scores
        DisplayScoreLabel("All Scores");
        GUILayout.BeginVertical(GUI.skin.box);
        allScoresScrollPos = GUILayout.BeginScrollView(allScoresScrollPos);
        DisplayScoreData(LumosLeaderboardsGUI.currentLeaderboard.scores);
        GUILayout.EndScrollView();
        GUILayout.EndVertical();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Refresh", GUILayout.ExpandWidth(false)))
        {
            Social.LoadScores(LumosLeaderboardsGUI.currentLeaderboard.id, null);
        }

        if (GUILayout.Button("More...", GUILayout.ExpandWidth(false)))
        {
            var length    = LumosLeaderboardsGUI.currentLeaderboard.scores.Length - 1;
            var lastScore = LumosLeaderboardsGUI.currentLeaderboard.scores[length];

            LumosLeaderboardsGUI.currentLeaderboard.LoadScores(1, lastScore.rank,
                                                               scores => {
                // Nothing yet.
            });
        }
        GUILayout.EndHorizontal();
    }
 /// Shows the achievements UI.
 public void ShowAchievementsUI()
 {
     LumosSocialGUI.ShowWindow(LumosGUIWindow.Achievements);
 }