Example #1
0
 public static YesNoCancelDialogResult YesNoCancelFormat(
     [NotNull] string title,
     YesNoCancelDialogResult defaultResult,
     [NotNull] string format,
     params object[] args)
 {
     return(YesNoCancelFormat(null, title, defaultResult, format, args));
 }
Example #2
0
 public static YesNoCancelDialogResult YesNoCancel(
     [CanBeNull] IWin32Window owner,
     [NotNull] string title,
     [NotNull] string message,
     YesNoCancelDialogResult defaultResult = YesNoCancelDialogResult.Yes)
 {
     return(Service.ShowYesNoCancel(owner, title, message, defaultResult));
 }
Example #3
0
        public IEnumerator SpawnSaveGameDialog(bool confirmFirst, bool canCancel)
        {
            bool spawnSaveGameDialog = true;

            if (confirmFirst)
            {
                spawnSaveGameDialog = false;
                GameObject              yesNoDialogChildEditor = GUIManager.SpawnNGUIChildEditor(gameObject, GUIManager.Get.NGUIYesNoCancelDialog, false);
                GUIYesNoCancelDialog    confirmDialog          = yesNoDialogChildEditor.GetComponent <GUIYesNoCancelDialog>();
                YesNoCancelDialogResult confirmResult          = new YesNoCancelDialogResult();
                confirmResult.CancelButton = canCancel;
                confirmResult.MessageType  = "Save Current Game?";
                //confirmResult.Message = "Click 'Yes' to save before quitting. Click 'Cancel' to return to the game.";
                GUIManager.SendEditObjectToChildEditor <YesNoCancelDialogResult>(yesNoDialogChildEditor, confirmResult);

                while (!confirmDialog.IsFinished)
                {
                    yield return(null);
                }

                //deal with the result
                switch (confirmResult.Result)
                {
                case DialogResult.Cancel:
                default:
                    //we'll exit without setting the confirm game state
                    spawnSaveGameDialog = false;
                    break;

                case DialogResult.No:
                    Profile.Get.CurrentGame.LastTimeDeclinedToSave = System.DateTime.Now;
                    spawnSaveGameDialog = false;
                    break;

                case DialogResult.Yes:
                    Debug.Log("Save game");
                    spawnSaveGameDialog = true;
                    break;
                }
            }

            if (spawnSaveGameDialog)
            {
                /*
                 *                      GameObject saveGameEditor = GUIManager.SpawnNGUIChildEditor (gameObject, GUIManager.Get.NGUISaveGameDialog, false);
                 *                      GUISaveGameDialog saveGameDialog = saveGameEditor.GetComponent <GUISaveGameDialog> ();
                 *                      SaveGameDialogResult saveGameResult = new SaveGameDialogResult ();
                 *                      GUIManager.SendEditObjectToChildEditor <SaveGameDialogResult> (saveGameEditor, saveGameResult);
                 *                      while (!saveGameDialog.IsFinished) {
                 *                              yield return null;
                 *                      }
                 */
            }

            yield break;
        }
Example #4
0
 public static YesNoCancelDialogResult YesNoCancelFormat(
     [CanBeNull] IWin32Window owner,
     [NotNull] string title,
     YesNoCancelDialogResult defaultResult,
     [NotNull] string format,
     params object[] args)
 {
     return(YesNoCancel(owner, title,
                        string.Format(format, args), defaultResult));
 }
Example #5
0
        /// <summary>
        /// Activity heavy lifting.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            //Get Argument Values
            string message = Message.Get(context) ?? String.Empty;
            string caption = Caption.Get(context) ?? String.Empty;
            XlateMessageBoxDefaultButtons defaultButtons = DefaultButtons.Get(context);

            //Heavy Lifting
            YesNoCancelDialogResult result = XlateMessageBox.YesNoCancel(message, caption, defaultButtons);

            DialogResult.Set(context, result);
        }
