コード例 #1
0
        private void menuSprite_Flip_Both_Click(object sender, EventArgs e)
        {
            Spriteset ss = ActiveSpriteset();
            Sprite    s  = ActiveSprite();

            if (s == null)
            {
                return;
            }

            if (!s.IsEmpty())
            {
                s.Flip(true, true);
                s.RecordUndoAction("flipboth", ActiveUndo());
                HandleSpriteDataChanged(ss);
            }
        }
コード例 #2
0
        private void menuSprite_Rotate_180_Click(object sender, EventArgs e)
        {
            Spriteset ss = ActiveSpriteset();
            Sprite    s  = ActiveSprite();

            if (s == null)
            {
                return;
            }

            if (!s.IsEmpty())
            {
                if (ss.RotateSelectedSprite(Sprite.RotateDirection.Clockwise180))
                {
                    s.RecordUndoAction("rotate180", ActiveUndo());
                    HandleSpriteDataChanged(ss);
                }
            }
        }
コード例 #3
0
        private void menuSprite_Clear_Click(object sender, EventArgs e)
        {
            Spriteset ss = ActiveSpriteset();
            Sprite    s  = ActiveSprite();

            if (s == null)
            {
                return;
            }

            if (!s.IsEmpty())
            {
                //if (!AskYesNo("Are you sure you want to erase the data in the currently selected sprite?"))
                if (!AskYesNo(ResourceMgr.GetString("EraseCurrentSprite")))
                {
                    return;
                }
                s.Clear();
                s.RecordUndoAction("clear", ActiveUndo());
                HandleSpriteDataChanged(ss);
            }
        }
コード例 #4
0
        private void menuSprite_Delete_Click(object sender, EventArgs e)
        {
            Spriteset ss = ActiveSpriteset();
            Sprite    s  = ActiveSprite();

            if (s == null)
            {
                return;
            }

            if (!s.IsEmpty())
            {
                // "Are you sure you want to delete the currently selected sprite?"
                if (!m_doc.AskYesNo(ResourceMgr.GetString("DeleteCurrentSprite")))
                {
                    return;
                }
            }

            ss.RemoveSelectedSprite(ActiveUndo());
            HandleSpriteDataChanged(ss);
        }
コード例 #5
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;
        }