|
|
@ -2,6 +2,7 @@
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
using System.Security.AccessControl;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using DotNetCTFDumper.MMFParser.EXE;
|
|
|
|
using DotNetCTFDumper.MMFParser.EXE;
|
|
|
|
using DotNetCTFDumper.MMFParser.EXE.Loaders.Events;
|
|
|
|
using DotNetCTFDumper.MMFParser.EXE.Loaders.Events;
|
|
|
@ -41,6 +42,7 @@ namespace DotNetCTFDumper.MMFParser.MFA.Loaders
|
|
|
|
public uint EventLine;
|
|
|
|
public uint EventLine;
|
|
|
|
public uint EventLineY;
|
|
|
|
public uint EventLineY;
|
|
|
|
public byte[] Saved;
|
|
|
|
public byte[] Saved;
|
|
|
|
|
|
|
|
public int EditorDataUnk;
|
|
|
|
|
|
|
|
|
|
|
|
public Events(ByteReader reader) : base(reader)
|
|
|
|
public Events(ByteReader reader) : base(reader)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -52,8 +54,7 @@ namespace DotNetCTFDumper.MMFParser.MFA.Loaders
|
|
|
|
|
|
|
|
|
|
|
|
public override void Read()
|
|
|
|
public override void Read()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Saved = Reader.ReadBytes(92);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
Version = Reader.ReadUInt16();
|
|
|
|
Version = Reader.ReadUInt16();
|
|
|
|
FrameType = Reader.ReadUInt16();
|
|
|
|
FrameType = Reader.ReadUInt16();
|
|
|
|
Items = new List<EventGroup>();
|
|
|
|
Items = new List<EventGroup>();
|
|
|
@ -109,7 +110,7 @@ namespace DotNetCTFDumper.MMFParser.MFA.Loaders
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == EventEditorData)
|
|
|
|
else if (name == EventEditorData)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Reader.Skip(4);
|
|
|
|
EditorDataUnk = Reader.ReadInt32();
|
|
|
|
ConditionWidth = Reader.ReadUInt16();
|
|
|
|
ConditionWidth = Reader.ReadUInt16();
|
|
|
|
ObjectHeight = Reader.ReadUInt16();
|
|
|
|
ObjectHeight = Reader.ReadUInt16();
|
|
|
|
Reader.Skip(12);
|
|
|
|
Reader.Skip(12);
|
|
|
@ -178,45 +179,42 @@ namespace DotNetCTFDumper.MMFParser.MFA.Loaders
|
|
|
|
|
|
|
|
|
|
|
|
public override void Write(ByteWriter Writer)
|
|
|
|
public override void Write(ByteWriter Writer)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Writer.WriteBytes(Saved);
|
|
|
|
//Writer.WriteBytes(Saved);
|
|
|
|
return;
|
|
|
|
//return;
|
|
|
|
Writer.WriteUInt16(Version);
|
|
|
|
using (ByteWriter debug = new ByteWriter(new MemoryStream()))
|
|
|
|
Writer.WriteInt16((short) FrameType);
|
|
|
|
|
|
|
|
Writer.WriteBytes(new byte[]{0x04,0x04,0x00,0x00});
|
|
|
|
|
|
|
|
if (Items != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Writer.WriteAscii(EventData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ByteWriter newWriter = new ByteWriter(new MemoryStream());
|
|
|
|
//Writer = new ByteWriter(new MemoryStream());
|
|
|
|
foreach (EventGroup eventGroup in Items)
|
|
|
|
Writer.WriteUInt16(Version);
|
|
|
|
{
|
|
|
|
Writer.WriteInt16((short) FrameType);
|
|
|
|
eventGroup.Write(newWriter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Writer.WriteWriter(newWriter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Comments != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Writer.WriteAscii(CommentData);
|
|
|
|
|
|
|
|
foreach (Comment comment in Comments)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
comment.Write(Writer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Objects != null)
|
|
|
|
//Writer.WriteBytes(new byte[] {0x04, 0x04, 0x00, 0x00});
|
|
|
|
{
|
|
|
|
// if (Items != null)
|
|
|
|
Writer.WriteAscii(ObjectData);
|
|
|
|
// {
|
|
|
|
Writer.WriteUInt32((uint) Objects.Count);
|
|
|
|
// Console.WriteLine("Writing EventData");
|
|
|
|
foreach (EventObject eventObject in Objects)
|
|
|
|
// Writer.WriteAscii(EventData);
|
|
|
|
{
|
|
|
|
//
|
|
|
|
eventObject.Write(Writer);
|
|
|
|
// ByteWriter newWriter = new ByteWriter(new MemoryStream());
|
|
|
|
}
|
|
|
|
// foreach (EventGroup eventGroup in Items)
|
|
|
|
}
|
|
|
|
// {
|
|
|
|
Writer.WriteAscii(EventEditorData);
|
|
|
|
// eventGroup.Write(newWriter);
|
|
|
|
Writer.Skip(4+2*2+4*3);
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Writer.WriteWriter(newWriter);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (Objects != null)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// Console.WriteLine("Writing EventObjects");
|
|
|
|
|
|
|
|
// Writer.WriteAscii(ObjectData);
|
|
|
|
|
|
|
|
// Writer.WriteUInt32((uint) Objects.Count);
|
|
|
|
|
|
|
|
// foreach (EventObject eventObject in Objects)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// eventObject.Write(Writer);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
if (ObjectTypes != null)
|
|
|
|
if (ObjectTypes != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Console.WriteLine("Writing ObjectTypes");
|
|
|
|
Writer.WriteAscii(ObjectListData);
|
|
|
|
Writer.WriteAscii(ObjectListData);
|
|
|
|
Writer.WriteInt16(-1);
|
|
|
|
Writer.WriteInt16(-1);
|
|
|
|
Writer.WriteInt16((short) ObjectTypes.Count);
|
|
|
|
Writer.WriteInt16((short) ObjectTypes.Count);
|
|
|
@ -224,24 +222,26 @@ namespace DotNetCTFDumper.MMFParser.MFA.Loaders
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Writer.WriteUInt16(objectType);
|
|
|
|
Writer.WriteUInt16(objectType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (ushort objectHandle in ObjectHandles)
|
|
|
|
foreach (ushort objectHandle in ObjectHandles)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Writer.WriteUInt16(objectHandle);
|
|
|
|
Writer.WriteUInt16(objectHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (ushort objectFlag in ObjectFlags)
|
|
|
|
foreach (ushort objectFlag in ObjectFlags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Writer.WriteUInt16(objectFlag);
|
|
|
|
Writer.WriteUInt16(objectFlag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Writer.WriteUInt16((ushort) Folders.Count);
|
|
|
|
Writer.WriteUInt16((ushort) Folders.Count);
|
|
|
|
foreach (string folder in Folders)
|
|
|
|
foreach (string folder in Folders)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Writer.AutoWriteUnicode(folder);
|
|
|
|
Writer.AutoWriteUnicode(folder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (X != 0)
|
|
|
|
if (X != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Console.WriteLine("Writing X");
|
|
|
|
Writer.WriteAscii(EditorPositionData);
|
|
|
|
Writer.WriteAscii(EditorPositionData);
|
|
|
|
Writer.WriteInt16(1);
|
|
|
|
Writer.WriteInt16(1);
|
|
|
|
Writer.WriteInt32((int) X);
|
|
|
|
Writer.WriteInt32((int) X);
|
|
|
@ -250,9 +250,9 @@ namespace DotNetCTFDumper.MMFParser.MFA.Loaders
|
|
|
|
Writer.WriteUInt32(CaretX);
|
|
|
|
Writer.WriteUInt32(CaretX);
|
|
|
|
Writer.WriteUInt32(CaretY);
|
|
|
|
Writer.WriteUInt32(CaretY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (LineY != 0)
|
|
|
|
if (LineY != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Console.WriteLine("Writing LineY");
|
|
|
|
Writer.WriteAscii(EditorLineData);
|
|
|
|
Writer.WriteAscii(EditorLineData);
|
|
|
|
Writer.WriteInt16(1);
|
|
|
|
Writer.WriteInt16(1);
|
|
|
|
Writer.WriteUInt32(LineY);
|
|
|
|
Writer.WriteUInt32(LineY);
|
|
|
@ -260,9 +260,49 @@ namespace DotNetCTFDumper.MMFParser.MFA.Loaders
|
|
|
|
Writer.WriteUInt32(EventLine);
|
|
|
|
Writer.WriteUInt32(EventLine);
|
|
|
|
Writer.WriteUInt32(EventLineY);
|
|
|
|
Writer.WriteUInt32(EventLineY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Console.WriteLine("Writing EventEditorData");
|
|
|
|
|
|
|
|
Writer.WriteAscii(EventEditorData);
|
|
|
|
|
|
|
|
Writer.WriteInt32(EditorDataUnk);
|
|
|
|
|
|
|
|
Writer.WriteInt16((short) ConditionWidth);
|
|
|
|
|
|
|
|
Writer.WriteInt16((short) ObjectHeight);
|
|
|
|
|
|
|
|
Writer.Skip(12);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Writer.Skip((4 + 2 * 2 + 4 * 3)-4);
|
|
|
|
|
|
|
|
|
|
|
|
Writer.WriteAscii(EventEnd);
|
|
|
|
Writer.WriteAscii(EventEnd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Fix commented part
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (Comments != null)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// Console.WriteLine("Writing Comments");
|
|
|
|
|
|
|
|
// Writer.WriteAscii(CommentData);
|
|
|
|
|
|
|
|
// foreach (Comment comment in Comments)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// comment.Write(Writer);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var data = ((MemoryStream) Writer.BaseStream).GetBuffer();
|
|
|
|
|
|
|
|
Array.Resize(ref data,(int) Writer.Size());
|
|
|
|
|
|
|
|
File.WriteAllBytes("MyEvents.bin",data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|