Esempio n. 1
0
        public UIDialogData(string title          = null,
                            string message        = null,
                            DialogActions buttons = null,
                            string focusButton    = null,
                            Vector3?position      = null,
                            Sprite icon           = null,

                            bool modal                    = false,
                            bool hideByModalClick         = true,
                            Sprite modalSprite            = null,
                            Color?modalColor              = null,
                            UnityAction closeButtonAction = null,
                            int forbidOperTime            = 0,
                            UnityAction modalClickAction  = null,
                            EDialogType eDialogType       = EDialogType.Default,
                            bool mutex                    = false)
        {
            strTitle          = title;
            strMessage        = message;
            strFocusButton    = focusButton;
            actButtons        = buttons;
            vec3Position      = position;
            sprIcon           = icon;
            sprModal          = modalSprite;
            colorModal        = modalColor;
            bModal            = modal;
            bHideByModalClick = hideByModalClick;
            actCloseButton    = closeButtonAction;
            nForbidOperTime   = forbidOperTime;
            actModalClick     = modalClickAction;
            DialogType        = eDialogType;
            bMutex            = mutex;
        }
Esempio n. 2
0
        /// <summary>
        /// Open AddPlaylistDialog.
        /// </summary>
        public void AddPlaylistDialog()
        {
            // create dialog from template
            var dialog = AddPlaylistDialogTemplate.Clone();

            // helper component with references to input fields
            var helper = dialog.GetComponent <PlaylistDialogHelper>();

            // reset input fields to default
            helper.Refresh();

            var actions = new DialogActions()
            {
                { "Add", () => CheckPlaylistDialog(helper) },

                // on click close dialog
                { "Cancel", Dialog.Close },
            };

            // open dialog
            dialog.Show(
                title: "Add playlist",
                buttons: actions,
                focusButton: "Sign in",
                modal: true,
                modalColor: new Color(0, 0, 0, 0.8f));
        }
	/**
	 * The constructor for the dialog
	 * @param title The title of the dialog
	 * @param message The message of the dialog
	 * @param buttons The buttons to show. The indices of these buttons is used the same as the param actions
	 * @param actions The actions that will be triggered. The indices of these actions is used the same as the param buttons
	 */
	public void construct (string title, string message, string[] buttons, DialogActions[] actions) {
		// Initialize the array
		this.actions = new Dictionary<string, DialogActions> ();

		// Set the title
		this.title.text = title;

		// Set the message
		this.message.text = message;

		// Loop for each param array entry
		for (int i = 0; i < Mathf.Min (buttonsArray.Count, buttons.Length, actions.Length); i++) {
			// Check if the button is available
			if (buttonsArray.ContainsKey (buttons [i])) {
				// Get the button
				Button button = null;
				buttonsArray.TryGetValue (buttons [i], out button);

				// Ensure the button is not already used
				// Show the button
				button.gameObject.SetActive (true);

				// Store the action
				this.actions.Add (buttons [i], actions [i]);
			}
		}
	}
Esempio n. 4
0
        /// <summary>
        /// Show dialog with TreeView.
        /// </summary>
        public void ShowDialogTreeView()
        {
            // create dialog from template
            var dialog = DialogTreeViewTemplate.Clone();

            // helper component with references to input fields
            var helper = dialog.GetComponent <DialogTreeViewInputHelper>();

            var actions = new DialogActions()
            {
                // on click close dialog
                { "Close", Dialog.Close },
            };

            // open dialog
            dialog.Show(
                title: "Dialog with TreeView",
                buttons: actions,
                focusButton: "Close",
                modal: true,
                modalColor: new Color(0, 0, 0, 0.8f));

            // reset input fields to default
            helper.Refresh();
        }
