Пример #1
0
 public override void ApplyUndo()
 {
     if (m_fAdd)
     {
         m_ss.RemoveSprite(m_sprite, null);
         m_ss.CurrentSprite = m_mgr.FindMostRecentSprite();
         if (m_ss.CurrentSprite == null)
         {
             m_ss.SelectFirstSprite();
         }
     }
     else
     {
         m_ss.AddSprite(m_sprite, null);
         m_ss.CurrentSprite = m_sprite;
     }
 }
Пример #2
0
        public void RemoveSprite(Sprite sToRemove, UndoMgr undo)
        {
            SpriteType stToRemove = null;
            Sprite     sPrev = null, sCurr = null, sNext = null;
            Sprite     sNewSelection = null;

            if (sToRemove == null)
            {
                return;
            }

            // Determine which sprite should be selected when this one is removed.
            foreach (SpriteType st in SpriteTypes)
            {
                if (sNewSelection != null)
                {
                    break;
                }

                foreach (Sprite s in st.Sprites)
                {
                    sPrev = sCurr;
                    sCurr = sNext;
                    sNext = s;
                    if (s == sToRemove)
                    {
                        stToRemove = st;
                    }
                    if (sCurr == sToRemove)
                    {
                        sNewSelection = sNext;
                        break;
                    }
                }
            }
            // If the last sprite is deleted, select the one before it.
            if (sNext == sToRemove)
            {
                sNewSelection = sCurr;
            }

            int nTiles = sToRemove.NumTiles;

            if (stToRemove == null)
            {
                return;
            }

            if (stToRemove.Sprites.Remove(sToRemove))
            {
                CurrentSprite = null;
                if (undo != null)
                {
                    CurrentSprite = undo.FindMostRecentSprite();
                }
                if (CurrentSprite == null)
                {
                    CurrentSprite = sNewSelection;
                }

                m_nSprites--;
                m_nTiles -= nTiles;

                if (undo != null)
                {
                    undo.Push(new UndoAction_AddSprite(undo, this, sToRemove, false));
                }

                if (m_doc.Owner != null)
                {
                    m_doc.Owner.HandleSpriteTypeChanged(this);
                }
            }

            foreach (Map m in m_Maps)
            {
                m.RemoveSpriteTilesFromMap(sToRemove);
            }
        }
Пример #3
0
        public void RemoveSprite(Sprite sToRemove, UndoMgr undo)
        {
            SpriteType stToRemove = null;
            Sprite sPrev = null, sCurr = null, sNext = null;
            Sprite sNewSelection = null;

            if (sToRemove == null)
                return;

            // Determine which sprite should be selected when this one is removed.
            foreach (SpriteType st in SpriteTypes)
            {
                if (sNewSelection != null)
                    break;

                foreach (Sprite s in st.Sprites)
                {
                    sPrev = sCurr;
                    sCurr = sNext;
                    sNext = s;
                    if (s == sToRemove)
                        stToRemove = st;
                    if (sCurr == sToRemove)
                    {
                        sNewSelection = sNext;
                        break;
                    }
                }
            }
            // If the last sprite is deleted, select the one before it.
            if (sNext == sToRemove)
                sNewSelection = sCurr;

            int nTiles = sToRemove.NumTiles;
            if (stToRemove == null)
                return;

            if (stToRemove.Sprites.Remove(sToRemove))
            {
                CurrentSprite = null;
                if (undo != null)
                    CurrentSprite = undo.FindMostRecentSprite();
                if (CurrentSprite == null)
                    CurrentSprite = sNewSelection;

                m_nSprites--;
                m_nTiles -= nTiles;

                if (undo != null)
                    undo.Push(new UndoAction_AddSprite(undo, this, sToRemove, false));

                if (m_doc.Owner != null)
                    m_doc.Owner.HandleSpriteTypeChanged(this);
            }

            foreach (Map m in m_Maps)
            {
                m.RemoveSpriteTilesFromMap(sToRemove);
            }
        }