Example #1
0
 // Token: 0x06004694 RID: 18068 RVA: 0x0017F464 File Offset: 0x0017D864
 public virtual void Start()
 {
     if (this.isStartedComboboxCustom)
     {
         return;
     }
     this.isStartedComboboxCustom = true;
     this.onSelectCallback        = delegate(int index)
     {
         this.OnSelect.Invoke(index, this.listView.Items[index]);
     };
     this.ToggleButton = this.toggleButton;
     this.ListView     = this.listView;
     if (this.listView != null)
     {
         this.listView.OnSelectObject.RemoveListener(new UnityAction <int>(this.SetCurrent));
         this.listCanvas = Utilites.FindCanvas(this.listParent);
         this.listView.gameObject.SetActive(true);
         this.listView.Start();
         if (this.listView.SelectedIndex == -1 && this.listView.Items.Count > 0)
         {
             this.listView.SelectedIndex = 0;
         }
         if (this.listView.SelectedIndex != -1)
         {
             this.UpdateCurrent();
         }
         this.listView.gameObject.SetActive(false);
         this.listView.OnSelectObject.AddListener(new UnityAction <int>(this.SetCurrent));
     }
 }
Example #2
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public virtual void Start()
        {
            if (isStartedComboboxCustom)
            {
                return;
            }
            isStartedComboboxCustom = true;

            onSelectCallback = (index) => OnSelect.Invoke(index, listView.Items[index]);

            ToggleButton = toggleButton;

            ListView = listView;

            if (listView != null)
            {
                listView.OnSelectObject.RemoveListener(SetCurrent);

                listCanvas = Utilites.FindCanvas(listParent);

                listView.gameObject.SetActive(true);
                listView.Start();
                if ((listView.SelectedIndex == -1) && (listView.Items.Count > 0))
                {
                    listView.SelectedIndex = 0;
                }
                if (listView.SelectedIndex != -1)
                {
                    UpdateCurrent();
                }
                listView.gameObject.SetActive(false);

                listView.OnSelectObject.AddListener(SetCurrent);
            }
        }
Example #3
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 #4
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 #5
0
 // Token: 0x0600493C RID: 18748 RVA: 0x00187517 File Offset: 0x00185917
 private void Start()
 {
     this.TooltipObject = this.tooltipObject;
     if (this.TooltipObject != null)
     {
         this.canvasTransform = Utilites.FindCanvas(this.tooltipObjectParent);
     }
     this.Hide();
 }
Example #6
0
        void Start()
        {
            TooltipObject = tooltipObject;

            if (TooltipObject != null)
            {
                canvasTransform = Utilites.FindCanvas(tooltipObjectParent);
            }
            Hide();
        }
Example #7
0
        void Start()
        {
            TooltipObject = tooltipObject;

            if (TooltipObject != null)
            {
                canvasTransform = Utilites.FindCanvas(tooltipObjectParent);
                TooltipObject.SetActive(false);
            }
        }
Example #8
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 #9
0
        /// <summary>
        /// Init this instance.
        /// </summary>
        public void Init()
        {
            canvasRect = Utilites.FindCanvas(transform) as RectTransform;
            canvas     = canvasRect.GetComponent <Canvas>();

            children.Clear();
            childrenLayouts.Clear();
            foreach (Transform child in transform)
            {
                var element = child.GetComponent <LayoutElement>() ?? child.gameObject.AddComponent <LayoutElement>();
                children.Add(child as RectTransform);
                childrenLayouts.Add(element);
            }

            //CalculateWidths();
            //ResetChildren();
            //Resize();
        }
Example #10
0
        /// <summary>
        /// Create modal helper with the specified parent, sprite and color.
        /// </summary>
        /// <param name="parent">Parent.</param>
        /// <param name="sprite">Sprite.</param>
        /// <param name="color">Color.</param>
        /// <param name="onClick">onClick callback</param>
        /// <returns>Modal helper index</returns>
        public static int Open(MonoBehaviour parent, Sprite sprite = null, Color?color = null, UnityAction onClick = null)
        {
            //check if in cache
            if (!Templates.Exists(key))
            {
                Templates.FindTemplates();
                CreateTemplate();
            }

            var modal = Templates.Instance(key);

            modal.transform.SetParent(Utilites.FindCanvas(parent.transform), false);
            modal.gameObject.SetActive(true);
            modal.transform.SetAsLastSibling();

            var rect = modal.transform as RectTransform;

            rect.sizeDelta        = new Vector2(0, 0);
            rect.anchorMin        = new Vector2(0, 0);
            rect.anchorMax        = new Vector2(1, 1);
            rect.anchoredPosition = new Vector2(0, 0);

            var img = modal.GetComponent <Image>();

            if (sprite != null)
            {
                img.sprite = sprite;
            }
            if (color != null)
            {
                img.color = (Color)color;
            }

            modal.OnClick.RemoveAllListeners();
            if (onClick != null)
            {
                modal.OnClick.AddListener(onClick);
            }

            used.Add(modal.GetInstanceID(), modal);
            return(modal.GetInstanceID());
        }