Esempio n. 5
0
        /// <summary>
        /// Open EditPlaylistDialog.
        /// </summary>
        public void EditPlaylistDialog()
        {
            // if not playlist do nothing
            if (!OrderLine.IsPlaylist)
            {
                return;
            }

            // create dialog from template
            var dialog = EditPlaylistDialogTemplate.Clone();

            // helper component with references to input fields
            var helper = dialog.GetComponent <PlaylistDialogHelper>();

            // reset input fields to default
            helper.Name.text = OrderLine.Item.Name;

            var actions = new DialogActions()
            {
                { "Change", () => CheckPlaylistDialog(helper) },

                // on click close dialog
                { "Cancel", Dialog.Close },
            };

            // open dialog
            dialog.Show(
                title: "Change playlist name",
                buttons: actions,
                focusButton: "Sign in",
                modal: true,
                modalColor: new Color(0, 0, 0, 0.8f));
        }
Esempio n. 6
0
        /// <summary>
        /// Show sing-in dialog.
        /// </summary>
        public void ShowDialogSignIn()
        {
            // create dialog from template
            var dialog = DialogSignInTemplate.Clone();

            // helper component with references to input fields
            var helper = dialog.GetComponent <DialogInputHelper>();

            // reset input fields to default
            helper.Refresh();

            var actions = new DialogActions()
            {
                // on click call SignInNotify
                { "Sign in", () => SignInNotify(helper) },

                // on click close dialog
                { "Cancel", Dialog.Close },
            };

            // open dialog
            dialog.Show(
                title: "Sign into your Account",
                buttons: actions,
                focusButton: "Sign in",
                modal: true,
                modalColor: new Color(0, 0, 0, 0.8f));
        }
Esempio n. 7
0
 public DialogUIBlueprint(string name, string title = null, string message = null, DialogActions buttons = null, bool model = false, Color?modelColor = null)
 {
     uiName          = name;
     this.title      = title;
     this.message    = message;
     this.buttons    = buttons;
     this.model      = model;
     this.modelColor = modelColor;
 }
 private void ShowDialog(string title, string content, DialogActions buttons)
 {
     UBB.toHtml(ref content);
     USpeedUI.TooltipAndDialog.UIDialogData data = new USpeedUI.TooltipAndDialog.UIDialogData(
         title: title,
         message: content,
         modal: true,
         hideByModalClick: false,
         buttons: buttons
         );
     UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_COMMON_DIALOG, data);
 }
Esempio n. 9
0
        /// <summary>
        /// Show warning.
        /// </summary>
        public void ShowWarning()
        {
            var actions = new DialogActions()
            {
                { "OK", Dialog.Close },
            };

            DialogSampleTemplate.Clone().Show(
                title: "Warning window",
                message: "Warning test",
                buttons: actions,
                focusButton: "OK",
                icon: AttentionIcon);
        }
Esempio n. 10
0
 private void ShowDialog(string title, string content, DialogActions buttons)
 {
     UBB.toHtml(ref content);
     TooltipAndDialog.UIDialogData data = new TooltipAndDialog.UIDialogData(
         title: title,
         message: content,
         modal: false,
         hideByModalClick: false,
         modalColor: Color.clear,
         buttons: buttons,
         mutex: true,
         eDialogType: EDialogType.LifeHeroCulture
         );
     UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_COMMON_DIALOG, data);
 }
Esempio n. 11
0
        /// <summary>
        /// Show modal dialog.
        /// </summary>
        public void ShowDialogModal()
        {
            var actions = new DialogActions()
            {
                { "Close", Dialog.Close },
            };

            DialogSampleTemplate.Clone().Show(
                title: "Modal Dialog",
                message: "Simple Modal Dialog.",
                buttons: actions,
                focusButton: "Close",
                modal: true,
                modalColor: new Color(0, 0, 0, 0.8f));
        }
Esempio n. 12
0
        /// <summary>
        /// Show dialog in the same position when it was closed.
        /// </summary>
        public void ShowDialogInPosition()
        {
            var dialog = DialogSampleTemplate.Clone();

            var actions = new DialogActions()
            {
                { "Close", () => Close(dialog) },
            };

            dialog.Show(
                title: "Simple Dialog",
                message: "Simple dialog with only close button.",
                buttons: actions,
                focusButton: "Close",
                position: dialog.transform.localPosition);
        }
