コード例 #1
0
ファイル: Form1.cs プロジェクト: sirius-black9999/mapedit
        public Form1()
        {
            this.InitializeComponent();
            this.Resize += (sender, args) => this.doLayout(this.ClientRectangle);
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.CloseInput = true;
            EntityStore.clearEntities();
            var fullpath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "entities2.xml");

            Debug.WriteLine(fullpath);
            if (File.Exists(fullpath))
            {
                EntityStore.LoadEntities(XmlReader.Create(File.Open(fullpath, FileMode.Open), settings));
                this.EntityBox.DataSource = EntityStore.getNames();
            }
            fullpath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "additions.xml");
            if (File.Exists(fullpath))
            {
                EntityStore.LoadEntities(XmlReader.Create(File.Open(fullpath, FileMode.Open), settings));
                this.EntityBox.DataSource = EntityStore.getNames();
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: sirius-black9999/mapedit
        private void LoadFileClick(object sender, EventArgs e)
        {
            FileDialog loadDialog = new OpenFileDialog();

            loadDialog.ShowDialog();
            if (loadDialog.FileName.Equals(""))
            {
                return;
            }
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.CloseInput = true;
            if (!loadDialog.FileName.Equals(""))
            {
                if (loadDialog.FileName.EndsWith("entities2.xml"))
                {
                    var fileToLoad = XmlReader.Create(File.Open(loadDialog.FileName, FileMode.Open), settings);
                    EntityStore.LoadEntities(fileToLoad);
                    this.EntityBox.DataSource = EntityStore.getNames();
                }
                else if (loadDialog.FileName.EndsWith("animations.b"))
                {
                    AnimationBinaryFile file = new AnimationBinaryFile();
                    file.Deserialize(File.Open(loadDialog.FileName, FileMode.Open));
                    XmlWriterSettings mySettings = new XmlWriterSettings();
                    mySettings.CloseOutput        = true;
                    mySettings.Indent             = true;
                    mySettings.OmitXmlDeclaration = true;
                    mySettings.ConformanceLevel   = ConformanceLevel.Auto;
                    StreamReader reader =
                        new StreamReader(
                            File.Open(
                                Path.Combine(
                                    Path.GetDirectoryName(Application.ExecutablePath),
                                    "animations.animlist"),
                                FileMode.Open));
                    reader.ReadLine();
                    int a = 0;
                    foreach (var type2 in file.result.unknown1)
                    {
                        a++;

                        string filename = a + ".anm2";
                        if (!reader.EndOfStream)
                        {
                            filename = reader.ReadLine();
                        }
                        filename = Path.Combine(loadDialog.FileName.Replace(".b", "_unpacked"), filename);
                        Directory.CreateDirectory(Path.GetDirectoryName(filename));

                        XmlWriter writer = XmlWriter.Create(filename, mySettings);
                        writer.WriteStartElement("AnimatedActor");
                        writer.WriteWhitespace("\n\t");
                        writer.WriteStartElement("info");
                        writer.WriteAttributeString("NameHash", type2.unknown1.ToString());
                        writer.WriteAttributeString("BasePath", type2.unknown2);
                        writer.WriteAttributeString("DefaultAnimation", type2.unknown7);
                        writer.WriteEndElement();
                        writer.WriteWhitespace("\n\t");

                        writer.WriteStartElement("content");
                        writer.WriteWhitespace("\n\t\t");
                        writer.WriteStartElement("Spritesheets");
                        foreach (var type3 in type2.unknown3)
                        {
                            writer.WriteWhitespace("\n\t\t\t");
                            writer.WriteStartElement("Spritesheet");
                            writer.WriteAttributeString("Path", type3.unknown1.ToString());
                            writer.WriteAttributeString("Id", type3.unknown2);
                            writer.WriteEndElement();
                        }
                        writer.WriteWhitespace("\n\t\t");
                        writer.WriteEndElement();

                        writer.WriteWhitespace("\n\t\t");
                        writer.WriteStartElement("Layers");
                        foreach (var type4 in type2.unknown4)
                        {
                            writer.WriteWhitespace("\n\t\t\t");
                            writer.WriteStartElement("Layer");
                            writer.WriteAttributeString("Name", type4.unknown1.ToString());
                            writer.WriteAttributeString("Id", type4.unknown2.ToString());
                            writer.WriteAttributeString("SpritesheetId", type4.unknown3);
                            writer.WriteEndElement();
                        }
                        writer.WriteWhitespace("\n\t\t");
                        writer.WriteEndElement();



                        writer.WriteWhitespace("\n\t\t");
                        writer.WriteStartElement("Nulls");
                        foreach (var type5 in type2.unknown5)
                        {
                            writer.WriteWhitespace("\n\t\t\t");
                            writer.WriteStartElement("Null");
                            writer.WriteAttributeString("Id", type5.unknown1.ToString());
                            writer.WriteAttributeString("Name", type5.unknown2);
                            writer.WriteEndElement();
                        }

                        writer.WriteWhitespace("\n\t\t");
                        writer.WriteEndElement();

                        writer.WriteWhitespace("\n\t\t");
                        writer.WriteStartElement("Events");
                        foreach (var type6 in type2.unknown6)
                        {
                            writer.WriteWhitespace("\n\t\t\t");
                            writer.WriteStartElement("Event");
                            writer.WriteAttributeString("Id", type6.unknown1.ToString());
                            writer.WriteAttributeString("Name", type6.unknown2);
                            writer.WriteEndElement();
                        }
                        writer.WriteWhitespace("\n\t\t");
                        writer.WriteEndElement();

                        writer.WriteWhitespace("\n\t\t");
                        writer.WriteStartElement("Animations");
                        foreach (var type7 in type2.unknown8)
                        {
                            writer.WriteWhitespace("\n\t\t\t");
                            writer.WriteStartElement("Animation");
                            writer.WriteAttributeString("Name", type7.unknown1);
                            writer.WriteAttributeString("FrameNum", type7.unknown2.ToString());
                            writer.WriteAttributeString("Loop", type7.unknown3.ToString());
                            writer.WriteStartElement("RootAnimation");
                            foreach (var type8 in type7.unknown4)
                            {
                                writer.WriteWhitespace("\n\t\t\t\t");
                                writer.WriteStartElement("RootFrame");
                                writer.WriteAttributeString("XPosition", type8.unknown1.ToString());
                                writer.WriteAttributeString("YPosition", type8.unknown2.ToString());
                                writer.WriteAttributeString("Delay", type8.unknown3.ToString());
                                writer.WriteAttributeString("Visible", type8.unknown4.ToString());
                                writer.WriteAttributeString("XScale", type8.unknown5.ToString());
                                writer.WriteAttributeString("YScale", type8.unknown6.ToString());
                                writer.WriteAttributeString("RedTint", type8.unknown7.ToString());
                                writer.WriteAttributeString("GreenTint", type8.unknown8.ToString());
                                writer.WriteAttributeString("BlueTint", type8.unknown9.ToString());
                                writer.WriteAttributeString("AlphaTint", type8.unknown10.ToString());
                                writer.WriteAttributeString("RedOffset", type8.unknown11.ToString());
                                writer.WriteAttributeString("GreenOffset", type8.unknown12.ToString());
                                writer.WriteAttributeString("BlueOffset", type8.unknown13.ToString());
                                writer.WriteAttributeString("Rotation", type8.unknown14.ToString());
                                writer.WriteAttributeString("Interpolated", type8.unknown15.ToString());
                                writer.WriteEndElement();
                            }

                            writer.WriteWhitespace("\n\t\t\t");
                            writer.WriteEndElement();
                            writer.WriteWhitespace("\n\t\t\t");

                            writer.WriteStartElement("LayerAnimations");
                            foreach (var type9 in type7.unknown5)
                            {
                                writer.WriteWhitespace("\n\t\t\t\t");
                                writer.WriteStartElement("Layer");
                                writer.WriteAttributeString("LayerID", type9.unknown1.ToString());
                                writer.WriteAttributeString("Visible", type9.unknown2.ToString());
                                writer.WriteWhitespace("\n\t\t\t\t\t");
                                writer.WriteStartElement("KeyFrames");
                                foreach (var type10 in type9.unknown3)
                                {
                                    writer.WriteWhitespace("\n\t\t\t\t\t\t");
                                    writer.WriteStartElement("Frame");
                                    writer.WriteAttributeString("XPosition", type10.unknown1.ToString());
                                    writer.WriteAttributeString("YPosition", type10.unknown2.ToString());
                                    writer.WriteAttributeString("XPivot", type10.unknown3.ToString());
                                    writer.WriteAttributeString("YPivot", type10.unknown4.ToString());
                                    writer.WriteAttributeString("Width", type10.unknown5.ToString());
                                    writer.WriteAttributeString("Height", type10.unknown6.ToString());
                                    writer.WriteAttributeString("XScale", type10.unknown7.ToString());
                                    writer.WriteAttributeString("YScale", type10.unknown8.ToString());
                                    writer.WriteAttributeString("Delay", type10.unknown9.ToString());
                                    writer.WriteAttributeString("Visible", type10.unknown10.ToString());
                                    writer.WriteAttributeString("XCrop", type10.unknown11.ToString());
                                    writer.WriteAttributeString("YCrop", type10.unknown12.ToString());
                                    writer.WriteAttributeString("RedTint", type10.unknown13.ToString());
                                    writer.WriteAttributeString("GreenTint", type10.unknown14.ToString());
                                    writer.WriteAttributeString("BlueTint", type10.unknown15.ToString());
                                    writer.WriteAttributeString("AlphaTint", type10.unknown16.ToString());
                                    writer.WriteAttributeString("RedOffset", type10.unknown17.ToString());
                                    writer.WriteAttributeString("GreenOffset", type10.unknown18.ToString());
                                    writer.WriteAttributeString("BlueOffset", type10.unknown19.ToString());
                                    writer.WriteAttributeString("AlphaOffset", type10.unknown20.ToString());
                                    writer.WriteAttributeString("Rotation", type10.unknown21.ToString());
                                    writer.WriteAttributeString("Interpolated", type10.unknown21.ToString());
                                    writer.WriteEndElement();
                                }

                                writer.WriteWhitespace("\n\t\t\t\t\t");
                                writer.WriteEndElement();
                                writer.WriteWhitespace("\n\t\t\t\t");
                                writer.WriteEndElement();
                            }

                            writer.WriteWhitespace("\n\t\t\t");
                            writer.WriteEndElement();
                            foreach (var type11 in type7.unknown6)
                            {
                                writer.WriteWhitespace("\n\t\t\t");
                                writer.WriteStartElement("NullAnimations");
                                writer.WriteAttributeString("NullId", type7.unknown2.ToString());
                                writer.WriteAttributeString("Visible", type7.unknown3.ToString());
                                foreach (var type8 in type11.unknown3)
                                {
                                    writer.WriteWhitespace("\n\t\t\t\t");
                                    writer.WriteStartElement("NullFrame");
                                    writer.WriteAttributeString("XPosition", type8.unknown1.ToString());
                                    writer.WriteAttributeString("YPosition", type8.unknown2.ToString());
                                    writer.WriteAttributeString("Delay", type8.unknown3.ToString());
                                    writer.WriteAttributeString("Visible", type8.unknown4.ToString());
                                    writer.WriteAttributeString("XScale", type8.unknown5.ToString());
                                    writer.WriteAttributeString("YScale", type8.unknown6.ToString());
                                    writer.WriteAttributeString("RedTint", type8.unknown7.ToString());
                                    writer.WriteAttributeString("GreenTint", type8.unknown8.ToString());
                                    writer.WriteAttributeString("BlueTint", type8.unknown9.ToString());
                                    writer.WriteAttributeString("AlphaTint", type8.unknown10.ToString());
                                    writer.WriteAttributeString("RedOffset", type8.unknown11.ToString());
                                    writer.WriteAttributeString("GreenOffset", type8.unknown12.ToString());
                                    writer.WriteAttributeString("BlueOffset", type8.unknown13.ToString());
                                    writer.WriteAttributeString("Rotation", type8.unknown14.ToString());
                                    writer.WriteAttributeString("Interpolated", type8.unknown15.ToString());
                                    writer.WriteEndElement();
                                }
                                writer.WriteWhitespace("\n\t\t\t");
                                writer.WriteEndElement();
                            }


                            writer.WriteWhitespace("\n\t\t\t");
                            writer.WriteStartElement("Triggers");
                            foreach (var type11 in type7.unknown7)
                            {
                                writer.WriteWhitespace("\n\t\t\t\t");
                                writer.WriteStartElement("Trigger");
                                writer.WriteAttributeString("EventId", type11.unknown1.ToString());
                                writer.WriteAttributeString("AtFrame", type11.unknown2.ToString());
                                writer.WriteEndElement();
                            }
                            writer.WriteWhitespace("\n\t\t\t");
                            writer.WriteEndElement();
                            writer.WriteWhitespace("\n\t\t");
                            writer.WriteEndElement();
                        }
                        writer.WriteWhitespace("\n\t");
                        writer.WriteEndElement();
                        writer.WriteWhitespace("\n");
                        writer.WriteEndElement();
                        writer.Close();
                    }
                    reader.Close();
                }
                else
                {
                    loadedFile = new StageBinaryFile();
                    loadedFile.Deserialize(File.Open(loadDialog.FileName, FileMode.Open));


                    this.Text = "Binding of isaac: Rebirth level editor - "
                                + Path.GetFileNameWithoutExtension(loadDialog.FileName);
                    this.roomComboBox.DataSource = loadedFile.RoomNames;
                }
            }
        }