Esempio n. 1
0
        public MapForm(ProjectMainForm parent, Map m, Spriteset ss, Sprite s)
        {
            m_parent = parent;

            m_ss = ss;

            InitializeComponent();

            SetMap(m);
            m_toolbox = new Toolbox_Map();
            m_optionbox = new Optionbox_Map();

            MdiParent = parent;
            FormBorderStyle = FormBorderStyle.SizableToolWindow;
            StartPosition = FormStartPosition.Manual;
            Visible = false;
            ControlBox = false;

            // Set to 16x.
            cbZoom.SelectedIndex = (int)ZoomLevel.Zoom_16x;
            cbZoom.Enabled = false;

            m_tileSpriteX = -1;
            m_tileSpriteY = -1;
        }
Esempio n. 2
0
        public void Test_LoadXML_sprite16_1x1()
        {
            Palette p = m_doc.Palettes.AddPalette16(Options.DefaultPaletteName, 0, "");

            Assert.IsNotNull(p);
            Spriteset ss = m_doc.Spritesets.AddSpriteset(Options.DefaultSpritesetName, 0, "", p);

            Assert.IsNotNull(ss);
            Sprite s = ss.AddSprite(1, 1, "sample", 0, "", 0, null);

            Assert.IsNotNull(s);

            XmlElement xnSprite = m_xd.CreateElement("sprite16");

            // Note: <sprite16> attributes not needed for test.
            Test_LoadXML_sprite16_AddTile(xnSprite, 0, 8, 8);
            Assert.IsTrue(s.LoadXML_sprite16(xnSprite, 0));

            // Verify the data is the same as the XML
            // Pixel 0 is the same as the tileid
            Assert.AreEqual(0, s.GetTile(0).GetPixel(0, 0));
            // Other pixels = x+y
            Assert.AreEqual(9, s.GetTile(0).GetPixel(4, 5));
            Assert.AreEqual(14, s.GetTile(0).GetPixel(7, 7));
        }
Esempio n. 3
0
 /// <summary>
 /// The current sprite seletion has changed.
 /// </summary>
 public void HandleSpriteSelectionChanged(Spriteset ss)
 {
     //m_doc.HasUnsavedChanges = true;
     ss.Palette.PaletteWindow().SpriteSelectionChanged();
     ss.SpritesetWindow.SpriteSelectionChanged();
     ss.SpriteWindow.SpriteSelectionChanged();
 }
Esempio n. 4
0
        public void Init(Document doc, Spriteset ss, int nWidth, int nHeight, string strName, int id, string strDesc, int nSubpalette)
        {
            m_doc = doc;
            m_ss  = ss;

            if (strName == "" ||
                ss.HasNamedSprite(strName)
                )
            {
                strName = ss.AutoGenerateSpriteName();
            }
            m_strName = strName;

            m_strDesc    = strDesc;
            SubpaletteID = nSubpalette;
            m_tileWidth  = nWidth;
            m_tileHeight = nHeight;

            int nTiles = NumTiles;

            m_Tiles = new Tile[nTiles];
            for (int i = 0; i < nTiles; i++)
            {
                m_Tiles[i] = new Tile(this, ss.NextTileId++);
            }

            // Make an initial snapshot of the (empty) sprite.
            m_snapshot = GetUndoData();
        }
Esempio n. 5
0
        public Map(Document doc, string strName, int id, string strDesc, Spriteset bgtiles)
        {
            m_doc = doc;
            m_ss  = bgtiles;
            m_ss.AddMap(this);

            m_strName = strName;
            m_id      = id;
            m_strDesc = strDesc;

            m_BackgroundMap = new BackgroundMapTileInfo[kMaxMapTilesX, kMaxMapTilesY];

            int nDefaultTile = -1;

            if (bgtiles.CurrentSprite != null)
            {
                nDefaultTile = bgtiles.CurrentSprite.FirstTileId;
            }
            for (int ix = 0; ix < kMaxMapTilesX; ix++)
            {
                for (int iy = 0; iy < kMaxMapTilesY; iy++)
                {
                    m_BackgroundMap[ix, iy].nTileIndex  = nDefaultTile;
                    m_BackgroundMap[ix, iy].nSubpalette = 0;
                }
            }

            // Make an initial snapshot of the (empty) map.
            m_snapshot = GetUndoData();

            if (m_doc.Owner != null)
            {
                m_winMap = new MapForm(m_doc.Owner, this, bgtiles, null);;
            }
        }