Esempio n. 13
0
        // Token: 0x06004623 RID: 17955 RVA: 0x0017D458 File Offset: 0x0017B858
        public void ShowDialogSimple()
        {
            Dialog        dialog         = Dialog.Template("DialogTemplateSample");
            string        title          = "Simple Dialog";
            string        message        = "Simple dialog with only close button.";
            DialogActions dialogActions  = new DialogActions();
            DialogActions dialogActions2 = dialogActions;
            string        key            = "Close";

            if (UITestSamples.f__mg2 == null)
            {
                UITestSamples.f__mg2 = new Func <bool>(Dialog.Close);
            }
            dialogActions2.Add(key, UITestSamples.f__mg2);
            dialog.Show(title, message, dialogActions, "Close", null, null, false, null, null, null);
        }
Esempio n. 14
0
        /// <summary>
        /// Show dialog with lots of text.
        /// </summary>
        public void ShowDialogExtended()
        {
            var actions = new DialogActions()
            {
                { "Show notification", CallShowNotifyAutohide },
                { "Open simple dialog", CallShowDialogSimple },
                { "Close", Dialog.Close },
            };

            DialogSampleTemplate.Clone().Show(
                title: "Another Dialog",
                message: "Same template with another position and long text.\nChange\nheight\nto\nfit\ntext.",
                buttons: actions,
                focusButton: "Show notification",
                position: new Vector3(40, -40, 0));
        }
Esempio n. 15
0
        /// <summary>
        /// Show dialog with Yes/No/Cancel buttons.
        /// </summary>
        public void ShowDialogYesNoCancel()
        {
            var actions = new DialogActions()
            {
                { "Yes", ShowNotifyYes },
                { "No", ShowNotifyNo },
                { "Cancel", Dialog.Close },
            };

            DialogSampleTemplate.Clone().Show(
                title: "Dialog Yes No Cancel",
                message: "Question?",
                buttons: actions,
                focusButton: "Yes",
                icon: QuestionIcon);
        }
Esempio n. 16
0
        /// <summary>
        /// Show simple dialog.
        /// </summary>
        public void ShowDialogSimple()
        {
            var canvas = Utilites.FindTopmostCanvas(transform).GetComponent <Canvas>();

            var dialog = DialogSampleTemplate.Clone();

            var actions = new DialogActions()
            {
                { "Close", Dialog.Close },
            };

            dialog.Show(
                title: "Simple Dialog",
                message: "Simple dialog with only close button.",
                buttons: actions,
                focusButton: "Close",
                canvas: canvas);
        }
Esempio n. 17
0
        // Token: 0x06004626 RID: 17958 RVA: 0x0017D588 File Offset: 0x0017B988
        public void ShowDialogExtended()
        {
            Dialog        dialog        = Dialog.Template("DialogTemplateSample");
            string        title         = "Another Dialog";
            string        message       = "Same template with another position and long text.\nChange\nheight\nto\nfit\ntext.";
            DialogActions dialogActions = new DialogActions();

            dialogActions.Add("Show notification", new Func <bool>(this.CallShowNotifyAutohide));
            dialogActions.Add("Open simple dialog", new Func <bool>(this.CallShowDialogSimple));
            DialogActions dialogActions2 = dialogActions;
            string        key            = "Close";

            if (UITestSamples.f__mg4 == null)
            {
                UITestSamples.f__mg4 = new Func <bool>(Dialog.Close);
            }
            dialogActions2.Add(key, UITestSamples.f__mg4);
            dialog.Show(title, message, dialogActions, "Show notification", new Vector3?(new Vector3(40f, -40f, 0f)), null, false, null, null, null);
        }
