Started working on events

master
1987kostya 4 years ago
parent e03e50a993
commit d8872e71e1

@ -189,6 +189,7 @@
<Compile Include="MMFParser\Decompiling\MFAGenerator.cs" /> <Compile Include="MMFParser\Decompiling\MFAGenerator.cs" />
<Compile Include="MMFParser\Decompiling\PAME2MFA.cs" /> <Compile Include="MMFParser\Decompiling\PAME2MFA.cs" />
<Compile Include="MMFParser\MFALoaders\ChunkList.cs" /> <Compile Include="MMFParser\MFALoaders\ChunkList.cs" />
<Compile Include="MMFParser\MFALoaders\Events.cs" />
<Compile Include="MMFParser\MFALoaders\Frame.cs" /> <Compile Include="MMFParser\MFALoaders\Frame.cs" />
<Compile Include="MMFParser\MFALoaders\FrameInstance.cs" /> <Compile Include="MMFParser\MFALoaders\FrameInstance.cs" />
<Compile Include="MMFParser\MFALoaders\FrameItem.cs" /> <Compile Include="MMFParser\MFALoaders\FrameItem.cs" />

@ -16,10 +16,11 @@ namespace DotNetCTFDumper.GUI
public HexViewForm(byte[] parsedData, byte[] rawData,Color color) public HexViewForm(byte[] parsedData, byte[] rawData,Color color)
{ {
InitializeComponent(); InitializeComponent();
sizeLabel.ForeColor = color; foreach (Control item in Controls)
rawBox.ForeColor = color; {
hexBox1.ForeColor = color; item.ForeColor = color;
}
hexBox1.InfoForeColor = Color.FromArgb(color.R/2, color.G/2, color.B/2); hexBox1.InfoForeColor = Color.FromArgb(color.R/2, color.G/2, color.B/2);
hexBox1.SelectionForeColor=Color.FromArgb(color.R, color.G, color.B); hexBox1.SelectionForeColor=Color.FromArgb(color.R, color.G, color.B);
hexBox1.SelectionBackColor=Color.FromArgb(color.R/4, color.G/4, color.B/4); hexBox1.SelectionBackColor=Color.FromArgb(color.R/4, color.G/4, color.B/4);

@ -119,6 +119,7 @@
// GameInfo // GameInfo
// //
this.GameInfo.AutoSize = true; this.GameInfo.AutoSize = true;
this.GameInfo.BackColor = System.Drawing.Color.Transparent;
this.GameInfo.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204))); this.GameInfo.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.GameInfo.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0))))); this.GameInfo.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.GameInfo.Location = new System.Drawing.Point(9, 55); this.GameInfo.Location = new System.Drawing.Point(9, 55);
@ -216,7 +217,6 @@
// //
this.MFABtn.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 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.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.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.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.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));