Esempio n. 6
0
        public Map(Document doc, string strName, int id, string strDesc, Spriteset bgtiles)
        {
            m_doc = doc;
            m_ss = bgtiles;
            m_ss.AddMap(this);

            m_strName = strName;
            m_id = id;
            m_strDesc = strDesc;

            m_BackgroundMap = new BackgroundMapTileInfo[kMaxMapTilesX, kMaxMapTilesY];

            int nDefaultTile = -1;
            if (bgtiles.CurrentSprite != null)
                nDefaultTile = bgtiles.CurrentSprite.FirstTileId;
            for (int ix = 0; ix < kMaxMapTilesX; ix++)
                for (int iy = 0; iy < kMaxMapTilesY; iy++)
                {
                    m_BackgroundMap[ix, iy].nTileIndex = nDefaultTile;
                    m_BackgroundMap[ix, iy].nSubpalette = 0;
                }

            // Make an initial snapshot of the (empty) map.
            m_snapshot = GetUndoData();

            if (m_doc.Owner != null)
            {
                m_winMap = new MapForm(m_doc.Owner, this, bgtiles, null); ;
            }
        }
Esempio n. 7
0
        private void menuSprite_Resize_Click(object sender, EventArgs e)
        {
            Spriteset ss = ActiveSpriteset();
            Sprite    s  = ActiveSprite();

            if (s == null)
            {
                return;
            }

            ToolStripMenuItem mi     = (sender as ToolStripMenuItem);
            string            strTag = mi.Tag as string;

            if (strTag == null || strTag == "")
            {
                return;
            }
            string[] aSize      = strTag.Split('x');
            int      tileWidth  = Int32.Parse(aSize[0]);
            int      tileHeight = Int32.Parse(aSize[1]);

            if (ss.ResizeSelectedSprite(tileWidth, tileHeight))
            {
                s.RecordUndoAction("resize", ActiveUndo());
                HandleSpriteDataChanged(ss);
            }
        }
Esempio n. 8
0
        public MapForm(ProjectMainForm parent, Map m, Spriteset ss, Sprite s)
        {
            m_parent = parent;

            m_ss = ss;

            InitializeComponent();

            SetMap(m);
            m_toolbox   = new Toolbox_Map();
            m_optionbox = new Optionbox_Map();

            MdiParent       = parent;
            FormBorderStyle = FormBorderStyle.SizableToolWindow;
            StartPosition   = FormStartPosition.Manual;
            Visible         = false;
            ControlBox      = false;

            // Set to 16x.
            cbZoom.SelectedIndex = (int)ZoomLevel.Zoom_16x;
            cbZoom.Enabled       = false;

            m_tileSpriteX = -1;
            m_tileSpriteY = -1;
        }
Esempio n. 9
0
            public void Test_LoadXML_OLD_sprite_2x4()
            {
                Palette p = m_doc.Palettes.AddPalette16(Options.DefaultPaletteName, 0, "");

                Assert.IsNotNull(p);

                Spriteset ss = m_doc.Spritesets.AddSpriteset(Options.DefaultSpritesetName, 0, "", p);

                Assert.IsNotNull(ss);

                Sprite s = ss.AddSprite(2, 4, "sample", 0, "", 0, null);

                Assert.IsNotNull(s);

                XmlElement xnSprite = m_xd.CreateElement("sprite");

                for (int i = 0; i < 8; i++)
                {
                    Test_LoadXML_OLD_sprite_AddTile(xnSprite, i);
                }
                Assert.IsTrue(m_filer.LoadXML_OLD_sprite(s, xnSprite.ChildNodes));

                // Verify the data is the same as the XML
                // Pixel 0 is the same as the tileid
                Assert.AreEqual(0, s.GetTile(0).GetPixel(0, 0));
                Assert.AreEqual(3, s.GetTile(3).GetPixel(0, 0));
                Assert.AreEqual(7, s.GetTile(7).GetPixel(0, 0));
                // Other pixels = x+y
                Assert.AreEqual(9, s.GetTile(0).GetPixel(4, 5));
                Assert.AreEqual(3, s.GetTile(4).GetPixel(0, 3));
                Assert.AreEqual(14, s.GetTile(7).GetPixel(7, 7));
            }