Esempio n. 18
0
        public DialogActions GetNewAction(EMessageBoxType _eType, Func <bool> _okCallback, Func <bool> _cancelCallback)
        {
            DialogActions result = new DialogActions();

            if ((_eType & EMessageBoxType.EMBT_OK) > 0)
            {
                result.Add(ULocalizationService.Instance.Get("UIView", "Common", "ConfirmBtn"), _okCallback);
            }
            else if ((_eType & EMessageBoxType.EMBT_Cancel) > 0)
            {
                result.Add(ULocalizationService.Instance.Get("UIView", "Common", "CancelBtn"), _cancelCallback);
            }
            else if ((_eType & EMessageBoxType.EMBT_OKCancel) > 0)
            {
                result.Add(ULocalizationService.Instance.Get("UIView", "Common", "ConfirmBtn"), _okCallback);
                result.Add(ULocalizationService.Instance.Get("UIView", "Common", "CancelBtn"), _cancelCallback);
            }

            return(result);
        }
Esempio n. 19
0
        // Token: 0x06004627 RID: 17959 RVA: 0x0017D638 File Offset: 0x0017BA38
        public void ShowDialogModal()
        {
            Dialog        dialog         = Dialog.Template("DialogTemplateSample");
            string        title          = "Modal Dialog";
            string        message        = "Simple Modal Dialog.";
            DialogActions dialogActions  = new DialogActions();
            DialogActions dialogActions2 = dialogActions;
            string        key            = "Close";

            if (UITestSamples.f__mg5 == null)
            {
                UITestSamples.f__mg5 = new Func <bool>(Dialog.Close);
            }
            dialogActions2.Add(key, UITestSamples.f__mg5);
            dialogActions = dialogActions;
            string focusButton = "Close";
            Color? modalColor  = new Color?(new Color(0f, 0f, 0f, 0.8f));

            dialog.Show(title, message, dialogActions, focusButton, null, null, true, null, modalColor, null);
        }
Esempio n. 20
0
    void CreateButtons(DialogActions buttons, string focusButton)
    {
        defaultButton.gameObject.SetActive(false);

        if (buttons == null)
        {
            return;
        }

        buttons.ForEach(x =>
        {
            var button = GetButton();

            UnityAction callback = () =>
            {
                if (x.Value())
                {
                    Hide();
                }
            };

            buttonsInUse.Add(x.Key, button);
            buttonsActions.Add(x.Key, callback);

            button.gameObject.SetActive(true);
            button.transform.SetAsLastSibling();

            var text = button.GetComponentInChildren <Text>();
            if (text)
            {
                text.text = x.Key;
            }

            button.onClick.AddListener(buttonsActions[x.Key]);

            if (x.Key == focusButton)
            {
                button.Select();
            }
        });
    }
Esempio n. 21
0
        // Token: 0x06004625 RID: 17957 RVA: 0x0017D4D4 File Offset: 0x0017B8D4
        public void ShowDialogYesNoCancel()
        {
            Dialog        dialog        = Dialog.Template("DialogTemplateSample");
            string        title         = "Dialog Yes No Cancel";
            string        message       = "Question?";
            DialogActions dialogActions = new DialogActions();

            dialogActions.Add("Yes", new Func <bool>(this.ShowNotifyYes));
            dialogActions.Add("No", new Func <bool>(this.ShowNotifyNo));
            DialogActions dialogActions2 = dialogActions;
            string        key            = "Cancel";

            if (UITestSamples.f__mg3 == null)
            {
                UITestSamples.f__mg3 = new Func <bool>(Dialog.Close);
            }
            dialogActions2.Add(key, UITestSamples.f__mg3);
            dialogActions = dialogActions;
            string focusButton = "Yes";
            Sprite icon        = this.questionIcon;

            dialog.Show(title, message, dialogActions, focusButton, null, icon, false, null, null, null);
        }
