Example #1
0
        private void DeleteAttachedLWF(Movie parent, LWFContainer lwfContainer,
                                       bool destroy = true, bool deleteFromDetachedLWFs = true)
        {
            string attachName  = lwfContainer.child.attachName;
            int    attachDepth = lwfContainer.child.depth;

            parent.m_attachedLWFs.Remove(attachName);
            parent.m_attachedLWFList.Remove(attachDepth);
            parent.m_attachedLWFDescendingList.Remove(attachDepth);
            if (deleteFromDetachedLWFs)
            {
                parent.m_detachedLWFs.Remove(attachName);
            }
            if (destroy)
            {
                if (lwfContainer.child.detachHandler != null)
                {
                    lwfContainer.child.detachHandler(lwfContainer.child);
                    lwfContainer.child.parent        = null;
                    lwfContainer.child.detachHandler = null;
                    lwfContainer.child.attachName    = null;
                    lwfContainer.child.depth         = -1;
                }
                else
                {
                    lwfContainer.child.Destroy();
                }
                lwfContainer.Destroy();
            }
        }
Example #2
0
        public void SwapAttachedLWFDepth(int depth0, int depth1)
        {
            if (m_attachedLWFs == null)
            {
                return;
            }

            int d = depth0;

            if (depth1 > d)
            {
                d = depth1;
            }
            for (int i = m_attachedLWFList.Count; i <= d; ++i)
            {
                m_attachedLWFList.Add(null);
            }

            LWFContainer attachedLWF0 = m_attachedLWFList[depth0];
            LWFContainer attachedLWF1 = m_attachedLWFList[depth1];

            if (attachedLWF0 != null)
            {
                attachedLWF0.child.depth = depth1;
            }
            if (attachedLWF1 != null)
            {
                attachedLWF1.child.depth = depth0;
            }
            m_attachedLWFList[depth0] = attachedLWF1;
            m_attachedLWFList[depth1] = attachedLWF0;
        }
Example #3
0
        public void AttachLWF(LWF attachLWF, string attachName,
                              int attachDepth             = -1, bool reorder = false,
                              DetachHandler detachHandler = null)
        {
            if (m_attachedLWFs == null)
            {
                m_attachedLWFs              = new AttachedLWFs();
                m_detachedLWFs              = new DetachDict();
                m_attachedLWFList           = new AttachedLWFList();
                m_attachedLWFDescendingList =
                    new AttachedLWFDescendingList(new DescendingComparer <int>());
            }

            LWFContainer lwfContainer;

            if (attachLWF.parent != null)
            {
                attachLWF.parent.m_attachedLWFs.TryGetValue(
                    attachLWF.attachName, out lwfContainer);
                DeleteAttachedLWF(attachLWF.parent, lwfContainer, false);
            }
            else
            {
                if (m_attachedLWFs.TryGetValue(attachName, out lwfContainer))
                {
                    DeleteAttachedLWF(this, lwfContainer);
                }
            }

            if (!reorder && attachDepth >= 0)
            {
                if (m_attachedLWFList.TryGetValue(attachDepth, out lwfContainer))
                {
                    DeleteAttachedLWF(this, lwfContainer);
                }
            }

            lwfContainer = new LWFContainer(this, attachLWF);

            if (attachLWF.interactive == true)
            {
                m_lwf.interactive = true;
            }
            attachLWF.parent        = this;
            attachLWF.detachHandler = detachHandler;
            attachLWF.attachName    = attachName;
            attachLWF.depth         = attachDepth >= 0 ? attachDepth :
                                      m_attachedLWFDescendingList.Keys.GetEnumerator().Current + 1;
            m_attachedLWFs[attachName] = lwfContainer;
            ReorderAttachedLWFList(reorder, attachLWF.depth, lwfContainer);

            m_lwf.isLWFAttached = true;
        }
