示例#1
0
        /// <summary>
        /// Confirms that the user wants to stop the gamelet and, if so, stops the gamelet.
        /// </summary>
        /// <returns>True if the user chooses to stop the gamelet and the gamelet stops
        /// successfully, false otherwise.</returns>
        bool PromptStopGame(ref Gamelet gamelet)
        {
            string gameletName = gamelet.DisplayName;
            bool   okToStop    = _actionRecorder.RecordUserAction(
                ActionType.GameletPrepare,
                () => _dialogUtil.ShowYesNo(ErrorStrings.GameletBusyWithAnotherAccount(gameletName),
                                            ErrorStrings.StopRunningGame));

            if (!okToStop)
            {
                return(false);
            }
            gamelet = StopGameOnGamelet(gamelet);
            return(gamelet != null);
        }
示例#2
0
        bool PromptToDeleteLaunch(GgpGrpc.Models.GameLaunch currentGameLaunch,
                                  List <Gamelet> gamelets, Gamelet selectedGamelet,
                                  ActionRecorder actionRecorder,
                                  string testAccount, string devAccount)
        {
            if (currentGameLaunch.GameLaunchState == GameLaunchState.IncompleteLaunch)
            {
                return(true);
            }

            bool   thisInstance = selectedGamelet.Name == currentGameLaunch.GameletName;
            string instanceName = gamelets
                                  .SingleOrDefault(g => g.Name == currentGameLaunch.GameletName)?.DisplayName;
            bool okToStop = actionRecorder.RecordUserAction(ActionType.GameLaunchStopPrompt,
                                                            () => _dialogUtil.ShowYesNo(
                                                                ErrorStrings.LaunchExistsDialogText(
                                                                    thisInstance, instanceName,
                                                                    testAccount, devAccount),
                                                                ErrorStrings.StopRunningGame));

            if (!okToStop)
            {
                // Developer opted to not stop the existing launch.
                // Launch can not proceed.
                return(false);
            }

            return(true);
        }
        public void RecordCancelableModal(bool completed)
        {
            bool ranTask = false;

            actionRecorder.RecordUserAction(MetricActionType,
                                            delegate()
            {
                ranTask = true;
                return(completed);
            });

            var expectedStatus = completed
                ? DeveloperEventStatus.Types.Code.Success
                : DeveloperEventStatus.Types.Code.Cancelled;

            Assert.IsTrue(ranTask);

            logEvent.StatusCode  = expectedStatus;
            logEvent.LatencyType = DeveloperLogEvent.Types.LatencyType.LatencyUser;
            metrics.Received(1).RecordEvent(EventType, logEvent);
        }
示例#4
0
        /// <summary>
        /// Select the first available gamelet, or let the user pick from multiple gamelets.
        /// Ensure the selected gamelet is in a valid state before returning.
        /// </summary>
        bool TrySelectGamelet(List <Gamelet> gamelets, out Gamelet result)
        {
            Gamelet gamelet = result = null;
            bool    res     = _actionRecorder.RecordUserAction(ActionType.GameletSelect, delegate
            {
                bool isValid;
                switch (gamelets.Count)
                {
                case 0:
                    throw new ConfigurationException(ErrorStrings.NoGameletsFound);

                case 1:
                    gamelet = gamelets[0];
                    isValid = true;
                    break;

                default:
                    gamelet = _gameletSelectionWindowFactory.Create(gamelets).Run();
                    isValid = gamelet != null;
                    break;
                }

                if (!isValid)
                {
                    return(false);
                }

                if (gamelet.State != GameletState.InUse && gamelet.State != GameletState.Reserved)
                {
                    throw new InvalidStateException(ErrorStrings.GameletInUnexpectedState(gamelet));
                }

                return(true);
            });

            result = gamelet;
            return(res);
        }