コード例 #1
0
        public UndoAction_MapEdit(UndoMgr mgr, Map m, Map.UndoData before, Map.UndoData after, string strDesc)
        {
            m_mgr = mgr;
            m_map = m;
            m_before = new Map.UndoData(before);
            m_after = new Map.UndoData(after);

            Description = "MapEdit " + m.Name + " " + strDesc;
        }
コード例 #2
0
        public UndoAction_AddSprite(UndoMgr mgr, Spriteset ss, Sprite sprite, bool fAdd)
        {
            m_mgr    = mgr;
            m_ss     = ss;
            m_sprite = sprite;
            m_fAdd   = fAdd;

            Description = (fAdd ? "AddSprite " : "RemoveSprite ") + sprite.Name;
        }
コード例 #3
0
        public UndoAction_MapEdit(UndoMgr mgr, Map m, Map.UndoData before, Map.UndoData after, string strDesc)
        {
            m_mgr    = mgr;
            m_map    = m;
            m_before = new Map.UndoData(before);
            m_after  = new Map.UndoData(after);

            Description = "MapEdit " + m.Name + " " + strDesc;
        }
コード例 #4
0
        public UndoAction_AddSprite(UndoMgr mgr, Spriteset ss, Sprite sprite, bool fAdd)
        {
            m_mgr = mgr;
            m_ss = ss;
            m_sprite = sprite;
            m_fAdd = fAdd;

            Description = (fAdd ? "AddSprite " : "RemoveSprite ") + sprite.Name;
        }
コード例 #5
0
ファイル: Subpalette.cs プロジェクト: nnn1590/spritely
        public void RecordUndoAction(string strDesc, UndoMgr undo)
        {
            if (undo == null)
            {
                return;
            }

            PaletteColorData            data   = GetUndoData();
            UndoAction_Subpalette16Edit action = new UndoAction_Subpalette16Edit(undo, this, m_snapshot, data, strDesc);
            bool fHandled = false;

            if (action.IsSelectionChange())
            {
                // Ignore selection changes
                fHandled = true;
            }
            else
            {
                // If the last undo action is also a PaletteEdit, try to merge them together
                UndoAction_Subpalette16Edit last_action = undo.GetCurrent() as UndoAction_Subpalette16Edit;
                if (last_action != null)
                {
                    // Merge 2 color changes (as long as they edit the same color)
                    int last_color, last_color_val1, last_color_val2;
                    int this_color, this_color_val1, this_color_val2;
                    if (last_action.IsColorChange(out last_color, out last_color_val1, out last_color_val2) &&
                        action.IsColorChange(out this_color, out this_color_val1, out this_color_val2)
                        )
                    {
                        if (last_color == this_color)
                        {
                            // If this color change takes it back to the original value, then
                            // delete the UndoAction.
                            if (last_color_val1 == this_color_val2)
                            {
                                undo.DeleteCurrent();
                            }
                            else
                            {
                                last_action.UpdateRedoData(data);
                            }
                            fHandled = true;
                        }
                    }
                }
            }
            if (!fHandled)
            {
                undo.Push(action);
            }

            // Update the snapshot for the next UndoAction
            RecordSnapshot();
        }
コード例 #6
0
ファイル: TabMgr.cs プロジェクト: jduranmaster/spritely
        public TabMgr(ProjectMainForm owner, TabId id)
        {
            m_owner = owner;
            m_eId = id;

            m_undo = new UndoMgr(owner, id);

            m_winLists = new List<Form>[(int)FormListType.MAX];
            for (int i=0; i<(int)FormListType.MAX; i++)
                m_winLists[(int)i] = new List<Form>();
        }
コード例 #7
0
        public UndoAction_SpriteEdit(UndoMgr mgr, Spriteset ss, Sprite sprite, Sprite.UndoData before, Sprite.UndoData after, string strDesc)
        {
            m_mgr = mgr;
            m_ss = ss;
            m_sprite = sprite;
            m_before = new Sprite.UndoData(before);
            m_after = new Sprite.UndoData(after);

            Description = "SpriteEdit " + sprite.Name + " " + strDesc;
            if (IsPaletteChange())
                Description += " " + before.subpalette + " to " + after.subpalette;
        }
コード例 #8
0
        private void menuEdit_Redo_Click(object sender, EventArgs e)
        {
            UndoMgr undo = ActiveUndo();

            if (undo == null)
            {
                return;
            }
            undo.ApplyRedo();

            HandleEverythingChanged();
        }
