Exemplo n.º 1
0
        public SpriteEditor(LevelEditorControl EdControl)
        {
            InitializeComponent();
            this.EdControl = EdControl;

            SSTable = ROM.GetInlineFile(ROM.Data.File_Modifiers);

            for (int i = 0; i < SpriteData.spriteNames.Count; i++)
            {
                int    ActorID = (int)ROM.GetClassIDFromTable(i);
                string sprite  = SpriteData.spriteNames[ActorID];
                spritelist[i] = i + ": " + sprite;
            }
            if (SpriteData.spriteNames.Count == 0)
            {
                string spriteText = LanguageManager.Get("SpriteEditor", "sprite");
                for (int s = 0; s < ROM.SpriteCount; s++)
                {
                    spritelist[s] = String.Format(spriteText, s);
                }
            }

            for (int l = 0; l < ROM.SpriteCount; l++)
            {
                curSprites.Add(l);
            }
            categoryList.Items.Add(LanguageManager.Get("SpriteEditor", "All"));
            categoryList.Items.Add(LanguageManager.Get("SpriteEditor", "InLevel"));
            categoryList.Items.Add(LanguageManager.Get("SpriteEditor", "InSpriteSets"));
            foreach (string cat in SpriteData.categories)
            {
                categoryList.Items.Add(cat);
            }
            categoryList.SelectedIndex = 0;

            UpdateDataEditor();
            UpdateInfo();

            LanguageManager.ApplyToContainer(this, "SpriteEditor");
            spriteTypeUpDown.Maximum = ROM.SpriteCount - 1;
        }