Example #4
0
        public void AttachLWF(LWF attachLWF, string attachName,
                              int attachDepth             = -1, bool reorder = false,
                              DetachHandler detachHandler = null)
        {
            if (m_attachedLWFs == null)
            {
                m_attachedLWFs    = new AttachedLWFs();
                m_detachedLWFs    = new DetachDict();
                m_attachedLWFList = new AttachedLWFList();
            }

            LWFContainer lwfContainer;

            if (attachLWF.parent != null)
            {
                attachLWF.parent.m_attachedLWFs.TryGetValue(
                    attachLWF.attachName, out lwfContainer);
                DeleteAttachedLWF(attachLWF.parent, lwfContainer, false);
            }
            else
            {
                if (m_attachedLWFs.TryGetValue(attachName, out lwfContainer))
                {
                    DeleteAttachedLWF(this, lwfContainer);
                }
            }

            if (!reorder && attachDepth >= 0 &&
                attachDepth <= m_attachedLWFList.Count - 1)
            {
                lwfContainer = m_attachedLWFList[attachDepth];
                if (lwfContainer != null)
                {
                    DeleteAttachedLWF(this, lwfContainer);
                }
            }

            lwfContainer = new LWFContainer(this, attachLWF);

            if (attachLWF.interactive == true)
            {
                m_lwf.interactive = true;
            }
            attachLWF.parent        = this;
            attachLWF.detachHandler = detachHandler;
            attachLWF.attachName    = attachName;
            attachLWF.depth         = attachDepth >= 0 ?
                                      attachDepth : m_attachedLWFList.Count;
            m_attachedLWFs[attachName] = lwfContainer;
            ReorderAttachedLWFList(reorder, attachLWF.depth, lwfContainer);

            m_lwf.isLWFAttached = true;
        }
Example #5
0
 public LWF GetAttachedLWF(int attachDepth)
 {
     if (m_attachedLWFs != null)
     {
         if (attachDepth < 0 || attachDepth >= m_attachedLWFList.Count)
         {
             return(null);
         }
         LWFContainer lwfContainer = m_attachedLWFList[attachDepth];
         return(lwfContainer == null ? null : lwfContainer.child);
     }
     return(null);
 }
Example #6
0
 private void ReorderAttachedLWFList(
     bool reorder, int index, LWFContainer lwfContainer)
 {
     m_attachedLWFList[index] = lwfContainer;
     if (reorder)
     {
         AttachedLWFList list = m_attachedLWFList;
         m_attachedLWFList           = new AttachedLWFList();
         m_attachedLWFDescendingList =
             new AttachedLWFDescendingList(new DescendingComparer <int>());
         int i = 0;
         foreach (LWFContainer l in list.Values)
         {
             l.child.depth                  = i;
             m_attachedLWFList[i]           = l;
             m_attachedLWFDescendingList[i] = i;
             ++i;
         }
     }
 }
Example #7
0
        public void AttachLWF(LWF attachLWF, string attachName,
		int attachDepth = -1, bool reorder = false,
		DetachHandler detachHandler = null)
        {
            if (m_attachedLWFs == null) {
            m_attachedLWFs = new AttachedLWFs();
            m_detachedLWFs = new DetachDict();
            m_attachedLWFList = new AttachedLWFList();
            }

            LWFContainer lwfContainer;
            if (attachLWF.parent != null) {
            attachLWF.parent.m_attachedLWFs.TryGetValue(
                attachLWF.attachName, out lwfContainer);
            DeleteAttachedLWF(attachLWF.parent, lwfContainer, false);
            } else {
            if (m_attachedLWFs.TryGetValue(attachName, out lwfContainer))
                DeleteAttachedLWF(this, lwfContainer);
            }

            if (!reorder && attachDepth >= 0 &&
                attachDepth <= m_attachedLWFList.Count - 1) {
            lwfContainer = m_attachedLWFList[attachDepth];
            if (lwfContainer != null)
                DeleteAttachedLWF(this, lwfContainer);
            }

            lwfContainer = new LWFContainer(this, attachLWF);

            if (attachLWF.interactive == true)
            m_lwf.interactive = true;
            attachLWF.parent = this;
            attachLWF.detachHandler = detachHandler;
            attachLWF.attachName = attachName;
            attachLWF.depth = attachDepth >= 0 ?
            attachDepth : m_attachedLWFList.Count;
            m_attachedLWFs[attachName] = lwfContainer;
            ReorderAttachedLWFList(reorder, attachLWF.depth, lwfContainer);

            m_lwf.isLWFAttached = true;
        }
Example #8
0
        private void DeleteAttachedLWF(Movie parent, LWFContainer lwfContainer,
                                       bool destroy = true, bool deleteFromDetachedLWFs = true)
        {
            string attachName  = lwfContainer.child.attachName;
            int    attachDepth = lwfContainer.child.depth;

            parent.m_attachedLWFs.Remove(attachName);
            parent.m_attachedLWFList[attachDepth] = null;
            if (deleteFromDetachedLWFs)
            {
                parent.m_detachedLWFs.Remove(attachName);
            }
            parent.ShrinkAttachedLWFList();
            if (destroy && lwfContainer.child.detachHandler != null)
            {
                lwfContainer.child.detachHandler(lwfContainer.child);
                lwfContainer.child.parent        = null;
                lwfContainer.child.detachHandler = null;
                lwfContainer.child.attachName    = null;
                lwfContainer.child.depth         = -1;
            }
        }