Example #6
0
        protected IEnumerator WaitForConfirmation(GameObject confirmEditor, YesNoCancelDialogResult result)
        {
            while (confirmEditor != null && mWaitingForConfirmation)
            {
                yield return(null);
            }

            if (result.Result == DialogResult.Yes)
            {
                //this is the ONE case where we call this ourselves
                TryToStartTrigger();
            }

            yield break;
        }
Example #7
0
        /// <summary>
        /// Shows the Yes/No/Cancel dialog.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="message">The message.</param>
        /// <param name="title">The title.</param>
        /// <param name="defaultResult">The default result.</param>
        /// <returns></returns>
        public YesNoCancelDialogResult ShowYesNoCancel(IWin32Window owner, string title,
                                                       string message,
                                                       YesNoCancelDialogResult
                                                       defaultResult)
        {
            Assert.ArgumentNotNullOrEmpty(title, nameof(title));
            Assert.ArgumentNotNullOrEmpty(message, nameof(message));

            _msg.Info(message);

            string msg = MsgBase.ReplaceBreakTags(message);

            MessageBoxDefaultButton defaultButton;

            switch (defaultResult)
            {
            case YesNoCancelDialogResult.Yes:
                defaultButton = MessageBoxDefaultButton.Button1;
                break;

            case YesNoCancelDialogResult.No:
                defaultButton = MessageBoxDefaultButton.Button2;
                break;

            case YesNoCancelDialogResult.Cancel:
                defaultButton = MessageBoxDefaultButton.Button3;
                break;

            default:
                throw new ArgumentException(
                          string.Format(
                              "Invalid default result ({0})", defaultResult),
                          nameof(defaultResult));
            }

            DialogResult result = Show(owner, msg, title,
                                       MessageBoxButtons.YesNoCancel,
                                       MessageBoxIcon.Question,
                                       defaultButton);

            _msg.DebugFormat("YES NO CANCEL Dialog: {0}, '{1}'. Answer: '{2}'",
                             msg, title, result);

            return(GetYesNoCancelAnswer(result));
        }
Example #8
0
        public void TryToTrigger()
        {
            if (mWaitingForConfirmation || mTryingToStart)
            {
                return;
            }

            TriggerFailureSources.Clear();
            TriggerFailureMessages.Clear();
            LastTriggerFailed = false;

            if (State.Behavior == TriggerBehavior.Once && State.NumTimesTriggered > 0)
            {
                OnTriggerFail.SaveInvoke(this);
            }

            if (State.Confirm != ConfirmationBehavior.Never)
            {
                if ((State.Confirm == ConfirmationBehavior.Once && State.NumTimesTriggered == 0) ||
                    State.Confirm == ConfirmationBehavior.Always)
                {
                    YesNoCancelDialogResult result = new YesNoCancelDialogResult();
                    result.Message      = State.ConfirmationMessage;
                    result.MessageType  = State.ConfirmationTitle;
                    result.CancelButton = false;
                    GameObject confirmEditor = GUIManager.SpawnNGUIChildEditor(gameObject, GUIManager.Get.NGUIYesNoCancelDialog, false);
                    GUIManager.SendEditObjectToChildEditor <YesNoCancelDialogResult>(new ChildEditorCallback <YesNoCancelDialogResult>(OnFinishConfirm),
                                                                                     confirmEditor,
                                                                                     result);

                    mWaitingForConfirmation = true;
                    StartCoroutine(WaitForConfirmation(confirmEditor, result));
                    return;
                }
            }
            else
            {
                TryToStartTrigger();
            }
        }
Example #9
0
 public void OnFinishConfirm(YesNoCancelDialogResult editObject, IGUIChildEditor <YesNoCancelDialogResult> childEditor)
 {
     GUIManager.ScaleDownEditor(childEditor.gameObject).Proceed(true);
     mWaitingForConfirmation = false;
 }