コード例 #9
0
        public TabMgr(ProjectMainForm owner, TabId id)
        {
            m_owner = owner;
            m_eId   = id;

            m_undo = new UndoMgr(owner, id);

            m_winLists = new List <Form> [(int)FormListType.MAX];
            for (int i = 0; i < (int)FormListType.MAX; i++)
            {
                m_winLists[(int)i] = new List <Form>();
            }
        }
コード例 #10
0
ファイル: UndoMgr.cs プロジェクト: jduranmaster/spritely
        public void TestInit()
        {
            m_doc = new Document(null);
            Assert.IsNotNull(m_doc);

            m_palette = m_doc.Palettes.AddPalette16(Options.DefaultPaletteName, 0, "");
            Assert.IsNotNull(m_palette);

            m_ss = m_doc.Spritesets.AddSpriteset(Options.DefaultSpritesetName, 0, "", m_palette);
            Assert.IsNotNull(m_ss);

            m_mgr = new UndoMgr(null, TabMgr.TabId.Sprites);
            Assert.IsNotNull(m_mgr);
        }
コード例 #11
0
ファイル: UndoMgr.cs プロジェクト: nnn1590/spritely
        public void TestInit()
        {
            m_doc = new Document(null);
            Assert.IsNotNull(m_doc);

            m_palette = m_doc.Palettes.AddPalette16(Options.DefaultPaletteName, 0, "");
            Assert.IsNotNull(m_palette);

            m_ss = m_doc.Spritesets.AddSpriteset(Options.DefaultSpritesetName, 0, "", m_palette);
            Assert.IsNotNull(m_ss);

            m_mgr = new UndoMgr(null, TabMgr.TabId.Sprites);
            Assert.IsNotNull(m_mgr);
        }
コード例 #12
0
        public UndoAction_SpriteEdit(UndoMgr mgr, Spriteset ss, Sprite sprite, Sprite.UndoData before, Sprite.UndoData after, string strDesc)
        {
            m_mgr    = mgr;
            m_ss     = ss;
            m_sprite = sprite;
            m_before = new Sprite.UndoData(before);
            m_after  = new Sprite.UndoData(after);

            Description = "SpriteEdit " + sprite.Name + " " + strDesc;
            if (IsPaletteChange())
            {
                Description += " " + before.subpalette + " to " + after.subpalette;
            }
        }
コード例 #13
0
        public UndoAction_Subpalette16Edit(UndoMgr mgr, Subpalette subpalette, PaletteColorData before, PaletteColorData after, string strDesc)
        {
            m_mgr = mgr;
            m_subpalette = subpalette;
            m_before = new PaletteColorData(before);
            m_after = new PaletteColorData(after);

            int b = before.currentColor;
            int a = after.currentColor;
            Description = "Subpalette16Edit " + subpalette.SubpaletteID + "," + before.currentColor + " ("
                + before.cRed[b] + "," + before.cGreen[b] + "," + before.cBlue[b]
                + ") -> ("
                + after.cRed[a] + "," + after.cGreen[a] + "," + after.cBlue[a]
                + ")";
        }
コード例 #14
0
        PaletteColorData m_after;               // Redo

        public UndoAction_Subpalette16Edit(UndoMgr mgr, Subpalette subpalette, PaletteColorData before, PaletteColorData after, string strDesc)
        {
            m_mgr        = mgr;
            m_subpalette = subpalette;
            m_before     = new PaletteColorData(before);
            m_after      = new PaletteColorData(after);

            int b = before.currentColor;
            int a = after.currentColor;

            Description = "Subpalette16Edit " + subpalette.SubpaletteID + "," + before.currentColor + " ("
                          + before.cRed[b] + "," + before.cGreen[b] + "," + before.cBlue[b]
                          + ") -> ("
                          + after.cRed[a] + "," + after.cGreen[a] + "," + after.cBlue[a]
                          + ")";
        }
コード例 #15
0
        private Sprite AddSprite_2(Sprite s, List <Sprite> slist, UndoMgr undo)
        {
            slist.Add(s);

            m_nSprites++;
            m_nTiles += (s.TileWidth * s.TileHeight);

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

            if (m_doc.Owner != null)
            {
                m_doc.Owner.HandleSpriteTypeChanged(this);
            }
            return(s);
        }