Esempio n. 10
0
        public bool LoadXML_bgmaps(XmlNode xnode)
        {
            foreach (XmlNode xn in xnode.ChildNodes)
            {
                switch (xn.Name)
                {
                case "map16":
                    string strName              = XMLUtils.GetXMLAttribute(xn, "name");
                    int    id                   = XMLUtils.GetXMLIntegerAttribute(xn, "id");
                    string strDesc              = XMLUtils.GetXMLAttribute(xn, "desc");
                    string strSize              = XMLUtils.GetXMLAttribute(xn, "size");
                    int    nSpritesetId         = XMLUtils.GetXMLIntegerAttribute(xn, "bgspriteset_id");
                    int    nDefaultSubpaletteId = XMLUtils.GetXMLIntegerAttribute(xn, "default_subpalette_id");

                    string[] aSize   = strSize.Split('x');
                    int      nWidth  = XMLUtils.ParseInteger(aSize[0]);
                    int      nHeight = XMLUtils.ParseInteger(aSize[1]);

                    Spriteset ts = m_doc.BackgroundSpritesets.GetSpriteset(nSpritesetId);
                    Map       m  = AddMap(strName, id, strDesc, ts);
                    if (!m.LoadXML_map16(xn, nDefaultSubpaletteId))
                    {
                        return(false);
                    }
                    break;
                }
            }
            return(true);
        }
Esempio n. 11
0
            public void Test_LoadXML_OLD_map_valid()
            {
                Palette p = m_doc.BackgroundPalettes.AddPalette16(Options.DefaultBgPaletteName, 0, "");

                Assert.IsNotNull(p);

                Spriteset ss = m_doc.BackgroundSpritesets.AddSpriteset(Options.DefaultBgTilesetName, 0, "", p);

                Assert.IsNotNull(ss);

                // Valid old map.
                XmlElement xnMap = m_xd.CreateElement("map");

                for (int id = 0; id < 32; id++)
                {
                    Test_LoadXML_OLD_map_AddRow(xnMap, id, 32);
                }
                Assert.IsTrue(m_filer.LoadXML_OLD_map(xnMap.ChildNodes));

                Assert.AreEqual(1, m_doc.BackgroundMaps.NumMaps);
                Map m = m_doc.BackgroundMaps.GetMap(0);

                Assert.IsNotNull(m);

                int nTileId, nSubpaletteId;

                m.GetTile(2, 4, out nTileId, out nSubpaletteId);
                Assert.AreEqual(6, nTileId);
                m.GetTile(7, 9, out nTileId, out nSubpaletteId);
                Assert.AreEqual(16, nTileId);
                m.GetTile(31, 31, out nTileId, out nSubpaletteId);
                Assert.AreEqual(62, nTileId);
            }
Esempio n. 12
0
        /// <summary>
        /// Copy the newly opened Document into the current document.
        /// </summary>
        /// <param name="doc">The newly opened document</param>
        private void Open_(Document doc)
        {
            // Copy data from newly loaded doc into this doc
            m_data = doc.m_data;
            // Update the document references to point to this document
            m_data.Palettes.UpdateDocument(this);
            m_data.Spritesets.UpdateDocument(this);
            m_data.BackgroundPalettes.UpdateDocument(this);
            m_data.BackgroundSpritesets.UpdateDocument(this);
            m_data.BackgroundMaps.UpdateDocument(this);
            m_data.Filer.UpdateDocument(this);

            Spriteset ss = m_data.Spritesets.Current;

            if (ss != null)
            {
                ss.SelectFirstSprite();
            }
            Spriteset bss = m_data.BackgroundSpritesets.Current;

            if (bss != null)
            {
                bss.SelectFirstSprite();
            }
            BgImages bgis = m_data.BackgroundImages;

            if (bgis != null)
            {
                bgis.SelectFirstImage();
            }
            Owner.ClearUndo();
        }