Example #9
0
 private void ReorderAttachedLWFList(
     bool reorder, int index, LWFContainer lwfContainer)
 {
     if (!reorder || index >= m_attachedLWFList.Count)
     {
         for (int i = m_attachedLWFList.Count; i < index; ++i)
         {
             m_attachedLWFList.Add(null);
         }
         m_attachedLWFList.Add(lwfContainer);
     }
     else
     {
         m_attachedLWFList.Insert(index, lwfContainer);
         if (reorder)
         {
             m_attachedLWFList.Remove(null);
             for (int i = 0; i < m_attachedLWFList.Count; ++i)
             {
                 m_attachedLWFList[i].child.depth = i;
             }
         }
     }
 }
Example #10
0
        private void ReorderAttachedLWFList(
		bool reorder, int index, LWFContainer lwfContainer)
        {
            if (!reorder || index >= m_attachedLWFList.Count) {
            for (int i = m_attachedLWFList.Count; i < index; ++i)
                m_attachedLWFList.Add(null);
            m_attachedLWFList.Add(lwfContainer);
            } else {
            m_attachedLWFList.Insert(index, lwfContainer);
            if (reorder) {
                m_attachedLWFList.Remove(null);
                for (int i = 0; i < m_attachedLWFList.Count; ++i)
                    m_attachedLWFList[i].child.depth = i;
            }
            }
        }
Example #11
0
        private void DeleteAttachedLWF(Movie parent, LWFContainer lwfContainer,
		bool destroy = true, bool deleteFromDetachedLWFs = true)
        {
            string attachName = lwfContainer.child.attachName;
            int attachDepth = lwfContainer.child.depth;
            parent.m_attachedLWFs.Remove(attachName);
            parent.m_attachedLWFList[attachDepth] = null;
            if (deleteFromDetachedLWFs)
            parent.m_detachedLWFs.Remove(attachName);
            parent.ShrinkAttachedLWFList();
            if (destroy && lwfContainer.child.detachHandler != null) {
            lwfContainer.child.detachHandler(lwfContainer.child);
            lwfContainer.child.parent = null;
            lwfContainer.child.detachHandler = null;
            lwfContainer.child.attachName = null;
            lwfContainer.child.depth = -1;
            }
        }
Example #12
0
        public void AttachLWF(LWF child, string attachName, int attachDepth = -1,
                              bool reorder = false, DetachHandler detachHandler = null)
        {
            if (m_attachedLWFs == null)
            {
                m_attachedLWFs              = new AttachedLWFs();
                m_detachedLWFs              = new DetachDict();
                m_attachedLWFList           = new AttachedLWFList();
                m_attachedLWFDescendingList =
                    new AttachedLWFDescendingList(new DescendingComparer <int>());
            }

            LWFContainer lwfContainer;

            if (child.parent != null)
            {
                child.parent.m_attachedLWFs.TryGetValue(
                    child.attachName, out lwfContainer);
                DeleteAttachedLWF(child.parent, lwfContainer, false);
            }
            if (m_attachedLWFs.TryGetValue(attachName, out lwfContainer))
            {
                DeleteAttachedLWF(this, lwfContainer);
            }

            if (!reorder && attachDepth >= 0)
            {
                if (m_attachedLWFList.TryGetValue(attachDepth, out lwfContainer))
                {
                    DeleteAttachedLWF(this, lwfContainer);
                }
            }

            lwfContainer = new LWFContainer(this, child);

            if (child.interactive == true)
            {
                m_lwf.SetInteractive();
            }
            child.parent        = this;
            child.detachHandler = detachHandler;
            child.attachName    = attachName;
            if (attachDepth >= 0)
            {
                child.depth = attachDepth;
            }
            else
            {
                AttachedLWFDescendingList.KeyCollection.Enumerator e =
                    m_attachedLWFDescendingList.Keys.GetEnumerator();
                if (e.MoveNext())
                {
                    child.depth = e.Current + 1;
                }
                else
                {
                    child.depth = 0;
                }
            }
            m_attachedLWFs[attachName] = lwfContainer;
            ReorderAttachedLWFList(reorder, child.depth, lwfContainer);

            m_lwf.SetLWFAttached();

            return;
        }