@ -24,39 +24,33 @@ namespace DotNetCTFDumper.GUI
public Color ColorTheme = Color.FromArgb(223,114,38); public Color ColorTheme = Color.FromArgb(223,114,38);
public PackDataForm PackForm; public PackDataForm PackForm;
public delegate void SaveHandler(int index, int all);
public MainForm() public MainForm()
{ {
//Buttons //Buttons
InitializeComponent(); InitializeComponent();
cryptKeyBtn.ForeColor = ColorTheme; foreach (Control item in Controls)
dumpSortedBtn.ForeColor = ColorTheme; {
showHexBtn.ForeColor = ColorTheme; item.ForeColor = ColorTheme;
FolderBTN.ForeColor = ColorTheme; item.BackColor=Color.Black;
MFABtn.ForeColor = ColorTheme; if(item is Button) item.BackColor=Color.FromArgb(30,30,30);
imagesButton.ForeColor = ColorTheme;
soundsButton.ForeColor = ColorTheme; if (item is Label)
packDataBtn.ForeColor = ColorTheme; {
//Menu item.BackColor = Color.Transparent;
saveChunkBtn.ForeColor = ColorTheme; item.Refresh();
saveChunkBtn.BackColor=Color.Black; }
viewHexBtn.ForeColor = ColorTheme;
viewHexBtn.BackColor=Color.Black; }
previewFrameBtn.ForeColor = ColorTheme;
previewFrameBtn.BackColor=Color.Black; foreach (var item in ChunkCombo.Items)
//Labels {
label1.ForeColor = ColorTheme; ((ToolStripItem)item).ForeColor = ColorTheme;
((ToolStripItem)item).BackColor=Color.Black;
}
label1.Text = Settings.DumperVersion; label1.Text = Settings.DumperVersion;
button1.ForeColor = ColorTheme;
GameInfo.ForeColor = ColorTheme;
loadingLabel.ForeColor = ColorTheme;
imageLabel.ForeColor = ColorTheme;
soundLabel.ForeColor=ColorTheme;
//Other
treeView1.ForeColor = ColorTheme;
listBox1.ForeColor = ColorTheme;
imageBar.ForeColor = ColorTheme;
soundBar.ForeColor = ColorTheme;
@ -187,6 +181,9 @@ namespace DotNetCTFDumper.GUI
} }
} }
} }
GameInfo.BackColor=Color.Transparent;
GameInfo.Refresh();
} }
public void AfterLoad() public void AfterLoad()
@ -253,12 +250,13 @@ namespace DotNetCTFDumper.GUI
toLog += $"Unique FrameItems: {Exe.Instance.GameData.Frameitems.NumberOfItems}\n"; toLog += $"Unique FrameItems: {Exe.Instance.GameData.Frameitems.NumberOfItems}\n";
toLog += $"Frame Count: {Exe.Instance.GameData.Frames.Count}\n"; toLog += $"Frame Count: {Exe.Instance.GameData.Frames.Count}\n";
toLog += $"Chunks Count: {Exe.Instance.GameData.GameChunks.Chunks.Count}\n"; toLog += $"Chunks Count: {Exe.Instance.GameData.GameChunks.Chunks.Count}\n";
if (Exe.Instance.GameData.GameChunks.GetChunk<ImageBank>() != null)
Exe.Instance.GameData.GameChunks.GetChunk<ImageBank>().OnImageSaved += UpdateImageBar;
if (Exe.Instance.GameData.GameChunks.GetChunk<SoundBank>() != null)
Exe.Instance.GameData.GameChunks.GetChunk<SoundBank>().OnSoundSaved += UpdateSoundBar;
if (Exe.Instance.GameData.GameChunks.GetChunk<MusicBank>() != null)
Exe.Instance.GameData.GameChunks.GetChunk<MusicBank>().OnMusicSaved += UpdateMusicBar;
//toLog += $"Runtime Subversion: {Exe.LatestInst.GameData.RuntimeSubversion}\n";
GameInfo.Text = toLog; GameInfo.Text = toLog;
} }
@ -301,6 +299,7 @@ namespace DotNetCTFDumper.GUI
if (!IsDumpingSounds) if (!IsDumpingSounds)
{ {
SetSoundElements(true); SetSoundElements(true);
IsDumpingSounds = true;
Backend.DumpSounds(this,true,true); Backend.DumpSounds(this,true,true);
} }
@ -316,6 +315,7 @@ namespace DotNetCTFDumper.GUI
if (!IsDumpingImages) if (!IsDumpingImages)
{ {
SetImageElements(true); SetImageElements(true);
IsDumpingImages = true;
Backend.DumpImages(this,true,true); Backend.DumpImages(this,true,true);
} }
@ -326,6 +326,23 @@ namespace DotNetCTFDumper.GUI
SetImageElements(false); SetImageElements(false);
} }
} }
private void musicsButton_Click(object sender, EventArgs e)
{
if (!IsDumpingMusics)
{
SetMusicElements(true);
IsDumpingMusics = true;
Backend.DumpMusics(this,true,true);
}
else
{
BreakMusics = true;
IsDumpingMusics = false;
SetMusicElements(false);
}
}
public void SetSoundElements(bool state) public void SetSoundElements(bool state)
@ -430,21 +447,19 @@ namespace DotNetCTFDumper.GUI
PackForm.Show(); PackForm.Show();
} }
private void musicsButton_Click(object sender, EventArgs e)
private void button2_Click(object sender, EventArgs e)
{ {
var myPic = new PictureBox();
var img = Exe.Instance.GameData.GameChunks.GetChunk<ImageBank>().Images[65].Bitmap;
myPic.SizeMode = PictureBoxSizeMode.StretchImage;
if (!IsDumpingMusics) myPic.Image = img;
{ myPic.Width = img.Width / 2;
Backend.DumpMusics(this,true,true); myPic.Height = img.Height / 2;
} Controls.Add(myPic);
else
{
BreakMusics = true;
IsDumpingMusics = false;
SetMusicElements(false);
}
}
}
} }
} }

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using DotNetCTFDumper.Utils; using DotNetCTFDumper.Utils;
using static DotNetCTFDumper.MMFParser.Data.ChunkList; using static DotNetCTFDumper.MMFParser.Data.ChunkList;
@ -170,8 +171,11 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Events
} }
}
public void Write(ByteWriter Writer)
{
} }
} }

