/// <summary>
    /// Draws the element.
    /// </summary>
    public void DrawElement()
    {
        // putting a box around the information for this number element
        // makes it clear when you're looking at the next element.
        GUILayout.BeginVertical(GUI.skin.box);

        // display the value of the element in all supported types.
        string elementLabel = string.Format(listElementLabel, valueAsInt, valueAsLong, valueAsDouble, valueAsString);

        AmazonGUIHelpers.CenteredLabel(elementLabel);

        // display the metadata associated with the element.
        if (null != metadata && metadata.Count > 0)
        {
            AmazonGUIHelpers.CenteredLabel(metadataLabel);
            // display the entire dictionary
            foreach (KeyValuePair <string, string> metadataKvP in metadata)
            {
                AmazonGUIHelpers.CenteredLabel(metadataKvP.ToString());
            }
        }
        // if there was no metadata, display a label making note of that
        else
        {
            AmazonGUIHelpers.CenteredLabel(noMetadataAvailableLabel);
        }

        GUILayout.EndVertical();
    }
Example #2
0
    /// <summary>
    /// Draws this hash set to the GUI
    /// </summary>
    public void DrawGUI()
    {
        // put a visual box around this syncable number
        GUILayout.BeginVertical(GUI.skin.box);

        // foldouts keep things clean, they let the interface remain
        // hidden until needed
        foldoutOpen = AmazonGUIHelpers.FoldoutWithLabel(foldoutOpen, hashSetTitle);

        // Hide the menu if the foldout is not open.
        if (foldoutOpen)
        {
            // this button lets the user fresh this hash set
            if (GUILayout.Button(refreshHashSetButtonLabel))
            {
                Refresh();
            }

            // if the hash set is empty, display a message.
            if (hashSet.Count == 0)
            {
                AmazonGUIHelpers.CenteredLabel(emptyHashSetLabel);
            }
            else
            {
                // display each entry in the hash set
                foreach (string hashSetString in hashSet)
                {
                    AmazonGUIHelpers.CenteredLabel(hashSetString);
                }
            }
        }

        GUILayout.EndVertical();
    }