Exemplo n.º 2
0
        public static void Load()
        {
            if (!ROM.isNSMBRom)
            {
                return;
            }

            //Delete existing
            datas.Clear();
            datas2.Clear();
            spriteNames.Clear();
            categoryIds.Clear();
            categories.Clear();
            spritesInCategory.Clear();

            datas  = new Dictionary <int, SpriteData>();
            datas2 = new Dictionary <int, SpriteData>();

            if (!File.Exists(path))
            {
                if (MessageBox.Show(LanguageManager.Get("SpriteData", "Prompt"), LanguageManager.Get("SpriteData", "PromptTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Update();
                }
                else
                {
                    return;
                }
            }
            try
            {
                FileStream fs   = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                XmlReader  xmlr = XmlReader.Create(fs);

                string rom_spritedata_path        = Path.Combine(Properties.Settings.Default.ROMFolder, "spritedata_patch.xml");
                bool   rom_spritedata_path_exists = File.Exists(rom_spritedata_path);
                string new_spritedata_path        = Path.Combine(directory, "new_spritedata.xml");
                bool   new_spritedata_path_exists = File.Exists(new_spritedata_path);

                xmlr.ReadToFollowing("category");
                do
                {
                    int id = int.Parse(xmlr.GetAttribute("id"));
                    categoryIds.Add(id);
                    categories.Add(xmlr.ReadElementContentAsString());
                    spritesInCategory.Add(id, new List <int>());
                } while (xmlr.ReadToNextSibling("category"));

                while (xmlr.ReadToFollowing("sprite"))
                {
                    bool       found_rom_data = false;
                    SpriteData d = readFromStream(xmlr);

                    //Check for custom spritedata
                    if (rom_spritedata_path_exists)
                    {
                        FileStream fs_rom   = new FileStream(rom_spritedata_path, FileMode.Open, FileAccess.Read, FileShare.Read);
                        XmlReader  xmlr_rom = XmlReader.Create(fs_rom);
                        while (xmlr_rom.ReadToFollowing("sprite"))
                        {
                            if (int.Parse(xmlr_rom.GetAttribute("id")) == d.spriteID)
                            {
                                d = readFromStream(xmlr_rom);
                                found_rom_data = true;
                            }
                        }
                        xmlr_rom.Close();
                        fs_rom.Close();
                    }

                    //Check for updated spritedata (forced patches)
                    if (!found_rom_data)
                    {
                        if (new_spritedata_path_exists)
                        {
                            FileStream fs_new   = new FileStream(new_spritedata_path, FileMode.Open, FileAccess.Read, FileShare.Read);
                            XmlReader  xmlr_new = XmlReader.Create(fs_new);
                            while (xmlr_new.ReadToFollowing("sprite"))
                            {
                                if (int.Parse(xmlr_new.GetAttribute("id")) == d.spriteID)
                                {
                                    d = readFromStream(xmlr_new);
                                }
                            }
                            xmlr_new.Close();
                            fs_new.Close();
                        }
                    }

                    spriteNames.Add(d.name);
                    spritesInCategory[d.categoryID].Add(d.spriteID);

                    if (d != null)
                    {
                        datas2.Add(d.spriteID, d);
                    }
                }

                for (int i = 0; i < datas2.Count; i++)
                {
                    int ActorID = ROM.GetClassIDFromTable(i);
                    datas.Add(i, datas2[ActorID]);
                }

                datas2.Clear();

                xmlr.Close();
                fs.Close();
            }
            catch (Exception e)
            {
                new ErrorMSGBox(LanguageManager.Get("SpriteData", "ErrorTitle"), LanguageManager.Get("SpriteData", "ErrorParse"), "", e.ToString()).ShowDialog();
                datas.Clear();
                datas2.Clear();
            }
        }
Exemplo n.º 3
0
        public static void Load()
        {
            if (!ROM.isNSMBRom)
            {
                return;
            }

            //Delete existing
            datas.Clear();
            datas2.Clear();
            spriteNames.Clear();
            categoryIds.Clear();
            categories.Clear();
            spritesInCategory.Clear();

            datas  = new Dictionary <int, SpriteData>();
            datas2 = new Dictionary <int, SpriteData>();

            if (!File.Exists(path))
            {
                if (MessageBox.Show(LanguageManager.Get("SpriteData", "Prompt"), LanguageManager.Get("SpriteData", "PromptTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Update();
                }
                else
                {
                    return;
                }
            }
            try
            {
                FileStream fs   = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                XmlReader  xmlr = XmlReader.Create(fs);

                xmlr.ReadToFollowing("category");
                do
                {
                    int id = int.Parse(xmlr.GetAttribute("id"));
                    categoryIds.Add(id);
                    categories.Add(xmlr.ReadElementContentAsString());
                    spritesInCategory.Add(id, new List <int>());
                } while (xmlr.ReadToNextSibling("category"));

                while (xmlr.ReadToFollowing("sprite"))
                {
                    SpriteData d = readFromStream(xmlr);

                    //Check for user spritedata
                    FileStream fs_user   = new FileStream(Path.Combine(directory, "user_spritedata.xml"), FileMode.Open, FileAccess.Read, FileShare.Read);
                    XmlReader  xmlr_user = XmlReader.Create(fs_user);
                    while (xmlr_user.ReadToFollowing("sprite"))
                    {
                        if (int.Parse(xmlr_user.GetAttribute("id")) == d.spriteID)
                        {
                            d = readFromStream(xmlr_user);
                        }
                    }
                    xmlr_user.Close();
                    fs_user.Close();

                    spriteNames.Add(d.name);
                    spritesInCategory[d.categoryID].Add(d.spriteID);

                    if (d != null)
                    {
                        datas2.Add(d.spriteID, d);
                    }
                }

                for (int i = 0; i < datas2.Count; i++)
                {
                    int ActorID = ROM.GetClassIDFromTable(i);
                    datas.Add(i, datas2[ActorID]);
                }

                datas2.Clear();

                xmlr.Close();
                fs.Close();
            }
            catch (Exception e)
            {
                new ErrorMSGBox(LanguageManager.Get("SpriteData", "ErrorTitle"), LanguageManager.Get("SpriteData", "ErrorParse"), "", e.ToString()).ShowDialog();
                datas.Clear();
                datas2.Clear();
            }
        }