Esempio n. 13
0
        /// <summary>
        /// Add a default sprite to the new document when Spritely is first launched.
        /// This is so that first-time users don't see an empty window - they can
        /// start editing their first sprite immediately.
        /// </summary>
        public void InitializeEmptyDocument()
        {
            // Palettes
            Palette16 pal = m_data.Palettes.AddPalette16(Options.DefaultPaletteName, 0, "");

            pal.SetDefaultPalette();

            // Spritesets
            Spriteset ss = m_data.Spritesets.AddSpriteset(Options.DefaultSpritesetName, Options.DefaultPaletteId, "", pal);

            // Add a single 2x2 sprite.
            ss.AddSprite(2, 2, "", -1, "", 0, null);
            ss.SelectFirstSprite();

            // Background palettes
            Palette16 bgpal = m_data.BackgroundPalettes.AddPalette16(Options.DefaultBgPaletteName, 0, "");

            bgpal.SetDefaultPalette();

            // Background tiles (bgsprites and bgtilegroups)
            Spriteset bss = m_data.BackgroundSpritesets.AddSpriteset(Options.DefaultBgTilesetName, Options.DefaultBgPaletteId, "", bgpal);

            // Add a single blank background tile.
            bss.AddSprite(1, 1, "", -1, "", 0, null);
            bss.SelectFirstSprite();

            // Background tile map
            m_data.BackgroundMaps.AddMap("map", 0, "", m_data.BackgroundSpritesets.Current);

            // The sprites we just added above don't count as document changes.
            HasUnsavedChanges = false;
        }
Esempio n. 14
0
        public SpritesetForm(ProjectMainForm parent, Spriteset ss)
        {
            m_parent = parent;
            m_ss     = ss;

            InitializeComponent();

            MdiParent       = parent;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
            StartPosition   = FormStartPosition.Manual;
            Visible         = false;
            ControlBox      = false;

            if (m_ss.IsBackground)
            {
                Text = "Tileset '" + ss.Name + "'";
            }
            else
            {
                Text = "Spriteset '" + ss.Name + "'";
            }

            cbPalette.Items.Add(ss.Palette.Name);
            cbPalette.SelectedIndex = 0;
        }
Esempio n. 15
0
        public bool LoadXML_spritesets(XmlNode xnode)
        {
            foreach (XmlNode xn in xnode.ChildNodes)
            {
                switch (xn.Name)
                {
                case "spriteset16":
                    string strName    = XMLUtils.GetXMLAttribute(xn, "name");
                    int    id         = XMLUtils.GetXMLIntegerAttribute(xn, "id");
                    string strDesc    = XMLUtils.GetXMLAttribute(xn, "desc");
                    int    nPaletteId = XMLUtils.GetXMLIntegerAttribute(xn, "palette_id");

                    Palette pal;
                    if (m_fBackground)
                    {
                        pal = m_doc.GetBackgroundPalette(id);
                    }
                    else
                    {
                        pal = m_doc.GetSpritePalette(id);
                    }
                    Spriteset s = AddSpriteset(strName, id, strDesc, pal);
                    if (!s.LoadXML_spriteset16(xn))
                    {
                        return(false);
                    }
                    break;

                case "spriteset256":
                    // NYI - ignore
                    break;
                }
            }
            return(true);
        }
Esempio n. 16
0
        public SpriteForm(ProjectMainForm parent, Spriteset ss, Sprite s)
        {
            m_parent = parent;

            m_ss = ss;

            InitializeComponent();

            SetSprite(s);
            m_toolbox   = new Toolbox_Sprite();
            m_optionbox = new Optionbox_Sprite();
            m_arrowbox  = new Arrowbox_Sprite();

            MdiParent       = parent;
            FormBorderStyle = FormBorderStyle.SizableToolWindow;
            StartPosition   = FormStartPosition.Manual;
            Visible         = false;
            ControlBox      = false;

            // Set to 16x.
            cbZoom.SelectedIndex = (int)ZoomLevel.Zoom_16x;

            if (m_brushTransparent == null)
            {
                m_brushTransparent = new System.Drawing.Drawing2D.HatchBrush(
                    Options.TransparentPattern,
                    Color.LightGray, Color.Transparent);
            }
        }