Esempio n. 22
0
        // Token: 0x06004628 RID: 17960 RVA: 0x0017D6CC File Offset: 0x0017BACC
        public void ShowDialogSignIn()
        {
            Dialog            dialog = Dialog.Template("DialogSignInTemplateSample");
            DialogInputHelper helper = dialog.GetComponent <DialogInputHelper>();

            helper.Refresh();
            Dialog        dialog2       = dialog;
            string        title         = "Sign into your Account";
            DialogActions dialogActions = new DialogActions();

            dialogActions.Add("Sign in", () => this.SignInNotify(helper));
            DialogActions dialogActions2 = dialogActions;
            string        key            = "Cancel";

            if (UITestSamples.f__mg6 == null)
            {
                UITestSamples.f__mg6 = new Func <bool>(Dialog.Close);
            }
            dialogActions2.Add(key, UITestSamples.f__mg6);
            dialogActions = dialogActions;
            Color?modalColor = new Color?(new Color(0f, 0f, 0f, 0.8f));

            dialog2.Show(title, null, dialogActions, "Sign in", null, null, true, null, modalColor, null);
        }
Esempio n. 23
0
        public IEntity ShowDialog(string ui, string title = null, string message = null, DialogActions butttons = null,
                                  bool model = false, Color?modelColor           = null)
        {
            var uiEntity = CreateUI(new DialogUIBlueprint(ui, title, message, butttons, model, modelColor ?? new Color(0.0f, 0.0f, 0.0f, 0.8f)));

            CreateUI(uiEntity);
            return(uiEntity);
        }
Esempio n. 24
0
        void CreateButtons(DialogActions buttons, string focusButton)
        {
            defaultButton.gameObject.SetActive(false);

            if (buttons==null)
            {
                return ;
            }

            buttons.ForEach(x => {
                var button = GetButton();

                UnityAction callback = () => {
                    if (x.Value())
                    {
                        Hide();
                    }
                };

                buttonsInUse.Add(x.Key, button);
                buttonsActions.Add(x.Key, callback);

                button.gameObject.SetActive(true);
                button.transform.SetAsLastSibling();

                var text = button.GetComponentInChildren<Text>();
                if (text)
                {
                    text.text = x.Key;
                }

                button.onClick.AddListener(buttonsActions[x.Key]);

                if (x.Key==focusButton)
                {
                    button.Select();
                }
            });
        }
Esempio n. 25
0
        /// <summary>
        /// Show dialog.
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</param>
        /// <param name="buttons">Buttons.</param>
        /// <param name="focusButton">Set focus on button with specified name.</param>
        /// <param name="position">Position.</param>
        /// <param name="icon">Icon.</param>
        /// <param name="modal">If set to <c>true</c> modal.</param>
        /// <param name="modalSprite">Modal sprite.</param>
        /// <param name="modalColor">Modal color.</param>
        /// <param name="canvas">Canvas.</param>
        public void Show(string title = null,
		                 string message = null,
		                 DialogActions buttons = null,
		                 string focusButton = null,
		                 Vector3? position = null,
		                 Sprite icon = null,

		                 bool modal = false,
		                 Sprite modalSprite = null,
		                 Color? modalColor = null,

		                 Canvas canvas = null)
        {
            if (position==null)
            {
                position = new Vector3(0, 0, 0);
            }

            if ((title!=null) && (TitleText!=null))
            {
                TitleText.text = title;
            }
            if ((message!=null) && (ContentText!=null))
            {
                contentText.text = message;
            }
            if ((icon!=null) && (Icon!=null))
            {
                Icon.sprite = icon;
            }

            var parent = (canvas!=null) ? canvas.transform : Utilites.FindCanvas(gameObject.transform);

            transform.SetParent(parent, false);

            if (modal)
            {
                modalKey = ModalHelper.Open(this, modalSprite, modalColor);
            }
            else
            {
                modalKey = null;
            }

            transform.SetAsLastSibling();

            transform.localPosition = (Vector3)position;
            gameObject.SetActive(true);

            CreateButtons(buttons, focusButton);
        }