@ -123,6 +123,7 @@ namespace DotNetCTFDumper.MMFParser.Data
public override void Write(ByteWriter Writer) public override void Write(ByteWriter Writer)
{ {
Writer.WriteAscii("MFU2"); Writer.WriteAscii("MFU2");
Writer.WriteInt32(MfaBuild); Writer.WriteInt32(MfaBuild);
Writer.WriteInt32(Product); Writer.WriteInt32(Product);
@ -189,7 +190,7 @@ namespace DotNetCTFDumper.MMFParser.Data
using (ByteWriter menuWriter = new ByteWriter(new MemoryStream())) using (ByteWriter menuWriter = new ByteWriter(new MemoryStream()))
{ {
Menu.Write(menuWriter); Menu.Write(menuWriter);
Writer.WriteUInt32((uint) menuWriter.BaseStream.Position); Writer.WriteUInt32((uint) menuWriter.BaseStream.Position);
Writer.WriteWriter(menuWriter); Writer.WriteWriter(menuWriter);
} }
@ -198,7 +199,7 @@ namespace DotNetCTFDumper.MMFParser.Data
{ {
Writer.WriteInt32(0); Writer.WriteInt32(0);
} }
Writer.WriteInt32(windowMenuIndex); Writer.WriteInt32(windowMenuIndex);
Writer.WriteInt32(menuImages.Count); Writer.WriteInt32(menuImages.Count);
foreach (KeyValuePair<int, int> valuePair in menuImages) foreach (KeyValuePair<int, int> valuePair in menuImages)
@ -218,7 +219,16 @@ namespace DotNetCTFDumper.MMFParser.Data
} }
Writer.WriteInt32(0);//custom qualifiers Writer.WriteInt32(0);//custom qualifiers
Writer.WriteInt32(0); //extensions Writer.WriteInt32(0); //extensions
Writer.WriteInt32(0); //frame Writer.WriteInt32(Frames.Count); //frame
var startPos = Reader.Tell() + 4 * Frames.Count + 4;
ByteWriter newWriter = new ByteWriter(new MemoryStream());
foreach (Frame frame in Frames)
{
Writer.WriteUInt32((uint) (startPos+newWriter.Tell()+4));
frame.Write(newWriter);
}
Writer.WriteUInt32((uint) (startPos+newWriter.Tell()+4));
Writer.WriteWriter(newWriter);