コード例 #16
0
ファイル: Map.cs プロジェクト: nnn1590/spritely
        public void RecordUndoAction(string strDesc, UndoMgr undo)
        {
            if (undo == null)
            {
                return;
            }

            UndoData data = GetUndoData();

            // Don't record anything if there aren't any changes
            if (!data.Equals(m_snapshot))
            {
                UndoAction_MapEdit action = new UndoAction_MapEdit(undo, this, m_snapshot, data, strDesc);
                undo.Push(action);

                // Update the snapshot for the next UndoAction
                RecordSnapshot();
            }
        }
コード例 #17
0
        public Sprite AddSprite(Sprite s, UndoMgr undo)
        {
            List <Sprite> slist = null;

            foreach (SpriteType st in SpriteTypes)
            {
                if (st.Width == s.TileWidth && st.Height == s.TileHeight)
                {
                    slist = st.Sprites;
                    break;
                }
            }

            if (slist == null)
            {
                return(null);
            }

            return(AddSprite_2(s, slist, undo));
        }
コード例 #18
0
        public Sprite DuplicateSprite(Sprite sToCopy, UndoMgr undo)
        {
            if (sToCopy == null)
            {
                return(null);
            }

            // Calulate an appropriate name for the copy
            string strNewBaseName;
            int    nCopy = 1;
            string strNewName;
            string strCopySuffix = ResourceMgr.GetString("CopySuffix");
            Match  m             = Regex.Match(sToCopy.Name, String.Format("^(.*){0}([0-9]*)$", strCopySuffix));

            if (m.Success)
            {
                strNewBaseName = String.Format("{0}{1}", m.Groups[1].Value, strCopySuffix);
                if (m.Groups[2].Value != "")
                {
                    nCopy = Int32.Parse(m.Groups[2].Value);
                }
                strNewName = String.Format("{0}{1}", strNewBaseName, ++nCopy);
            }
            else
            {
                strNewBaseName = String.Format("{0}{1}", sToCopy.Name, strCopySuffix);
                strNewName     = strNewBaseName;
            }

            while (HasNamedSprite(strNewName))
            {
                strNewName = String.Format("{0}{1}", strNewBaseName, ++nCopy);
            }

            Sprite sNew = AddSprite(sToCopy.TileWidth, sToCopy.TileHeight, strNewName, NextTileId++, sToCopy.Description, undo);

            sNew.Duplicate(sToCopy);
            return(sNew);
        }
コード例 #19
0
ファイル: Spriteset.cs プロジェクト: jduranmaster/spritely
        public Sprite DuplicateSprite(Sprite sToCopy, UndoMgr undo)
        {
            if (sToCopy == null)
                return null;

            // Calulate an appropriate name for the copy
            string strNewBaseName;
            int nCopy = 1;
            string strNewName;
            string strCopySuffix = ResourceMgr.GetString("CopySuffix");
            Match m = Regex.Match(sToCopy.Name, String.Format("^(.*){0}([0-9]*)$", strCopySuffix));
            if (m.Success)
            {
                strNewBaseName = String.Format("{0}{1}", m.Groups[1].Value, strCopySuffix);
                if (m.Groups[2].Value != "")
                    nCopy = Int32.Parse(m.Groups[2].Value);
                strNewName = String.Format("{0}{1}", strNewBaseName, ++nCopy);
            }
            else
            {
                strNewBaseName = String.Format("{0}{1}", sToCopy.Name, strCopySuffix);
                strNewName = strNewBaseName;
            }

            while (HasNamedSprite(strNewName))
                strNewName = String.Format("{0}{1}", strNewBaseName, ++nCopy);

            Sprite sNew = AddSprite(sToCopy.TileWidth, sToCopy.TileHeight, strNewName, NextTileId++, sToCopy.Description, undo);
            sNew.Duplicate(sToCopy);
            return sNew;
        }
コード例 #20
0
        private Sprite AddSprite_(int nWidth, int nHeight, string strName, int id, string strDesc, int nSubpalette, UndoMgr undo)
        {
            List <Sprite> slist = null;

            // Make sure that the requested size is valid.
            foreach (SpriteType st in SpriteTypes)
            {
                if (st.Width == nWidth && st.Height == nHeight)
                {
                    slist = st.Sprites;
                }
            }

            // Invalid sprite size - return.
            if (slist == null)
            {
                return(null);
            }

            Sprite s = new Sprite(m_doc, this, nWidth, nHeight, strName, id, strDesc, nSubpalette);

            return(AddSprite_2(s, slist, undo));
        }
