Example #1
0
        // Token: 0x06004839 RID: 18489 RVA: 0x00183874 File Offset: 0x00181C74
        public static int Open(MonoBehaviour parent, Sprite sprite = null, Color?color = null)
        {
            if (!ModalHelper.Templates.Exists(ModalHelper.key))
            {
                ModalHelper.Templates.FindTemplates();
                ModalHelper.CreateTemplate();
            }
            ModalHelper modalHelper = ModalHelper.Templates.Instance(ModalHelper.key);

            modalHelper.transform.SetParent(Utilites.FindCanvas(parent.transform), false);
            modalHelper.gameObject.SetActive(true);
            modalHelper.transform.SetAsLastSibling();
            RectTransform component = modalHelper.GetComponent <RectTransform>();

            component.sizeDelta        = new Vector2(0f, 0f);
            component.anchorMin        = new Vector2(0f, 0f);
            component.anchorMax        = new Vector2(1f, 1f);
            component.anchoredPosition = new Vector2(0f, 0f);
            Image component2 = modalHelper.GetComponent <Image>();

            if (sprite != null)
            {
                component2.sprite = sprite;
            }
            if (color != null)
            {
                component2.color = color.Value;
            }
            ModalHelper.used.Add(modalHelper.GetInstanceID(), modalHelper);
            return(modalHelper.GetInstanceID());
        }
Example #2
0
        // Token: 0x060046BB RID: 18107 RVA: 0x0017FB44 File Offset: 0x0017DF44
        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?(new Vector3(0f, 0f, 0f));
            }
            if (title != null && this.TitleText != null)
            {
                this.TitleText.text = title;
            }
            if (message != null && this.ContentText != null)
            {
                this.contentText.text = message;
            }
            if (icon != null && this.Icon != null)
            {
                this.Icon.sprite = icon;
            }
            Transform parent = (!(canvas != null)) ? Utilites.FindCanvas(base.gameObject.transform) : canvas.transform;

            base.transform.SetParent(parent, false);
            if (modal)
            {
                this.modalKey = new int?(ModalHelper.Open(this, modalSprite, modalColor));
            }
            else
            {
                this.modalKey = null;
            }
            base.transform.SetAsLastSibling();
            base.transform.localPosition = position.Value;
            base.gameObject.SetActive(true);
            this.CreateButtons(buttons, focusButton);
        }
Example #3
0
        /// <summary>
        /// Display specified image.
        /// </summary>
        /// <param name="image">Image to display.</param>
        /// <param name="modalSprite">Modal background sprite.</param>
        /// <param name="modalColor">Modal background color.</param>
        /// <param name="canvas">Canvas.</param>
        public virtual void Show(
            Sprite image,
            Sprite modalSprite = null,
            Color?modalColor   = null,
            Canvas canvas      = null)
        {
            GetComponent <Image>().sprite = image;

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

            if (parent != null)
            {
                transform.SetParent(parent, false);
            }

            if (modalColor == null)
            {
                modalColor = new Color(0, 0, 0, 0.8f);
            }

            ModalKey = ModalHelper.Open(this, modalSprite, modalColor, Close);

            transform.SetAsLastSibling();

            gameObject.SetActive(true);
        }
Example #4
0
        /// <summary>
        /// Show picker.
        /// </summary>
        /// <param name="defaultValue">Default value.</param>
        /// <param name="onSelect">Callback with selected value.</param>
        /// <param name="onCancel">Callback when picker closed without any value selected.</param>
        /// <param name="modalSprite">Modal sprite.</param>
        /// <param name="modalColor">Modal color.</param>
        /// <param name="canvas">Canvas.</param>
        public virtual void Show(
            TValue defaultValue,
            Action <TValue> onSelect,
            Action onCancel    = null,
            Sprite modalSprite = null,
            Color?modalColor   = null,

            Canvas canvas = null)
        {
            OnSelect = onSelect;
            OnCancel = onCancel;

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

            if (parent != null)
            {
                transform.SetParent(parent, false);
            }

            if (modalColor == null)
            {
                modalColor = new Color(0, 0, 0, 0.8f);
            }

            ModalKey = ModalHelper.Open(this, modalSprite, modalColor, Close);

            transform.SetAsLastSibling();

            gameObject.SetActive(true);

            BeforeOpen(defaultValue);
        }
Example #5
0
        /// <summary>
        /// Shows the list.
        /// </summary>
        public virtual void ShowList()
        {
            if (listView == null)
            {
                return;
            }

            listView.gameObject.SetActive(true);

            ModalKey = ModalHelper.Open(this, null, new Color(0, 0, 0, 0f), HideList);

            if (ListViewCanvas != null)
            {
                ListViewParent = listView.transform.parent;
                listView.transform.SetParent(ListViewCanvas);
            }

            if (listView.Layout != null)
            {
                listView.Layout.UpdateLayout();
            }

            if (listView.SelectComponent())
            {
                SetChildDeselectListener(EventSystem.current.currentSelectedGameObject);
            }
            else
            {
                EventSystem.current.SetSelectedGameObject(listView.gameObject);
            }
        }