@ -1,4 +1,5 @@
using System.IO; using System;
using System.IO;
using DotNetCTFDumper.MMFParser.Data; using DotNetCTFDumper.MMFParser.Data;
using DotNetCTFDumper.Utils; using DotNetCTFDumper.Utils;
@ -6,8 +7,8 @@ namespace DotNetCTFDumper.MMFParser.Decompiling
{ {
public static class MFAGenerator public static class MFAGenerator
{ {
public static readonly string TemplatePath = @"C:\Users\MED45\Downloads\testNoFrames.mfa"; //public static readonly string TemplatePath = @"C:\Users\MED45\Downloads\testNoFrames.mfa";
// public static readonly string TemplatePath = @"C:\Users\ivani\Desktop\CTFResearch\testNoFrames.mfa"; public static readonly string TemplatePath = @"C:\Users\ivani\Desktop\CTFResearch\testNoFrames.mfa";
public static void BuildMFA() public static void BuildMFA()
{ {
@ -17,13 +18,15 @@ namespace DotNetCTFDumper.MMFParser.Decompiling
template.Read(); //Loading template template.Read(); //Loading template
var gameMFA = template; //Pame2Mfa.Translate(template, Exe.LatestInst.GameData); //Translation Pame2Mfa.Translate(ref template, Exe.Instance.GameData); //Translation
var mfaWriter = var mfaWriter =
new ByteWriter( new ByteWriter(
Settings.GameName.Length > 0 ? $"{Settings.DumpPath}\\{Exe.Instance.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 FileMode.Create); //New writer for new MFA
gameMFA.Write(mfaWriter); //Writing new MFA template.Write(mfaWriter); //Writing new MFA
mfaWriter.Dispose();
Logger.Log("MFA Done",true,ConsoleColor.Yellow);
} }
public static void ReadTestMFA() public static void ReadTestMFA()
@ -32,6 +35,9 @@ namespace DotNetCTFDumper.MMFParser.Decompiling
var template = new MFA(mfaReader); var template = new MFA(mfaReader);
Settings.DoMFA = true; Settings.DoMFA = true;
template.Read(); template.Read();
//Add modifications
var mfaWriter = new ByteWriter("outTest.mfa", FileMode.Create); var mfaWriter = new ByteWriter("outTest.mfa", FileMode.Create);
template.Write(mfaWriter); template.Write(mfaWriter);
} }

@ -5,17 +5,19 @@ namespace DotNetCTFDumper.MMFParser.Decompiling
{ {
public static class Pame2Mfa public static class Pame2Mfa
{ {
public static MFA Translate(MFA template, GameData game) public static void Translate(ref MFA mfa, GameData game)
{ {
MFA mfa = template;
mfa.MfaBuild = 4; //mfa.MfaBuild = 4;
mfa.Product = (int) game.ProductVersion; //mfa.Product = (int) game.ProductVersion;
mfa.BuildVersion = 283; mfa.BuildVersion = 283;
mfa.Name = game.Name; mfa.Name = game.Name;
mfa.Description = $"Decompiled with {Settings.DumperVersion}"; mfa.Description = $"Decompiled with {Settings.DumperVersion}";
mfa.Path = game.EditorFilename; mfa.Path = game.EditorFilename;
return;
//mfa.Stamp = wtf; //mfa.Stamp = wtf;
mfa.Fonts = game.Fonts; if (game.Fonts != null) mfa.Fonts = game.Fonts;
mfa.Sounds = game.Sounds; mfa.Sounds = game.Sounds;
foreach (var item in mfa.Sounds.Items) foreach (var item in mfa.Sounds.Items)
{ {
@ -49,20 +51,11 @@ namespace DotNetCTFDumper.MMFParser.Decompiling
mfa.BuildType = 0; mfa.BuildType = 0;
mfa.BuildPath = game.TargetFilename; mfa.BuildPath = game.TargetFilename;
mfa.CommandLine = ""; mfa.CommandLine = "";
mfa.Aboutbox = game.AboutText.Length > 0 mfa.Aboutbox = game.AboutText?.Length > 0
? game.AboutText ? game?.AboutText
: "This game was decompiled with " + Settings.DumperVersion; : "This game was decompiled with " + Settings.DumperVersion;
return mfa;
} }
} }
} }

@ -0,0 +1,384 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Runtime.InteropServices;
using DotNetCTFDumper.MMFParser.ChunkLoaders.Events;
using DotNetCTFDumper.MMFParser.Data;
using DotNetCTFDumper.Utils;
namespace DotNetCTFDumper.MMFParser.MFALoaders
{
public class Events:DataLoader
{
public readonly string EventData = "Evts";
public readonly string CommentData = "Rems";
public readonly string ObjectData = "EvOb";
public readonly string EventEditorData = "EvCs";
public readonly string ObjectListData = "EvEd";
public readonly string TimeListData = "EvEd";
public readonly string EditorPositionData = "EvTs";
public readonly string EditorLineData = "EvLs";
public readonly string EventEnd ="!DNE";
public List<EventGroup> Items;
public ushort Version;
public ushort FrameType;
public List<Comment> Comments;
public List<EventObject> Objects;
public ushort ConditionWidth;
public ushort ObjectHeight;
public List<ushort> ObjectTypes;
public List<ushort> ObjectHandles;
public List<ushort> ObjectFlags;
public List<string> Folders;
public uint X;
public uint Y;
public uint CaretType;
public uint CaretX;
public uint CaretY;
public uint LineY;
public uint LineItemType;
public uint EventLine;
public uint EventLineY;
public Events(ByteReader reader) : base(reader)
{
}
public Events(Data.ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
Version = Reader.ReadUInt16();
FrameType = Reader.ReadUInt16();
Items = new List<EventGroup>();
while (true)
{
string name = Reader.ReadAscii(4);
if (name == EventData)
{
uint size = Reader.ReadUInt32();
uint end = (uint) (Reader.Tell() + size);
while (true)
{
EventGroup evGrp = new EventGroup(Reader);
evGrp.Read();
Items.Add(evGrp);
if (Reader.Tell() >= end) break;
}
}
else if (name == CommentData)
{
try
{
uint len = Reader.ReadUInt32();
Comments = new List<Comment>();
Comment comment = new Comment(Reader);
comment.Read();
Comments.Add(comment);
}
catch
{
//What the fuck?
/*
import code
code.interact(local = locals())
*/
}
}
else if (name == ObjectData)
{
Objects = new List<EventObject>();
uint len = Reader.ReadUInt32();
for (int i = 0; i < len; i++)
{
EventObject eventObject = new EventObject(Reader);
eventObject.Read();
Objects.Add(eventObject);
}
}
else if (name == EventEditorData)
{
Reader.Skip(4);
ConditionWidth = Reader.ReadUInt16();
ObjectHeight = Reader.ReadUInt16();
Reader.Skip(12);
}
else if (name == ObjectListData)
{
short count = Reader.ReadInt16();
short realCount = count;
if (count == -1)
{
realCount = Reader.ReadInt16();
}
ObjectTypes = new List<ushort>();
for (int i = 0; i < realCount; i++)
{
ObjectTypes.Add(Reader.ReadUInt16());
}
ObjectHandles = new List<ushort>();
for (int i = 0; i < realCount; i++)
{
ObjectHandles.Add(Reader.ReadUInt16());
}
ObjectFlags = new List<ushort>();
for (int i = 0; i < realCount; i++)
{
ObjectFlags.Add(Reader.ReadUInt16());
}
if (count == -1)
{
Folders = new List<string>();
var folderCount = Reader.ReadUInt16();
for (int i = 0; i < folderCount; i++)
{
Folders.Add( Reader.AutoReadUnicode());
}
}
}
else if (name == TimeListData)
{
throw new NotImplementedException("I don't like no timelist");
}
else if (name == EditorPositionData)
{
if(Reader.ReadUInt16()!=1) throw new NotImplementedException("Invalid chunkversion");
X = Reader.ReadUInt32();
Y = Reader.ReadUInt32();
CaretType = Reader.ReadUInt32();
CaretX = Reader.ReadUInt32();
CaretY = Reader.ReadUInt32();
}
else if (name == EditorLineData)
{
if(Reader.ReadUInt16()!=1) throw new NotImplementedException("Invalid chunkversion");
LineY = Reader.ReadUInt32();
LineItemType = Reader.ReadUInt32();
EventLine = Reader.ReadUInt32();
EventLineY = Reader.ReadUInt32();
}
else if (name == EventEnd) break;
//else throw new NotImplementedException("Fuck Something Broken");
}
}
public override void Write(ByteWriter Writer)
{
Writer.WriteUInt16(Version);
Writer.WriteInt16((short) FrameType);
if (Items != null)
{
Writer.WriteAscii(EventData);
ByteWriter newWriter = new ByteWriter(new MemoryStream());
foreach (EventGroup eventGroup in Items)
{
eventGroup.Write(newWriter);
}
Writer.WriteWriter(newWriter);
}
if (Comments != null)
{
Writer.WriteAscii(CommentData);
foreach (Comment comment in Comments)
{
comment.Write(Writer);
}
}
if (Objects != null)
{
Writer.WriteAscii(ObjectData);
Writer.WriteUInt32((uint) Objects.Count);
foreach (EventObject eventObject in Objects)
{
eventObject.Write(Writer);
}
}
Writer.WriteAscii(EventEditorData);
Writer.Skip(4+2*2+4*3);
if (ObjectTypes != null)
{
Writer.WriteAscii(ObjectListData);
Writer.WriteInt16(-1);
Writer.WriteInt16((short) ObjectTypes.Count);
foreach (ushort objectType in ObjectTypes)
{
Writer.WriteUInt16(objectType);
}
foreach (ushort objectHandle in ObjectHandles)
{
Writer.WriteUInt16(objectHandle);
}
foreach (ushort objectFlag in ObjectFlags)
{
Writer.WriteUInt16(objectFlag);
}
Writer.WriteUInt16((ushort) Folders.Count);
foreach (string folder in Folders)
{
Writer.AutoWriteUnicode(folder);
}
}
if (X != 0)
{
Writer.WriteAscii(EditorPositionData);
Writer.WriteInt16(1);
Writer.WriteInt32((int) X);
Writer.WriteInt32((int) Y);
Writer.WriteUInt32(CaretType);
Writer.WriteUInt32(CaretX);
Writer.WriteUInt32(CaretY);
}
if (LineY != 0)
{
Writer.WriteAscii(EditorLineData);
Writer.WriteInt16(1);
Writer.WriteUInt32(LineY);
Writer.WriteUInt32(LineItemType);
Writer.WriteUInt32(EventLine);
Writer.WriteUInt32(EventLineY);
}
Writer.WriteAscii(EventEnd);
}
public override void Print()
{
throw new System.NotImplementedException();
}
}
public class Comment:DataLoader
{
public uint Handle;
public string Value;
public Comment(ByteReader reader) : base(reader)
{
}
public Comment(Data.ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
Handle = Reader.ReadUInt32();
Value = Helper.AutoReadUnicode(Reader);
}
public override void Write(ByteWriter Writer)
{
Writer.WriteUInt32(Handle);
Writer.AutoWriteUnicode(Value);
}
public override void Print()
{
throw new System.NotImplementedException();
}
}
public class EventObject : DataLoader
{
public uint Handle;
public ushort ObjectType;
public ushort ItemType;
public string Name;
public string TypeName;
public ushort Flags;
public uint ItemHandle;
public uint InstanceHandle;
public string Code;
public string IconBuffer;
public ushort SystemQualifier;
public EventObject(ByteReader reader) : base(reader)
{
}
public EventObject(Data.ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
Handle = Reader.ReadUInt32();
ObjectType = Reader.ReadUInt16();
ItemType = Reader.ReadUInt16();
Name = Reader.AutoReadUnicode();//Not Sure
TypeName = Reader.AutoReadUnicode();//Not Sure
Flags = Reader.ReadUInt16();
if (ObjectType == 1)//FrameItemType
{
ItemHandle = Reader.ReadUInt32();
InstanceHandle = Reader.ReadUInt32();
}
else if (ObjectType == 2)//ShortcutItemType
{
Code = Reader.ReadAscii(4);
if (Code == "OIC2")//IconBufferCode
{
IconBuffer = Reader.AutoReadUnicode();
}
}
if (ObjectType == 3) //SystemItemType
{
SystemQualifier = Reader.ReadUInt16();
}
}
public override void Write(ByteWriter Writer)
{
Writer.WriteUInt32(Handle);
Writer.WriteUInt16(ObjectType);
Writer.WriteUInt16(ItemType);
Writer.AutoWriteUnicode(Name);//Not Sure
Writer.AutoWriteUnicode(TypeName);//Not Sure
Writer.WriteUInt16(Flags);
if (ObjectType == 1)
{
Writer.WriteUInt32(ItemHandle);
Writer.WriteUInt32(InstanceHandle);
}
else if (ObjectType == 2)
{
Writer.WriteAscii(Code);
if (Code == "OIC2")
{
Writer.AutoWriteUnicode(IconBuffer);
}
}
if (ObjectType == 3)
{
Writer.WriteUInt16(SystemQualifier);
}
}
public override void Print()
{
throw new System.NotImplementedException();
}
}
}

@ -53,7 +53,7 @@ namespace DotNetCTFDumper.Utils
return temp; return temp;
} }
public static string AutoReadUnicode(ByteReader reader) public static string AutoReadUnicode(this ByteReader reader)
{ {
var len = reader.ReadInt16(); var len = reader.ReadInt16();
reader.Skip(2); reader.Skip(2);
@ -180,19 +180,7 @@ namespace DotNetCTFDumper.Utils
} }
} }
public static void OnImageSaved(int index, int 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 OneKb = 1024;
private const long OneMb = OneKb * 1024; private const long OneMb = OneKb * 1024;

@ -33,6 +33,7 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders
public override void Read() public override void Read()
{ {
long currentPosition = Reader.Tell(); long currentPosition = Reader.Tell();
uint headerSize = Reader.ReadUInt32(); uint headerSize = Reader.ReadUInt32();
int menuOffset = Reader.ReadInt32(); int menuOffset = Reader.ReadInt32();
@ -46,14 +47,14 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders
Load(Reader); Load(Reader);
Reader.Seek(currentPosition + accelOffset); Reader.Seek(currentPosition + accelOffset);
AccelShift = new List<byte>();
AccelKey = new List<short>();
AccelId = new List<short>();
for (int i = 0; i < accelSize / 8; i++) for (int i = 0; i < accelSize / 8; i++)
{ {
AccelShift = new List<byte>();
AccelKey = new List<short>();
AccelId = new List<short>();
AccelShift.Add(Reader.ReadByte()); AccelShift.Add(Reader.ReadByte());
;
Reader.Skip(1); Reader.Skip(1);
AccelKey.Add(Reader.ReadInt16()); AccelKey.Add(Reader.ReadInt16());
AccelId.Add(Reader.ReadInt16()); AccelId.Add(Reader.ReadInt16());
@ -65,7 +66,7 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders
{ {
writer.WriteInt32(20); writer.WriteInt32(20);
writer.WriteInt32(20); writer.WriteInt32(20);
writer.WriteInt32(0); writer.WriteInt32(458);
ByteWriter menuDataWriter = new ByteWriter(new MemoryStream()); ByteWriter menuDataWriter = new ByteWriter(new MemoryStream());
@ -74,7 +75,7 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders
item.Write(menuDataWriter); item.Write(menuDataWriter);
} }
writer.WriteUInt32((uint) (24 + menuDataWriter.BaseStream.Position)); writer.WriteUInt32((uint) ( menuDataWriter.BaseStream.Position)+62);//shit
writer.WriteInt32(AccelKey.Count * 8); writer.WriteInt32(AccelKey.Count * 8);
writer.WriteInt32(0); writer.WriteInt32(0);
writer.WriteWriter(menuDataWriter); writer.WriteWriter(menuDataWriter);
@ -152,7 +153,7 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders
Mnemonic = Name[i + 1].ToString().ToUpper(); Mnemonic = Name[i + 1].ToString().ToUpper();
} }
Name = Name.Replace("&", ""); //Name = Name.Replace("&", "");
} }
Console.WriteLine(Name); Console.WriteLine(Name);
@ -171,12 +172,12 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders
} }
String MName = Name; String MName = Name;
if (Mnemonic != null) if (Mnemonic!=null)
{ {
MName = MName.Replace(Mnemonic, "&" + Mnemonic); //MName = MName.Replace(Mnemonic, "&" + Mnemonic);
} }
writer.AutoWriteUnicode(MName); writer.WriteUnicode(MName);
} }
} }
} }

