Beispiel #1
0
        private bool LoadXML_OLD_sprites(XmlNodeList xnl, bool fBackground)
        {
            Palette   p;
            Spriteset ts;

            if (fBackground)
            {
                p  = m_doc.GetBackgroundPalette(0);
                ts = m_doc.BackgroundSpritesets.AddSpriteset(Options.DefaultBgTilesetName, 0, "", p);
            }
            else
            {
                p  = m_doc.GetSpritePalette(0);
                ts = m_doc.Spritesets.AddSpriteset(Options.DefaultSpritesetName, 0, "", p);
            }
            foreach (XmlNode xn in xnl)
            {
                if (xn.Name == "sprite")
                {
                    string   strName       = XMLUtils.GetXMLAttribute(xn, "name");
                    string   strDesc       = XMLUtils.GetXMLAttribute(xn, "desc");
                    int      nSubpaletteId = XMLUtils.GetXMLIntegerAttribute(xn, "palette");
                    string   strSize       = XMLUtils.GetXMLAttribute(xn, "size");
                    int      id            = XMLUtils.GetXMLIntegerAttribute(xn, "id");
                    int      nFirstTileID  = XMLUtils.GetXMLIntegerAttribute(xn, "firsttileid");
                    string[] aSize         = strSize.Split('x');
                    int      nWidth        = XMLUtils.ParseInteger(aSize[0]);
                    int      nHeight       = XMLUtils.ParseInteger(aSize[1]);

                    Sprite s = ts.AddSprite(nWidth, nHeight, strName, id, strDesc, nSubpaletteId, null);
                    if (s == null)
                    {
                        // "Invalid sprite size ({0}) for sprite named '{1}'."
                        m_doc.ErrorId("ErrorInvalidSpriteSize", strSize, strName);
                        return(false);
                    }

                    if (!LoadXML_OLD_sprite(s, xn.ChildNodes))
                    {
                        // Error message already displayed
                        return(false);
                    }

                    // Since we just loaded from a file, update the snapshot without creating an UndoAction
                    s.RecordSnapshot();
                }
            }
            return(true);
        }
Beispiel #2
0
        private void menuSprite_Duplicate_Click(object sender, EventArgs e)
        {
            Spriteset ss = ActiveSpriteset();
            Sprite    s  = ActiveSprite();

            if (s == null)
            {
                return;
            }

            Sprite sToCopy = s;
            Sprite sNew    = ss.DuplicateSprite(sToCopy, ActiveUndo());

            if (sNew != null)
            {
                sNew.RecordSnapshot();
                ss.CurrentSprite = sNew;
                HandleSpriteDataChanged(ss);
            }
        }