Example #6
0
        // Token: 0x0600483A RID: 18490 RVA: 0x00183988 File Offset: 0x00181D88
        private static void CreateTemplate()
        {
            GameObject  gameObject = new GameObject(ModalHelper.key);
            ModalHelper template   = gameObject.AddComponent <ModalHelper>();

            gameObject.AddComponent <Image>();
            ModalHelper.Templates.Add(ModalHelper.key, template, true);
        }
Example #7
0
        /// <summary>
        /// Close lightbox.
        /// </summary>
        public virtual void Close()
        {
            gameObject.SetActive(false);

            if (ModalKey != null)
            {
                ModalHelper.Close((int)ModalKey);
            }
        }
Example #8
0
        /// <summary>
        /// Close dialog.
        /// </summary>
        public void Hide()
        {
            if (modalKey != null)
            {
                ModalHelper.Close((int)modalKey);
            }

            Return();
        }
Example #9
0
        /// <summary>
        /// Close dialog.
        /// </summary>
        public virtual void Hide()
        {
            if (ModalKey != null)
            {
                ModalHelper.Close((int)ModalKey);
            }

            //Return();
        }
Example #10
0
        // Token: 0x060046BC RID: 18108 RVA: 0x0017FC88 File Offset: 0x0017E088
        public void Hide()
        {
            int?num = this.modalKey;

            if (num != null)
            {
                int?num2 = this.modalKey;
                ModalHelper.Close(num2.Value);
            }
            this.Return();
        }
Example #11
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);

            if (parent != null)
            {
                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);
        }
Example #12
0
        /// <summary>
        /// Close picker.
        /// </summary>
        protected virtual void Close()
        {
            BeforeClose();

            if (ModalKey != null)
            {
                ModalHelper.Close((int)ModalKey);
            }

            Return();
        }
Example #13
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>
        /// <param name="content">Content.</param>
        /// <param name="onClose">On close callback.</param>
        /// <param name="onCancel">On cancel callback.</param>
        public virtual void Show(
            string title   = null,
            string message = null,
            IList <DialogButton> buttons = null,
            string focusButton           = null,
            Vector3?position             = null,
            Sprite icon               = null,
            bool modal                = false,
            Sprite modalSprite        = null,
            Color?modalColor          = null,
            Canvas canvas             = null,
            RectTransform content     = null,
            Action onClose            = null,
            Func <int, bool> onCancel = null)
        {
            if (IsTemplate)
            {
                Debug.LogWarning("Use the template clone, not the template itself: DialogTemplate.Clone().Show(...), not DialogTemplate.Show(...)");
            }

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

            OnClose  = onClose;
            OnCancel = onCancel;
            SetInfo(title, message, icon);
            SetContent(content);

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

            if (parent != null)
            {
                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);
        }
Example #14
0
        /// <summary>
        /// Close popup.
        /// </summary>
        public virtual void Close()
        {
            if (ModalKey != null)
            {
                ModalHelper.Close((int)ModalKey);
            }

            if (ClosedEvent != null)
            {
                ClosedEvent.Invoke();
            }
            //Return();
        }
Example #15
0
        public virtual void OnDisable()
        {
            //不能直接执行HideList,因为父节点已经是非激活状态
            if (ModalKey != null)
            {
                ModalHelper.Close((int)ModalKey);
                ModalKey = null;
            }

            if (listView != null)
            {
                listView.gameObject.SetActive(false);
            }
        }
Example #16
0
        /// <summary>
        /// Close.
        /// </summary>
        public void Close()
        {
            if (DrivesModalKey != null)
            {
                ModalHelper.Close((int)DrivesModalKey);
                DrivesModalKey = null;
            }

            if (DrivesParent != null)
            {
                transform.SetParent(DrivesParent);
            }
            gameObject.SetActive(false);
        }
Example #17
0
        /// <summary>
        /// Show popup.
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</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 virtual void Show(string title     = null,
                                 string message   = null,
                                 Vector3?position = null,
                                 Sprite icon      = null,

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

                                 Canvas canvas = null)
        {
            if (ClosedEvent == null)
            {
                ClosedEvent = new UnityEvent();
            }


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

            SetInfo(title, message, icon);

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

            if (parent != null)
            {
                transform.SetParent(parent, false);
            }

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

            transform.SetAsLastSibling();

            //transform.localPosition = (Vector3)position;
            //gameObject.SetActive(true);
        }