@ -46,6 +46,13 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks
Settings.DumpImages = cache; Settings.DumpImages = cache;
} }
public event MainForm.SaveHandler OnImageSaved;
public override void Read() public override void Read()
{ {
if (!Settings.DoMFA) Reader.Seek(0); //Reset the reader to avoid bugs when dumping more than once if (!Settings.DoMFA) Reader.Seek(0); //Reset the reader to avoid bugs when dumping more than once
@ -70,11 +77,11 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks
Images.Add(item.Handle, item); Images.Add(item.Handle, item);
if (SaveImages) item.Save($"{Settings.ImagePath}\\" + item.Handle.ToString() + ".png"); if (SaveImages) item.Save($"{Settings.ImagePath}\\" + item.Handle.ToString() + ".png");
OnImageSaved?.Invoke(i,(int) NumberOfItems);
Helper.OnImageSaved(i, (int) NumberOfItems);
if (Exe.Instance.GameData.ProductBuild >= 284) if (Settings.Build >= 284)
item.Handle -= 1; item.Handle -= 1;
//images[item.handle] = item; //images[item.handle] = item;

@ -30,7 +30,7 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks
Read(); Read();
Settings.DumpMusic = cache; Settings.DumpMusic = cache;
} }
public event MainForm.SaveHandler OnMusicSaved;
public override void Read() public override void Read()
{ {
//Someone is using this lol? //Someone is using this lol?
@ -45,7 +45,7 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks
if (MainForm.BreakMusics) break; if (MainForm.BreakMusics) break;
var item = new MusicFile(Reader); var item = new MusicFile(Reader);
item.Read(); item.Read();
Helper.OnMusicSaved(i,NumOfItems); OnMusicSaved?.Invoke(i,(int) NumOfItems);
Items.Add(item); Items.Add(item);
} }
} }