Example #3
0
    /// <summary>
    /// Displays retrieved scores, and a button to retrieve them.
    /// </summary>
    void DisplayScoreRetrieval()
    {
        if (GUILayout.Button(retrieveScoresButtonLabel))
        {
            Social.LoadScores(leaderboardExampleID, RetrieveScoreCallback);
        }

        // If a list of scores has been received, display it.
        if (null != scores)
        {
            foreach (IScore score in scores)
            {
                // Put each score in a box to visually separate them.
                GUILayout.BeginVertical(GUI.skin.box);
                GUILayout.BeginHorizontal();
                // Display the leaderboard the score belongs to, and its value on one line.
                AmazonGUIHelpers.CenteredLabel(string.Format(scoreLeaderboardLabel, score.leaderboardID));
                AmazonGUIHelpers.CenteredLabel(score.formattedValue);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                // Display the user and the rank on another line.
                AmazonGUIHelpers.CenteredLabel(string.Format(scoreUserLabel, score.userID));
                AmazonGUIHelpers.CenteredLabel(string.Format(scoreRankLabel, score.rank));
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
        }
    }
 /// <summary>
 /// Displays the menu for when GameCircle is unavailable.
 /// </summary>
 private void DisplayGameCircleUnavailableMenu()
 {
     if (!string.IsNullOrEmpty(gameCircleInitializationStatusLabel))
     {
         AmazonGUIHelpers.CenteredLabel(gameCircleInitializationStatusLabel);
     }
 }
    /// <summary>
    /// Draws an interface for this syncable number helper.
    /// </summary>
    /// <param name='dataMap'>
    /// Whispersync data map.
    /// </param>
    public void DrawGUI(AGSGameDataMap dataMap)
    {
        // if the datamap is not available, display a message and leave.
        if (null == dataMap)
        {
            AmazonGUIHelpers.CenteredLabel(nullDataMapLabel);
            return;
        }

        // if the hash sets aren't initialize, attempt to initialize them.
        if (null == hashSets)
        {
            InitializeHashSets(dataMap);
        }

        // if the hash sets are still null, display a message and leave.
        if (null == hashSets)
        {
            AmazonGUIHelpers.CenteredLabel(nullHashSets);
            return;
        }

        // This button refreshes all hash sets at once.
        if (GUILayout.Button(refreshAllHashSetsButtonLabel))
        {
            RefreshAllHashSets();
        }

        // display each hash set.
        foreach (AmazonGameCircleExampleWSHashSet hashSet in hashSets)
        {
            hashSet.DrawGUI();
        }
    }
 /// <summary>
 /// Displays the status of the GameCircle plugin loading.
 /// </summary>
 private void DisplayLoadingGameCircleMenu()
 {
     if (!string.IsNullOrEmpty(gameCircleInitializationStatusLabel))
     {
         AmazonGUIHelpers.CenteredLabel(gameCircleInitializationStatusLabel);
     }
     AmazonGUIHelpers.CenteredLabel(string.Format(loadingTimeLabel, (System.DateTime.Now - initRequestTime).TotalSeconds));
 }
Example #7
0
    /// <summary>
    /// Unity / MonoBehaviour function for GUI behaviour.
    /// </summary>
    void OnGUI()
    {
        // Some initialization behaviour can only be called from within the OnGUI function.
        // initialize UI early returns if it is already initialized
        InitializeUI();

        // This menu has a local UI skin with buttons scaled up, and other touch enhancements.
        ApplyLocalUISkin();

        AmazonGUIHelpers.BeginMenuLayout();

        // Wrapping all of the menu in a scroll view allows the individual menu systems to not need to handle being off screen.
        scroll = GUILayout.BeginScrollView(scroll);

        // Display if the GameCircle plugin is ready..
        AmazonGUIHelpers.CenteredLabel(string.Format(isServiceReadyLabel, AGSClient.IsServiceReady()));

        // If GameCircle is not initialized, display the initialization menu.
        if (initializationMenu.InitializationStatus != AmazonGameCircleExampleInitialization.EInitializationStatus.Ready)
        {
            initializationMenu.DrawMenu();
        }
        else
        {
            // This button opens the generic GameCircle overlay.
            if (GUILayout.Button(gameCircleOverlayButtonLabel))
            {
                AGSClient.ShowGameCircleOverlay();
            }

            // This button opens the GameCircle sign in page.
            if (GUILayout.Button(gameCircleSignInButtonLabel))
            {
                AGSClient.ShowSignInPage();
            }

            // Once GameCircle is initialized, display all submenus, for achievements, leaderboards, and other GameCircle features.
            foreach (AmazonGameCircleExampleBase subMenu in gameCircleExampleMenus)
            {
                GUILayout.BeginVertical(GUI.skin.box);
                subMenu.foldoutOpen = AmazonGUIHelpers.FoldoutWithLabel(subMenu.foldoutOpen, subMenu.MenuTitle());
                if (subMenu.foldoutOpen)
                {
                    subMenu.DrawMenu();
                }
                GUILayout.EndVertical();
            }
        }

        GUILayout.EndScrollView();

        AmazonGUIHelpers.EndMenuLayout();

        // If the UI skin is not reverted at the end of the function,
        // any other OnGUI behavior might end up using the settings applied here.
        RevertLocalUISkin();
    }
    /// <summary>
    /// Draws the menu. Note that this must be called from an OnGUI function.
    /// </summary>
    public override void DrawMenu()
    {
        // this button will open the leaderboard overlay.
        if (GUILayout.Button(DisplayLeaderboardOverlayButtonLabel))
        {
            AGSLeaderboardsClient.ShowLeaderboardsOverlay();
        }

        // If the leaderboard list has not been requested yet, display
        // a button that requests the leaderboard list.
        if (string.IsNullOrEmpty(requestLeaderboardsStatus))
        {
            if (GUILayout.Button(requestLeaderboardsButtonLabel))
            {
                RequestLeaderboards();
            }
        }
        else
        {
            // once a request has been made for the list of leaderboards,
            // display the status message of that process.
            AmazonGUIHelpers.CenteredLabel(requestLeaderboardsStatus);
            if (!string.IsNullOrEmpty(requestLeaderboardsStatusMessage))
            {
                AmazonGUIHelpers.CenteredLabel(requestLeaderboardsStatusMessage);
            }

            // If the leaderboards are not ready, display how long it has been since the request was put in.
            if (!leaderboardsReady)
            {
                AmazonGUIHelpers.CenteredLabel(string.Format(leaderboardRequestTimeLabel, (System.DateTime.Now - leaderboardsRequestTime).TotalSeconds));
            }
            else
            {
                // Once the leaderboard list request callback has been received,
                // display the leaderboards if available.
                if (null != leaderboardList && leaderboardList.Count > 0)
                {
                    foreach (AGSLeaderboard leaderboard in leaderboardList)
                    {
                        DisplayLeaderboard(leaderboard);
                    }
                }
                // If the leaderboards are not available, display a message explaining that.
                else
                {
                    AmazonGUIHelpers.CenteredLabel(noLeaderboardsAvailableLabel);
                }
                // display the invalid leaderboard (used to make sure GameCircle handles invalid data gracefully)
                if (null != invalidLeaderboard)
                {
                    DisplayLeaderboard(invalidLeaderboard);
                }
            }
        }
    }
    /// <summary>
    /// Shows the achievement descriptions.
    /// </summary>
    void ShowAchievementDescriptions()
    {
        // This foldout hides the achievement descriptions until the user wishes to see them.
        achievementsDescriptionsFoldout = AmazonGUIHelpers.FoldoutWithLabel(achievementsDescriptionsFoldout,
                                                                            achievementDescriptionsLabel);
        if (!achievementsDescriptionsFoldout)
        {
            return;
        }
        switch (achievementDescriptionStatus)
        {
        // If the achievement descriptions have not been retrieved yet,
        // display a button that begins the retrieval process.
        case GameCircleSocialExample.AsyncOperationStatus.Inactive:
            if (GUILayout.Button(retrieveDataButtonLabel))
            {
                achievementDescriptionStatus = GameCircleSocialExample.AsyncOperationStatus.Waiting;
                Social.LoadAchievementDescriptions(AchievementDescriptionsCallback);
            }
            break;

        // While waiting, display a simple message.
        case GameCircleSocialExample.AsyncOperationStatus.Waiting:
            AmazonGUIHelpers.CenteredLabel(waitingLabel);
            break;

        // If achievement descriptions were not retrieved, display a message that none are available.
        case GameCircleSocialExample.AsyncOperationStatus.Failed:
            AmazonGUIHelpers.CenteredLabel(noAchievementDescriptionsLabel);
            break;

        // If the achievement descriptions were retrieved (and are available), display them.
        case GameCircleSocialExample.AsyncOperationStatus.Success:
            // If the achievement description list is null or empty, display a message.
            if (null == achievementDescriptions || 0 == achievementDescriptions.Length)
            {
                AmazonGUIHelpers.CenteredLabel(noAchievementDescriptionsLabel);
            }
            else
            {
                // Display each achievement description, each in its own box.
                // Have the ID and title on one line, and the description on the next.
                foreach (IAchievementDescription description in achievementDescriptions)
                {
                    GUILayout.BeginVertical(GUI.skin.box);
                    GUILayout.BeginHorizontal();
                    AmazonGUIHelpers.CenteredLabel(description.id);
                    AmazonGUIHelpers.CenteredLabel(description.title);
                    GUILayout.EndHorizontal();
                    AmazonGUIHelpers.CenteredLabel(description.achievedDescription);
                    GUILayout.EndVertical();
                }
            }
            break;
        }
    }
    /// <summary>
    /// Shows the achievements.
    /// </summary>
    void ShowAchievements()
    {
        // This foldout will hide the achievement list when the user does not want to see it.
        achievementsFoldout = AmazonGUIHelpers.FoldoutWithLabel(achievementsFoldout, achievementsLabel);
        if (!achievementsFoldout)
        {
            return;
        }
        switch (achievementStatus)
        {
        // If the achievements have not been retrieved yet,
        // display a button that begins the retrieval process.
        case GameCircleSocialExample.AsyncOperationStatus.Inactive:
            if (GUILayout.Button(retrieveDataButtonLabel))
            {
                achievementStatus = GameCircleSocialExample.AsyncOperationStatus.Waiting;
                Social.LoadAchievements(AchievementsCallback);
            }
            break;

        // While waiting, display a simple message.
        case GameCircleSocialExample.AsyncOperationStatus.Waiting:
            AmazonGUIHelpers.CenteredLabel(waitingLabel);
            break;

        // If achievement descriptions were not retrieved, display a message that none are available.
        case GameCircleSocialExample.AsyncOperationStatus.Failed:
            AmazonGUIHelpers.CenteredLabel(noAchievementsLabel);
            break;

        // If the achievement descriptions were retrieved (and are available), display them.
        case GameCircleSocialExample.AsyncOperationStatus.Success:
            if (null == achievements || 0 == achievements.Length)
            {
                // If the list of achievements was null or empty, display a message that
                // no achievements are available.
                AmazonGUIHelpers.CenteredLabel(noAchievementDescriptionsLabel);
            }
            else
            {
                // display each achievement in a box, with the ID and percent complete on the same line.
                foreach (IAchievement achievement in achievements)
                {
                    GUILayout.BeginVertical(GUI.skin.box);
                    GUILayout.BeginHorizontal();
                    AmazonGUIHelpers.CenteredLabel(achievement.id);
                    AmazonGUIHelpers.CenteredLabel(string.Format(achievementPercent, achievement.percentCompleted));
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }
            }
            break;
        }
    }
Example #11
0
    /// <summary>
    /// Initializes the UI for the GameCircle example menu. If already initialized, bails out.
    /// This function needs to be called from OnGUI to access GUI features.
    /// </summary>
    void InitializeUI()
    {
        if (uiInitialized)
        {
            return;
        }
        uiInitialized   = true;
        localGuiSkin    = GUI.skin;
        originalGuiSkin = GUI.skin;

        AmazonGUIHelpers.SetGUISkinTouchFriendly(localGuiSkin);
    }
Example #12
0
    /// <summary>
    /// Draws the GameCircle Player Menu. Note that this must be called from an OnGUI function.
    /// </summary>
    public override void DrawMenu()
    {
        // Once the Status string is not null, player retrieval has begun.
        // This button begins the player retrieval process.
        if (GUILayout.Button(playerRetrieveButtonLabel))
        {
            RequestLocalPlayerData();
        }

        if (!string.IsNullOrEmpty(playerStatus))
        {
            AmazonGUIHelpers.CenteredLabel(playerStatus);
            // If there is a status / error message, display it.
            if (!string.IsNullOrEmpty(playerStatusMessage))
            {
                AmazonGUIHelpers.CenteredLabel(playerStatusMessage);
            }
            // player has been received, display it.
            if (null != player)
            {
                // When the player information is null (for guest accounts),
                // displaying "null" looks nicer than an empty string
                string playerId  = !string.IsNullOrEmpty(player.playerId) ? player.playerId : nullAsString;
                string alias     = !string.IsNullOrEmpty(player.alias) ? player.alias : nullAsString;
                string avatarUrl = !string.IsNullOrEmpty(player.avatarUrl) ? player.avatarUrl : nullAsString;

                AmazonGUIHelpers.CenteredLabel(string.Format(playerLabel, playerId, alias, avatarUrl));
            }
        }

        AmazonGUIHelpers.CenteredLabel(string.Format(isSignedInLabel, AGSPlayerClient.IsSignedIn() ? "true" : "false"));

        // Always listen for signed in state change events.
        if (!haveSubscribedToSignedInStateChangeEvents)
        {
            AGSPlayerClient.OnSignedInStateChangedEvent += OnSignedInStateChanged;
            haveSubscribedToSignedInStateChangeEvents    = true;
        }

        // If a signed in state change event has happened, display when it happened.
        if (haveGotStateChangeEvent && lastSignInStateChangeEvent != null)
        {
            double timeElapsed = (System.DateTime.Now - lastSignInStateChangeEvent.Value).TotalSeconds;
            if (signedInStateChange)
            {
                AmazonGUIHelpers.CenteredLabel(string.Format(signedInEventLabel, timeElapsed));
            }
            else
            {
                AmazonGUIHelpers.CenteredLabel(string.Format(signedOutEventLabel, timeElapsed));
            }
        }
    }
Example #13
0
 /// <summary>
 /// Displays the interface for reporting a new score.
 /// </summary>
 void DisplayScoreReporter()
 {
     // This slider will allow for selecting a score to be uploaded.
     scoreValue = (long)AmazonGUIHelpers.DisplayCenteredSlider((float)scoreValue,
                                                               (float)scoreMinValue,
                                                               (float)scoreMaxValue,
                                                               scoreValueLabel);
     // This button will report the score to the leaderboard.
     if (GUILayout.Button(reportScoreButtonLabel))
     {
         Social.ReportScore(scoreValue, leaderboardExampleID, ReportScoreCallback);
     }
 }
Example #14
0
    /// <summary>
    /// Displays the results of reporting a score
    /// </summary>
    void DisplayScoreReportResult()
    {
        // If a score has not been reported yet,
        // then display an empty line to keep the spacing here correct.
        string reportedScoreResult = string.Empty;

        if (scoreReportSuccessful.HasValue)
        {
            // Display a message mentioning the status of the score report result.
            reportedScoreResult = scoreReportSuccessful.Value ? scoreReportSuccessLabel : scoreReportFailureLabel;
        }
        AmazonGUIHelpers.CenteredLabel(reportedScoreResult);
    }
Example #15
0
    /// <summary>
    /// Draws an interface for this developer string.
    /// </summary>
    /// <param name='dataMap'>
    /// The GameCircle Data map.
    /// </param>
    public void DrawGUI(AGSGameDataMap dataMap)
    {
        // if the datamap is not available, display a message and leave.
        if (null == dataMap)
        {
            AmazonGUIHelpers.CenteredLabel(nullDataMapLabel);
            return;
        }

        // if the hash sets aren't initialize, attempt to initialize them.
        if (null == developerString)
        {
            InitializeDeveloperString(dataMap);
        }

        // if the hash sets are still null, display a message and leave.
        if (null == developerString)
        {
            AmazonGUIHelpers.CenteredLabel(nullDeveloperString);
            return;
        }

        if (GUILayout.Button(refreshDeveloperStringsButtonLabel))
        {
            developerStringKeys = dataMap.getDeveloperStringKeys();
        }
        if (null != developerStringKeys)
        {
            foreach (string key in developerStringKeys)
            {
                AmazonGUIHelpers.CenteredLabel(key);
            }
        }

        // Display the data available on the developer string
        AmazonGUIHelpers.CenteredLabel(string.Format(cloudValueLabel, developerString.getCloudValue()));
        AmazonGUIHelpers.CenteredLabel(string.Format(valueLabel, developerString.getValue()));
        AmazonGUIHelpers.CenteredLabel(string.Format(inConflictLabel, developerString.inConflict().ToString()));
        AmazonGUIHelpers.CenteredLabel(string.Format(isSetLabel, developerString.isSet().ToString()));

        // This button sets the developer string to the developerStringValue.
        if (GUILayout.Button(string.Format(setValueButtonLabel, developerStringValue)))
        {
            developerString.setValue(developerStringValue);
            // If there was a conflict, mark it was resolved, the value has been set.
            if (developerString.inConflict())
            {
                developerString.markAsResolved();
            }
        }
    }
Example #16
0
    /// <summary>
    /// Displays an individual achievement.
    /// </summary>
    /// <param name='achievement'>
    /// The achievement to display.
    /// </param>
    void DisplayAchievement(AGSAchievement achievement)
    {
        // Place a box around each achievement, to make it clear in the UI
        // what controls are for what achievement.
        GUILayout.BeginVertical(GUI.skin.box);

        // If this achievement has not been added to the foldout dictionary, add it.
        if (!achievementsFoldout.ContainsKey(achievement.id))
        {
            achievementsFoldout.Add(achievement.id, false);
        }

        // Display a foldout for this achievement.
        // Foldouts keep the menu tidy.
        achievementsFoldout[achievement.id] = AmazonGUIHelpers.FoldoutWithLabel(achievementsFoldout[achievement.id], string.Format(achievementProgressLabel, achievement.id));

        // If the foldout is open, display the achievement information.
        if (achievementsFoldout[achievement.id])
        {
            // The controls for automatically word wrapping a label are not great,
            // so replacing every third comma in the string returned from the achievement's toString function
            // will allow for a cleaner display of each achievement's data
            AmazonGUIHelpers.AnchoredLabel(AddNewlineEveryThirdComma(achievement.ToString()), TextAnchor.UpperCenter);

            // if this achievement has no pending progress submissions, display information to submit an update.
            if (!achievementsSubmissionStatus.ContainsKey(achievement.id) || string.IsNullOrEmpty(achievementsSubmissionStatus[achievement.id]))
            {
                // Display a centered slider, with the minimum value on the left, and maximum value on the right.
                // This lets the user select a value for the achievement's progress.
                achievement.progress = AmazonGUIHelpers.DisplayCenteredSlider(achievement.progress, achievementMinValue, achievementMaxValue, achievementPercent);

                // This button submits an update to the achievement's progress to the GameCircle plugin.
                if (GUILayout.Button(submitAchievementButtonLabel))
                {
                    SubmitAchievement(achievement.id, achievement.progress);
                }
            }
            else
            {
                // If the achievement update is in the process of being submitted, display the submission status.
                AmazonGUIHelpers.CenteredLabel(achievementsSubmissionStatus[achievement.id]);

                if (achievementsSubmissionStatusMessage.ContainsKey(achievement.id) && !string.IsNullOrEmpty(achievementsSubmissionStatusMessage[achievement.id]))
                {
                    AmazonGUIHelpers.CenteredLabel(achievementsSubmissionStatusMessage[achievement.id]);
                }
            }
        }
        GUILayout.EndVertical();
    }
    /// <summary>
    /// Draws the Social menu.
    /// </summary>
    void DrawSocialMenu()
    {
        // Display a message that the Social API is available.
        AmazonGUIHelpers.CenteredLabel(initializationSuccessfulLabel);

        // Put a box around each submenu to visually separate them from each other.
        GUILayout.BeginVertical(GUI.skin.box);
        achievementsExample.DrawAchievementsMenu();
        GUILayout.EndVertical();

        GUILayout.BeginVertical(GUI.skin.box);
        leaderboardsExample.DrawLeaderboardsMenu();
        GUILayout.EndVertical();
    }
Example #18
0
 /// <summary>
 /// Displays the metadata associated with this number.
 /// </summary>
 void DisplayMetadata()
 {
     if (null != metadataDictionary && metadataDictionary.Count > 0)
     {
         // display every key value pair of metadata
         foreach (KeyValuePair <string, string> metadataKvP in metadataDictionary)
         {
             AmazonGUIHelpers.CenteredLabel(metadataKvP.ToString());
         }
     }
     else
     {
         // if there is no metadata available, display a label explaining that.
         AmazonGUIHelpers.CenteredLabel(noMetaDataAvailableLabel);
     }
 }
    /// <summary>
    /// Draws the developer string.
    /// </summary>
    void DrawDeveloperString()
    {
        if (null == developerString)
        {
            return;
        }

        // Put this box, to visually separate it from other UI.
        GUILayout.BeginVertical(GUI.skin.box);
        // foldouts make menus cleaner.
        developerStringFoldout = AmazonGUIHelpers.FoldoutWithLabel(developerStringFoldout, developerStringLabel);
        if (developerStringFoldout)
        {
            developerString.DrawGUI(dataMap);
        }
        GUILayout.EndVertical();
    }
    /// <summary>
    /// Draws the hash sets.
    /// </summary>
    void DrawHashSets()
    {
        // make sure the hashSets have been initialized
        if (null == hashSets)
        {
            return;
        }

        // Put this box, to visually separate it from other UI.
        GUILayout.BeginVertical(GUI.skin.box);
        // foldouts make menus cleaner.
        hashSetsFoldout = AmazonGUIHelpers.FoldoutWithLabel(hashSetsFoldout, hashSetsLabel);
        if (hashSetsFoldout)
        {
            // display the hash sets
            hashSets.DrawGUI(dataMap);
        }
        GUILayout.EndVertical();
    }
Example #21
0
    /// <summary>
    /// Draws the leaderboards menu.
    /// </summary>
    public void DrawLeaderboardsMenu()
    {
        // Hide the leaderboards menu with a foldout.
        leaderboardsMenuFoldout = AmazonGUIHelpers.FoldoutWithLabel(leaderboardsMenuFoldout, leaderboardsMenuLabel);
        if (!leaderboardsMenuFoldout)
        {
            return;
        }

        // This button will open the leaderboards overlay.
        if (GUILayout.Button(leaderboardsOverlayLabel))
        {
            Social.ShowLeaderboardUI();
        }

        DisplayScoreReporter();
        DisplayScoreReportResult();
        DisplayScoreRetrieval();
    }
    /// <summary>
    /// Draws the menu. Note that this must be called from an OnGUI function.
    /// </summary>
    public override void DrawMenu()
    {
        switch (InitializationStatus)
        {
        case EInitializationStatus.Uninitialized:
            DisplayInitGameCircleMenu();
            break;

        case EInitializationStatus.InitializationRequested:
            AmazonGUIHelpers.BoxedCenteredLabel(pluginName);
            DisplayLoadingGameCircleMenu();
            break;

        case EInitializationStatus.Unavailable:
            DisplayGameCircleUnavailableMenu();
            break;

        default:
            break;
        }
    }
 /// <summary>
 /// Draws the syncable number lists.
 /// </summary>
 void DrawSyncableNumberLists()
 {
     // Can't draw it if it isn't initialized yet.
     if (null == syncableNumberLists)
     {
         return;
     }
     // A box around this area of the menu helps visually separate it in the UI.
     GUILayout.BeginVertical(GUI.skin.box);
     // foldouts make menus cleaner.
     syncableNumberListsFoldout = AmazonGUIHelpers.FoldoutWithLabel(syncableNumberListsFoldout, numberListsLabel);
     if (syncableNumberListsFoldout)
     {
         // Draw test case submenus, for saving numbers in different ways.
         foreach (AmazonGameCircleExampleWSNumberList numberList in syncableNumberLists)
         {
             numberList.DrawGUI(dataMap);
         }
     }
     GUILayout.EndVertical();
 }
 /// <summary>
 /// Draws the list of syncable numbers.
 /// </summary>
 void DrawSyncableNumbers()
 {
     // Can't draw it if it isn't initialized yet.
     if (null == syncableNumbers)
     {
         return;
     }
     // Put the area for number synchronization in a box, to visually separate it from other UI.
     GUILayout.BeginVertical(GUI.skin.box);
     // foldouts make menus cleaner.
     syncableNumbersFoldout = AmazonGUIHelpers.FoldoutWithLabel(syncableNumbersFoldout, syncableNumbersLabel);
     if (syncableNumbersFoldout)
     {
         // Draw test case submenus, for saving numbers in different ways.
         foreach (AmazonGameCircleExampleWSSyncableNumber syncableNumber in syncableNumbers)
         {
             syncableNumber.DrawGUI(dataMap);
         }
     }
     GUILayout.EndVertical();
 }
Example #25
0
    /// <summary>
    /// Draws a slider for this syncable number helper.
    /// This allows the user to select a new value for the number stored.
    /// </summary>
    void DrawSlider()
    {
        switch (type)
        {
        case AvailableSyncableNumberType.Int:
            intNumber = (int)AmazonGUIHelpers.DisplayCenteredSlider(
                (float)intNumber, lowestSliderValue, highestSlidervalue, numberSliderLabel);
            break;

        case AvailableSyncableNumberType.Double:
            doubleNumber = (double)AmazonGUIHelpers.DisplayCenteredSlider(
                (float)doubleNumber, lowestSliderValue, highestSlidervalue, numberSliderLabel);
            break;

        case AvailableSyncableNumberType.Long:
            longNumber = (long)AmazonGUIHelpers.DisplayCenteredSlider(
                (float)longNumber, lowestSliderValue, highestSlidervalue, numberSliderLabel);
            break;

        case AvailableSyncableNumberType.String:
            // It's easiest to just use the intNumber for the string's slider display.
            if (int.TryParse(stringNumber, out intNumber))
            {
                intNumber = (int)AmazonGUIHelpers.DisplayCenteredSlider(
                    (float)intNumber, lowestSliderValue, highestSlidervalue, numberSliderLabel);
                stringNumber = intNumber.ToString();
            }
            else
            {
                // if it couldn't be parsed, just display whatever value it was
                AmazonGUIHelpers.CenteredLabel(stringNumber);
            }
            break;

        default:
            AGSClient.LogGameCircleWarning(unhandledSyncableNumberTypeError);
            break;
        }
    }
    /// <summary>
    /// Displays the menu for initializing GameCircle
    /// </summary>
    private void DisplayInitGameCircleMenu()
    {
        if (GUILayout.Button(string.Format(pluginInitializationButton, pluginName)))
        {
            InitializeGameCircle();
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label(GUIContent.none);

        GUILayout.BeginVertical(GUI.skin.box);

        GUILayout.Label(GUIContent.none);
        usesLeaderboards = GUILayout.Toggle(usesLeaderboards, usesLeaderboardsLabel);
        GUILayout.Label(GUIContent.none);
        usesAchievements = GUILayout.Toggle(usesAchievements, usesAchievementsLabel);
        GUILayout.Label(GUIContent.none);
        usesWhispersync = GUILayout.Toggle(usesWhispersync, usesWhispersyncLabel);

        AmazonGUIHelpers.AnchoredLabel(toastLocationLabel, TextAnchor.LowerCenter);
        if (null != toastLocations)
        {
            toastLocation = (GameCirclePopupLocation)GUILayout.SelectionGrid((int)toastLocation, toastLocations, 3);
        }

        GUILayout.Label(GUIContent.none);

        if (GUILayout.Button(enablePopups ? popupsEnabledLabel : popupsDisabledLabel))
        {
            enablePopups = !enablePopups;
        }

        GUILayout.EndVertical();


        GUILayout.Label(GUIContent.none);

        GUILayout.EndHorizontal();
    }
    /// <summary>
    /// Draws an interface for this syncable number helper.
    /// </summary>
    /// <param name='dataMap'>
    /// The GameCircle Data map.
    /// </param>
    public void DrawGUI(AGSGameDataMap dataMap)
    {
        // put a visual box around this syncable number
        GUILayout.BeginVertical(GUI.skin.box);

        // foldouts keep things clean, they let the interface remain
        // hidden until needed
        foldoutOpen = AmazonGUIHelpers.FoldoutWithLabel(foldoutOpen, SyncableVariableName());

        // Hide the menu if the foldout is not open.
        if (foldoutOpen)
        {
            // If the value has not been retrieved from Whispersync yet, retrieve it.
            if (!ValueAvailable())
            {
                RetrieveAccumulatingNumberValue(dataMap);
            }

            // Show the value.
            AmazonGUIHelpers.CenteredLabel(ValueLabel());

            // This button increments the value.
            if (GUILayout.Button(incrementButtonLabel))
            {
                IncrementValue(dataMap);
            }

            // This button decrements the value.
            if (GUILayout.Button(decrementButtonLabel))
            {
                DecrementValue(dataMap);
            }
        }

        // Always make sure to match begin and end GUILayout functions.
        GUILayout.EndVertical();
    }
    /// <summary>
    /// Unity MonoBehaviour OnGUI override, for displaying menus.
    /// </summary>
    void OnGUI()
    {
        // Some initialization behaviour can only be called from within the OnGUI function.
        // initialize UI early returns if it is already initialized
        InitializeUI();
        ApplyLocalUISkin();
        AmazonGUIHelpers.BeginMenuLayout();

        // Wrapping all of the menu in a scroll view allows the individual menu systems to not need to handle being off screen.
        scroll = GUILayout.BeginScrollView(scroll);

        // Track the state of the Social API to display the correct menu.
        switch (socialInitialization)
        {
        case AsyncOperationStatus.Inactive:
            DrawInitializationMenu();
            break;

        case AsyncOperationStatus.Waiting:
            AmazonGUIHelpers.CenteredLabel(waitingForSocialInitialization);
            break;

        case AsyncOperationStatus.Failed:
            AmazonGUIHelpers.CenteredLabel(initializationFailedLabel);
            break;

        case AsyncOperationStatus.Success:
            DrawSocialMenu();
            break;
        }
        GUILayout.EndScrollView();

        AmazonGUIHelpers.EndMenuLayout();

        RevertLocalUISkin();
    }
    /// <summary>
    /// Draws the achievement menu.
    /// </summary>
    public void DrawAchievementsMenu()
    {
        // Use a foldout to hide this menu when the user does not want to see it.
        achievementsMenuFoldout = AmazonGUIHelpers.FoldoutWithLabel(achievementsMenuFoldout, achievementMenuLabel);
        if (!achievementsMenuFoldout)
        {
            return;
        }
        // This button opens the achievements overlay.
        if (GUILayout.Button(achievementOverlayLabel))
        {
            Social.ShowAchievementsUI();
        }

        // Show the achievements.
        GUILayout.BeginVertical(GUI.skin.box);
        ShowAchievements();
        GUILayout.EndVertical();

        // Show the achievement descriptions.
        GUILayout.BeginVertical(GUI.skin.box);
        ShowAchievementDescriptions();
        GUILayout.EndVertical();
    }
    /// <summary>
    /// Draws the menu. Note that this must be called from an OnGUI function.
    /// </summary>
    public override void DrawMenu()
    {
        // if cloud data has been received, show how long ago that was.
        if (lastOnNewCloudData.HasValue)
        {
            double timeElapsed = (System.DateTime.Now - lastOnNewCloudData.Value).TotalSeconds;
            AmazonGUIHelpers.CenteredLabel(string.Format(cloudDataLastReceivedLabel, timeElapsed));
        }

        if (lastOnDataUploadedToCloud.HasValue)
        {
            double timeElapsed = (System.DateTime.Now - lastOnDataUploadedToCloud.Value).TotalSeconds;
            AmazonGUIHelpers.CenteredLabel(string.Format(uploadedToCloudLabel, timeElapsed));
        }

        if (lastOnThrottled.HasValue)
        {
            double timeElapsed = (System.DateTime.Now - lastOnThrottled.Value).TotalSeconds;
            AmazonGUIHelpers.CenteredLabel(string.Format(lastThrottledLabel, timeElapsed));
        }

        if (lastOnDiskWriteComplete.HasValue)
        {
            double timeElapsed = (System.DateTime.Now - lastOnDiskWriteComplete.Value).TotalSeconds;
            AmazonGUIHelpers.CenteredLabel(string.Format(diskWriteCompleteLabel, timeElapsed));
        }

        if (lastOnFirstSynchronize.HasValue)
        {
            double timeElapsed = (System.DateTime.Now - lastOnFirstSynchronize.Value).TotalSeconds;
            AmazonGUIHelpers.CenteredLabel(string.Format(firstSynchronizeLabel, timeElapsed));
        }

        if (lastOnAlreadySynchronized.HasValue)
        {
            double timeElapsed = (System.DateTime.Now - lastOnAlreadySynchronized.Value).TotalSeconds;
            AmazonGUIHelpers.CenteredLabel(string.Format(alreadySychronizedLabel, timeElapsed));
        }

        if (lastOnSyncFailed.HasValue)
        {
            double timeElapsed = (System.DateTime.Now - lastOnSyncFailed.Value).TotalSeconds;
            AmazonGUIHelpers.CenteredLabel(string.Format(syncFailedLabel, timeElapsed, failReason));
        }


        else
        {
            // display a message that cloud data has not been received yet.
            AmazonGUIHelpers.CenteredLabel(noCloudDataReceivedLabel);
        }

        // This button allows the user to synchronize GameCircle data.
        if (GUILayout.Button(syncDataButtonLabel))
        {
            AGSWhispersyncClient.Synchronize();
        }

        // a small space to spread things out.
        GUILayout.Label(GUIContent.none);

        // This button allows the user to flush GameCircle data.
        if (GUILayout.Button(flushButtonLabel))
        {
            AGSWhispersyncClient.Flush();
        }

        // a small space to spread things out.
        GUILayout.Label(GUIContent.none);

        // try and initialize the Whispersync data map.
        InitializeDataMapIfAvailable();

        if (null == dataMap)
        {
            // if it couldn't be retrieved, bail out with an error.
            AmazonGUIHelpers.CenteredLabel(whispersyncUnavailableLabel);
            return;
        }

        // draws the available syncable numbers
        DrawSyncableNumbers();

        // draws the available accumulating numbers
        DrawAccumulatingNumbers();

        // draws the available syncable number lists
        DrawSyncableNumberLists();

        // draws the available hash sets.
        DrawHashSets();

        // draws the developer string
        DrawDeveloperString();
    }