コード例 #21
0
        public Sprite AddSprite(int nWidth, int nHeight, string strName, int id, string strDesc, int nSubpalette, UndoMgr undo)
        {
            if (id == -1)
            {
                id = NextTileId++;
            }
            Sprite s = AddSprite_(nWidth, nHeight, strName, id, strDesc, nSubpalette, undo);

            // Make this the currently selected sprite.
            CurrentSprite = s;
            return(s);
        }
コード例 #22
0
 public Sprite AddSprite(int nWidth, int nHeight, string strName, int id, string strDesc, UndoMgr undo)
 {
     return(AddSprite(nWidth, nHeight, strName, id, strDesc, 0, undo));
 }
コード例 #23
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);
            }
        }
コード例 #24
0
 public void RemoveSelectedSprite(UndoMgr undo)
 {
     RemoveSprite(CurrentSprite, undo);
 }
コード例 #25
0
ファイル: Spriteset.cs プロジェクト: jduranmaster/spritely
        private Sprite AddSprite_(int nWidth, int nHeight, string strName, int id, string strDesc, int nSubpalette, UndoMgr undo)
        {
            List<Sprite> slist = null;

            // Make sure that the requested size is valid.
            foreach (SpriteType st in SpriteTypes)
            {
                if (st.Width == nWidth && st.Height == nHeight)
                    slist = st.Sprites;
            }

            // Invalid sprite size - return.
            if (slist == null)
                return null;

            Sprite s = new Sprite(m_doc, this, nWidth, nHeight, strName, id, strDesc, nSubpalette);
            return AddSprite_2(s, slist, undo);
        }
コード例 #26
0
ファイル: Spriteset.cs プロジェクト: jduranmaster/spritely
        private Sprite AddSprite_2(Sprite s, List<Sprite> slist, UndoMgr undo)
        {
            slist.Add(s);

            m_nSprites++;
            m_nTiles += (s.TileWidth * s.TileHeight);

            if (undo != null)
                undo.Push(new UndoAction_AddSprite(undo, this, s, true));

            if (m_doc.Owner != null)
                m_doc.Owner.HandleSpriteTypeChanged(this);
            return s;
        }