Esempio n. 17
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;
        }
        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;
        }
Esempio n. 19
0
        public Map AddMap(string strName, int id, string strDesc, Spriteset bgtiles)
        {
            if (m_maps.ContainsKey(id))
                return null;

            Map m = new Map(m_doc, strName, id, strDesc, bgtiles);
            m_maps.Add(id, m);
            m_mapCurrent = m;
            return m;
        }
Esempio n. 20
0
        public SpriteProperties(Document doc, Spriteset ss)
        {
            InitializeComponent();

            m_doc = doc;
            m_ss = ss;
            m_sprite = m_ss.CurrentSprite;

            UpdateSpriteInfo();
        }
Esempio n. 21
0
        public SpriteProperties(Document doc, Spriteset ss)
        {
            InitializeComponent();

            m_doc    = doc;
            m_ss     = ss;
            m_sprite = m_ss.CurrentSprite;

            UpdateSpriteInfo();
        }
Esempio n. 22
0
        private void menuSprite_Arrange_MoveDown_Click(object sender, EventArgs e)
        {
            Spriteset ss = ActiveSpriteset();
            Sprite    s  = ActiveSprite();

            if (s == null)
            {
                return;
            }
        }
Esempio n. 23
0
        public void Test_LoadXML_map16_32x32()
        {
            Palette p = m_doc.BackgroundPalettes.AddPalette16(Options.DefaultBgPaletteName, 0, "");

            Assert.IsNotNull(p);

            Spriteset ss = m_doc.BackgroundSpritesets.AddSpriteset(Options.DefaultBgTilesetName, 0, "", p);

            Assert.IsNotNull(ss);

            Map m = m_doc.BackgroundMaps.AddMap("map", 0, "", ss);

            Assert.AreEqual(1, m_doc.BackgroundMaps.NumMaps);
            Assert.IsNotNull(m);

            // Valid map.
            XmlElement xnMap = m_xd.CreateElement("map16");

            Test_LoadXML_map16_AddBlock(xnMap, 0, 32, 32);
            // <map16> attributes are not needed for test.
            Assert.IsTrue(m.LoadXML_map16(xnMap, 0));

            int  nTileId, nSubpaletteId;
            bool fHorizontal, fVertical;

            m.GetTile(2, 4, out nTileId, out nSubpaletteId);
            m.GetFlip(2, 4, out fHorizontal, out fVertical);
            Assert.AreEqual(6, nTileId);
            Assert.AreEqual(0, nSubpaletteId);

            m.GetTile(7, 9, out nTileId, out nSubpaletteId);
            Assert.AreEqual(16, nTileId);
            Assert.AreEqual(0, nSubpaletteId);

            m.GetTile(31, 31, out nTileId, out nSubpaletteId);
            Assert.AreEqual(62, nTileId);
            Assert.AreEqual(1, nSubpaletteId);                  // x==y, so subpalette=1

            m.GetFlip(0, 0, out fHorizontal, out fVertical);
            Assert.IsTrue(fHorizontal);
            Assert.IsTrue(fVertical);

            m.GetFlip(0, 5, out fHorizontal, out fVertical);
            Assert.IsFalse(fHorizontal);
            Assert.IsTrue(fVertical);

            m.GetFlip(5, 0, out fHorizontal, out fVertical);
            Assert.IsTrue(fHorizontal);
            Assert.IsFalse(fVertical);

            m.GetFlip(5, 5, out fHorizontal, out fVertical);
            Assert.IsFalse(fHorizontal);
            Assert.IsFalse(fVertical);
        }
        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;
        }
Esempio n. 25
0
        /// <summary>
        /// One of the spritetypes has changed.
        /// E.g., by having a sprite added, deleted or having its tile geometry changed.
        /// </summary>
        public void HandleSpriteTypeChanged(Spriteset ss)
        {
            m_doc.HasUnsavedChanges = true;

            SpritesetForm win = ss.SpritesetWindow;

            if (win != null)
            {
                win.RecalcScrollHeights();
                win.AdjustScrollbar();
            }
        }
Esempio n. 26
0
        public Map AddMap(string strName, int id, string strDesc, Spriteset bgtiles)
        {
            if (m_maps.ContainsKey(id))
            {
                return(null);
            }

            Map m = new Map(m_doc, strName, id, strDesc, bgtiles);

            m_maps.Add(id, m);
            m_mapCurrent = m;
            return(m);
        }
