Esempio n. 1
0
        public void Initialize(IHeaderItem header, VesselGroup group, bool startOn)
        {
            if (header == null || group == null)
            {
                return;
            }

            _parent = group;

            _headerInterface = header;

            if (m_NameText != null)
            {
                m_NameText.OnTextUpdate.Invoke(header.HeaderName);
            }

            if (m_InfoText != null)
            {
                m_InfoText.OnTextUpdate.Invoke(header.HeaderInfo);
            }

            AssignHeaderObject(header.HeaderImage);

            if (m_HeaderToggle != null)
            {
                m_HeaderToggle.isOn = startOn;
            }

            _loaded = true;
        }
        public void Init(ReorderableList reorderableList)
        {
            _reorderableList = reorderableList;

            VesselGroup group = GetComponentInParent <VesselGroup>();

            if (group == null)
            {
                return;
            }

            _scale        = group.Scale;
            _rect         = group.GetComponent <RectTransform>();
            _parentHeader = group.Header;
        }
Esempio n. 3
0
        public void Initialize(ISubHeaderItem header, VesselSubGroup group, VesselGroup grand, bool last, bool startOn)
        {
            if (header == null || group == null)
            {
                return;
            }

            _parent      = group;
            _grandParent = grand;

            _headerInterface = header;

            if (m_NameText != null)
            {
                m_NameText.OnTextUpdate.Invoke(header.HeaderName);
            }

            if (m_InfoText != null)
            {
                m_InfoText.OnTextUpdate.Invoke(header.HeaderInfo);
            }

            if (m_ConnectorIcon != null)
            {
                m_ConnectorIcon.sprite = last ? m_EndConnector : m_DoubleConnector;
            }

            AssignHeaderObject(header.HeaderImage);

            if (m_HeaderToggle != null)
            {
                m_HeaderToggle.isOn = startOn;
            }

            _loaded = true;
        }
Esempio n. 4
0
        public void Initialize(IVesselSubGroup group, VesselGroup parent, bool last)
        {
            if (group == null)
            {
                return;
            }

            _groupInterface = group;
            _parent         = parent;

            _final = last;

            ClearUI();

            AddHeader(group.SubHeader);

            AddVessels(group.Vessels);

            //Debug.Log("[BTK] Sub Group Initialize: " + group.StartOn);

            if (_anim != null)
            {
                _anim.SetBool("open", group.StartOn);
                _anim.SetBool("instant", group.Instant && group.StartOn);
            }

            if (_animRoutine != null)
            {
                StopCoroutine(_animRoutine);
                _animRoutine = null;
            }

            _animating = false;

            _animRoutine = StartCoroutine(WaitForExpand());
        }
Esempio n. 5
0
        private IEnumerator RefreshChildren()
        {
            yield return(new WaitForEndOfFrame());

            if (_rect.childCount > 0)
            {
                var first = _rect.GetChild(0);

                if (first != null && first.gameObject.name != "Fake")
                {
                    VesselGroup group = first.GetComponent <VesselGroup>();

                    int timer = 0;

                    while (group == null)
                    {
                        if (timer > 20)
                        {
                            yield break;
                        }

                        group = first.GetComponent <VesselGroup>();
                        timer++;

                        if (group == null)
                        {
                            yield return(null);
                        }
                    }

                    while (!group.Initialized || group.Header == null)
                    {
                        yield return(null);
                    }

                    //Handle new chilren
                    for (int i = 0; i < _rect.childCount; i++)
                    {
                        if (_rect.GetChild(i) == null)
                        {
                            continue;
                        }

                        if (_cachedChildren.Contains(_rect.GetChild(i)))
                        {
                            continue;
                        }

                        VesselGroup child = _rect.GetChild(i).GetComponent <VesselGroup>();

                        if (child != null)
                        {
                            _ele = child.Header.DragHandle.AddComponent <ReorderableListElement>();
                            _ele.Init(_extList);
                        }

                        _cachedChildren.Add(_rect.GetChild(i));
                        _cachedListElement.Add(_ele);
                    }
                }
            }

            ////HACK a little hack, if I don't wait one frame I don't have the right deleted children
            yield return(null);

            //Remove deleted child
            for (int i = _cachedChildren.Count - 1; i >= 0; i--)
            {
                if (_cachedChildren[i] == null)
                {
                    _cachedChildren.RemoveAt(i);
                    _cachedListElement.RemoveAt(i);
                }
            }
        }