コード例 #27
0
        /// <summary>
        /// Enable/disable menu items as appropriate
        /// </summary>
        private void ActivateMenuItems()
        {
            bool fHasDoc        = m_doc != null;
            bool fSpriteEditing = m_tabCurrent.Id == TabMgr.TabId.Sprites || m_tabCurrent.Id == TabMgr.TabId.BackgroundMaps;

            // Enable/disable File menu items
            menuFile.Enabled             = true;
            menuFile_New.Enabled         = true;
            menuFile_Open.Enabled        = true;
            menuFile_Close.Enabled       = fHasDoc;
            menuFile_Save.Enabled        = fHasDoc;
            menuFile_SaveAs.Enabled      = fHasDoc;
            menuFile_Export.Enabled      = fHasDoc;
            menuFile_RecentFiles.Enabled = (m_recent.Count != 0);
            menuFile_Exit.Enabled        = true;

            menuEdit.Enabled = true;
            UndoMgr undo     = ActiveUndo();
            bool    fCanUndo = fHasDoc && undo != null && undo.CanUndo();
            bool    fCanRedo = fHasDoc && undo != null && undo.CanRedo();

            menuEdit_Undo.Enabled  = fCanUndo;
            menuEdit_Redo.Enabled  = fCanRedo;
            menuEdit_Cut.Enabled   = false;
            menuEdit_Copy.Enabled  = false;
            menuEdit_Paste.Enabled = false;

            menuProject.Enabled                        = true;
            menuProject_Platform.Enabled               = true;
            menuProject_Platform_GBA.Enabled           = true;
            menuProject_Platform_GBA.Checked           = Options.Platform == Options.PlatformType.GBA;
            menuProject_Platform_NDS.Enabled           = true;
            menuProject_Platform_NDS.Checked           = Options.Platform == Options.PlatformType.NDS;
            menuProject_Palettes.Enabled               = true;
            menuProject_Palettes_New.Enabled           = false;
            menuProject_Spritesets.Enabled             = true;
            menuProject_Spritesets_New.Enabled         = false;
            menuProject_BackgroundPalettes.Enabled     = true;
            menuProject_BackgroundPalettes_New.Enabled = false;
            menuProject_BackgroundTilesets.Enabled     = true;
            menuProject_BackgroundTilesets_New.Enabled = false;
            menuProject_BackgroundMaps.Enabled         = true;
            menuProject_BackgroundMaps_New.Enabled     = false;

            // Enable/disable Sprite menu items
            menuSprite.Enabled = true;
            Sprite s = ActiveSprite();

            if (s != null)
            {
                menuSprite_New.Enabled       = true;
                menuSprite_Duplicate.Enabled = true;
                menuSprite_Clear.Enabled     = !s.IsEmpty();
                menuSprite_Resize.Enabled    = true;
                menuSprite_Delete.Enabled    = true;

                menuSprite_Resize_1x1.Enabled = !s.IsSize(1, 1);
                menuSprite_Resize_1x2.Enabled = !s.IsSize(1, 2);
                menuSprite_Resize_1x4.Enabled = !s.IsSize(1, 4);
                menuSprite_Resize_2x1.Enabled = !s.IsSize(2, 1);
                menuSprite_Resize_2x2.Enabled = !s.IsSize(2, 2);
                menuSprite_Resize_2x4.Enabled = !s.IsSize(2, 4);
                menuSprite_Resize_4x1.Enabled = !s.IsSize(4, 1);
                menuSprite_Resize_4x2.Enabled = !s.IsSize(4, 2);
                menuSprite_Resize_4x4.Enabled = !s.IsSize(4, 4);

                //bool fFirst, fLast;
                //tab.SpriteList.IsFirstLastSpriteOfType(s, out fFirst, out fLast);
                menuSprite_Properties.Enabled              = true;
                menuSprite_Rotate.Enabled                  = true;
                menuSprite_Rotate_Clockwise.Enabled        = true;
                menuSprite_Rotate_Counterclockwise.Enabled = true;
                menuSprite_Flip.Enabled             = true;
                menuSprite_Flip_Horizontal.Enabled  = true;
                menuSprite_Flip_Vertical.Enabled    = true;
                menuSprite_Arrange.Enabled          = false;
                menuSprite_Arrange_MoveUp.Enabled   = false;              // !fFirst;
                menuSprite_Arrange_MoveDown.Enabled = false;              // !fLast;
            }
            else
            {
                // The 'new sprite' option is always enabled when were in sprite editing mode.
                menuSprite_New.Enabled = fHasDoc && fSpriteEditing;

                // Disable all sprite editing options if there is no sprite selection or
                // if we're not editing sprites.
                menuSprite_Duplicate.Enabled               = false;
                menuSprite_Clear.Enabled                   = false;
                menuSprite_Resize.Enabled                  = false;
                menuSprite_Delete.Enabled                  = false;
                menuSprite_Properties.Enabled              = false;
                menuSprite_Rotate.Enabled                  = false;
                menuSprite_Rotate_Clockwise.Enabled        = false;
                menuSprite_Rotate_Counterclockwise.Enabled = false;
                menuSprite_Flip.Enabled             = false;
                menuSprite_Flip_Horizontal.Enabled  = false;
                menuSprite_Flip_Vertical.Enabled    = false;
                menuSprite_Arrange.Enabled          = false;
                menuSprite_Arrange_MoveUp.Enabled   = false;
                menuSprite_Arrange_MoveDown.Enabled = false;
            }

            // Enable/disable Palette menu items
            menuPalette.Enabled = true;
            Palette p             = ActivePalette();
            bool    fValidPalette = false;

            if (p.PaletteType == Palette.Type.Color16)
            {
                Palette16 p16 = p as Palette16;
                if (p16.GetCurrentSubpalette() != null)
                {
                    fValidPalette = true;
                }
            }
            else
            {
                fValidPalette = true;
            }
            if (fValidPalette)
            {
                menuPalette_Copy.Enabled         = false;
                menuPalette_Paste.Enabled        = false;
                menuPalette_Clear.Enabled        = false;
                menuPalette_ViewEncoding.Enabled = fSpriteEditing;
                menuPalette_Color.Enabled        = false;
                menuPalette_Color_Copy.Enabled   = false;
                menuPalette_Color_Paste.Enabled  = false;
                menuPalette_Color_Clear.Enabled  = false;
            }
            else
            {
                menuPalette_Copy.Enabled         = false;
                menuPalette_Paste.Enabled        = false;
                menuPalette_Clear.Enabled        = false;
                menuPalette_ViewEncoding.Enabled = false;
                menuPalette_Color.Enabled        = false;
                menuPalette_Color_Copy.Enabled   = false;
                menuPalette_Color_Paste.Enabled  = false;
                menuPalette_Color_Clear.Enabled  = false;
            }

            menuWindow.Enabled         = true;
            menuWindow_Arrange.Enabled = fHasDoc;

            menuHelp.Enabled       = true;
            menuHelp_About.Enabled = true;

            // Used for debugging only - set to false for release builds.
            menuTest.Visible = Options.DEBUG;
            menuTest_RunUnittests.Visible    = true;
            menuTest_ShowUndoHistory.Visible = true;
            menuTest_ShowUndoHistory.Checked = UndoHistoryVisible;
            menuTest_CollisionTest.Visible   = true;
        }