Esempio n. 27
0
        public Spriteset AddSpriteset(string strName, int id, string strDesc, Palette pal)
        {
            // Don't allow a second spriteset with the same id.
            if (m_spritesets.ContainsKey(id))
                return null;

            Spriteset ss = new Spriteset(m_doc, strName, id, strDesc, pal);
            m_spritesets.Add(id, ss);

            // Make this spriteset the current one.
            m_ssCurrent = ss;
            return ss;
        }
Esempio n. 28
0
        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);
        }
Esempio n. 29
0
        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);
        }
Esempio n. 30
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;
            }
        }
Esempio n. 31
0
        /// <summary>
        /// The data for one (or more) of the sprites has changed.
        /// </summary>
        public void HandleSpriteDataChanged(Spriteset ss)
        {
            m_doc.HasUnsavedChanges = true;
            ss.SpritesetWindow.SpriteDataChanged();
            ss.SpriteWindow.SpriteDataChanged();

            if (ss.IsBackground)
            {
                Map m = ActiveMap();
                if (m != null)
                {
                    m.MapWindow.SpriteDataChanged();
                }
            }
        }
Esempio n. 32
0
        public Spriteset AddSpriteset(string strName, int id, string strDesc, Palette pal)
        {
            // Don't allow a second spriteset with the same id.
            if (m_spritesets.ContainsKey(id))
            {
                return(null);
            }

            Spriteset ss = new Spriteset(m_doc, strName, id, strDesc, pal);

            m_spritesets.Add(id, ss);

            // Make this spriteset the current one.
            m_ssCurrent = ss;
            return(ss);
        }
Esempio n. 33
0
        private void menuSprite_Properties_Click(object sender, EventArgs e)
        {
            Spriteset ss = ActiveSpriteset();
            Sprite    s  = ActiveSprite();

            if (s == null)
            {
                return;
            }

            SpriteProperties properties = new SpriteProperties(m_doc, ss);

            properties.ShowDialog();

            // The name of the sprite may have changed, so update the form title.
            ss.SpriteWindow.SetTitle();
        }
Esempio n. 34
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);
            }
        }
Esempio n. 35
0
        private void menuSprite_New_Click(object sender, EventArgs e)
        {
            Spriteset ss = ActiveSpriteset();

            ToolStripMenuItem mi     = (sender as ToolStripMenuItem);
            string            strTag = mi.Tag as string;

            if (strTag == null || strTag == "")
            {
                return;
            }
            string[] aSize   = strTag.Split('x');
            int      nWidth  = Int32.Parse(aSize[0]);
            int      nHeight = Int32.Parse(aSize[1]);

            ss.AddSprite(nWidth, nHeight, "", -1, "", 0, ActiveUndo());
            HandleSpriteDataChanged(ss);
        }
Esempio n. 36
0
            public void Test_LoadXML_OLD_map_35rows()
            {
                Palette p = m_doc.BackgroundPalettes.AddPalette16(Options.DefaultBgPaletteName, 0, "");

                Assert.IsNotNull(p);

                Spriteset ss = m_doc.BackgroundSpritesets.AddSpriteset(Options.DefaultBgTilesetName, 0, "", p);

                Assert.IsNotNull(ss);

                // Map with 35 rows
                XmlElement xnMap = m_xd.CreateElement("map");

                for (int id = 0; id < 35; id++)
                {
                    Test_LoadXML_OLD_map_AddRow(xnMap, id, 32);
                }
                Assert.IsFalse(m_filer.LoadXML_OLD_map(xnMap.ChildNodes));
            }
Esempio n. 37
0
        public CollisionTest(Document d)
        {
            m_doc = d;

            InitializeComponent();

            xOffset = 0;
            yOffset = 0;

            ss = d.Owner.ActiveSpriteset();

            s1 = ss.CurrentSprite;
            s2 = ss.NextSprite(s1);

            mask1 = CalcMask(s1, out mask1w, out mask1h);
            mask2 = CalcMask(s2, out mask2w, out mask2h);

            CollisionCheck();
        }