Example #11
0
        /// <summary>
        /// Update.
        /// </summary>
        protected virtual void Update()
        {
            var rt     = transform as RectTransform;
            var canvas = Utilites.FindCanvas(rt).GetComponent <Canvas>();

            Vector2 point;
            float   distance = 0f;

            var camera = canvas.renderMode == RenderMode.ScreenSpaceCamera ? canvas.worldCamera : null;

            RectTransformUtility.ScreenPointToLocalPointInRectangle(rt, Input.mousePosition, camera, out point);

            var old_size  = rt.rect.size;
            var half_size = old_size / 2f;
            var delta_x   = point.x - Mathf.Max(Mathf.Min(point.x, half_size.x), -half_size.x);
            var delta_y   = point.y - Mathf.Max(Mathf.Min(point.y, half_size.y), -half_size.y);

            distance = Mathf.Sqrt(Mathf.Pow(delta_x, 2) + Mathf.Pow(delta_y, 2));
            distance = Mathf.Clamp(distance, 0f, Distance);

            var new_size = Vector2.Lerp(MaxSize, MinSize, distance / Distance);

            new_size.x = Mathf.Round(new_size.x);
            new_size.y = Mathf.Round(new_size.y);

            if ((old_size.x != new_size.x) || (old_size.y != new_size.y))
            {
                rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Round(new_size.x));
                rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.Round(new_size.y));
            }

            if (ScrollCompensation != null)
            {
                var compensation = new_size - MinSize;
                compensation.x *= Mathf.Clamp(point.x / half_size.x, -1f, 1f);
                compensation.y *= Mathf.Clamp(point.y / half_size.y, -1f, 1f);

                ScrollCompensation.Add(compensation);
            }
        }
Example #12
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public virtual void Start()
        {
            if (isStartedComboboxCustom)
            {
                return;
            }
            isStartedComboboxCustom = true;

            onSelectCallback = index => OnSelect.Invoke(index, listView.DataSource[index]);

            SetToggleButton(toggleButton);

            SetListView(listView);

            if (listView != null)
            {
                current.gameObject.SetActive(false);

                listView.OnSelectObject.RemoveListener(UpdateView);
                listView.OnDeselectObject.RemoveListener(UpdateView);

                listCanvas = Utilites.FindCanvas(listParent);

                listView.gameObject.SetActive(true);
                listView.Start();
                if ((listView.SelectedIndex == -1) && (listView.DataSource.Count > 0) && (!listView.Multiple))
                {
                    listView.SelectedIndex = 0;
                }
                if (listView.SelectedIndex != -1)
                {
                    UpdateView();
                }
                listView.gameObject.SetActive(false);

                listView.OnSelectObject.AddListener(UpdateView);
                listView.OnDeselectObject.AddListener(UpdateView);
            }
        }
Example #13
0
        /// <summary>
        /// Init this instance.
        /// </summary>
        public void Init()
        {
            canvasRect = Utilites.FindCanvas(transform) as RectTransform;
            canvas     = canvasRect.GetComponent <Canvas>();

            children.Clear();
            childrenLayouts.Clear();
            int i = 0;

            foreach (Transform child in transform)
            {
                var element = child.GetComponent <LayoutElement>() ?? child.gameObject.AddComponent <LayoutElement>();
                children.Add(child as RectTransform);
                childrenLayouts.Add(element);

                var cell = child.gameObject.AddComponent <ResizableHeaderDragCell>();
                cell.Position                = i;
                cell.ResizableHeader         = this;
                cell.AllowDropCursor         = AllowDropCursor;
                cell.AllowDropCursorHotSpot  = AllowDropCursorHotSpot;
                cell.DeniedDropCursor        = DeniedDropCursor;
                cell.DeniedDropCursorHotSpot = DeniedDropCursorHotSpot;

                var events = child.gameObject.AddComponent <ResizableHeaderCell>();
                events.OnInitializePotentialDragEvent.AddListener(OnInitializePotentialDrag);
                events.OnBeginDragEvent.AddListener(OnBeginDrag);
                events.OnDragEvent.AddListener(OnDrag);
                events.OnEndDragEvent.AddListener(OnEndDrag);

                i++;
            }
            positions = Enumerable.Range(0, i).ToList();

            CalculateWidths();
            //ResetChildren();
            //Resize();
        }
Example #14
0
 /// <summary>
 /// Raises the initialize potential drag event.
 /// </summary>
 /// <param name="eventData">Event data.</param>
 public virtual void OnInitializePotentialDrag(PointerEventData eventData)
 {
     canvasRect = Utilites.FindCanvas(transform) as RectTransform;
     canvas     = canvasRect.GetComponent <Canvas>();
 }
Example #15
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 public void Init()
 {
     canvas = Utilites.FindCanvas(transform).GetComponent <Canvas>();
 }
Example #16
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 public void Init()
 {
     canvasRect = Utilites.FindCanvas(transform) as RectTransform;
     canvas     = canvasRect.GetComponent <Canvas>();
 }
Example #17
0
 // Token: 0x060046DE RID: 18142 RVA: 0x00180391 File Offset: 0x0017E791
 public void OnInitializePotentialDrag(PointerEventData eventData)
 {
     this.canvasRect = (Utilites.FindCanvas(base.transform) as RectTransform);
     this.canvas     = this.canvasRect.GetComponent <Canvas>();
 }