From e171a46eac4061cf097253e73f06f35c9af95bae Mon Sep 17 00:00:00 2001 From: 1987kostya Date: Wed, 9 Dec 2020 11:05:54 +0600 Subject: [PATCH] GUI refactor, ImageBank refactor, MIDI support, ObjectInfo refactor --- NetMFAPatcher/DotNetCTFDumper.csproj | 7 +- NetMFAPatcher/GUI/ChunkNode.cs | 6 +- NetMFAPatcher/GUI/CryptoKeyForm.Designer.cs | 7 +- NetMFAPatcher/GUI/CryptoKeyForm.cs | 5 +- NetMFAPatcher/GUI/HexViewForm.Designer.cs | 6 +- NetMFAPatcher/GUI/HexViewForm.cs | 5 +- NetMFAPatcher/GUI/MainForm.Designer.cs | 327 +++++++++--------- NetMFAPatcher/GUI/MainForm.cs | 294 +++++++++------- NetMFAPatcher/GUI/MainForm.resx | 9 - NetMFAPatcher/GUI/PackDataForm.Designer.cs | 7 +- NetMFAPatcher/GUI/PackDataForm.cs | 9 +- .../MMFParser/ChunkLoaders/Events/Events.cs | 9 +- .../ChunkLoaders/Events/EventsParts.cs | 12 +- .../Events/Expressions/Expression.cs | 6 +- .../Events/Parameters/AlterableValue.cs | 8 +- .../ChunkLoaders/Events/Parameters/Colour.cs | 4 +- .../ChunkLoaders/Events/Parameters/Create.cs | 4 +- .../ChunkLoaders/Events/Parameters/Every.cs | 4 +- .../ChunkLoaders/Events/Parameters/Float.cs | 4 +- .../Events/Parameters/GlobalValue.cs | 4 +- .../ChunkLoaders/Events/Parameters/Int.cs | 4 +- .../Events/Parameters/ParamObject.cs | 4 +- .../Events/Parameters/ParameterCommon.cs | 6 +- .../Events/Parameters/Position.cs | 4 +- .../ChunkLoaders/Events/Parameters/Remark.cs | 4 +- .../ChunkLoaders/Events/Parameters/Sample.cs | 4 +- .../ChunkLoaders/Events/Parameters/Short.cs | 4 +- .../ChunkLoaders/Events/Parameters/Time.cs | 4 +- .../MMFParser/ChunkLoaders/ExtData.cs | 8 +- .../MMFParser/ChunkLoaders/Globals.cs | 9 +- .../MMFParser/ChunkLoaders/ObjectNames.cs | 11 +- .../ChunkLoaders/Objects/Animations.cs | 10 +- .../ChunkLoaders/Objects/Backdrop.cs | 59 ++++ .../ChunkLoaders/Objects/Counters.cs | 109 ++++++ .../ChunkLoaders/Objects/ObjectCommon.cs | 194 +++++------ .../MMFParser/ChunkLoaders/Objects/Value.cs | 7 +- NetMFAPatcher/MMFParser/Data/ChunkList.cs | 56 +-- NetMFAPatcher/MMFParser/Data/DataLoader.cs | 6 +- NetMFAPatcher/MMFParser/Data/EXE.cs | 14 +- NetMFAPatcher/MMFParser/Data/GameData.cs | 59 ++-- NetMFAPatcher/MMFParser/Data/MFA.cs | 28 +- NetMFAPatcher/MMFParser/Data/PackData.cs | 11 +- .../MMFParser/Decompiling/MFAGenerator.cs | 10 +- .../MMFParser/Decompiling/PAME2MFA.cs | 4 +- NetMFAPatcher/Program.cs | 23 +- NetMFAPatcher/Settings.cs | 10 +- NetMFAPatcher/Utils/BitDict.cs | 2 +- NetMFAPatcher/Utils/ByteFlag.cs | 2 +- NetMFAPatcher/Utils/ByteReader.cs | 2 +- NetMFAPatcher/Utils/ByteWriter.cs | 2 +- NetMFAPatcher/Utils/Decompressor.cs | 3 +- NetMFAPatcher/Utils/Decryption.cs | 5 +- NetMFAPatcher/Utils/Helper.cs | 29 +- NetMFAPatcher/Utils/ImageDumper.cs | 127 +++++-- NetMFAPatcher/Utils/ImageHelper.cs | 11 +- NetMFAPatcher/Utils/Logger.cs | 2 +- NetMFAPatcher/mmfparser/Constants.cs | 10 +- .../mmfparser/chunkloaders/AppHeader.cs | 25 +- .../mmfparser/chunkloaders/AppMenu.cs | 12 +- .../mmfparser/chunkloaders/ChunkLoader.cs | 17 +- NetMFAPatcher/mmfparser/chunkloaders/Frame.cs | 50 ++- .../mmfparser/chunkloaders/FrameItems.cs | 30 +- .../mmfparser/chunkloaders/ObjectInfo.cs | 41 ++- .../mmfparser/chunkloaders/StringChunk.cs | 12 +- .../mmfparser/chunkloaders/banks/FontBank.cs | 6 +- .../mmfparser/chunkloaders/banks/ImageBank.cs | 51 +-- .../mmfparser/chunkloaders/banks/MusicBank.cs | 56 ++- .../mmfparser/chunkloaders/banks/SoundBank.cs | 21 +- NetMFAPatcher/mmfparser/chunkloaders/yves.cs | 14 +- .../mmfparser/mfaloaders/ChunkList.cs | 6 +- .../mmfparser/mfaloaders/Controls.cs | 7 +- NetMFAPatcher/mmfparser/mfaloaders/Frame.cs | 6 +- .../mmfparser/mfaloaders/FrameItem.cs | 8 +- .../mmfparser/mfaloaders/ImageBank.cs | 11 +- NetMFAPatcher/mmfparser/mfaloaders/Layer.cs | 6 +- .../mmfparser/mfaloaders/ValueList.cs | 6 +- .../mmfparser/mfaloaders/mfachunks/Active.cs | 4 +- .../mfaloaders/mfachunks/AnimationObject.cs | 6 +- .../mfaloaders/mfachunks/Behaviours.cs | 6 +- .../mfaloaders/mfachunks/Movements.cs | 6 +- .../mfaloaders/mfachunks/ObjectLoader.cs | 6 +- 81 files changed, 1158 insertions(+), 849 deletions(-) create mode 100644 NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Backdrop.cs create mode 100644 NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Counters.cs diff --git a/NetMFAPatcher/DotNetCTFDumper.csproj b/NetMFAPatcher/DotNetCTFDumper.csproj index 3640951..9761aae 100644 --- a/NetMFAPatcher/DotNetCTFDumper.csproj +++ b/NetMFAPatcher/DotNetCTFDumper.csproj @@ -9,7 +9,7 @@ AnyCPU {86D99F9E-98FB-4E50-AB68-F5C115850C33} Exe - NetMFAPatcher + DotNetCTFDumper DotNetCTFDumper v4.7.2 512 @@ -67,12 +67,13 @@ bin\x64\Release\ TRACE true - none + full x64 7.3 prompt MinimumRecommendedRules.ruleset true + true @@ -147,6 +148,8 @@ + + diff --git a/NetMFAPatcher/GUI/ChunkNode.cs b/NetMFAPatcher/GUI/ChunkNode.cs index 166f0da..fb4ef2f 100644 --- a/NetMFAPatcher/GUI/ChunkNode.cs +++ b/NetMFAPatcher/GUI/ChunkNode.cs @@ -1,8 +1,8 @@ using System.Windows.Forms; -using NetMFAPatcher.MMFParser.ChunkLoaders; -using NetMFAPatcher.MMFParser.Data; +using DotNetCTFDumper.MMFParser.ChunkLoaders; +using DotNetCTFDumper.MMFParser.Data; -namespace NetMFAPatcher.GUI +namespace DotNetCTFDumper.GUI { public class ChunkNode:TreeNode { diff --git a/NetMFAPatcher/GUI/CryptoKeyForm.Designer.cs b/NetMFAPatcher/GUI/CryptoKeyForm.Designer.cs index f9fdb04..055aa7b 100644 --- a/NetMFAPatcher/GUI/CryptoKeyForm.Designer.cs +++ b/NetMFAPatcher/GUI/CryptoKeyForm.Designer.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace NetMFAPatcher.GUI +namespace DotNetCTFDumper.GUI { partial class CryptoKeyForm { @@ -43,6 +43,7 @@ namespace NetMFAPatcher.GUI this.charBox.BackColor = System.Drawing.Color.Black; this.charBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.charBox.Dock = System.Windows.Forms.DockStyle.Top; + this.charBox.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.charBox.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.charBox.Location = new System.Drawing.Point(0, 0); this.charBox.Name = "charBox"; @@ -57,7 +58,7 @@ namespace NetMFAPatcher.GUI this.hexBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.hexBox1.ColumnInfoVisible = true; this.hexBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.hexBox1.Font = new System.Drawing.Font("Segoe UI", 9F); + this.hexBox1.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.hexBox1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.hexBox1.LineInfoVisible = true; this.hexBox1.Location = new System.Drawing.Point(0, 20); @@ -75,6 +76,7 @@ namespace NetMFAPatcher.GUI this.plusButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.plusButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); this.plusButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.plusButton.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.plusButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.plusButton.Location = new System.Drawing.Point(616, 0); this.plusButton.Name = "plusButton"; @@ -89,6 +91,7 @@ namespace NetMFAPatcher.GUI this.minusButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.minusButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); this.minusButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.minusButton.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.minusButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.minusButton.Location = new System.Drawing.Point(589, 0); this.minusButton.Name = "minusButton"; diff --git a/NetMFAPatcher/GUI/CryptoKeyForm.cs b/NetMFAPatcher/GUI/CryptoKeyForm.cs index 326d954..470f1bb 100644 --- a/NetMFAPatcher/GUI/CryptoKeyForm.cs +++ b/NetMFAPatcher/GUI/CryptoKeyForm.cs @@ -1,11 +1,10 @@ using System; using System.Drawing; -using System.Text; using System.Windows.Forms; using Be.Windows.Forms; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.GUI +namespace DotNetCTFDumper.GUI { public partial class CryptoKeyForm : Form { diff --git a/NetMFAPatcher/GUI/HexViewForm.Designer.cs b/NetMFAPatcher/GUI/HexViewForm.Designer.cs index 3104ea1..cabc1e6 100644 --- a/NetMFAPatcher/GUI/HexViewForm.Designer.cs +++ b/NetMFAPatcher/GUI/HexViewForm.Designer.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace NetMFAPatcher.GUI +namespace DotNetCTFDumper.GUI { partial class HexViewForm { @@ -40,6 +40,7 @@ namespace NetMFAPatcher.GUI // rawBox // this.rawBox.Dock = System.Windows.Forms.DockStyle.Top; + this.rawBox.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.rawBox.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.rawBox.Location = new System.Drawing.Point(0, 0); this.rawBox.Name = "rawBox"; @@ -55,7 +56,7 @@ namespace NetMFAPatcher.GUI this.hexBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.hexBox1.ColumnInfoVisible = true; this.hexBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.hexBox1.Font = new System.Drawing.Font("Segoe UI", 9F); + this.hexBox1.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.hexBox1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.hexBox1.LineInfoVisible = true; this.hexBox1.Location = new System.Drawing.Point(0, 28); @@ -72,6 +73,7 @@ namespace NetMFAPatcher.GUI // sizeLabel // this.sizeLabel.Dock = System.Windows.Forms.DockStyle.Bottom; + this.sizeLabel.Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.sizeLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.sizeLabel.Location = new System.Drawing.Point(0, 369); this.sizeLabel.Name = "sizeLabel"; diff --git a/NetMFAPatcher/GUI/HexViewForm.cs b/NetMFAPatcher/GUI/HexViewForm.cs index 81817fb..bbada4f 100644 --- a/NetMFAPatcher/GUI/HexViewForm.cs +++ b/NetMFAPatcher/GUI/HexViewForm.cs @@ -1,12 +1,11 @@ using System; using System.ComponentModel.Design; using System.Drawing; -using System.Text; using System.Windows.Forms; using Be.Windows.Forms; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.GUI +namespace DotNetCTFDumper.GUI { public partial class HexViewForm : Form { diff --git a/NetMFAPatcher/GUI/MainForm.Designer.cs b/NetMFAPatcher/GUI/MainForm.Designer.cs index abde6c8..1738641 100644 --- a/NetMFAPatcher/GUI/MainForm.Designer.cs +++ b/NetMFAPatcher/GUI/MainForm.Designer.cs @@ -1,7 +1,4 @@ -using System; -using System.Windows.Forms; - -namespace NetMFAPatcher.GUI +namespace DotNetCTFDumper.GUI { partial class MainForm { @@ -39,17 +36,14 @@ namespace NetMFAPatcher.GUI this.listBox1 = new System.Windows.Forms.ListBox(); this.GameInfo = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); - this.ImageBox = new System.Windows.Forms.CheckBox(); - this.SoundBox = new System.Windows.Forms.CheckBox(); - this.ChunkBox = new System.Windows.Forms.CheckBox(); - this.ImagesBar = new System.Windows.Forms.ProgressBar(); - this.ImagesLabel = new System.Windows.Forms.Label(); - this.SoundsLabel = new System.Windows.Forms.Label(); - this.SoundBar = new System.Windows.Forms.ProgressBar(); + this.imageBar = new System.Windows.Forms.ProgressBar(); + this.imageLabel = new System.Windows.Forms.Label(); + this.soundLabel = new System.Windows.Forms.Label(); + this.soundBar = new System.Windows.Forms.ProgressBar(); this.FolderBTN = new System.Windows.Forms.Button(); this.MFABtn = new System.Windows.Forms.Button(); - this.SoundsButton = new System.Windows.Forms.Button(); - this.ImagesButton = new System.Windows.Forms.Button(); + this.soundsButton = new System.Windows.Forms.Button(); + this.imagesButton = new System.Windows.Forms.Button(); this.loadingLabel = new System.Windows.Forms.Label(); this.cryptKeyBtn = new System.Windows.Forms.Button(); this.showHexBtn = new System.Windows.Forms.Button(); @@ -58,6 +52,9 @@ namespace NetMFAPatcher.GUI this.saveChunkBtn = new System.Windows.Forms.ToolStripMenuItem(); this.viewHexBtn = new System.Windows.Forms.ToolStripMenuItem(); this.packDataBtn = new System.Windows.Forms.Button(); + this.musicsButton = new System.Windows.Forms.Button(); + this.musicBar = new System.Windows.Forms.ProgressBar(); + this.musicLabel = new System.Windows.Forms.Label(); this.ChunkCombo.SuspendLayout(); this.SuspendLayout(); // @@ -143,100 +140,61 @@ namespace NetMFAPatcher.GUI this.label1.TabIndex = 4; this.label1.Text = "CTFDumper 0.1.1 Debug"; // - // ImageBox - // - this.ImageBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.ImageBox.ForeColor = System.Drawing.Color.Lime; - this.ImageBox.Location = new System.Drawing.Point(9, 239); - this.ImageBox.Name = "ImageBox"; - this.ImageBox.Size = new System.Drawing.Size(104, 24); - this.ImageBox.TabIndex = 5; - this.ImageBox.Text = "Dump Images"; - this.ImageBox.UseVisualStyleBackColor = true; - this.ImageBox.Visible = false; - this.ImageBox.CheckedChanged += new System.EventHandler(this.ImageBox_CheckedChanged); - // - // SoundBox - // - this.SoundBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.SoundBox.ForeColor = System.Drawing.Color.Lime; - this.SoundBox.Location = new System.Drawing.Point(9, 269); - this.SoundBox.Name = "SoundBox"; - this.SoundBox.Size = new System.Drawing.Size(104, 24); - this.SoundBox.TabIndex = 6; - this.SoundBox.Text = "Dump Sounds"; - this.SoundBox.UseVisualStyleBackColor = true; - this.SoundBox.Visible = false; - this.SoundBox.CheckedChanged += new System.EventHandler(this.SoundBox_CheckedChanged); - // - // ChunkBox - // - this.ChunkBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.ChunkBox.ForeColor = System.Drawing.Color.Lime; - this.ChunkBox.Location = new System.Drawing.Point(9, 299); - this.ChunkBox.Name = "ChunkBox"; - this.ChunkBox.Size = new System.Drawing.Size(104, 24); - this.ChunkBox.TabIndex = 7; - this.ChunkBox.Text = "Export Chunks\r\n"; - this.ChunkBox.UseVisualStyleBackColor = true; - this.ChunkBox.Visible = false; - this.ChunkBox.CheckedChanged += new System.EventHandler(this.ChunkBox_CheckedChanged); - // - // ImagesBar - // - this.ImagesBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.ImagesBar.BackColor = System.Drawing.Color.Black; - this.ImagesBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.ImagesBar.Location = new System.Drawing.Point(190, 367); - this.ImagesBar.Name = "ImagesBar"; - this.ImagesBar.Size = new System.Drawing.Size(126, 23); - this.ImagesBar.Step = 2; - this.ImagesBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.ImagesBar.TabIndex = 8; - this.ImagesBar.Visible = false; - // - // ImagesLabel - // - this.ImagesLabel.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.ImagesLabel.BackColor = System.Drawing.Color.Transparent; - this.ImagesLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.ImagesLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); - this.ImagesLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.ImagesLabel.Location = new System.Drawing.Point(322, 367); - this.ImagesLabel.Name = "ImagesLabel"; - this.ImagesLabel.Size = new System.Drawing.Size(126, 24); - this.ImagesLabel.TabIndex = 9; - this.ImagesLabel.Text = "0/0"; - this.ImagesLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.ImagesLabel.Visible = false; - // - // SoundsLabel - // - this.SoundsLabel.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.SoundsLabel.BackColor = System.Drawing.Color.Black; - this.SoundsLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.SoundsLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); - this.SoundsLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.SoundsLabel.Location = new System.Drawing.Point(322, 415); - this.SoundsLabel.Name = "SoundsLabel"; - this.SoundsLabel.Size = new System.Drawing.Size(126, 24); - this.SoundsLabel.TabIndex = 11; - this.SoundsLabel.Text = "0/0"; - this.SoundsLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.SoundsLabel.Visible = false; - // - // SoundBar - // - this.SoundBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.SoundBar.BackColor = System.Drawing.Color.Black; - this.SoundBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.SoundBar.Location = new System.Drawing.Point(190, 415); - this.SoundBar.Name = "SoundBar"; - this.SoundBar.Size = new System.Drawing.Size(126, 23); - this.SoundBar.Step = 2; - this.SoundBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.SoundBar.TabIndex = 10; - this.SoundBar.Visible = false; + // imageBar + // + this.imageBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.imageBar.BackColor = System.Drawing.Color.Black; + this.imageBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); + this.imageBar.Location = new System.Drawing.Point(190, 367); + this.imageBar.Name = "imageBar"; + this.imageBar.Size = new System.Drawing.Size(126, 23); + this.imageBar.Step = 2; + this.imageBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.imageBar.TabIndex = 8; + this.imageBar.Visible = false; + // + // imageLabel + // + this.imageLabel.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.imageLabel.BackColor = System.Drawing.Color.Transparent; + this.imageLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.imageLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); + this.imageLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); + this.imageLabel.Location = new System.Drawing.Point(322, 367); + this.imageLabel.Name = "imageLabel"; + this.imageLabel.Size = new System.Drawing.Size(126, 24); + this.imageLabel.TabIndex = 9; + this.imageLabel.Text = "0/0"; + this.imageLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.imageLabel.Visible = false; + // + // soundLabel + // + this.soundLabel.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.soundLabel.BackColor = System.Drawing.Color.Black; + this.soundLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.soundLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); + this.soundLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); + this.soundLabel.Location = new System.Drawing.Point(322, 415); + this.soundLabel.Name = "soundLabel"; + this.soundLabel.Size = new System.Drawing.Size(126, 24); + this.soundLabel.TabIndex = 11; + this.soundLabel.Text = "0/0"; + this.soundLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.soundLabel.Visible = false; + // + // soundBar + // + this.soundBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.soundBar.BackColor = System.Drawing.Color.Black; + this.soundBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); + this.soundBar.Location = new System.Drawing.Point(190, 415); + this.soundBar.Name = "soundBar"; + this.soundBar.Size = new System.Drawing.Size(126, 23); + this.soundBar.Step = 2; + this.soundBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.soundBar.TabIndex = 10; + this.soundBar.Visible = false; // // FolderBTN // @@ -245,7 +203,7 @@ namespace NetMFAPatcher.GUI this.FolderBTN.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.FolderBTN.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.FolderBTN.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.FolderBTN.Location = new System.Drawing.Point(190, 453); + this.FolderBTN.Location = new System.Drawing.Point(101, 309); this.FolderBTN.Name = "FolderBTN"; this.FolderBTN.Size = new System.Drawing.Size(83, 42); this.FolderBTN.TabIndex = 12; @@ -258,10 +216,11 @@ namespace NetMFAPatcher.GUI // this.MFABtn.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.MFABtn.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); + this.MFABtn.Enabled = false; this.MFABtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.MFABtn.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.MFABtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.MFABtn.Location = new System.Drawing.Point(101, 453); + this.MFABtn.Location = new System.Drawing.Point(12, 453); this.MFABtn.Name = "MFABtn"; this.MFABtn.Size = new System.Drawing.Size(83, 42); this.MFABtn.TabIndex = 13; @@ -270,37 +229,37 @@ namespace NetMFAPatcher.GUI this.MFABtn.Visible = false; this.MFABtn.Click += new System.EventHandler(this.MFABtn_Click); // - // SoundsButton - // - this.SoundsButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.SoundsButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); - this.SoundsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.SoundsButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); - this.SoundsButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.SoundsButton.Location = new System.Drawing.Point(101, 405); - this.SoundsButton.Name = "SoundsButton"; - this.SoundsButton.Size = new System.Drawing.Size(83, 42); - this.SoundsButton.TabIndex = 14; - this.SoundsButton.Text = "Dump Sounds"; - this.SoundsButton.UseVisualStyleBackColor = false; - this.SoundsButton.Visible = false; - this.SoundsButton.Click += new System.EventHandler(this.SoundsButton_Click); - // - // ImagesButton - // - this.ImagesButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.ImagesButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); - this.ImagesButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.ImagesButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); - this.ImagesButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.ImagesButton.Location = new System.Drawing.Point(101, 357); - this.ImagesButton.Name = "ImagesButton"; - this.ImagesButton.Size = new System.Drawing.Size(83, 42); - this.ImagesButton.TabIndex = 15; - this.ImagesButton.Text = "Dump\r\nImages"; - this.ImagesButton.UseVisualStyleBackColor = false; - this.ImagesButton.Visible = false; - this.ImagesButton.Click += new System.EventHandler(this.ImagesButton_Click); + // soundsButton + // + this.soundsButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.soundsButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); + this.soundsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.soundsButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); + this.soundsButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); + this.soundsButton.Location = new System.Drawing.Point(101, 405); + this.soundsButton.Name = "soundsButton"; + this.soundsButton.Size = new System.Drawing.Size(83, 42); + this.soundsButton.TabIndex = 14; + this.soundsButton.Text = "Dump Sounds"; + this.soundsButton.UseVisualStyleBackColor = false; + this.soundsButton.Visible = false; + this.soundsButton.Click += new System.EventHandler(this.soundsButton_Click); + // + // imagesButton + // + this.imagesButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.imagesButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); + this.imagesButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.imagesButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); + this.imagesButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); + this.imagesButton.Location = new System.Drawing.Point(101, 357); + this.imagesButton.Name = "imagesButton"; + this.imagesButton.Size = new System.Drawing.Size(83, 42); + this.imagesButton.TabIndex = 15; + this.imagesButton.Text = "Dump\r\nImages"; + this.imagesButton.UseVisualStyleBackColor = false; + this.imagesButton.Visible = false; + this.imagesButton.Click += new System.EventHandler(this.imagesButton_Click); // // loadingLabel // @@ -321,7 +280,7 @@ namespace NetMFAPatcher.GUI this.cryptKeyBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.cryptKeyBtn.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.cryptKeyBtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.cryptKeyBtn.Location = new System.Drawing.Point(12, 405); + this.cryptKeyBtn.Location = new System.Drawing.Point(12, 357); this.cryptKeyBtn.Name = "cryptKeyBtn"; this.cryptKeyBtn.Size = new System.Drawing.Size(83, 42); this.cryptKeyBtn.TabIndex = 17; @@ -352,7 +311,7 @@ namespace NetMFAPatcher.GUI this.dumpSortedBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.dumpSortedBtn.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.dumpSortedBtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.dumpSortedBtn.Location = new System.Drawing.Point(12, 453); + this.dumpSortedBtn.Location = new System.Drawing.Point(12, 405); this.dumpSortedBtn.Name = "dumpSortedBtn"; this.dumpSortedBtn.Size = new System.Drawing.Size(83, 42); this.dumpSortedBtn.TabIndex = 19; @@ -388,7 +347,7 @@ namespace NetMFAPatcher.GUI this.packDataBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.packDataBtn.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.packDataBtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); - this.packDataBtn.Location = new System.Drawing.Point(12, 357); + this.packDataBtn.Location = new System.Drawing.Point(12, 309); this.packDataBtn.Name = "packDataBtn"; this.packDataBtn.Size = new System.Drawing.Size(83, 42); this.packDataBtn.TabIndex = 20; @@ -397,28 +356,72 @@ namespace NetMFAPatcher.GUI this.packDataBtn.Visible = false; this.packDataBtn.Click += new System.EventHandler(this.packDataBtn_Click); // + // musicsButton + // + this.musicsButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.musicsButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); + this.musicsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.musicsButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); + this.musicsButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); + this.musicsButton.Location = new System.Drawing.Point(101, 453); + this.musicsButton.Name = "musicsButton"; + this.musicsButton.Size = new System.Drawing.Size(83, 42); + this.musicsButton.TabIndex = 21; + this.musicsButton.Text = "Dump Musics"; + this.musicsButton.UseVisualStyleBackColor = false; + this.musicsButton.Visible = false; + this.musicsButton.Click += new System.EventHandler(this.musicsButton_Click); + // + // musicBar + // + this.musicBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.musicBar.BackColor = System.Drawing.Color.Black; + this.musicBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); + this.musicBar.Location = new System.Drawing.Point(190, 463); + this.musicBar.Name = "musicBar"; + this.musicBar.Size = new System.Drawing.Size(126, 23); + this.musicBar.Step = 2; + this.musicBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.musicBar.TabIndex = 22; + this.musicBar.Visible = false; + // + // musicLabel + // + this.musicLabel.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.musicLabel.BackColor = System.Drawing.Color.Black; + this.musicLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.musicLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); + this.musicLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); + this.musicLabel.Location = new System.Drawing.Point(322, 463); + this.musicLabel.Name = "musicLabel"; + this.musicLabel.Size = new System.Drawing.Size(126, 24); + this.musicLabel.TabIndex = 23; + this.musicLabel.Text = "0/0"; + this.musicLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.musicLabel.Visible = false; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(943, 507); + this.Controls.Add(this.musicLabel); + this.Controls.Add(this.musicBar); + this.Controls.Add(this.musicsButton); this.Controls.Add(this.packDataBtn); this.Controls.Add(this.dumpSortedBtn); this.Controls.Add(this.showHexBtn); this.Controls.Add(this.cryptKeyBtn); this.Controls.Add(this.loadingLabel); - this.Controls.Add(this.ImagesButton); - this.Controls.Add(this.SoundsButton); + this.Controls.Add(this.imagesButton); + this.Controls.Add(this.soundsButton); this.Controls.Add(this.MFABtn); this.Controls.Add(this.FolderBTN); - this.Controls.Add(this.SoundsLabel); - this.Controls.Add(this.SoundBar); - this.Controls.Add(this.ImagesLabel); - this.Controls.Add(this.ImagesBar); - this.Controls.Add(this.ChunkBox); - this.Controls.Add(this.SoundBox); - this.Controls.Add(this.ImageBox); + this.Controls.Add(this.soundLabel); + this.Controls.Add(this.soundBar); + this.Controls.Add(this.imageLabel); + this.Controls.Add(this.imageBar); this.Controls.Add(this.label1); this.Controls.Add(this.GameInfo); this.Controls.Add(this.listBox1); @@ -434,17 +437,23 @@ namespace NetMFAPatcher.GUI this.PerformLayout(); } + private System.Windows.Forms.Button musicsButton; + + private System.Windows.Forms.ProgressBar imageBar; + private System.Windows.Forms.Label imageLabel; + private System.Windows.Forms.Button imagesButton; + private System.Windows.Forms.ProgressBar musicBar; + private System.Windows.Forms.Label musicLabel; + private System.Windows.Forms.ProgressBar soundBar; + private System.Windows.Forms.Label soundLabel; + private System.Windows.Forms.Button soundsButton; + private System.Windows.Forms.Button button1; - private System.Windows.Forms.CheckBox ChunkBox; private System.Windows.Forms.ContextMenuStrip ChunkCombo; private System.Windows.Forms.Button cryptKeyBtn; private System.Windows.Forms.Button dumpSortedBtn; private System.Windows.Forms.Button FolderBTN; private System.Windows.Forms.Label GameInfo; - private System.Windows.Forms.CheckBox ImageBox; - private System.Windows.Forms.ProgressBar ImagesBar; - private System.Windows.Forms.Button ImagesButton; - private System.Windows.Forms.Label ImagesLabel; private System.Windows.Forms.Label label1; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.Label loadingLabel; @@ -453,10 +462,6 @@ namespace NetMFAPatcher.GUI private System.Windows.Forms.Button packDataBtn; private System.Windows.Forms.ToolStripMenuItem saveChunkBtn; private System.Windows.Forms.Button showHexBtn; - private System.Windows.Forms.ProgressBar SoundBar; - private System.Windows.Forms.CheckBox SoundBox; - private System.Windows.Forms.Button SoundsButton; - private System.Windows.Forms.Label SoundsLabel; private System.Windows.Forms.TreeView treeView1; private System.Windows.Forms.ToolStripMenuItem viewHexBtn; diff --git a/NetMFAPatcher/GUI/MainForm.cs b/NetMFAPatcher/GUI/MainForm.cs index 137036c..89554a3 100644 --- a/NetMFAPatcher/GUI/MainForm.cs +++ b/NetMFAPatcher/GUI/MainForm.cs @@ -4,24 +4,26 @@ using System.Diagnostics; using System.Drawing; using System.Threading; using System.Windows.Forms; -using Be.Windows.Forms; -using NetMFAPatcher.MMFParser.ChunkLoaders; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.MMFParser.Decompiling; -using NetMFAPatcher.Utils; - -namespace NetMFAPatcher.GUI +using DotNetCTFDumper.MMFParser.ChunkLoaders; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Banks; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.MMFParser.Decompiling; +using DotNetCTFDumper.Utils; + +namespace DotNetCTFDumper.GUI { public partial class MainForm : Form { public static bool IsDumpingImages; public static bool IsDumpingSounds; + public static bool IsDumpingMusics; public static bool BreakImages; public static bool BreakSounds; + public static bool BreakMusics; public Thread LoaderThread; public Color ColorTheme = Color.FromArgb(223,114,38); public PackDataForm PackForm; + public MainForm() { @@ -32,8 +34,8 @@ namespace NetMFAPatcher.GUI showHexBtn.ForeColor = ColorTheme; FolderBTN.ForeColor = ColorTheme; MFABtn.ForeColor = ColorTheme; - ImagesButton.ForeColor = ColorTheme; - SoundsButton.ForeColor = ColorTheme; + imagesButton.ForeColor = ColorTheme; + soundsButton.ForeColor = ColorTheme; packDataBtn.ForeColor = ColorTheme; //Menu saveChunkBtn.ForeColor = ColorTheme; @@ -46,13 +48,15 @@ namespace NetMFAPatcher.GUI button1.ForeColor = ColorTheme; GameInfo.ForeColor = ColorTheme; loadingLabel.ForeColor = ColorTheme; - ImagesLabel.ForeColor = ColorTheme; - SoundsLabel.ForeColor=ColorTheme; + imageLabel.ForeColor = ColorTheme; + soundLabel.ForeColor=ColorTheme; //Other treeView1.ForeColor = ColorTheme; listBox1.ForeColor = ColorTheme; - ImagesBar.ForeColor = ColorTheme; - SoundBar.ForeColor = ColorTheme; + imageBar.ForeColor = ColorTheme; + soundBar.ForeColor = ColorTheme; + + } @@ -60,11 +64,20 @@ namespace NetMFAPatcher.GUI private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { var worker = new BackgroundWorker(); - worker.DoWork += (senderA, eA) => { StartReading(); }; - worker.RunWorkerCompleted += (senderA, eA) => { AfterLoad(); }; + worker.DoWork += worker_DoWork; + worker.RunWorkerCompleted += worker_RunWorkerCompleted; worker.RunWorkerAsync(); } + void worker_DoWork(object sender, DoWorkEventArgs e) + { + StartReading(); + } + + void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + AfterLoad(); + } private void button1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); @@ -72,34 +85,34 @@ namespace NetMFAPatcher.GUI private void MainForm_Load(object sender, EventArgs e) { - listBox1.Items.Clear(); - loadingLabel.Visible = false; + listBox1.Items.Clear(); } - + + private void StartReading() { var path = openFileDialog1.FileName; - ImagesBar.Value = 0; - SoundBar.Value = 0; + Program.ReadFile(path, Settings.Verbose, Settings.DumpImages, Settings.DumpSounds); + imageBar.Value = 0; + soundBar.Value = 0; GameInfo.Text = ""; loadingLabel.Visible = true; - ImagesLabel.Text = "0/0"; - SoundsLabel.Text = "0/0"; - ImageBox.Enabled = false; - SoundBox.Enabled = false; - ChunkBox.Enabled = false; + imageLabel.Text = "Using nonGUI mode"; + soundLabel.Text = "Using nonGUI mode"; + MFABtn.Visible = false; FolderBTN.Visible = false; - ImagesButton.Visible = false; - SoundsButton.Visible = false; + imagesButton.Visible = false; + soundsButton.Visible = false; + musicsButton.Visible = false; cryptKeyBtn.Visible = false; showHexBtn.Visible = false; dumpSortedBtn.Visible = false; packDataBtn.Visible = false; + - - Program.ReadFile(path, Settings.Verbose, Settings.DumpImages, Settings.DumpSounds); + } private void treeView1_AfterDblClick(object sender, EventArgs e) @@ -129,34 +142,23 @@ namespace NetMFAPatcher.GUI case "viewHexBtn": ShowHex(); break; - } - } private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { var nodeChunk = ((ChunkNode) treeView1.SelectedNode).chunk; var nodeLoader = ((ChunkNode) treeView1.SelectedNode).loader; - Console.WriteLine("NodeChunk:"+nodeChunk!=null); - Console.WriteLine("NodeLoader:"+nodeLoader!=null); - ChunkList.Chunk chunk = null; listBox1.Items.Clear(); - if (nodeChunk != null) chunk = nodeChunk; - //if (nodeLoader.Chunk != null) chunk = nodeLoader.Chunk; - if (chunk != null) + if (nodeChunk != null) { - chunk = nodeChunk; - listBox1.Items.Add($"Name: {chunk.Name}"); - listBox1.Items.Add($"Id: {chunk.Id}"); - listBox1.Items.Add($"Flag: {chunk.Flag}"); - listBox1.Items.Add($"Size: {chunk.Size.ToPrettySize()}"); - if (chunk.DecompressedSize>-1)listBox1.Items.Add($"Decompressed Size: {chunk.DecompressedSize.ToPrettySize()}"); - - - + listBox1.Items.Add($"Name: {nodeChunk.Name}"); + listBox1.Items.Add($"Id: {nodeChunk.Id}"); + listBox1.Items.Add($"Flag: {nodeChunk.Flag}"); + listBox1.Items.Add($"Size: {nodeChunk.Size.ToPrettySize()}"); + if (nodeChunk.DecompressedSize>-1)listBox1.Items.Add($"Decompressed Size: {nodeChunk.DecompressedSize.ToPrettySize()}"); } if (nodeLoader != null) @@ -178,9 +180,9 @@ namespace NetMFAPatcher.GUI public void AfterLoad() { - GameData gameData = null; - - gameData = Exe.LatestInst.GameData; + //GameData gameData = null; + var exe = Exe.Instance; + var gameData = exe.GameData; treeView1.Nodes.Clear(); @@ -199,11 +201,11 @@ namespace NetMFAPatcher.GUI if (item.Loader is Frame frame) foreach (var frmChunk in frame.Chunks.Chunks) { - var frameNode = Helper.GetChunkNode(frmChunk);//new ChunkNode(frmChunk.Name, frmChunk); + var frameNode = Helper.GetChunkNode(frmChunk); newNode.Nodes.Add(frameNode); if (frameNode.loader is ObjectInstances) { - var objs = frame.Chunks.get_chunk(); + var objs = frame.Chunks.GetChunk(); if (objs != null) { foreach (var frmitem in objs.Items) @@ -216,13 +218,12 @@ namespace NetMFAPatcher.GUI } } - ImageBox.Enabled = true; - SoundBox.Enabled = true; - ChunkBox.Enabled = true; + MFABtn.Visible = true; FolderBTN.Visible = true; - ImagesButton.Visible = true; - SoundsButton.Visible = true; + imagesButton.Visible = true; + soundsButton.Visible = true; + musicsButton.Visible = true; cryptKeyBtn.Visible = true; //showHexBtn.Visible = true; dumpSortedBtn.Visible = true; @@ -230,17 +231,17 @@ namespace NetMFAPatcher.GUI GameInfo.Visible = true; loadingLabel.Visible = false; var toLog = ""; - toLog += $"Title:{Exe.LatestInst.GameData.Name}\n"; - toLog += $"Copyright:{Exe.LatestInst.GameData.Copyright}\n"; - toLog += $"Editor Filename: {Exe.LatestInst.GameData.EditorFilename}\n"; - toLog += $"Product Version: {Exe.LatestInst.GameData.ProductVersion}\n"; - toLog += $"Build: {Exe.LatestInst.GameData.Build}\n"; - toLog += $"Runtime Version: {Exe.LatestInst.GameData.RuntimeVersion}\n"; - toLog += $"Number Of Images: {Exe.LatestInst.GameData.Images.NumberOfItems}\n"; - toLog += $"Number Of Sounds: {Exe.LatestInst.GameData.Sounds.NumOfItems}\n"; - toLog += $"Unique FrameItems: {Exe.LatestInst.GameData.Frameitems.NumberOfItems}\n"; - toLog += $"Frame Count: {Exe.LatestInst.GameData.Frames.Count}\n"; - toLog += $"Chunks Count: {Exe.LatestInst.GameData.GameChunks.Chunks.Count}\n"; + toLog += $"Title:{Exe.Instance.GameData.Name}\n"; + toLog += $"Copyright:{Exe.Instance.GameData.Copyright}\n"; + toLog += $"Editor Filename: {Exe.Instance.GameData.EditorFilename}\n"; + toLog += $"Product Version: {Exe.Instance.GameData.ProductVersion}\n"; + toLog += $"Build: {Exe.Instance.GameData.Build}\n"; + toLog += $"Runtime Version: {Exe.Instance.GameData.RuntimeVersion}\n"; + toLog += $"Number Of Images: {Exe.Instance.GameData.Images.NumberOfItems}\n"; + toLog += $"Number Of Sounds: {(Exe.Instance.GameData.Sounds!= null ? Exe.Instance.GameData.Sounds.NumOfItems: 0)}\n"; + toLog += $"Unique FrameItems: {Exe.Instance.GameData.Frameitems.NumberOfItems}\n"; + toLog += $"Frame Count: {Exe.Instance.GameData.Frames.Count}\n"; + toLog += $"Chunks Count: {Exe.Instance.GameData.GameChunks.Chunks.Count}\n"; @@ -251,39 +252,29 @@ namespace NetMFAPatcher.GUI } - private void ImageBox_CheckedChanged(object sender, EventArgs e) - { - Settings.DumpImages = ImageBox.Checked; - ImagesBar.Visible = ImageBox.Checked; - ImagesLabel.Visible = ImageBox.Checked; - } - - private void SoundBox_CheckedChanged(object sender, EventArgs e) - { - Settings.DumpSounds = SoundBox.Checked; - SoundBar.Visible = SoundBox.Checked; - SoundsLabel.Visible = SoundBox.Checked; - } - - private void ChunkBox_CheckedChanged(object sender, EventArgs e) - { - Settings.SaveChunks = ChunkBox.Checked; - } + public void UpdateImageBar(int index, int all) { all -= 1; - ImagesBar.Value = (int) (index / (float) all * 100); - ImagesLabel.Text = $"{index}/{all}"; + imageBar.Value = (int) (index / (float) all * 100); + imageLabel.Text = $"{index}/{all}"; } public void UpdateSoundBar(int index, int all) { all -= 1; - SoundBar.Value = (int) (index / (float) all * 100); - SoundsLabel.Text = $"{index}/{all}"; + soundBar.Value = (int) (index / (float) all * 100); + soundLabel.Text = $"{index}/{all}"; + } + public void UpdateMusicBar(int index, int all) + { + all -= 1; + musicBar.Value = (int) (index / (float) all * 100); + musicLabel.Text = $"{index}/{all}"; } + private void FolderBTN_Click(object sender, EventArgs e) { Process.Start($"{Settings.DumpPath}"); @@ -294,80 +285,76 @@ namespace NetMFAPatcher.GUI MFAGenerator.BuildMFA(); } - private void SoundsButton_Click(object sender, EventArgs e) + private void soundsButton_Click(object sender, EventArgs e) { if (!IsDumpingSounds) { - SoundBar.Visible = true; - SoundsLabel.Visible = true; - SoundsButton.Text = "Cancel"; + soundBar.Visible = true; + soundLabel.Visible = true; + soundsButton.Text = "Cancel"; + soundBar.Value = 0; IsDumpingSounds = true; + BreakSounds = false; var worker = new BackgroundWorker(); worker.DoWork += (senderA, eA) => { - var cachedImgState = Settings.DumpSounds; - Settings.DumpSounds = true; - Exe.LatestInst.GameData.GameChunks.get_chunk().Read(); - Settings.DumpSounds = cachedImgState; + Exe.Instance.GameData.GameChunks.GetChunk().Read(true); }; worker.RunWorkerCompleted += (senderA, eA) => { - SoundBar.Visible = false; - SoundsLabel.Visible = false; + soundBar.Visible = false; + soundLabel.Visible = false; Logger.Log("Sounds done"); - SoundsButton.Text = "Dump Sounds"; + soundsButton.Text = "Dump Sounds"; }; worker.RunWorkerAsync(); } else { BreakSounds = true; - SoundBar.Visible = false; - SoundsLabel.Visible = false; - SoundsButton.Text = "Dump Sounds"; + soundBar.Visible = false; + soundLabel.Visible = false; + soundsButton.Text = "Dump Sounds"; IsDumpingSounds = false; } } - private void ImagesButton_Click(object sender, EventArgs e) + private void imagesButton_Click(object sender, EventArgs e) { if (!IsDumpingImages) { - ImagesBar.Visible = true; - ImagesLabel.Visible = true; - ImagesButton.Text = "Cancel"; + imageBar.Visible = true; + imageLabel.Visible = true; + imagesButton.Text = "Cancel"; + imageBar.Value = 0; IsDumpingImages = true; - //ImagesLabel.BackColor=Color.Transparent; - //ImagesLabel.ForeColor=Color.Red; - - ; + BreakImages = false; var worker = new BackgroundWorker(); worker.DoWork += (senderA, eA) => { - var cachedImgState = Settings.DumpImages; - Settings.DumpImages = true; - Exe.LatestInst.GameData.GameChunks.get_chunk().Read(); - Settings.DumpImages = cachedImgState; + Exe.Instance.GameData.GameChunks.GetChunk().Read(true,true); }; worker.RunWorkerCompleted += (senderA, eA) => { - ImagesBar.Visible = false; - ImagesLabel.Visible = false; - ImagesButton.Text = "Dump\nImages"; - Logger.Log("Images done"); + imageBar.Visible = false; + imageLabel.Visible = false; + Logger.Log("Images done",true,ConsoleColor.Yellow); + imagesButton.Text = "Dump Images"; }; worker.RunWorkerAsync(); } else { BreakImages = true; - ImagesBar.Visible = false; - ImagesLabel.Visible = false; - ImagesButton.Text = "Dump\nImages"; + imageBar.Visible = false; + imageLabel.Visible = false; + imagesButton.Text = "Dump Images"; IsDumpingImages = false; } } + + private void cryptKeyBtn_Click(object sender, EventArgs e) { @@ -417,7 +404,27 @@ namespace NetMFAPatcher.GUI private void dumpSortedBtn_Click(object sender, EventArgs e) { - ImageDumper.DumpImages(); + imageBar.Visible = true; + imageLabel.Visible = true; + var worker = new BackgroundWorker(); + worker.DoWork += (senderA, eA) => + { + + Settings.DumpImages = true; + var bank = Exe.Instance.GameData.GameChunks.GetChunk(); + bank.SaveImages=false; + bank.Read(); + + }; + worker.RunWorkerCompleted += (senderA, eA) => + { + imageBar.Visible = false; + imageLabel.Visible = false; + + + ImageDumper.DumpImages(); + }; + worker.RunWorkerAsync(); } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) @@ -439,8 +446,45 @@ namespace NetMFAPatcher.GUI private void packDataBtn_Click(object sender, EventArgs e) { - if(PackForm==null)PackForm = new PackDataForm(Exe.LatestInst.PackData,ColorTheme); + if(PackForm==null)PackForm = new PackDataForm(Exe.Instance.PackData,ColorTheme); PackForm.Show(); } + + private void musicsButton_Click(object sender, EventArgs e) + { + var bank = Exe.Instance.GameData.GameChunks.GetChunk(); + if (bank == null) return; + if (!IsDumpingMusics) + { + musicBar.Visible = true; + musicLabel.Visible = true; + musicsButton.Text = "Cancel"; + musicBar.Value = 0; + IsDumpingMusics = true; + BreakMusics = false; + var worker = new BackgroundWorker(); + worker.DoWork += (senderA, eA) => + { + Exe.Instance.GameData.GameChunks.GetChunk().Read(true); + }; + worker.RunWorkerCompleted += (senderA, eA) => + { + musicBar.Visible = false; + musicLabel.Visible = false; + Logger.Log("Musics done",true,ConsoleColor.Yellow); + musicsButton.Text = "Dump Musics"; + }; + worker.RunWorkerAsync(); + } + else + { + BreakMusics = true; + musicBar.Visible = false; + musicLabel.Visible = false; + musicsButton.Text = "Dump Musics"; + IsDumpingMusics = false; + } + + } } } \ No newline at end of file diff --git a/NetMFAPatcher/GUI/MainForm.resx b/NetMFAPatcher/GUI/MainForm.resx index e188e6f..8fae3ca 100644 --- a/NetMFAPatcher/GUI/MainForm.resx +++ b/NetMFAPatcher/GUI/MainForm.resx @@ -120,15 +120,6 @@ 17, 17 - - True - - - True - - - True - 150, 17 diff --git a/NetMFAPatcher/GUI/PackDataForm.Designer.cs b/NetMFAPatcher/GUI/PackDataForm.Designer.cs index f7fc705..af1d778 100644 --- a/NetMFAPatcher/GUI/PackDataForm.Designer.cs +++ b/NetMFAPatcher/GUI/PackDataForm.Designer.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace NetMFAPatcher.GUI +namespace DotNetCTFDumper.GUI { partial class PackDataForm { @@ -43,8 +43,10 @@ namespace NetMFAPatcher.GUI // this.listBox1.BackColor = System.Drawing.SystemColors.WindowText; this.listBox1.Dock = System.Windows.Forms.DockStyle.Left; + this.listBox1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.listBox1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 14; this.listBox1.Items.AddRange(new object[] {"PackFile1", "PackFile2", "PackFile3", "PackFile4", "PackFile5", "PackFile6"}); this.listBox1.Location = new System.Drawing.Point(0, 0); this.listBox1.Name = "listBox1"; @@ -56,6 +58,7 @@ namespace NetMFAPatcher.GUI // this.dumpButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); this.dumpButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.dumpButton.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.dumpButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.dumpButton.Location = new System.Drawing.Point(204, 105); this.dumpButton.Name = "dumpButton"; @@ -69,6 +72,7 @@ namespace NetMFAPatcher.GUI // this.dumpAllButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64))))); this.dumpAllButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.dumpAllButton.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.dumpAllButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.dumpAllButton.Location = new System.Drawing.Point(204, 148); this.dumpAllButton.Name = "dumpAllButton"; @@ -80,6 +84,7 @@ namespace NetMFAPatcher.GUI // // infoLabel // + this.infoLabel.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.infoLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.infoLabel.Location = new System.Drawing.Point(204, 14); this.infoLabel.Name = "infoLabel"; diff --git a/NetMFAPatcher/GUI/PackDataForm.cs b/NetMFAPatcher/GUI/PackDataForm.cs index 980c7bd..0422e46 100644 --- a/NetMFAPatcher/GUI/PackDataForm.cs +++ b/NetMFAPatcher/GUI/PackDataForm.cs @@ -1,15 +1,12 @@ using System; using System.ComponentModel; -using System.ComponentModel.Design; using System.Drawing; using System.IO; -using System.Text; using System.Windows.Forms; -using Be.Windows.Forms; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.GUI +namespace DotNetCTFDumper.GUI { public partial class PackDataForm : Form { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Events.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Events.cs index 1193949..74cf39d 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Events.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Events.cs @@ -1,12 +1,9 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events { public class Events : ChunkLoader { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/EventsParts.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/EventsParts.cs index b71f2f3..3256f8b 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/EventsParts.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/EventsParts.cs @@ -1,13 +1,9 @@ -using NetMFAPatcher.MMFParser.Data; -using System; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; - -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events { public class Condition : DataLoader { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Expressions/Expression.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Expressions/Expression.cs index 0227c74..221f7a6 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Expressions/Expression.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Expressions/Expression.cs @@ -1,8 +1,8 @@ using System; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Expressions +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Expressions { class Expression : DataLoader { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/AlterableValue.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/AlterableValue.cs index 22537c5..dcde2a9 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/AlterableValue.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/AlterableValue.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class AlterableValue : Short { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Colour.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Colour.cs index e4c9a80..3a38408 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Colour.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Colour.cs @@ -1,7 +1,7 @@ using System.Drawing; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Colour : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Create.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Create.cs index 9c11265..d01dcdb 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Create.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Create.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Create : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Every.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Every.cs index 88f491e..d554d2b 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Every.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Every.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Every : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Float.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Float.cs index 1c284ef..db30f9d 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Float.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Float.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Float : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/GlobalValue.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/GlobalValue.cs index b421fac..5e6fb77 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/GlobalValue.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/GlobalValue.cs @@ -1,7 +1,7 @@ using System; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class GlobalValue : Short { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Int.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Int.cs index 3ca24c0..b5532ff 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Int.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Int.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Int : Short { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/ParamObject.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/ParamObject.cs index dca0bc7..f966dc5 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/ParamObject.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/ParamObject.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class ParamObject : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/ParameterCommon.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/ParameterCommon.cs index 8159cb3..3154163 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/ParameterCommon.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/ParameterCommon.cs @@ -1,8 +1,8 @@ using System; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class ParameterCommon : DataLoader { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Position.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Position.cs index 4fcdbcf..eb63360 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Position.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Position.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Position : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Remark.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Remark.cs index 91c7110..f60f9d5 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Remark.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Remark.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Remark : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Sample.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Sample.cs index 80c69c7..11c8318 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Sample.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Sample.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Sample : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Short.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Short.cs index b10a8da..dccc12d 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Short.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Short.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Short : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Time.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Time.cs index 9c71409..69c3d30 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Time.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Events/Parameters/Time.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters { class Time : ParameterCommon { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/ExtData.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/ExtData.cs index e946e71..314ea57 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/ExtData.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/ExtData.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { class ExtData : ChunkLoader { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Globals.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Globals.cs index 8891c9a..da299f4 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Globals.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Globals.cs @@ -1,12 +1,9 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { public class GlobalValues : ChunkLoader { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/ObjectNames.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/ObjectNames.cs index 067477c..355cd2f 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/ObjectNames.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/ObjectNames.cs @@ -1,13 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { class ObjectNames : ChunkLoader//Fucking trash { diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Animations.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Animations.cs index 299d88a..39f4d05 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Animations.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Animations.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Objects +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Objects { public class Animations:ChunkLoader { @@ -28,13 +28,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Objects offsets.Add(Reader.ReadInt16()); } AnimationDict = new Dictionary(); - if (offsets.Count <= 0) return; - for (int i = 0; i < 1; i++)//I am stupid faggot, i don't know, whats wrong with this list + for (int i = 0; i < offsets.Count; i++) { var offset = offsets[i]; if (offset != 0) { - Console.WriteLine("Offset: "+offset); Reader.Seek(currentPosition+offset); var anim = new Animation(Reader); anim.Read(); diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Backdrop.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Backdrop.cs new file mode 100644 index 0000000..e3988e5 --- /dev/null +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Backdrop.cs @@ -0,0 +1,59 @@ +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; + +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Objects +{ + public enum Obstacle + { + None = 0, + Solid = 1, + Platform = 2, + Ladder = 3, + Transparent = 4 + } + + public enum Collision + { + Fine = 0, + Box = 1 + } + public class Backdrop:ChunkLoader + { + + public int Size; + public Obstacle ObstacleType; + public Collision CollisionType; + public int Width; + public int Height; + public int Image; + + public Backdrop(ByteReader reader) : base(reader) + { + } + + public Backdrop(ChunkList.Chunk chunk) : base(chunk) + { + } + + public override void Read() + { + Size = Reader.ReadInt32(); + ObstacleType = (Obstacle) Reader.ReadInt16(); + CollisionType = (Collision) Reader.ReadInt16(); + Width = Reader.ReadInt32(); + Height = Reader.ReadInt32(); + Image = Reader.ReadInt16(); + + } + + public override void Print(bool ext) + { + throw new System.NotImplementedException(); + } + + public override string[] GetReadableData() + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Counters.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Counters.cs new file mode 100644 index 0000000..8794280 --- /dev/null +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Counters.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; + +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Objects +{ + public class Counter:ChunkLoader + { + public short Size; + public int Initial; + public int Minimum; + public int Maximum; + + public Counter(ByteReader reader) : base(reader) + { + } + + public Counter(ChunkList.Chunk chunk) : base(chunk) + { + } + + public override void Read() + { + Size = Reader.ReadInt16(); + Initial = Reader.ReadInt32(); + Minimum = Reader.ReadInt32(); + Maximum = Reader.ReadInt32(); + } + + public override void Print(bool ext) + { + throw new System.NotImplementedException(); + } + + public override string[] GetReadableData() + { + throw new System.NotImplementedException(); + } + } + + public class Counters : ChunkLoader + { + int _intDigitsMask = 0xF; + int _floatDigitsMask = 0xF0; + int _formatFloat = 0x0200; + int _floatDigitsShift = 4; + int _useDecimals = 0x0400; + int _floatDecimalsMask = 0xF000; + int _floatDecimalsShift = 12; + int _floatPad = 0x0800; + public List Frames; + + public Counters(ByteReader reader) : base(reader) + { + } + + public Counters(ChunkList.Chunk chunk) : base(chunk) + { + } + + public override void Read() + { + var size = Reader.ReadUInt32(); + var width = Reader.ReadUInt32(); + var height = Reader.ReadUInt32(); + var player = Reader.ReadUInt16(); + var displayType = Reader.ReadUInt16(); + var flags = Reader.ReadUInt16(); + + var integerDigits = flags & _intDigitsMask; + var formatFloat = (flags & _formatFloat) != 0; + var floatDigits = (flags & _floatDigitsMask) >> _floatDigitsShift + 1; + var useDecimals = (flags & _useDecimals) != 0; + var decimals = (flags & _floatDecimalsMask) >> _floatDecimalsShift; + var addNulls = (flags & _floatPad) != 0; + + var inverse = ByteFlag.GetFlag(flags, 8); + var font = Reader.ReadUInt16(); + if (displayType == 0) return; + else if (displayType == 1 || displayType == 4) + { + Frames = new List(); + var count = Reader.ReadInt16(); + for (int i = 0; i < count; i++) + { + Frames.Add(Reader.ReadUInt16()); + } + } + else if (displayType == 2 || displayType == 3 || displayType == 5) + { + //TODO: Shapes + throw new NotImplementedException(); + } + + } + + public override void Print(bool ext) + { + throw new System.NotImplementedException(); + } + + public override string[] GetReadableData() + { + throw new System.NotImplementedException(); + } + } + +} \ No newline at end of file diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/ObjectCommon.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/ObjectCommon.cs index 48f14df..77b08e2 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/ObjectCommon.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/ObjectCommon.cs @@ -1,11 +1,9 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Objects +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Objects { public class ObjectCommon : ChunkLoader { @@ -76,148 +74,144 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Objects } ); + public Color BackColor; + public ObjectInfo Parent; + public Counters Counters; + public byte[] ExtensionData; + public int ExtensionPrivate; + public int ExtensionId; + public int ExtensionVersion; + public ObjectCommon(ByteReader reader) : base(reader) { } - + public ObjectCommon(ByteReader reader,ObjectInfo parent) : base(reader) + { + Parent = parent; + } public ObjectCommon(ChunkList.Chunk chunk) : base(chunk) { } + public override void Read() { + if (Parent.ObjectType != 2) return; long currentPosition = Reader.Tell(); int size = Reader.ReadInt32(); - bool newobj = Settings.Build > 284; - if (newobj && true) + bool newobj = Settings.Build >= 284; + if (newobj) { _animationsOffset = (short) Reader.ReadUInt16(); _movementsOffset = Reader.ReadUInt16(); - short version = Reader.ReadInt16(); - Reader.ReadBytes(2); - ushort extensionOffset = Reader.ReadUInt16(); - ushort counterOffset = Reader.ReadUInt16(); - flags.flag = Reader.ReadUInt32(); - - long end = Reader.Tell() + 16; - - List qualifiers = new List(); - for (int i = 0; i < 8; i++) - { - short qualifier = Reader.ReadInt16(); - if (qualifier == -1) break; - qualifiers.Add(qualifier); - } - - Reader.Seek(end); - - short systemObjectOffset = Reader.ReadInt16(); - - _valuesOffset = Reader.ReadInt16(); - _stringsOffset = Reader.ReadInt16(); - new_flags.flag = Reader.ReadUInt16(); - preferences.flag = Reader.ReadUInt16(); - Identifier = Reader.ReadFourCc(); - Color backColor = Reader.ReadColor(); - int fadeinOffset = Reader.ReadInt32(); - int fadeoutOffset = Reader.ReadInt32(); - } - else if (newobj) - { - _counterOffset = Reader.ReadInt16(); - short version = Reader.ReadInt16(); - Reader.ReadBytes(2); - _movementsOffset = (ushort) Reader.ReadInt16(); - _extensionOffset = Reader.ReadInt16(); - _animationsOffset = Reader.ReadInt16(); - uint flags = Reader.ReadUInt32(); - long end = Reader.Tell() + 16; - List qualifiers = new List(); - for (int i = 0; i < 8; i++) - { - short qualifier = Reader.ReadInt16(); - if (qualifier == -1) break; - qualifiers.Add(qualifier); - } - - Reader.Seek(end); - - _valuesOffset = Reader.ReadInt16(); - _stringsOffset = Reader.ReadInt16(); - ushort newFlags = Reader.ReadUInt16(); - byte[] preferences = Reader.ReadFourCc(); - Color backColor = Reader.ReadColor(); - _fadeinOffset = Reader.ReadInt32(); - _fadeoutOffset = Reader.ReadInt32(); } else { _movementsOffset = Reader.ReadUInt16(); _animationsOffset = Reader.ReadInt16(); - short version = Reader.ReadInt16(); - _counterOffset = Reader.ReadInt16(); + } + short version = Reader.ReadInt16(); + _counterOffset = (short) Reader.ReadUInt16(); + _systemObjectOffset = (short) Reader.ReadUInt16(); + + flags.flag = Reader.ReadUInt32(); + var end = Reader.Tell() + 16; + Reader.Seek(end); + if (newobj) + { _systemObjectOffset = Reader.ReadInt16(); - Reader.ReadBytes(2); - flags.flag = Reader.ReadUInt32(); - - _end = Reader.Tell() + 16; - - List qualifiers = new List(); - for (int i = 0; i < 8; i++) - { - short qualifier = Reader.ReadInt16(); - if (qualifier == -1) break; - qualifiers.Add(qualifier); - } - - Reader.Seek(_end); - + + } + else + { _extensionOffset = Reader.ReadInt16(); - - _valuesOffset = Reader.ReadInt16(); - _stringsOffset = Reader.ReadInt16(); - new_flags.flag = Reader.ReadUInt16(); - preferences.flag = Reader.ReadUInt16(); - byte[] identifier = Reader.ReadFourCc(); - Color backColor = Reader.ReadColor(); - _fadeinOffset = Reader.ReadInt32(); - _fadeoutOffset = Reader.ReadInt32(); } + + _valuesOffset = Reader.ReadInt16(); + _stringsOffset = Reader.ReadInt16(); + new_flags.flag = Reader.ReadUInt16(); + preferences.flag = Reader.ReadUInt16(); + byte[] identifier = Reader.ReadFourCc(); + BackColor = Reader.ReadColor(); + _fadeinOffset = Reader.ReadInt32(); + _fadeoutOffset = Reader.ReadInt32(); if (_movementsOffset != 0) { //Reader.Seek(currentPosition+_movementsOffset); //var movements = new Movements(Reader); //movements.Read(); + Console.WriteLine("Movements done"); } - - Console.WriteLine("Movements done"); + + if (_valuesOffset != 0) { Reader.Seek(currentPosition + _valuesOffset); AlterableValues values = new AlterableValues(Reader); values.Read(); + Console.WriteLine("Values done"); } - - Console.WriteLine("Values done"); + + if (_stringsOffset != 0) { Reader.Seek(currentPosition + _stringsOffset); AlterableStrings strings = new AlterableStrings(Reader); strings.Read(); + Console.WriteLine("Strings done"); } - - Console.WriteLine("Strings done"); - if (_animationsOffset != 0) + + + if (_animationsOffset != 0&& Parent.ObjectType==2) { - Reader.Seek(currentPosition + _stringsOffset); + Reader.Seek(currentPosition + _animationsOffset); Animations = new Animations(Reader); - Animations.Read(); + Console.WriteLine("Animations done"); + } + + /*if (_counterOffset != 0) + { + Reader.Seek(currentPosition + _counterOffset); + var counter = new Counter(Reader); + counter.Read(); + Console.WriteLine("Counters done"); } - Console.WriteLine("Animations done"); + if (_extensionOffset != 0) + { + var dataSize = Reader.ReadInt32() - 20; + ExtensionVersion = Reader.ReadInt32(); + ExtensionId = Reader.ReadInt32(); + ExtensionPrivate = Reader.ReadInt32(); + if (dataSize != 0) + ExtensionData = Reader.ReadBytes(dataSize); + Console.WriteLine("Extensions Done"); + + }*/ + + if (_systemObjectOffset > 0) + { + Console.WriteLine("Reading System Object"); + Reader.Seek(currentPosition+_systemObjectOffset); + if (Parent.ObjectType == ((int) Constants.ObjectType.Text) || + Parent.ObjectType == ((int) Constants.ObjectType.Question)) + { + //TODO; Text.read(); + } + else if (Parent.ObjectType == ((int) Constants.ObjectType.Score) || + Parent.ObjectType == ((int) Constants.ObjectType.Lives)|| + Parent.ObjectType == ((int) Constants.ObjectType.Counter)) + { + Counters = new Counters(Reader); + Counters.Read(); + } + + } + + Console.WriteLine("SysObjOff: " + _systemObjectOffset); Console.WriteLine("ExtOff: " + _extensionOffset); } diff --git a/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Value.cs b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Value.cs index e7e0f69..852aec8 100644 --- a/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Value.cs +++ b/NetMFAPatcher/MMFParser/ChunkLoaders/Objects/Value.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; -using System.Windows.Forms; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Objects +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Objects { public class AlterableValues:ChunkLoader { diff --git a/NetMFAPatcher/MMFParser/Data/ChunkList.cs b/NetMFAPatcher/MMFParser/Data/ChunkList.cs index a3c5ccc..bd92c25 100644 --- a/NetMFAPatcher/MMFParser/Data/ChunkList.cs +++ b/NetMFAPatcher/MMFParser/Data/ChunkList.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; using System.IO; -using System.Windows.Forms; -using NetMFAPatcher.MMFParser.ChunkLoaders; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Constants; +using System.Xml.Linq; +using DotNetCTFDumper.MMFParser.ChunkLoaders; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Banks; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.Data +namespace DotNetCTFDumper.MMFParser.Data { public class ChunkList { @@ -24,36 +23,14 @@ namespace NetMFAPatcher.MMFParser.Data chunk.Verbose = Verbose; chunk.Read(exeReader); chunk.Loader = LoadChunk(chunk); - - if (chunk.Loader != null) - { - if (chunk.Loader.Verbose) - { - //chunk.loader.Print(Program.LogAll); - } - } - if (chunk.Verbose) - { - chunk.Print(false); - - - - - - } - Chunks.Add(chunk); if (chunk.Id == 8750) { chunk.BuildKey(); } - - - + if (exeReader.Tell() >= exeReader.Size()) break; if (chunk.Id == 32639) break; //LAST chunkID } - - //Logger.Log(verbose ? $" Total Chunks Count: {chunks.Count}":"ChunkList Done", true, ConsoleColor.Blue); } public class Chunk @@ -84,6 +61,7 @@ namespace NetMFAPatcher.MMFParser.Data public void Read(ByteReader exeReader) { + Id = exeReader.ReadInt16(); Name = this.ActualName(); @@ -161,20 +139,20 @@ namespace NetMFAPatcher.MMFParser.Data string copyright = ""; string project = ""; - var titleChunk = _chunkList.get_chunk(); + var titleChunk = _chunkList.GetChunk(); if (titleChunk != null) title = titleChunk.Value; - var copyrightChunk = _chunkList.get_chunk(); + var copyrightChunk = _chunkList.GetChunk(); if (copyrightChunk != null) copyright = copyrightChunk.Value; - var projectChunk = _chunkList.get_chunk(); + var projectChunk = _chunkList.GetChunk(); if (projectChunk != null) project = projectChunk.Value; Settings.AppName=title; Settings.Copyright = copyright; Settings.ProjectPath = project; - if (Exe.LatestInst.GameData.ProductBuild > 284) + if (Exe.Instance.GameData.ProductBuild > 284) { Decryption.MakeKey(title, copyright, project); } @@ -258,6 +236,9 @@ namespace NetMFAPatcher.MMFParser.Data case 26216: loader = new SoundBank(chunk); break; + case 26217: + loader = new MusicBank(chunk); + break; case 17477: loader = new ObjectName(chunk); break; @@ -281,6 +262,7 @@ namespace NetMFAPatcher.MMFParser.Data //loader = new Events(chunk);//NOT WORKING break; + } if (loader != null) @@ -293,7 +275,7 @@ namespace NetMFAPatcher.MMFParser.Data } - public T get_chunk() where T : ChunkLoader + public T GetChunk() where T : ChunkLoader { foreach (Chunk chunk in Chunks) { @@ -308,10 +290,6 @@ namespace NetMFAPatcher.MMFParser.Data //Logger.Log($"ChunkLoader {typeof(T).Name} not found", true, ConsoleColor.Red); return null; } - public T get_loader(ChunkLoader loader) where T : ChunkLoader - { - - return (T)loader; - } + } } \ No newline at end of file diff --git a/NetMFAPatcher/MMFParser/Data/DataLoader.cs b/NetMFAPatcher/MMFParser/Data/DataLoader.cs index e904bd5..4b78599 100644 --- a/NetMFAPatcher/MMFParser/Data/DataLoader.cs +++ b/NetMFAPatcher/MMFParser/Data/DataLoader.cs @@ -1,7 +1,7 @@ -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.Data +namespace DotNetCTFDumper.MMFParser.Data { public abstract class DataLoader { diff --git a/NetMFAPatcher/MMFParser/Data/EXE.cs b/NetMFAPatcher/MMFParser/Data/EXE.cs index 396cc47..835d484 100644 --- a/NetMFAPatcher/MMFParser/Data/EXE.cs +++ b/NetMFAPatcher/MMFParser/Data/EXE.cs @@ -1,28 +1,24 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.Data +namespace DotNetCTFDumper.MMFParser.Data { public class Exe { public PackData PackData; public GameData GameData; - public static Exe LatestInst; + public static Exe Instance; public void ParseExe(ByteReader exeReader) { - Exe.LatestInst = this; + Logger.Log($"Executable: {Settings.GameName}\n", true, ConsoleColor.DarkRed); string sig = exeReader.ReadAscii(2); Logger.Log("EXE Header: " + sig, true, ConsoleColor.Yellow); if (sig != "MZ") { - Console.WriteLine("Invalid executable signature"); + Logger.Log("Invalid executable signature",true,ConsoleColor.Red); } exeReader.Seek(60, SeekOrigin.Begin); diff --git a/NetMFAPatcher/MMFParser/Data/GameData.cs b/NetMFAPatcher/MMFParser/Data/GameData.cs index c90a3c9..e5589dc 100644 --- a/NetMFAPatcher/MMFParser/Data/GameData.cs +++ b/NetMFAPatcher/MMFParser/Data/GameData.cs @@ -1,15 +1,10 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using DotNetCTFDumper.MMFParser.ChunkLoaders; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Banks; +using DotNetCTFDumper.Utils; -using NetMFAPatcher.MMFParser.ChunkLoaders; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.Utils; - - -namespace NetMFAPatcher.MMFParser.Data +namespace DotNetCTFDumper.MMFParser.Data { public class GameData { @@ -62,10 +57,10 @@ namespace NetMFAPatcher.MMFParser.Data else if (magic == Constants.GameHeader) Constants.IsUnicode = false;//PAME else Logger.Log("Couldn't found any known headers", true, ConsoleColor.Red);//Header not found - RuntimeVersion = exeReader.ReadUInt16(); // - RuntimeSubversion = exeReader.ReadUInt16(); //0 - ProductVersion = (Constants.Products)exeReader.ReadInt32(); //CTF/MMF2/MMF1.5/CNC - ProductBuild = exeReader.ReadInt32(); //CTF Build + RuntimeVersion = exeReader.ReadUInt16(); + RuntimeSubversion = exeReader.ReadUInt16(); + ProductVersion = (Constants.Products)exeReader.ReadInt32(); + ProductBuild = exeReader.ReadInt32();//Easy Access Settings.Build=ProductBuild; Build = ProductBuild; @@ -74,24 +69,26 @@ namespace NetMFAPatcher.MMFParser.Data GameChunks.Read(exeReader); //Load chunks into gamedata for easier access - if (GameChunks.get_chunk() != null) Name = GameChunks.get_chunk().Value; - if (GameChunks.get_chunk() != null) Copyright = GameChunks.get_chunk().Value; - if (GameChunks.get_chunk()!=null) Author = GameChunks.get_chunk().Value; - if (GameChunks.get_chunk() != null) EditorFilename = GameChunks.get_chunk().Value; - if (GameChunks.get_chunk() != null) TargetFilename = GameChunks.get_chunk().Value; - if (GameChunks.get_chunk() != null) Menu = GameChunks.get_chunk(); - if (GameChunks.get_chunk() != null) Header = GameChunks.get_chunk(); - if (GameChunks.get_chunk() != null) Sounds = GameChunks.get_chunk(); - if (GameChunks.get_chunk() != null) Music = GameChunks.get_chunk(); - if (GameChunks.get_chunk() != null) Fonts = GameChunks.get_chunk(); - if (GameChunks.get_chunk() != null) Images = GameChunks.get_chunk(); - if (GameChunks.get_chunk() != null) Icon = GameChunks.get_chunk(); - if (GameChunks.get_chunk() != null) GStrings = GameChunks.get_chunk(); - if (GameChunks.get_chunk() != null) GValues = GameChunks.get_chunk(); - if (GameChunks.get_chunk() != null) Frameitems = GameChunks.get_chunk(); + //Can only be accessed from here AFTER loading all the chunks + //If you need it AT LOADING - use ChunkList.get_chunk(); + if (GameChunks.GetChunk() != null) Name = GameChunks.GetChunk().Value; + if (GameChunks.GetChunk() != null) Copyright = GameChunks.GetChunk().Value; + if (GameChunks.GetChunk()!=null) Author = GameChunks.GetChunk().Value; + if (GameChunks.GetChunk() != null) EditorFilename = GameChunks.GetChunk().Value; + if (GameChunks.GetChunk() != null) TargetFilename = GameChunks.GetChunk().Value; + if (GameChunks.GetChunk() != null) Menu = GameChunks.GetChunk(); + if (GameChunks.GetChunk() != null) Header = GameChunks.GetChunk(); + if (GameChunks.GetChunk() != null) Sounds = GameChunks.GetChunk(); + if (GameChunks.GetChunk() != null) Music = GameChunks.GetChunk(); + if (GameChunks.GetChunk() != null) Fonts = GameChunks.GetChunk(); + if (GameChunks.GetChunk() != null) Images = GameChunks.GetChunk(); + if (GameChunks.GetChunk() != null) Icon = GameChunks.GetChunk(); + if (GameChunks.GetChunk() != null) GStrings = GameChunks.GetChunk(); + if (GameChunks.GetChunk() != null) GValues = GameChunks.GetChunk(); + if (GameChunks.GetChunk() != null) Frameitems = GameChunks.GetChunk(); Frames = GameChunks.Frames; //Its a list, so i have to manually parse them in chunk list. - Print(); + //Print(); } public void Print() { @@ -136,12 +133,12 @@ namespace NetMFAPatcher.MMFParser.Data foreach (var item in Frames) { Logger.Log($" Frame: {item.Name,25}, Size: {item.Width,4}x{item.Height,4}, Number of objects: {item.CountOfObjs,5}", true, ConsoleColor.Cyan); - var objects = item.Chunks.get_chunk(); + var objects = item.Chunks.GetChunk(); if (objects != null) { foreach (var obj in objects.Items) { - Logger.Log($" Object: {obj.Name}", true, ConsoleColor.Green); + Logger.Log($" Object: {obj.Name} - {obj.Handle} - {obj.FrameItem.ObjectType}", true, ConsoleColor.Green); } } diff --git a/NetMFAPatcher/MMFParser/Data/MFA.cs b/NetMFAPatcher/MMFParser/Data/MFA.cs index 2a0b52d..3eddb44 100644 --- a/NetMFAPatcher/MMFParser/Data/MFA.cs +++ b/NetMFAPatcher/MMFParser/Data/MFA.cs @@ -1,17 +1,14 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Linq; -using System.Net.NetworkInformation; -using System.Windows.Forms; -using NetMFAPatcher.MMFParser.ChunkLoaders; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.MMFParser.MFALoaders; -using NetMFAPatcher.Utils; -using Controls = NetMFAPatcher.MMFParser.MFALoaders.Controls; -using Frame = NetMFAPatcher.MMFParser.MFALoaders.Frame; - -namespace NetMFAPatcher.MMFParser.Data +using DotNetCTFDumper.MMFParser.ChunkLoaders; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Banks; +using DotNetCTFDumper.MMFParser.MFALoaders; +using DotNetCTFDumper.Utils; +using Controls = DotNetCTFDumper.MMFParser.MFALoaders.Controls; +using Frame = DotNetCTFDumper.MMFParser.MFALoaders.Frame; + +namespace DotNetCTFDumper.MMFParser.Data { public class MFA : DataLoader { @@ -134,13 +131,18 @@ namespace NetMFAPatcher.MMFParser.Data Fonts.Write(writer); writer.WriteAscii(SoundBankId); Sounds.Write(writer); + writer.WriteAscii(MusicBankId); //music.Write();//cum cum cum cum cum cum cum cum writer.WriteInt32(0);//someone is using musics lol? + //TODO: Do music + //I am not an asshole lol writer.WriteAscii(ImageBankId); Icons.Write(writer); + return; writer.WriteAscii(ImageBankId); Images.Write(writer); + writer.AutoWriteUnicode(Name); writer.AutoWriteUnicode(Author); writer.AutoWriteUnicode(Description); @@ -208,9 +210,9 @@ namespace NetMFAPatcher.MMFParser.Data writer.AutoWriteUnicode(item.Item3); writer.WriteInt32(item.Item4); writer.WriteBytes(item.Item5); - writer.WriteInt32(Frames.Count); + } - writer.WriteInt32(Extensions.Count); + writer.WriteInt32(Frames.Count); var startPosition = writer.Tell() + 4 * Frames.Count + 4; //help //how to implement write writer diff --git a/NetMFAPatcher/MMFParser/Data/PackData.cs b/NetMFAPatcher/MMFParser/Data/PackData.cs index ab20665..069b17f 100644 --- a/NetMFAPatcher/MMFParser/Data/PackData.cs +++ b/NetMFAPatcher/MMFParser/Data/PackData.cs @@ -1,14 +1,9 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Reflection.Emit; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.Data +namespace DotNetCTFDumper.MMFParser.Data { public class PackData { @@ -47,7 +42,7 @@ namespace NetMFAPatcher.MMFParser.Data exeReader.Skip(value); if (!exeReader.Check(value)) break; } - exeReader.BaseStream.Position -= 5;//wtf lol + header = exeReader.ReadFourCc(); exeReader.Seek(offset); diff --git a/NetMFAPatcher/MMFParser/Decompiling/MFAGenerator.cs b/NetMFAPatcher/MMFParser/Decompiling/MFAGenerator.cs index 3e48ec3..9ad8b99 100644 --- a/NetMFAPatcher/MMFParser/Decompiling/MFAGenerator.cs +++ b/NetMFAPatcher/MMFParser/Decompiling/MFAGenerator.cs @@ -1,8 +1,8 @@ using System.IO; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.Decompiling +namespace DotNetCTFDumper.MMFParser.Decompiling { public static class MFAGenerator { @@ -16,11 +16,11 @@ namespace NetMFAPatcher.MMFParser.Decompiling template.Read(); //Loading template - var gameMFA = Pame2Mfa.Translate(template, Exe.LatestInst.GameData); //Translation + var gameMFA = template;//Pame2Mfa.Translate(template, Exe.LatestInst.GameData); //Translation var mfaWriter = new ByteWriter( - Settings.GameName.Length > 0 ? $"{Settings.DumpPath}\\{Exe.LatestInst.GameData.Name}.mfa" : "out.mfa", + Settings.GameName.Length > 0 ? $"{Settings.DumpPath}\\{Exe.Instance.GameData.Name}.mfa" : "out.mfa", FileMode.Create); //New writer for new MFA gameMFA.Write(mfaWriter); //Writing new MFA } diff --git a/NetMFAPatcher/MMFParser/Decompiling/PAME2MFA.cs b/NetMFAPatcher/MMFParser/Decompiling/PAME2MFA.cs index 83b2999..623d563 100644 --- a/NetMFAPatcher/MMFParser/Decompiling/PAME2MFA.cs +++ b/NetMFAPatcher/MMFParser/Decompiling/PAME2MFA.cs @@ -1,7 +1,7 @@  -using NetMFAPatcher.MMFParser.Data; +using DotNetCTFDumper.MMFParser.Data; -namespace NetMFAPatcher.MMFParser.Decompiling +namespace DotNetCTFDumper.MMFParser.Decompiling { public static class Pame2Mfa { diff --git a/NetMFAPatcher/Program.cs b/NetMFAPatcher/Program.cs index 4d03f47..8342c68 100644 --- a/NetMFAPatcher/Program.cs +++ b/NetMFAPatcher/Program.cs @@ -1,12 +1,12 @@ using System; using System.IO; using System.Windows.Forms; -using NetMFAPatcher.GUI; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.MMFParser.Decompiling; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.GUI; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.MMFParser.Decompiling; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher +namespace DotNetCTFDumper { internal class Program { @@ -73,16 +73,19 @@ namespace NetMFAPatcher Settings.DumpImages = dumpImages; Settings.DumpSounds = dumpSounds; Settings.Verbose = verbose; + var exeReader = new ByteReader(path, FileMode.OpenOrCreate); + var currentExe = new Exe(); + Exe.Instance = currentExe; + currentExe.ParseExe(exeReader); + Logger.Log("Finished!", true, ConsoleColor.Yellow); + return; if (File.Exists(path)) { if (path.EndsWith(".exe")) { Settings.DoMFA = false; - var exeReader = new ByteReader(path, FileMode.OpenOrCreate); - var currentExe = new Exe(); - currentExe.ParseExe(exeReader); - Logger.Log("Finished!", true, ConsoleColor.Yellow); + } else if (path.EndsWith(".mfa")) { @@ -106,7 +109,9 @@ namespace NetMFAPatcher { Directory.CreateDirectory($"{Settings.ImagePath}"); Directory.CreateDirectory($"{Settings.SoundPath}"); + Directory.CreateDirectory($"{Settings.MusicPath}"); Directory.CreateDirectory($"{Settings.ChunkPath}"); + Directory.CreateDirectory($"{Settings.ExtensionPath}"); diff --git a/NetMFAPatcher/Settings.cs b/NetMFAPatcher/Settings.cs index 76e9652..f95e3bf 100644 --- a/NetMFAPatcher/Settings.cs +++ b/NetMFAPatcher/Settings.cs @@ -1,13 +1,13 @@ using System.IO; -using System.Runtime.Remoting.Messaging; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher +namespace DotNetCTFDumper { public static class Settings { public static bool DumpImages; public static bool DumpSounds; + public static bool DumpMusic; public static bool SaveChunks; public static bool Verbose; @@ -16,6 +16,8 @@ namespace NetMFAPatcher public static string DumpPath => $"DUMP\\{GameName}"; public static string ImagePath=>$"{DumpPath}\\ImageBank"; public static string SoundPath=>$"{DumpPath}\\SoundBank"; + public static string MusicPath=>$"{DumpPath}\\MusicBank"; + public static string ChunkPath=>$"{DumpPath}\\Chunks"; public static string ExtensionPath=>$"{DumpPath}\\Extensions"; @@ -29,7 +31,7 @@ namespace NetMFAPatcher public static bool DoMFA; public static bool UseGUI; - public static string DumperVersion = "CTFAN 0.1.1 Debug"; + public static string DumperVersion = "CTFAN 0.1.1-c Debug"; public static byte[] EncryptionKey=>Decryption.DecryptionKey; diff --git a/NetMFAPatcher/Utils/BitDict.cs b/NetMFAPatcher/Utils/BitDict.cs index b94e1da..a458e91 100644 --- a/NetMFAPatcher/Utils/BitDict.cs +++ b/NetMFAPatcher/Utils/BitDict.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { public class BitDict { diff --git a/NetMFAPatcher/Utils/ByteFlag.cs b/NetMFAPatcher/Utils/ByteFlag.cs index c095958..ce51382 100644 --- a/NetMFAPatcher/Utils/ByteFlag.cs +++ b/NetMFAPatcher/Utils/ByteFlag.cs @@ -1,6 +1,6 @@ using System; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { public static class ByteFlag { diff --git a/NetMFAPatcher/Utils/ByteReader.cs b/NetMFAPatcher/Utils/ByteReader.cs index 8e299eb..02d4e78 100644 --- a/NetMFAPatcher/Utils/ByteReader.cs +++ b/NetMFAPatcher/Utils/ByteReader.cs @@ -3,7 +3,7 @@ using System.Drawing; using System.IO; using System.Text; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { public class ByteReader : BinaryReader { diff --git a/NetMFAPatcher/Utils/ByteWriter.cs b/NetMFAPatcher/Utils/ByteWriter.cs index 04bd842..b0c806f 100644 --- a/NetMFAPatcher/Utils/ByteWriter.cs +++ b/NetMFAPatcher/Utils/ByteWriter.cs @@ -3,7 +3,7 @@ using System.Drawing; using System.IO; using System.Text; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { public class ByteWriter : BinaryWriter { diff --git a/NetMFAPatcher/Utils/Decompressor.cs b/NetMFAPatcher/Utils/Decompressor.cs index c3dd08e..0c9b5c0 100644 --- a/NetMFAPatcher/Utils/Decompressor.cs +++ b/NetMFAPatcher/Utils/Decompressor.cs @@ -1,8 +1,7 @@ using System; using System.Diagnostics; -using System.Windows.Forms; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { public static class Decompressor { diff --git a/NetMFAPatcher/Utils/Decryption.cs b/NetMFAPatcher/Utils/Decryption.cs index eb751e9..4e7b241 100644 --- a/NetMFAPatcher/Utils/Decryption.cs +++ b/NetMFAPatcher/Utils/Decryption.cs @@ -1,11 +1,8 @@ using System; using System.IO; -using System.Linq; -using System.Management.Instrumentation; using System.Runtime.InteropServices; -using System.Text; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { class Decryption { diff --git a/NetMFAPatcher/Utils/Helper.cs b/NetMFAPatcher/Utils/Helper.cs index 08f91a4..e637ec3 100644 --- a/NetMFAPatcher/Utils/Helper.cs +++ b/NetMFAPatcher/Utils/Helper.cs @@ -5,13 +5,13 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text.RegularExpressions; -using NetMFAPatcher.GUI; -using NetMFAPatcher.MMFParser; -using NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters; -using NetMFAPatcher.MMFParser.ChunkLoaders.Objects; -using NetMFAPatcher.MMFParser.Data; +using DotNetCTFDumper.GUI; +using DotNetCTFDumper.MMFParser; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Events.Parameters; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Objects; +using DotNetCTFDumper.MMFParser.Data; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { static class Helper { @@ -181,13 +181,17 @@ namespace NetMFAPatcher.Utils public static void OnImageSaved(int index, int all) { - Program.MyForm.UpdateImageBar(index, all); + Program.MyForm.UpdateImageBar(index, all); } public static void OnSoundSaved(int index, int all) { Program.MyForm.UpdateSoundBar(index, all); } + public static void OnMusicSaved(int index, int all) + { + Program.MyForm.UpdateSoundBar(index, all); + } private const long OneKb = 1024; private const long OneMb = OneKb * 1024; @@ -284,5 +288,16 @@ namespace NetMFAPatcher.Utils // Step 3: return the new array. return result; } + + public static void WriteWriter(this ByteWriter writer, ByteWriter toWrite) + { + var endPos = toWrite.Tell(); + toWrite.Seek(0); + for (int i = 0; i < endPos; i++) + { + writer.WriteInt8(((MemoryStream)(toWrite.BaseStream)).GetBuffer()[i]); + } + + } } } \ No newline at end of file diff --git a/NetMFAPatcher/Utils/ImageDumper.cs b/NetMFAPatcher/Utils/ImageDumper.cs index 8181a3a..a4373c2 100644 --- a/NetMFAPatcher/Utils/ImageDumper.cs +++ b/NetMFAPatcher/Utils/ImageDumper.cs @@ -1,12 +1,15 @@ -using System.Drawing; +using System; +using System.Collections.Generic; using System.IO; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.MMFParser.ChunkLoaders.Objects; -using NetMFAPatcher.MMFParser.Data; +using System.Linq; +using DotNetCTFDumper.MMFParser.ChunkLoaders; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Banks; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Objects; +using DotNetCTFDumper.MMFParser.Data; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { - public class ImageDumper + public static class ImageDumper { public static void DumpImages() { @@ -17,39 +20,115 @@ namespace NetMFAPatcher.Utils public static void Dump() { var rootFolder = $"{Settings.DumpPath}\\ImageBank\\Sorted"; - var Bank = Exe.LatestInst.GameData.GameChunks.get_chunk(); - foreach (var frame in Exe.LatestInst.GameData.Frames) + var Bank = Exe.Instance.GameData.GameChunks.GetChunk(); + foreach (var frame in Exe.Instance.GameData.Frames) { if (frame.Objects != null) { - var currentFramePath = rootFolder + "\\" + frame.Name; - Directory.CreateDirectory(currentFramePath); + var currentFramePath = rootFolder + "\\" + Helper.CleanInput(frame.Name); + foreach (var item in frame.Objects.Items) { - var currentObjPath = currentFramePath + "\\" + item.Handle; + + var currentObjPath = currentFramePath + "\\" + Helper.CleanInput(item.Name); Directory.CreateDirectory(currentObjPath); - var anims = (item.FrameItem.Properties).Loader.Animations.AnimationDict; - foreach (var key in anims.Keys) + var frames = item.FrameItem.GetFrames(); + foreach (var key in frames.Keys) + { + + frames.TryGetValue(key, out var name); + Bank.Images.TryGetValue(key, out var actualFrame); + try + { + var path = + $"{Settings.ImagePath}\\Sorted\\{frame.Name}\\{Helper.CleanInput(item.Name)}\\{name}"; + Directory.CreateDirectory(Path.GetDirectoryName(path)); + Logger.Log("Saving Image: "+path); + actualFrame.Save(path); + + } + catch (Exception e) + { + Logger.Log("Error while dumping images: "+e.Message,true,ConsoleColor.Red); + + } + + + } + } + } + } + Logger.Log("Sorted Images Done",true,ConsoleColor.Yellow); + } + + + + + public static Dictionary GetFrames(this ObjectInfo obj) + { + Dictionary frames = new Dictionary(); + + + if (obj.Properties.Loader is ObjectCommon common) + { + if (obj.ObjectType == 2) + { + foreach (var animKey in common.Animations.AnimationDict.Keys) + { + var anim = common.Animations.AnimationDict[animKey]; + foreach (var dirKey in anim.DirectionDict.Keys) { - var anim = anims[key]; - var directions = anim.DirectionDict; - foreach (var key1 in directions.Keys) + var dir = anim.DirectionDict[dirKey]; + foreach (var frame in dir.Frames) { - var dir = directions[0]; - foreach (var AnimFrame in dir.Frames) + if (!frames.ContainsKey(frame)) { - ImageItem img = null; - Bank.Images.TryGetValue(AnimFrame, out img); - img.Save(currentObjPath+"\\"+AnimFrame+".png"); + var animIndex = common.Animations.AnimationDict.Keys.ToList().IndexOf(animKey); + var dirIndex = anim.DirectionDict.Keys.ToList().IndexOf(dirKey); + var frameIndex = dir.Frames.IndexOf(frame); + string finalPath = ""; + var animAll = dir.Frames.Count == 1; + if(!animAll) + { + if (common.Animations.AnimationDict.Keys.Count > 1) + { + finalPath += $"Animation{animIndex}\\"; + } + } + + if (anim.DirectionDict.Keys.Count > 1) + { + finalPath += $"Direction{dirIndex}\\"; + } + + + finalPath += $"{(animAll ? ("Animation"+animIndex.ToString()):(frameIndex.ToString()))}.png"; + + frames.Add(frame, finalPath); } } - } - + } } } - + else if (obj.ObjectType == 7) + { + var counters = common.Counters; + if (counters == null) return frames; + foreach (var item in counters.Frames) + { + frames.Add(item,item.ToString()); + } + } + } + else if (obj.Properties.Loader is Backdrop backdrop) + { + frames.Add(backdrop.Image,"0.png"); } + + + return frames; + } } } \ No newline at end of file diff --git a/NetMFAPatcher/Utils/ImageHelper.cs b/NetMFAPatcher/Utils/ImageHelper.cs index a146d62..32edb04 100644 --- a/NetMFAPatcher/Utils/ImageHelper.cs +++ b/NetMFAPatcher/Utils/ImageHelper.cs @@ -1,6 +1,6 @@ using System; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { public static class ImageHelper { @@ -73,9 +73,12 @@ namespace NetMFAPatcher.Utils byte g = (byte) ((newShort & 992) >> 5); byte b = (byte) ((newShort & 31)); - colorArray[(y * stride) + (x * 4) + 0] = (byte) (r << 3); - colorArray[(y * stride) + (x * 4) + 1] = (byte) (g << 3); - colorArray[(y * stride) + (x * 4) + 2] = (byte) (b << 3); + r=(byte) (r << 3); + g=(byte) (g << 3); + b=(byte) (b << 3); + colorArray[(y * stride) + (x * 4) + 2] = r; + colorArray[(y * stride) + (x * 4) + 1] = g; + colorArray[(y * stride) + (x * 4) + 0] = b; colorArray[(y * stride) + (x * 4) + 3] = 255; position += 2; } diff --git a/NetMFAPatcher/Utils/Logger.cs b/NetMFAPatcher/Utils/Logger.cs index 9cba4b9..53198b1 100644 --- a/NetMFAPatcher/Utils/Logger.cs +++ b/NetMFAPatcher/Utils/Logger.cs @@ -1,7 +1,7 @@ using System; using System.IO; -namespace NetMFAPatcher.Utils +namespace DotNetCTFDumper.Utils { public static class Logger { diff --git a/NetMFAPatcher/mmfparser/Constants.cs b/NetMFAPatcher/mmfparser/Constants.cs index ea42f90..0facb80 100644 --- a/NetMFAPatcher/mmfparser/Constants.cs +++ b/NetMFAPatcher/mmfparser/Constants.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NetMFAPatcher.MMFParser +namespace DotNetCTFDumper.MMFParser { public static class Constants { @@ -108,7 +102,7 @@ namespace NetMFAPatcher.MMFParser DemoFilePath=13123, RandomSeed=13124, FrameLayerEffects=13125, - BlurayFrameOptions=13126, + BluRayFrameOptions=13126, MvTimerBase=13127, MosaicImageTable=13128, FrameEffects=13129, diff --git a/NetMFAPatcher/mmfparser/chunkloaders/AppHeader.cs b/NetMFAPatcher/mmfparser/chunkloaders/AppHeader.cs index db87643..3d5261d 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/AppHeader.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/AppHeader.cs @@ -1,15 +1,10 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; - -namespace NetMFAPatcher.MMFParser.ChunkLoaders +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { public class AppHeader : ChunkLoader { @@ -66,18 +61,22 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders { Reader = new ByteReader(Chunk.ChunkData); Size = Reader.ReadInt32(); - Flags.flag=(uint) Reader.ReadInt16();//I finally got my balls back + Flags.flag=(uint) Reader.ReadInt16(); - var newFlags = Reader.ReadInt16(); //read flags or no balls - var graphicsMode = Reader.ReadInt16(); //i am serious - var otherflags = Reader.ReadInt16(); //last chance to get balls back + NewFlags.flag = (uint) Reader.ReadInt16(); + var graphicsMode = Reader.ReadInt16(); + var otherflags = Reader.ReadInt16();// I am an asshole + //TODO: Add OtherFlags + WindowWidth = Reader.ReadInt16(); WindowHeight = Reader.ReadInt16(); + InitialScore = (int) (Reader.ReadUInt32() ^ 0xffffffff); InitialLives = (int) (Reader.ReadUInt32() ^ 0xffffffff); + var controls = new Controls(Reader); controls.Read(); - // controls.Print(false); + BorderColor = Reader.ReadColor(); NumberOfFrames = Reader.ReadInt32(); diff --git a/NetMFAPatcher/mmfparser/chunkloaders/AppMenu.cs b/NetMFAPatcher/mmfparser/chunkloaders/AppMenu.cs index 9d22f62..8836237 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/AppMenu.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/AppMenu.cs @@ -1,13 +1,9 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; - -namespace NetMFAPatcher.MMFParser.ChunkLoaders +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; + +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { public class AppMenu : ChunkLoader { diff --git a/NetMFAPatcher/mmfparser/chunkloaders/ChunkLoader.cs b/NetMFAPatcher/mmfparser/chunkloaders/ChunkLoader.cs index b1c90c9..0af2bd6 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/ChunkLoader.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/ChunkLoader.cs @@ -1,18 +1,23 @@ -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { - public abstract class ChunkLoader//:DataLoader + public abstract class ChunkLoader { + public Chunk Chunk; public ByteReader Reader; + public bool Verbose = false; - protected ChunkLoader(ByteReader reader) + + public ChunkLoader(ByteReader reader) { this.Reader = reader; } + protected ChunkLoader(Chunk chunk) { this.Chunk = chunk; @@ -25,5 +30,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders public abstract void Print(bool ext); public abstract string[] GetReadableData(); + + } } \ No newline at end of file diff --git a/NetMFAPatcher/mmfparser/chunkloaders/Frame.cs b/NetMFAPatcher/mmfparser/chunkloaders/Frame.cs index 5d6f8b0..1ce0172 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/Frame.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/Frame.cs @@ -1,18 +1,10 @@ - -using NetMFAPatcher.MMFParser.Data; -using System; +using System; using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters; -using NetMFAPatcher.MMFParser.MFALoaders; -using NetMFAPatcher.Utils; -using ChunkList = NetMFAPatcher.MMFParser.Data.ChunkList; - -namespace NetMFAPatcher.MMFParser.ChunkLoaders +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; +using ChunkList = DotNetCTFDumper.MMFParser.Data.ChunkList; + +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { class FrameName : StringChunk { @@ -76,28 +68,33 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders public override void Read() { + var frameReader = new ByteReader(Chunk.ChunkData); Chunks = new ChunkList(); + Chunks.Verbose = false; Chunks.Read(frameReader); - - var name = Chunks.get_chunk(); + //return; + var name = Chunks.GetChunk(); if (name != null) //Just to be sure { this.Name = name.Value; + Console.WriteLine("Reading Frame: "+Name); } - var password = Chunks.get_chunk(); + var password = Chunks.GetChunk(); if (password != null) //Just to be sure { this.Password = password.Value; } - Header = Chunks.get_chunk(); + + + Header = Chunks.GetChunk(); Width = Header.Width; Height = Header.Height; Background = Header.Background; //Flags = header.Flags; - Objects = Chunks.get_chunk(); + Objects = Chunks.GetChunk(); if(Objects!=null) { CountOfObjs = Objects.CountOfObjects; @@ -247,20 +244,19 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders public override void Read() { - - Handle = Reader.ReadUInt16(); - //if (Handle > 0) Handle -= 1; - ObjectInfo = Reader.ReadUInt16(); + ObjectInfo = (ushort) Reader.ReadInt16(); + Handle = (ushort) Reader.ReadInt16(); + X = Reader.ReadInt32(); Y = Reader.ReadInt32(); ParentType = Reader.ReadInt16(); ParentHandle = Reader.ReadInt16(); Layer = Reader.ReadInt16(); - Reader.Skip(2); + var reserved = Reader.ReadInt16(); + //------------------------- if (FrameItem != null) Name = FrameItem.Name; else Name = $"UNKNOWN-{Handle}"; - Console.WriteLine("ObjectInfoHandle: "+Handle); } @@ -268,7 +264,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders { get { - return Exe.LatestInst.GameData.GameChunks.get_chunk().GetItemByHandle(Handle); + return Exe.Instance.GameData.GameChunks.GetChunk().FromHandle(Handle); } } @@ -284,7 +280,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders $"Name: {Name}", $"Type:{(Constants.ObjectType)FrameItem.ObjectType} - {FrameItem.ObjectType}", $"Position: {X,5}x{Y,5}", - $"Size: CUMxCUM" + $"Size: NotImplementedYet" }; } diff --git a/NetMFAPatcher/mmfparser/chunkloaders/FrameItems.cs b/NetMFAPatcher/mmfparser/chunkloaders/FrameItems.cs index f7f4d0f..afecd59 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/FrameItems.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/FrameItems.cs @@ -1,15 +1,10 @@ -using NetMFAPatcher.MMFParser.Data; -using System; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.MMFParser.MFALoaders; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { public class FrameItems : ChunkLoader { @@ -38,7 +33,6 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders for (int i = 0; i < NumberOfItems; i++) { var item = new ObjectInfo(Reader); - item.Verbose = false; item.Read(); ItemDict.Add(item.Handle, item); Names.Add(item.Name); @@ -48,10 +42,22 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders } - public ObjectInfo GetItemByHandle(int handle) + public ObjectInfo FromHandle(int handle) { ItemDict.TryGetValue(handle, out var ret); return ret; } + + public List FromName(string name) + { + var tempList = new List(); + foreach (var key in ItemDict.Keys) + { + var item = ItemDict[key]; + if(item.Name==name)tempList.Add(item); + } + + return tempList; + } } } diff --git a/NetMFAPatcher/mmfparser/chunkloaders/ObjectInfo.cs b/NetMFAPatcher/mmfparser/chunkloaders/ObjectInfo.cs index f994657..03bff6d 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/ObjectInfo.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/ObjectInfo.cs @@ -1,12 +1,11 @@ using System; -using NetMFAPatcher.MMFParser.Data; using System.Collections.Generic; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.MMFParser.ChunkLoaders.Objects; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Objects; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { public class ObjectInfo : ChunkLoader { @@ -60,13 +59,13 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders if (loader is ObjectName) { - var actualLoader = infoChunks.get_loader(loader); + var actualLoader = (ObjectName)(loader); Name = actualLoader.Value; } else if (loader is ObjectHeader) { - var actualLoader = infoChunks.get_loader(loader); + var actualLoader = (ObjectHeader)(loader); Handle = actualLoader.Handle; ObjectType = actualLoader.ObjectType; Flags = actualLoader.Flags; @@ -84,7 +83,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders if (Properties != null) { - //Properties.ReadNew(ObjectType); + //Properties.ReadNew(ObjectType,this); } } } @@ -103,7 +102,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders public class ObjectProperties : ChunkLoader { public bool IsCommon; - public ObjectCommon Loader; + public ChunkLoader Loader; public ObjectProperties(ByteReader reader) : base(reader) { @@ -113,17 +112,25 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders { } - public void ReadNew(int ObjectType) + public void ReadNew(int ObjectType,ObjectInfo parent) { - Reader.Seek(0); - //var objType = 2;//THIS IS SHITCODE - IsCommon = true;//ITS NOT DONE - if (ObjectType == 2) + + //TODO: Fix shit + Console.WriteLine("Reading properties of "+parent.Name); + if (ObjectType == 1)//Backdrop + { + Loader = new Backdrop(Reader); + } + else if(ObjectType==2|| ObjectType==7) + { + IsCommon = true; + Loader = new ObjectCommon(Reader,parent); + } + + if (Loader != null) { - Loader = new ObjectCommon(Reader); Loader.Read(); } - } public override void Read() diff --git a/NetMFAPatcher/mmfparser/chunkloaders/StringChunk.cs b/NetMFAPatcher/mmfparser/chunkloaders/StringChunk.cs index d918628..086acc5 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/StringChunk.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/StringChunk.cs @@ -1,14 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; - -namespace NetMFAPatcher.MMFParser.ChunkLoaders +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { public class StringChunk : ChunkLoader { diff --git a/NetMFAPatcher/mmfparser/chunkloaders/banks/FontBank.cs b/NetMFAPatcher/mmfparser/chunkloaders/banks/FontBank.cs index 3abc2be..8d186b1 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/banks/FontBank.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/banks/FontBank.cs @@ -1,7 +1,7 @@ -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks { public class FontBank : ChunkLoader { diff --git a/NetMFAPatcher/mmfparser/chunkloaders/banks/ImageBank.cs b/NetMFAPatcher/mmfparser/chunkloaders/banks/ImageBank.cs index 0bd2811..5c9e906 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/banks/ImageBank.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/banks/ImageBank.cs @@ -1,21 +1,19 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Eventing; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; -using System.Security.Cryptography.X509Certificates; -using System.Windows.Forms; -using NetMFAPatcher.GUI; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; - -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks +using DotNetCTFDumper.GUI; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; + +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks { public class ImageBank : ChunkLoader { + public bool SaveImages=true; public Dictionary Images = new Dictionary(); public uint NumberOfItems; @@ -38,10 +36,20 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks $"Number of images: {NumberOfItems}" }; } + public void Read(bool load,bool save) + { + var cache = Settings.DumpImages; + Settings.DumpImages = load; + SaveImages = save; + Read(); + Settings.DumpImages = cache; + } public override void Read() { Reader.Seek(0); //Reset the reader to avoid bugs when dumping more than once + Images = new Dictionary(); + NumberOfItems = Reader.ReadUInt32(); @@ -59,14 +67,13 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks var item = new ImageItem(Reader); item.Read(); Images.Add(item.Handle, item); - if (Settings.DumpImages) - { - item.Save($"{Settings.ImagePath}\\" + item.Handle.ToString() + ".png"); - Console.ReadKey(); + + if(SaveImages)item.Save($"{Settings.ImagePath}\\" + item.Handle.ToString() + ".png"); + Helper.OnImageSaved(i, (int) NumberOfItems); - } + - if (Exe.LatestInst.GameData.ProductBuild >= 284) + if (Exe.Instance.GameData.ProductBuild >= 284) item.Handle -= 1; //images[item.handle] = item; @@ -115,7 +122,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks public override void Read() { - Handle = Reader.ReadInt32(); + Handle = Reader.ReadInt32()-1; Position = (int) Reader.Tell(); Load(); } @@ -150,6 +157,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks _width = imageReader.ReadInt16(); _height = imageReader.ReadInt16(); _graphicMode = imageReader.ReadByte(); //Graphic mode is always 4 for SL + Console.WriteLine("COLORMODE: "+_graphicMode); Flags.flag = imageReader.ReadByte(); imageReader.Skip(2); @@ -262,13 +270,14 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks chunk.WriteBytes(_transparent); chunk.WriteBytes(rawImg); - chunk.WriteBytes(rawAlpha); + if(Flags["Alpha"])chunk.WriteBytes(rawAlpha); writer.WriteInt32(Handle); - - chunk.Seek(0); - MemoryStream ms = (MemoryStream) chunk.BaseStream; - writer.WriteBytes(ms.GetBuffer()); + + + writer.WriteWriter(chunk); + //MemoryStream ms = (MemoryStream) chunk.BaseStream; + //writer.WriteBytes(ms.GetBuffer()); } diff --git a/NetMFAPatcher/mmfparser/chunkloaders/banks/MusicBank.cs b/NetMFAPatcher/mmfparser/chunkloaders/banks/MusicBank.cs index 299ccce..1ea6efe 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/banks/MusicBank.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/banks/MusicBank.cs @@ -1,9 +1,13 @@ using System; using System.Collections.Generic; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using System.IO; +using System.Net; +using System.Windows.Forms; +using DotNetCTFDumper.GUI; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks { public class MusicBank : ChunkLoader { @@ -19,17 +23,29 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks { throw new NotImplementedException(); } + public void Read(bool save) + { + var cache = Settings.DumpMusic; + Settings.DumpMusic = save; + Read(); + Settings.DumpMusic = cache; + } public override void Read() { //Someone is using this lol? + //Actually,yes + Reader.Seek(0); Items = new List(); NumOfItems = Reader.ReadInt32(); + if (!Settings.DumpMusic) return; Console.WriteLine(NumOfItems); for (int i = 0; i < NumOfItems; i++) { + if (MainForm.BreakMusics) break; var item = new MusicFile(Reader); item.Read(); + Helper.OnMusicSaved(i,NumOfItems); Items.Add(item); } } @@ -45,9 +61,13 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks public class MusicFile : ChunkLoader { - public int Handle; - public string Name = "ERROR"; + + public int Checksum; + public int References; + public string Name; + private uint _flags; public byte[] Data; + public int Handle; public override void Print(bool ext) { @@ -58,8 +78,34 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks throw new NotImplementedException(); } + public override void Read() { + var compressed = true; + Handle = Reader.ReadInt32(); + if (compressed) + { + Reader = Decompressor.DecompressAsReader(Reader,out int decompressed); + } + + Checksum = Reader.ReadInt32(); + References = Reader.ReadInt32(); + var size = Reader.ReadUInt32(); + _flags = Reader.ReadUInt32(); + var reserved = Reader.ReadInt32(); + var nameLen = Reader.ReadInt32(); + Name = Reader.ReadWideString(nameLen); + Data = Reader.ReadBytes((int) (size - nameLen)); + if (Settings.DumpMusic) + { + Logger.Log("Saving MIDI: "+Name); + Save($"{Settings.MusicPath}\\{Helper.CleanInput(Name)}.MID"); + } + } + + public void Save(string filename) + { + File.WriteAllBytes(filename,Data); } public MusicFile(ByteReader reader) : base(reader) diff --git a/NetMFAPatcher/mmfparser/chunkloaders/banks/SoundBank.cs b/NetMFAPatcher/mmfparser/chunkloaders/banks/SoundBank.cs index c1f0bf2..1f40731 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/banks/SoundBank.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/banks/SoundBank.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.IO; -using NetMFAPatcher.GUI; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.GUI; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks +namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks { public class SoundBank : ChunkLoader { @@ -25,16 +25,24 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks $"Number of sounds: {NumOfItems}" }; } + public void Read(bool dump) + { + var cache = Settings.DumpSounds; + Settings.DumpSounds = dump; + Read(); + Settings.DumpSounds = cache; + + } public override void Read() { //Implementing for standalone-only because of my lazyness - if(!Settings.DoMFA) Reader.Seek(0);//Reset the reader to avoid bugs when dumping more than once + Reader.Seek(0);//Reset the reader to avoid bugs when dumping more than once Items = new List(); NumOfItems = Reader.ReadInt32(); Logger.Log("Found " + NumOfItems + " sounds"); - if (!Settings.DumpSounds&&!Settings.DoMFA) return; + if (!Settings.DumpSounds) return; for (int i = 0; i < NumOfItems; i++) { @@ -107,6 +115,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks public int Flags; public bool IsCompressed = true; + public override void Read() { var start = Reader.Tell(); diff --git a/NetMFAPatcher/mmfparser/chunkloaders/yves.cs b/NetMFAPatcher/mmfparser/chunkloaders/yves.cs index 165c982..6e42b87 100644 --- a/NetMFAPatcher/mmfparser/chunkloaders/yves.cs +++ b/NetMFAPatcher/mmfparser/chunkloaders/yves.cs @@ -3,15 +3,11 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.ChunkLoaders +namespace DotNetCTFDumper.MMFParser.ChunkLoaders { public class AppIcon : ChunkLoader { @@ -28,7 +24,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders public override void Read() { - return; + Logger.Log("dumpingIcon"); Reader.ReadBytes(Reader.ReadInt32() - 4); List colorIndexes = new List(); @@ -76,7 +72,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders bmp.Save("icon.png"); } - File.WriteAllBytes("fatcock.raw", _points.ToArray()); + } diff --git a/NetMFAPatcher/mmfparser/mfaloaders/ChunkList.cs b/NetMFAPatcher/mmfparser/mfaloaders/ChunkList.cs index ca134b6..14762cc 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/ChunkList.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/ChunkList.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders +namespace DotNetCTFDumper.MMFParser.MFALoaders { class ChunkList : DataLoader//This is used for MFA reading/writing { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/Controls.cs b/NetMFAPatcher/mmfparser/mfaloaders/Controls.cs index 8d608bb..9c31a5f 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/Controls.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/Controls.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; -using System.Windows.Forms; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders +namespace DotNetCTFDumper.MMFParser.MFALoaders { public class Controls : DataLoader { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/Frame.cs b/NetMFAPatcher/mmfparser/mfaloaders/Frame.cs index 0599867..f458288 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/Frame.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/Frame.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Drawing; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders +namespace DotNetCTFDumper.MMFParser.MFALoaders { public class Frame : DataLoader { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/FrameItem.cs b/NetMFAPatcher/mmfparser/mfaloaders/FrameItem.cs index c3d7c67..42ed650 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/FrameItem.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/FrameItem.cs @@ -1,9 +1,9 @@ using System; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.MMFParser.MFALoaders.mfachunks; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.MMFParser.MFALoaders.mfachunks; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders +namespace DotNetCTFDumper.MMFParser.MFALoaders { public class FrameItem : DataLoader { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/ImageBank.cs b/NetMFAPatcher/mmfparser/mfaloaders/ImageBank.cs index 28f6282..ee72ecb 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/ImageBank.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/ImageBank.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Linq; -using NetMFAPatcher.MMFParser.ChunkLoaders.Banks; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; -using static NetMFAPatcher.MMFParser.Data.ChunkList; +using DotNetCTFDumper.MMFParser.ChunkLoaders.Banks; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; +using static DotNetCTFDumper.MMFParser.Data.ChunkList; -namespace NetMFAPatcher.MMFParser.MFALoaders +namespace DotNetCTFDumper.MMFParser.MFALoaders { public class AgmiBank : DataLoader { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/Layer.cs b/NetMFAPatcher/mmfparser/mfaloaders/Layer.cs index 22fb061..d1db328 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/Layer.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/Layer.cs @@ -1,8 +1,8 @@ using System; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders +namespace DotNetCTFDumper.MMFParser.MFALoaders { class Layer : DataLoader { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/ValueList.cs b/NetMFAPatcher/mmfparser/mfaloaders/ValueList.cs index 2eae8d4..ef8ad4a 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/ValueList.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/ValueList.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders +namespace DotNetCTFDumper.MMFParser.MFALoaders { public class ValueList : DataLoader { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Active.cs b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Active.cs index f7ad233..e9c59bf 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Active.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Active.cs @@ -1,6 +1,6 @@ -using NetMFAPatcher.Utils; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks +namespace DotNetCTFDumper.MMFParser.MFALoaders.mfachunks { class Active : AnimationObject { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/AnimationObject.cs b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/AnimationObject.cs index 65484dc..822ba14 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/AnimationObject.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/AnimationObject.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks +namespace DotNetCTFDumper.MMFParser.MFALoaders.mfachunks { class AnimationObject:ObjectLoader { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Behaviours.cs b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Behaviours.cs index 033c00a..1b0cefc 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Behaviours.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Behaviours.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks +namespace DotNetCTFDumper.MMFParser.MFALoaders.mfachunks { class Behaviours : DataLoader { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Movements.cs b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Movements.cs index cc4230c..5a5110d 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Movements.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/Movements.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks +namespace DotNetCTFDumper.MMFParser.MFALoaders.mfachunks { class Movements : DataLoader { diff --git a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/ObjectLoader.cs b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/ObjectLoader.cs index 9b581fd..0c22e8f 100644 --- a/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/ObjectLoader.cs +++ b/NetMFAPatcher/mmfparser/mfaloaders/mfachunks/ObjectLoader.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Drawing; -using NetMFAPatcher.MMFParser.Data; -using NetMFAPatcher.Utils; +using DotNetCTFDumper.MMFParser.Data; +using DotNetCTFDumper.Utils; -namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks +namespace DotNetCTFDumper.MMFParser.MFALoaders.mfachunks { class ObjectLoader : DataLoader {