@ -33,7 +33,7 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks
Settings.DumpSounds = cache; Settings.DumpSounds = cache;
} }
public event MainForm.SaveHandler OnSoundSaved;
public override void Read() public override void Read()
{ {
//Implementing for standalone-only because of my lazyness //Implementing for standalone-only because of my lazyness
@ -58,7 +58,8 @@ namespace DotNetCTFDumper.MMFParser.ChunkLoaders.Banks
var item = new SoundItem(Reader); var item = new SoundItem(Reader);
item.IsCompressed = IsCompressed; item.IsCompressed = IsCompressed;
item.Read(); item.Read();
Helper.OnSoundSaved(i, NumOfItems);
OnSoundSaved?.Invoke(i,(int) NumOfItems);
Items.Add(item); Items.Add(item);

@ -54,6 +54,14 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders
public int Button2; public int Button2;
public int Button3; public int Button3;
public int Button4; public int Button4;
public int Unk1;
public int Unk2;
public int Unk3;
public int Unk4;
public int Unk5;
public int Unk6;
public int Unk7;
public int Unk8;
public PlayerControl(ByteReader reader) : base(reader) public PlayerControl(ByteReader reader) : base(reader)
@ -79,10 +87,15 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders
Button2 = Reader.ReadInt32(); Button2 = Reader.ReadInt32();
Button3 = Reader.ReadInt32(); Button3 = Reader.ReadInt32();
Button4 = Reader.ReadInt32(); Button4 = Reader.ReadInt32();
for (int i = 0; i < 8; i++) Unk1 = Reader.ReadInt32();
{ Unk2 = Reader.ReadInt32();
Reader.ReadInt32(); Unk3 = Reader.ReadInt32();
} Unk4 = Reader.ReadInt32();
Unk5 = Reader.ReadInt32();
Unk6 = Reader.ReadInt32();
Unk7 = Reader.ReadInt32();
Unk8 = Reader.ReadInt32();
} }
public override void Write(ByteWriter writer) public override void Write(ByteWriter writer)
@ -97,10 +110,15 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders
writer.WriteInt32(Button2); writer.WriteInt32(Button2);
writer.WriteInt32(Button3); writer.WriteInt32(Button3);
writer.WriteInt32(Button4); writer.WriteInt32(Button4);
for (int i = 0; i < 8; i++) writer.WriteInt32(Unk1);
{ writer.WriteInt32(Unk2);
writer.WriteInt32(0); writer.WriteInt32(Unk3);
} writer.WriteInt32(Unk4);
writer.WriteInt32(Unk5);
writer.WriteInt32(Unk6);
writer.WriteInt32(Unk7);
writer.WriteInt32(Unk8);
} }

