示例#1
0
        private void AddClick(object sender, EventArgs e)
        {
            var tempRoom = loadedFile.Rooms[this.roomComboBox.SelectedIndex];

            var spawn = tempRoom.FindSpawn(this.selectedX, this.selectedY);

            if (spawn.X != -1)
            {
                var temp = EntityStore.findByID(int.Parse(TextboxType.Text), int.Parse(TextboxVariant.Text), int.Parse(TextboxSubType.Text));
                spawn.AddEntity(temp);
                this.refreshRooms();
            }
            else
            {
                var tempspawn = new StageBinaryFile.Spawn {
                    X = (short)this.selectedX, Y = (short)this.selectedY
                };

                var tempEnt = EntityStore.findByID(int.Parse(TextboxType.Text), int.Parse(TextboxVariant.Text), int.Parse(TextboxSubType.Text));
                if (tempEnt.name != null)
                {
                    tempspawn.AddEntity(tempEnt);
                }
                tempRoom.AddSpawn(tempspawn);
                this.refreshRooms();
            }
        }
示例#2
0
        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();
            }
        }
示例#3
0
        private void InitializeComponent()
        {
            this.tabs = new TabControl();
            TabPage page = new TabPage("edit rooms");

            this.mainPanel         = new Panel();
            this.LoadButton        = new Button();
            this.EntityBox         = new ComboBox();
            this.ControlsPanel     = new Panel();
            this.WeightButton      = new Button();
            this.weightTextBox     = new TextBox();
            this.TextboxType       = new TextBox();
            this.TextboxVariant    = new TextBox();
            this.TextboxSubType    = new TextBox();
            this.RemoveButton      = new Button();
            this.addButton         = new Button();
            this.tileEntityListBox = new ListBox();
            this.LabelSubtype      = new Label();
            this.LabelVariant      = new Label();
            this.LabelType         = new Label();
            this.roomComboBox      = new ComboBox();
            this.saveButton        = new Button();
            this.TilePanel         = new Panel();


            this.mainPanel.Text = "edit rooms";
            this.mainPanel.Controls.Add(this.ControlsPanel);
            this.mainPanel.Controls.Add(TilePanel);
            page.Controls.Add(mainPanel);
            this.tabs.Controls.Add(page);
            //
            // button1
            //
            this.LoadButton.Name     = "LoadButton";
            this.LoadButton.TabIndex = 0;
            this.LoadButton.Text     = "Load File";
            this.LoadButton.UseVisualStyleBackColor = true;
            this.LoadButton.Click += this.LoadFileClick;
            //
            // comboBox1
            //
            this.EntityBox.FormattingEnabled = true;
            this.EntityBox.Name                  = "EntityBox";
            this.EntityBox.TabIndex              = 1;
            this.EntityBox.SelectedIndexChanged += (sender, args) =>
            {
                StageBinaryFile.Entity temp =
                    EntityStore.findByName(
                        this.EntityBox.SelectedItem as string);
                TextboxType.Text    = "" + temp.Type;
                TextboxVariant.Text = "" + temp.Variant;
                TextboxSubType.Text = "" + temp.Subtype;
            };
            //
            // panel1
            //
            this.ControlsPanel.Controls.Add(this.WeightButton);
            this.ControlsPanel.Controls.Add(this.weightTextBox);
            this.ControlsPanel.Controls.Add(this.TextboxType);
            this.ControlsPanel.Controls.Add(this.TextboxVariant);
            this.ControlsPanel.Controls.Add(this.TextboxSubType);
            this.ControlsPanel.Controls.Add(this.RemoveButton);
            this.ControlsPanel.Controls.Add(this.addButton);
            this.ControlsPanel.Controls.Add(this.tileEntityListBox);
            this.ControlsPanel.Controls.Add(this.LabelSubtype);
            this.ControlsPanel.Controls.Add(this.LabelVariant);
            this.ControlsPanel.Controls.Add(this.LabelType);
            this.ControlsPanel.Controls.Add(this.roomComboBox);
            this.ControlsPanel.Controls.Add(this.EntityBox);
            this.ControlsPanel.Controls.Add(this.saveButton);
            this.ControlsPanel.Controls.Add(this.LoadButton);
            this.ControlsPanel.Name     = "ControlsPanel";
            this.ControlsPanel.TabIndex = 2;

            //
            // Tile panel
            //
            this.TilePanel.Name       = "TilePanel";
            this.TilePanel.AutoScroll = true;

            //
            // button4
            //
            this.WeightButton.Name     = "WeightButton";
            this.WeightButton.TabIndex = 8;
            this.WeightButton.Text     = "set weight";
            this.WeightButton.UseVisualStyleBackColor = true;
            this.WeightButton.Click += this.SetWeight;
            //
            // textBox1
            //
            this.weightTextBox.Name      = "WeightTextbox";
            this.weightTextBox.TabIndex  = 7;
            this.TextboxType.Name        = "TextboxType";
            this.TextboxType.TabIndex    = 7;
            this.TextboxVariant.Name     = "TextboxVariant";
            this.TextboxVariant.TabIndex = 7;
            this.TextboxSubType.Name     = "TextboxSubtype";
            this.TextboxSubType.TabIndex = 7;
            //
            // button3
            //
            this.RemoveButton.Name     = "RemoveButton";
            this.RemoveButton.TabIndex = 6;
            this.RemoveButton.Text     = "REMOVE";
            this.RemoveButton.UseVisualStyleBackColor = true;
            this.RemoveButton.Click += this.RemoveClick;
            //
            // button2
            //
            this.addButton.Name     = "addButton";
            this.addButton.TabIndex = 5;
            this.addButton.Text     = "ADD";
            this.addButton.UseVisualStyleBackColor = true;
            this.addButton.Click += this.AddClick;
            //
            // listBox1
            //
            this.tileEntityListBox.FormattingEnabled = true;
            this.tileEntityListBox.Name                  = "TileEntitiesList";
            this.tileEntityListBox.TabIndex              = 4;
            this.tileEntityListBox.SelectedIndexChanged += this.SelectedEntityChanged;
            //
            // label2
            //
            this.LabelVariant.AutoSize = true;
            this.LabelVariant.Name     = "LabelVariant";
            this.LabelVariant.TabIndex = 3;
            this.LabelVariant.Text     = "Variant";

            this.LabelSubtype.AutoSize = true;
            this.LabelSubtype.Name     = "LabelSubtype";
            this.LabelSubtype.TabIndex = 3;
            this.LabelSubtype.Text     = "SubType";
            //
            // label1
            //
            this.LabelType.AutoSize = true;
            this.LabelType.Name     = "LabelType";
            this.LabelType.TabIndex = 2;
            this.LabelType.Text     = "Type";
            //
            // comboBox2
            //
            this.roomComboBox.FormattingEnabled = true;
            this.roomComboBox.Name                  = "roomComboBox";
            this.roomComboBox.TabIndex              = 1;
            this.roomComboBox.SelectedIndexChanged += this.RoomChanged;
            //
            // button5
            //
            this.saveButton.Name     = "saveButton";
            this.saveButton.TabIndex = 0;
            this.saveButton.Text     = "Save file";
            this.saveButton.UseVisualStyleBackColor = true;
            this.saveButton.Click += this.saveFile;
            //
            // Form1
            //
            //this.AutoScaleDimensions = new SizeF(6F, 13F);
            //this.AutoScaleMode = AutoScaleMode.Font;
            this.ClientSize = new Size(898, 482);
            this.Controls.Add(tabs);
            this.Name = "LevelEditor";
            this.Text = "Binding of isaac: Rebirth level editor - no level loaded";

            doLayout(this.ClientRectangle);
        }
示例#4
0
        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;
                }
            }
        }