Esempio n. 38
0
        public CollisionTest(Document d)
        {
            m_doc = d;

            InitializeComponent();

            xOffset = 0;
            yOffset = 0;

            ss = d.Owner.ActiveSpriteset();

            s1 = ss.CurrentSprite;
            s2 = ss.NextSprite(s1);

            mask1 = CalcMask(s1, out mask1w, out mask1h);
            mask2 = CalcMask(s2, out mask2w, out mask2h);

            CollisionCheck();
        }
Esempio n. 39
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);
                }
            }
        }
Esempio n. 40
0
        public SpritesetForm(ProjectMainForm parent, Spriteset ss)
        {
            m_parent = parent;
            m_ss = ss;

            InitializeComponent();

            MdiParent = parent;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
            StartPosition = FormStartPosition.Manual;
            Visible = false;
            ControlBox = false;

            if (m_ss.IsBackground)
                Text = "Tileset '" + ss.Name + "'";
            else
                Text = "Spriteset '" + ss.Name + "'";

            cbPalette.Items.Add(ss.Palette.Name);
            cbPalette.SelectedIndex = 0;
        }
Esempio n. 41
0
 /// <summary>
 /// The sprite display options have changed..
 /// </summary>
 public void HandleSpriteDisplayOptionsChanged(Spriteset ss)
 {
     ss.Palette.PaletteWindow().SpriteDisplayOptionChanged();
     ss.SpriteWindow.SpriteDisplayOptionChanged();
 }
Esempio n. 42
0
 /// <summary>
 /// The current sprite seletion has changed.
 /// </summary>
 public void HandleSpriteSelectionChanged(Spriteset ss)
 {
     //m_doc.HasUnsavedChanges = true;
     ss.Palette.PaletteWindow().SpriteSelectionChanged();
     ss.SpritesetWindow.SpriteSelectionChanged();
     ss.SpriteWindow.SpriteSelectionChanged();
 }
Esempio n. 43
0
        /// <summary>
        /// One of the spritetypes has changed.
        /// E.g., by having a sprite added, deleted or having its tile geometry changed.
        /// </summary>
        public void HandleSpriteTypeChanged(Spriteset ss)
        {
            m_doc.HasUnsavedChanges = true;

            SpritesetForm win = ss.SpritesetWindow;
            if (win != null)
            {
                win.RecalcScrollHeights();
                win.AdjustScrollbar();
            }
        }
Esempio n. 44
0
 public void Clear()
 {
     m_spritesets.Clear();
     m_ssCurrent = null;
 }
Esempio n. 45
0
        /// <summary>
        /// The data for one (or more) of the sprites has changed.
        /// </summary>
        public void HandleSpriteDataChanged(Spriteset ss)
        {
            m_doc.HasUnsavedChanges = true;
            ss.SpritesetWindow.SpriteDataChanged();
            ss.SpriteWindow.SpriteDataChanged();

            if (ss.IsBackground)
            {
                Map m = ActiveMap();
                if (m != null)
                    m.MapWindow.SpriteDataChanged();
            }
        }
Esempio n. 46
0
        public void Init(Document doc, Spriteset ss, int nWidth, int nHeight, string strName, int id, string strDesc, int nSubpalette)
        {
            m_doc = doc;
            m_ss = ss;

            if (strName == ""
                || ss.HasNamedSprite(strName)
                )
                strName = ss.AutoGenerateSpriteName();
            m_strName = strName;

            m_strDesc = strDesc;
            SubpaletteID = nSubpalette;
            m_tileWidth = nWidth;
            m_tileHeight = nHeight;

            int nTiles = NumTiles;
            m_Tiles = new Tile[nTiles];
            for (int i=0; i < nTiles; i++)
                m_Tiles[i] = new Tile(this, ss.NextTileId++);

            // Make an initial snapshot of the (empty) sprite.
            m_snapshot = GetUndoData();
        }
Esempio n. 47
0
 // This assumes that width x height are valid.
 public Sprite(Document doc, Spriteset ts, int nWidth, int nHeight, string strName, int id, string strDesc, int nSubpalette)
 {
     Init(doc, ts, nWidth, nHeight, strName, id, strDesc, nSubpalette);
 }