Example #18
0
        /// <summary>
        /// Hides the list.
        /// </summary>
        public virtual void HideList()
        {
            if (ModalKey != null)
            {
                ModalHelper.Close((int)ModalKey);
                ModalKey = null;
            }

            if (listView == null)
            {
                return;
            }
            if (ListCanvas != null)
            {
                listView.transform.SetParent(ListViewParent);
            }
            listView.gameObject.SetActive(false);
        }
Example #19
0
        /// <summary>
        /// Open DrivesListView.
        /// </summary>
        public void Open()
        {
            if (!DrivesLoaded)
            {
                Load();
            }

            DrivesModalKey = ModalHelper.Open(this, null, new Color(0, 0, 0, 0f), Close);
            DrivesParent   = transform.parent;

            var canvas = Utilites.FindTopmostCanvas(transform);

            transform.SetParent(canvas);

            SelectedIndices.ForEach(Deselect);

            gameObject.SetActive(true);
        }
Example #20
0
        /// <summary>
        /// Show popup.
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</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 virtual void Show(string title     = null,
                                 string message   = null,
                                 Vector3?position = null,
                                 Sprite icon      = null,

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

                                 Canvas canvas = null)
        {
            if (IsTemplate)
            {
                Debug.LogWarning("Use the template clone, not the template itself: PopupTemplate.Clone().Show(...), not PopupTemplate.Show(...)");
            }

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

            SetInfo(title, message, icon);

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

            if (parent != null)
            {
                transform.SetParent(parent, false);
            }

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

            transform.SetAsLastSibling();

            transform.localPosition = (Vector3)position;
            gameObject.SetActive(true);
        }
Example #21
0
        /// <summary>
        /// Close dialog.
        /// </summary>
        public virtual void Hide()
        {
            if (ModalKey != null)
            {
                ModalHelper.Close((int)ModalKey);
                if (m_actionModalClick != null)
                {
                    m_actionModalClick.Invoke();
                    m_actionModalClick = null;
                }
            }

            if (onDialogHideEvent != null)
            {
                onDialogHideEvent(this);
            }

            Return();
        }
Example #22
0
        /// <summary>
        /// Show picker.
        /// </summary>
        /// <param name="defaultValue">Default value.</param>
        /// <param name="onSelect">Callback with selected value.</param>
        /// <param name="onCancel">Callback when picker closed without any value selected.</param>
        /// <param name="modalSprite">Modal sprite.</param>
        /// <param name="modalColor">Modal color.</param>
        /// <param name="canvas">Canvas.</param>
        public virtual void Show(
            TValue defaultValue,
            Action <TValue> onSelect,
            Action onCancel    = null,
            Sprite modalSprite = null,
            Color?modalColor   = null,

            Canvas canvas = null)
        {
            if (IsTemplate)
            {
                Debug.LogWarning("Use the template clone, not the template itself: PickerTemplate.Clone().Show(...), not PickerTemplate.Show(...)");
            }

            OnSelect = onSelect;
            OnCancel = onCancel;

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

            if (parent != null)
            {
                transform.SetParent(parent, false);
            }

            if (modalColor == null)
            {
                modalColor = new Color(0, 0, 0, 0.8f);
            }

            ModalKey = ModalHelper.Open(this, modalSprite, modalColor, Close);

            transform.SetAsLastSibling();

            gameObject.SetActive(true);

            BeforeOpen(defaultValue);
        }
Example #23
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 virtual void Show(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,

                                 Transform canvas = null,

                                 UnityAction closeBtnAction   = null,
                                 UnityAction modalclickAction = null)
        {
            if (position == null)
            {
                position = new Vector3(0, 0, 0);
            }

            SetInfo(title, message, icon);

            ParentTrans = canvas;

            var topCanvas = Utilites.FindTopmostCanvas(ParentTrans);

            if (topCanvas != null)
            {
                transform.SetParent(topCanvas, false);
            }

            if (modal)
            {
                if (hideByModalClick)
                {
                    ModalKey = ModalHelper.Open(this, modalSprite, modalColor, Hide, transform as RectTransform);
                }
                else
                {
                    ModalKey = ModalHelper.Open(this, modalSprite, modalColor, null, transform as RectTransform);
                }
                m_actionModalClick = modalclickAction;
            }
            else
            {
                ModalKey = null;
            }

            transform.SetAsLastSibling();

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

            CreateButtons(buttons, focusButton);

            if (CloseButton != null)
            {
                CloseButton.onClick.AddListener(Hide);
                if (closeBtnAction != null)
                {
                    CloseButton.onClick.AddListener(closeBtnAction);
                }
            }
        }