@ -25,6 +25,7 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders
public int StampHandle; public int StampHandle;
public int ActiveLayer; public int ActiveLayer;
public List<Layer> Layers; public List<Layer> Layers;
public Events Events;
public Frame(ByteReader reader) : base(reader) public Frame(ByteReader reader) : base(reader)
{ {
@ -58,19 +59,25 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders
} }
//TODO: Do transitions //TODO: Do transitions
Writer.WriteInt8(0); Writer.WriteInt8(0);
Writer.WriteInt8(0);
Writer.WriteInt32(Items.Count);
foreach (var item in Items) foreach (var item in Items)
{ {
item.Write(Writer); item.Write(Writer);
} }
Writer.WriteInt32(Folders.Count);
foreach (var item in Folders) foreach (var item in Folders)
{ {
item.Write(Writer); item.Write(Writer);
} }
Writer.WriteInt32(Instances.Count);
foreach (var item in Instances) foreach (var item in Instances)
{ {
item.Write(Writer); item.Write(Writer);
} }
Events.Write(Writer);
@ -145,6 +152,8 @@ namespace DotNetCTFDumper.MMFParser.MFALoaders
//inst.Read(); //inst.Read();
Instances.Add(inst); Instances.Add(inst);
} }
Events = new Events(Reader);
Events.Read();

Loading…
Cancel
Save