Esempio n. 26
0
    /// <summary>
    ///  Show DialogBox
    /// </summary>
    public void Show(DialogActions buttons = null,
                     string title          = null,
                     string message        = null,
                     string focusButton    = null,
                     Vector3?position      = null,
                     Sprite icon           = null,

                     bool modal         = true,
                     Sprite modalSprite = null,
                     Color?modalColor   = null,

                     Canvas canvas = null,
                     bool autoHide = false)
    {
        //setting default value
        if (position == null)
        {
            position = new Vector3(0, 0, 0);
        }
        if (modalColor == null)
        {
            modalColor = new Color(0, 0, 0, 0.5f);
        }
        if ((message != null) && (ContentText != null))
        {
            contentText.text = message;
        }

        if ((icon != null) && (Icon != null))
        {
            Icon.sprite = icon;
            Icon.gameObject.SetActive(true);
        }
        else
        {
            Icon.gameObject.SetActive(false);
        }

        if ((title != null) && (TitleText != null))
        {
            TitleText.text = title;
            TitleText.gameObject.SetActive(true);
        }
        else
        {
            TitleText.gameObject.SetActive(false);
        }

        var parent = (canvas != null) ? canvas.transform : Global.MessageCanvas;

        transform.SetParent(parent, false);

        if (modal)
        {
            modalKey = ModleLayer.Open(this, modalSprite, modalColor);
        }
        else
        {
            modalKey = null;
        }


        transform.SetAsLastSibling();

        transform.localPosition = (Vector3)position;
        gameObject.SetActive(true);

        CreateButtons(buttons, focusButton);

        if (autoHide)
        {
            StartCoroutine(HideAuto());
        }
    }
Esempio n. 27
0
    /// <summary>
    ///  Show DialogBox
    /// </summary>
    public void Show(DialogActions buttons = null,
                     string title = null,
                     string message = null,
                     string focusButton = null,
                     Vector3? position = null,
                     Sprite icon = null,

                     bool modal = true,
                     Sprite modalSprite = null,
                     Color? modalColor = null,

                     Canvas canvas = null,
                     bool autoHide = false)
    {
        //setting default value
        if (position == null) position = new Vector3(0, 0, 0);
        if (modalColor == null) modalColor = new Color(0, 0, 0, 0.5f);
        if ((message != null) && (ContentText != null)) contentText.text = message;

        if ((icon != null) && (Icon != null))
        {
            Icon.sprite = icon;
            Icon.gameObject.SetActive(true);
        }
        else
        {
            Icon.gameObject.SetActive(false);
        }

        if ((title != null) && (TitleText != null))
        {
            TitleText.text = title;
            TitleText.gameObject.SetActive(true);
        }
        else
        {
            TitleText.gameObject.SetActive(false);
        }

        var parent = (canvas != null) ? canvas.transform : Global.MessageCanvas;

        transform.SetParent(parent, false);

        if (modal) modalKey = ModleLayer.Open(this, modalSprite, modalColor);
        else modalKey = null;

        transform.SetAsLastSibling();

        transform.localPosition = (Vector3)position;
        gameObject.SetActive(true);

        CreateButtons(buttons, focusButton);

        if(autoHide)
        {
            StartCoroutine(HideAuto());
        }
    }
Esempio n. 28
0
	/**
	 * Method that shows the much needed generic dialog
	 * @param title The title of the dialog
	 * @param message The message of the dialog
	 * @param buttons The buttons to show. The indices of these buttons is used the same as the param actions
	 * @param actions The actions that will be triggered. The indices of these actions is used the same as the param buttons
	 */
	public void showDialog (string title, string message, string[] buttons, DialogActions[] actions) {
		// Show the dialog
		dialogController.gameObject.SetActive (true);

		// Call the constructor
		dialogController.construct (title, message, buttons, actions);
	}