コード例 #28
0
ファイル: Subpalette.cs プロジェクト: jduranmaster/spritely
        public void RecordUndoAction(string strDesc, UndoMgr undo)
        {
            if (undo == null)
                return;

            PaletteColorData data = GetUndoData();
            UndoAction_Subpalette16Edit action = new UndoAction_Subpalette16Edit(undo, this, m_snapshot, data, strDesc);
            bool fHandled = false;

            if (action.IsSelectionChange())
            {
                // Ignore selection changes
                fHandled = true;
            }
            else
            {
                // If the last undo action is also a PaletteEdit, try to merge them together
                UndoAction_Subpalette16Edit last_action = undo.GetCurrent() as UndoAction_Subpalette16Edit;
                if (last_action != null)
                {
                    // Merge 2 color changes (as long as they edit the same color)
                    int last_color, last_color_val1, last_color_val2;
                    int this_color, this_color_val1, this_color_val2;
                    if (last_action.IsColorChange(out last_color, out last_color_val1, out last_color_val2)
                        && action.IsColorChange(out this_color, out this_color_val1, out this_color_val2)
                        )
                    {
                        if (last_color == this_color)
                        {
                            // If this color change takes it back to the original value, then
                            // delete the UndoAction.
                            if (last_color_val1 == this_color_val2)
                                undo.DeleteCurrent();
                            else
                                last_action.UpdateRedoData(data);
                            fHandled = true;
                        }
                    }
                }
            }
            if (!fHandled)
                undo.Push(action);

            // Update the snapshot for the next UndoAction
            RecordSnapshot();
        }
コード例 #29
0
ファイル: Spriteset.cs プロジェクト: jduranmaster/spritely
        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);
            }
        }
コード例 #30
0
ファイル: Spriteset.cs プロジェクト: jduranmaster/spritely
 public Sprite AddSprite(int nWidth, int nHeight, string strName, int id, string strDesc, UndoMgr undo)
 {
     return AddSprite(nWidth, nHeight, strName, id, strDesc, 0, undo);
 }
コード例 #31
0
ファイル: Spriteset.cs プロジェクト: jduranmaster/spritely
        public Sprite AddSprite(int nWidth, int nHeight, string strName, int id, string strDesc, int nSubpalette, UndoMgr undo)
        {
            if (id == -1)
                id = NextTileId++;
            Sprite s = AddSprite_(nWidth, nHeight, strName, id, strDesc, nSubpalette, undo);

            // Make this the currently selected sprite.
            CurrentSprite = s;
            return s;
        }
コード例 #32
0
ファイル: Sprite.cs プロジェクト: jduranmaster/spritely
        public void RecordUndoAction(string strDesc, UndoMgr undo)
        {
            if (undo == null)
                return;

            UndoData data = GetUndoData();

            // Don't record anything if there aren't any changes
            if (!data.Equals(m_snapshot))
            {
                UndoAction_SpriteEdit action = new UndoAction_SpriteEdit(undo, m_ss, this, m_snapshot, data, strDesc);
                undo.Push(action);

                // Update the snapshot for the next UndoAction
                RecordSnapshot();
            }
        }
コード例 #33
0
ファイル: Spriteset.cs プロジェクト: jduranmaster/spritely
        public Sprite AddSprite(Sprite s, UndoMgr undo)
        {
            List<Sprite> slist = null;

            foreach (SpriteType st in SpriteTypes)
            {
                if (st.Width == s.TileWidth && st.Height == s.TileHeight)
                {
                    slist = st.Sprites;
                    break;
                }
            }

            if (slist == null)
                return null;

            return AddSprite_2(s, slist, undo);
        }
コード例 #34
0
ファイル: Spriteset.cs プロジェクト: jduranmaster/spritely
 public void RemoveSelectedSprite(UndoMgr undo)
 {
     RemoveSprite(CurrentSprite, undo);
 }