Merge branch 'master' of github.com:alcexhim/UniversalEditor
This commit is contained in:
commit
3837bcbe34
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
namespace UniversalEditor.DataFormats.FileSystem.FeverPitchStudios.UTF
|
||||
{
|
||||
public class UTFDataFormat : DataFormat
|
||||
{
|
||||
private DataFormatReference _dfr = null;
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReference();
|
||||
_dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All);
|
||||
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
private uint mvarFormatVersion = 0;
|
||||
public uint FormatVersion { get { return mvarFormatVersion; } set { mvarFormatVersion = value; } }
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
string signature = reader.ReadFixedLengthString(4);
|
||||
if (signature != "UTF\0") throw new InvalidDataFormatException("File does not begin with 'UTF', 0x00");
|
||||
|
||||
mvarFormatVersion = reader.ReadUInt32();
|
||||
|
||||
uint tableOffset = reader.ReadUInt32();
|
||||
uint tableLength = reader.ReadUInt32();
|
||||
uint unknown1 = reader.ReadUInt32();
|
||||
uint entryLength = reader.ReadUInt32(); // always 44?
|
||||
uint nameTableOffset = reader.ReadUInt32(); // always 56?
|
||||
uint totalNameTableLength = reader.ReadUInt32();
|
||||
uint nameTableLength = reader.ReadUInt32();
|
||||
uint fileDataOffset = reader.ReadUInt32();
|
||||
uint unknown2 = reader.ReadUInt32();
|
||||
uint unknown3 = reader.ReadUInt32();
|
||||
uint unknown4 = reader.ReadUInt32();
|
||||
uint unknown5 = reader.ReadUInt32();
|
||||
|
||||
int tableEntryCount = (int)((double)tableLength / entryLength);
|
||||
|
||||
base.Accessor.Seek(nameTableOffset, SeekOrigin.Begin);
|
||||
string[] nameTableEntries = new string[tableEntryCount];
|
||||
for (int i = 0; i < tableEntryCount; i++)
|
||||
{
|
||||
// TODO: figure out how to read name table entries (not documented in Xentax)
|
||||
}
|
||||
|
||||
for (int i = 0; i < tableEntryCount; i++)
|
||||
{
|
||||
// table offset of next entry in same hierarchy level
|
||||
uint nextOffset = reader.ReadUInt32();
|
||||
// offset of entry's name in name table
|
||||
uint nameOffset = reader.ReadUInt32();
|
||||
|
||||
// 16:folder else:file
|
||||
UTFFlags flags = (UTFFlags)reader.ReadUInt32();
|
||||
uint unknown6 = reader.ReadUInt32();
|
||||
// file:offset in file data, folder:offset of its first entry in table
|
||||
uint dataOffset = reader.ReadUInt32();
|
||||
uint totalSize = reader.ReadUInt32();
|
||||
uint size1 = reader.ReadUInt32();
|
||||
uint size2 = reader.ReadUInt32();
|
||||
uint unknown7 = reader.ReadUInt32();
|
||||
uint unknown8 = reader.ReadUInt32();
|
||||
uint unknown9 = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.FileSystem.FeverPitchStudios.UTF
|
||||
{
|
||||
public enum UTFFlags : uint
|
||||
{
|
||||
None = 0,
|
||||
Folder = 16
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
namespace UniversalEditor.DataFormats.FileSystem.GremlinInteractive.ActuaSoccer.MAD
|
||||
{
|
||||
public class MADDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReference();
|
||||
_dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All);
|
||||
_dfr.ExportOptions.Add(new CustomOptionChoice("FormatVersion", "Format &version:", true, new CustomOptionFieldChoice[]
|
||||
{
|
||||
new CustomOptionFieldChoice("Type 1 (includes file names)", MADFormatVersion.Type1, true),
|
||||
new CustomOptionFieldChoice("Type 2 (does not include file names)", MADFormatVersion.Type2)
|
||||
}));
|
||||
_dfr.ImportOptions.Add(new CustomOptionChoice("FormatVersion", "Format &version:", true, new CustomOptionFieldChoice[]
|
||||
{
|
||||
new CustomOptionFieldChoice("Type 1 (includes file names)", MADFormatVersion.Type1, true),
|
||||
new CustomOptionFieldChoice("Type 2 (does not include file names)", MADFormatVersion.Type2)
|
||||
}));
|
||||
_dfr.Filters.Add("Gremlin Interactive - Actua Soccer MAD archive", new string[] { "*.mad" });
|
||||
_dfr.Sources.Add("http://wiki.xentax.com/index.php?title=GRAF:Actua_Soccer_MAD");
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
private MADFormatVersion mvarFormatVersion = MADFormatVersion.Type1;
|
||||
public MADFormatVersion FormatVersion { get { return mvarFormatVersion; } set { mvarFormatVersion = value; } }
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
|
||||
long currentOffset = reader.Accessor.Position;
|
||||
|
||||
// calculate count of files
|
||||
if (mvarFormatVersion == MADFormatVersion.Type1)
|
||||
{
|
||||
reader.ReadFixedLengthString(16);
|
||||
}
|
||||
uint firstFileOffset = reader.ReadUInt32();
|
||||
|
||||
uint fileCount = 0;
|
||||
switch (mvarFormatVersion)
|
||||
{
|
||||
case MADFormatVersion.Type1:
|
||||
{
|
||||
fileCount = (uint)((double)firstFileOffset / 24);
|
||||
break;
|
||||
}
|
||||
case MADFormatVersion.Type2:
|
||||
{
|
||||
fileCount = (uint)((double)firstFileOffset / 8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reader.Accessor.Seek(currentOffset, SeekOrigin.Begin);
|
||||
|
||||
for (uint i = 0; i < fileCount; i++)
|
||||
{
|
||||
string fileName = i.ToString().PadLeft(8, '0');
|
||||
if (mvarFormatVersion == MADFormatVersion.Type1)
|
||||
{
|
||||
fileName = reader.ReadFixedLengthString(16).TrimNull();
|
||||
}
|
||||
uint offset = reader.ReadUInt32();
|
||||
uint length = reader.ReadUInt32();
|
||||
|
||||
File file = fsom.AddFile(fileName);
|
||||
file.Size = length;
|
||||
file.Properties.Add("reader", reader);
|
||||
file.Properties.Add("offset", offset);
|
||||
file.Properties.Add("length", length);
|
||||
file.DataRequest += file_DataRequest;
|
||||
}
|
||||
}
|
||||
private void file_DataRequest(object sender, DataRequestEventArgs e)
|
||||
{
|
||||
File file = (sender as File);
|
||||
Reader reader = (Reader)file.Properties["reader"];
|
||||
uint offset = (uint)file.Properties["offset"];
|
||||
uint length = (uint)file.Properties["length"];
|
||||
reader.Seek(offset, SeekOrigin.Begin);
|
||||
e.Data = reader.ReadBytes(length);
|
||||
}
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
File[] files = fsom.GetAllFiles();
|
||||
|
||||
Writer writer = base.Accessor.Writer;
|
||||
uint offset = 0;
|
||||
|
||||
for (uint i = 0; i < files.Length; i++)
|
||||
{
|
||||
offset += 8;
|
||||
if (mvarFormatVersion == MADFormatVersion.Type1) offset += 16;
|
||||
}
|
||||
for (uint i = 0; i < files.Length; i++)
|
||||
{
|
||||
if (mvarFormatVersion == MADFormatVersion.Type1) writer.WriteFixedLengthString(files[i].Name, 16);
|
||||
uint length = (uint)files[i].Size;
|
||||
writer.WriteUInt32(offset);
|
||||
writer.WriteUInt32(length);
|
||||
offset += length;
|
||||
}
|
||||
for (uint i = 0; i < files.Length; i++)
|
||||
{
|
||||
writer.WriteBytes(files[i].GetDataAsByteArray());
|
||||
}
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.FileSystem.GremlinInteractive.ActuaSoccer.MAD
|
||||
{
|
||||
public enum MADFormatVersion
|
||||
{
|
||||
Type1,
|
||||
Type2
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
namespace UniversalEditor.DataFormats.FileSystem.KensLabyrinth.KZP
|
||||
{
|
||||
public class KZPDataFormat : DataFormat
|
||||
{
|
||||
private DataFormatReference _dfr = null;
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReference();
|
||||
_dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All);
|
||||
_dfr.Filters.Add("Ken's Labyrinth KZP archive", new string[] { "*.kzp" });
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
ushort fileCount = reader.ReadUInt16();
|
||||
for (ushort i = 0; i < fileCount; i++)
|
||||
{
|
||||
string fileName = reader.ReadFixedLengthString(8).TrimNull();
|
||||
uint offset = reader.ReadUInt32();
|
||||
uint length = 0;
|
||||
if (i == fileCount - 1)
|
||||
{
|
||||
length = (uint)(base.Accessor.Length - offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
string nextFileName = reader.ReadFixedLengthString(8);
|
||||
uint nextFileOffset = reader.ReadUInt32();
|
||||
reader.Seek(-12, SeekOrigin.Current);
|
||||
length = (uint)(nextFileOffset - offset);
|
||||
}
|
||||
|
||||
File file = fsom.AddFile(fileName);
|
||||
file.Size = length;
|
||||
file.Properties.Add("reader", reader);
|
||||
file.Properties.Add("offset", offset);
|
||||
file.Properties.Add("length", length);
|
||||
file.DataRequest += file_DataRequest;
|
||||
}
|
||||
}
|
||||
private void file_DataRequest(object sender, DataRequestEventArgs e)
|
||||
{
|
||||
File file = (sender as File);
|
||||
Reader reader = (Reader)file.Properties["reader"];
|
||||
uint offset = (uint)file.Properties["offset"];
|
||||
uint length = (uint)file.Properties["length"];
|
||||
reader.Seek(offset, SeekOrigin.Begin);
|
||||
e.Data = reader.ReadBytes(length);
|
||||
}
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Writer writer = base.Accessor.Writer;
|
||||
File[] files = fsom.GetAllFiles();
|
||||
writer.WriteUInt16((ushort)files.Length);
|
||||
|
||||
uint offset = (uint)(2 + (12 * (ushort)files.Length));
|
||||
for (ushort i = 0; i < (ushort)files.Length; i++)
|
||||
{
|
||||
writer.WriteFixedLengthString(files[i].Name, 8);
|
||||
writer.WriteUInt32(offset);
|
||||
offset += (uint)files[i].Size;
|
||||
}
|
||||
for (ushort i = 0; i < (ushort)files.Length; i++)
|
||||
{
|
||||
writer.WriteBytes(files[i].GetDataAsByteArray());
|
||||
}
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
namespace UniversalEditor.DataFormats.FileSystem.PrincessWaltz.ARC
|
||||
{
|
||||
public class ARCDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReference();
|
||||
_dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All);
|
||||
_dfr.Filters.Add("Princess Waltz ARC", new string[] { "*.arc" });
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
uint fileExtensionCount = reader.ReadUInt32();
|
||||
Dictionary<string, uint> countsByExtension = new Dictionary<string, uint>();
|
||||
for (uint i = 0; i < fileExtensionCount; i++)
|
||||
{
|
||||
string extension = reader.ReadFixedLengthString(4).TrimNull();
|
||||
uint fileCount = reader.ReadUInt32();
|
||||
uint unknown1 = reader.ReadUInt32();
|
||||
countsByExtension.Add(extension, fileCount);
|
||||
}
|
||||
foreach (KeyValuePair<string, uint> kvp in countsByExtension)
|
||||
{
|
||||
uint count = kvp.Value;
|
||||
for (uint j = 0; j < count; j++)
|
||||
{
|
||||
string fileName = reader.ReadFixedLengthString(8).TrimNull();
|
||||
byte padding = reader.ReadByte();
|
||||
fileName += "." + kvp.Key;
|
||||
|
||||
uint length = reader.ReadUInt32();
|
||||
uint offset = reader.ReadUInt32();
|
||||
|
||||
File file = fsom.AddFile(fileName);
|
||||
file.Size = length;
|
||||
file.Properties.Add("reader", reader);
|
||||
file.Properties.Add("length", length);
|
||||
file.Properties.Add("offset", offset);
|
||||
file.DataRequest += file_DataRequest;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void file_DataRequest(object sender, DataRequestEventArgs e)
|
||||
{
|
||||
File file = (sender as File);
|
||||
Reader reader = (Reader)file.Properties["reader"];
|
||||
uint length = (uint)file.Properties["length"];
|
||||
uint offset = (uint)file.Properties["offset"];
|
||||
reader.Seek(offset, SeekOrigin.Begin);
|
||||
e.Data = reader.ReadBytes(length);
|
||||
}
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Writer writer = base.Accessor.Writer;
|
||||
|
||||
Dictionary<string, List<File>> filesByExtension = new Dictionary<string, List<File>>();
|
||||
File[] files = fsom.GetAllFiles();
|
||||
foreach (File file in files)
|
||||
{
|
||||
string ext = System.IO.Path.GetExtension(file.Name);
|
||||
if (ext.StartsWith(".")) ext = ext.Substring(1);
|
||||
if (!filesByExtension.ContainsKey(ext))
|
||||
{
|
||||
filesByExtension.Add(ext, new List<File>());
|
||||
}
|
||||
filesByExtension[ext].Add(file);
|
||||
}
|
||||
|
||||
uint fileExtensionCount = (uint)filesByExtension.Count;
|
||||
writer.WriteUInt32(fileExtensionCount);
|
||||
foreach (KeyValuePair<string, List<File>> kvp in filesByExtension)
|
||||
{
|
||||
writer.WriteFixedLengthString(kvp.Key, 4);
|
||||
writer.WriteUInt32((uint)kvp.Value.Count);
|
||||
writer.WriteUInt32(0);
|
||||
}
|
||||
|
||||
uint offset = (uint)(4 + (12 * filesByExtension.Count) + (17 * files.Length));
|
||||
|
||||
foreach (KeyValuePair<string, List<File>> kvp in filesByExtension)
|
||||
{
|
||||
foreach (File file in kvp.Value)
|
||||
{
|
||||
string fileName = System.IO.Path.GetFileNameWithoutExtension(file.Name);
|
||||
writer.WriteFixedLengthString(fileName, 8);
|
||||
writer.WriteByte(0);
|
||||
|
||||
uint length = (uint)file.Size;
|
||||
writer.WriteUInt32(length);
|
||||
writer.WriteUInt32(offset);
|
||||
offset += length;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, List<File>> kvp in filesByExtension)
|
||||
{
|
||||
foreach (File file in kvp.Value)
|
||||
{
|
||||
writer.WriteBytes(file.GetDataAsByteArray());
|
||||
}
|
||||
}
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,10 +92,14 @@
|
||||
<Compile Include="DataFormats\FileSystem\FAT\FATFileAttributes.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\FAT\FATMediaDescriptor.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\FAT\FATUserAttributes.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\FeverPitchStudios\UTF\UTFDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\FeverPitchStudios\UTF\UTFFlags.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\FFS\FFSDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\FSB\FSBDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\Garena\YanghxDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\GCD\GCDDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\GremlinInteractive\ActuaSoccer\MAD\MADDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\GremlinInteractive\ActuaSoccer\MAD\MADFormatVersion.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\IndianaJones\GOB\GOBDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\GPW\GPWDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\Hardball\MB6DataFormat.cs" />
|
||||
@ -110,6 +114,7 @@
|
||||
<Compile Include="DataFormats\FileSystem\ISO\ISOVolumeDescriptorType.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\JackOrlando\JackOrlandoDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\JadeEmpire\RIMDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\KensLabyrinth\KZP\KZPDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\LHA\LHADataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\LHA\LZHDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\MementoMori\RESCompressionType.cs" />
|
||||
@ -131,6 +136,7 @@
|
||||
<Compile Include="DataFormats\FileSystem\PCK\PCKDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\PKG\PKGDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\PRF\PRFDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\PrincessWaltz\ARC\ARCDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\ProDOS\ProDOSDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\REEVEsoft\Freeze\ICEDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\Roxor\PCK\PCKDataFormat.cs" />
|
||||
@ -143,6 +149,7 @@
|
||||
<Compile Include="DataFormats\FileSystem\SevenZip\SevenZipPackInfo.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\SevenZip\SevenZipUnpackInfo.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\SilentHill\ARC\SilentHillARCDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\SinisterGames\GUT\GUTDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\SPIS\SPISDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\StellaGames\LzmaPack\PACKDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\StellaGames\LzmaPack\PACKFileAttributes.cs" />
|
||||
|
||||
@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
namespace UniversalEditor.Plugins.Gainax.DataFormats.LBX
|
||||
{
|
||||
public class LBXDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReference();
|
||||
_dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All);
|
||||
_dfr.Filters.Add("Gainax LBX archive", new string[] { "*.lbx" });
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
if (base.Accessor.Length < 6) throw new InvalidDataFormatException("File must be greater than 4 bytes");
|
||||
|
||||
base.Accessor.Seek(-6, SeekOrigin.End);
|
||||
|
||||
ushort fileCount = reader.ReadUInt16();
|
||||
uint directoryOffset = reader.ReadUInt32();
|
||||
if (directoryOffset > base.Accessor.Length) throw new InvalidDataFormatException("Directory offset goes past end of file");
|
||||
|
||||
base.Accessor.Seek(directoryOffset, SeekOrigin.Begin);
|
||||
|
||||
for (ushort i = 0; i < fileCount; i++)
|
||||
{
|
||||
string fileName = reader.ReadFixedLengthString(12).TrimNull();
|
||||
uint offset = reader.ReadUInt32();
|
||||
uint length = reader.ReadUInt32();
|
||||
|
||||
File file = fsom.AddFile(fileName);
|
||||
file.Size = length;
|
||||
file.Properties.Add("reader", reader);
|
||||
file.Properties.Add("offset", offset);
|
||||
file.Properties.Add("length", length);
|
||||
file.DataRequest += file_DataRequest;
|
||||
}
|
||||
}
|
||||
|
||||
private void file_DataRequest(object sender, DataRequestEventArgs e)
|
||||
{
|
||||
File file = (sender as File);
|
||||
Reader reader = (Reader)file.Properties["reader"];
|
||||
uint offset = (uint)file.Properties["offset"];
|
||||
uint length = (uint)file.Properties["length"];
|
||||
|
||||
reader.Accessor.Seek(offset, SeekOrigin.Begin);
|
||||
e.Data = reader.ReadBytes(length);
|
||||
}
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Writer writer = base.Accessor.Writer;
|
||||
|
||||
File[] files = fsom.GetAllFiles();
|
||||
uint[] offsets = new uint[files.Length];
|
||||
uint[] lengths = new uint[files.Length];
|
||||
|
||||
uint offset = 0;
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
byte[] data = files[i].GetDataAsByteArray();
|
||||
writer.WriteBytes(data);
|
||||
|
||||
lengths[i] = (uint)data.Length;
|
||||
offsets[i] = offset;
|
||||
offset += (uint)data.Length;
|
||||
}
|
||||
|
||||
uint directoryOffset = (uint)base.Accessor.Position;
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
writer.WriteFixedLengthString(files[i].Name, 12);
|
||||
writer.WriteUInt32(offsets[i]);
|
||||
writer.WriteUInt32(lengths[i]);
|
||||
}
|
||||
|
||||
writer.WriteUInt16((ushort)files.Length);
|
||||
writer.WriteUInt32(directoryOffset);
|
||||
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Gainax plugin for Universal Editor")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Mike Becker's Software")]
|
||||
[assembly: AssemblyProduct("Universal Editor Plugin Pack")]
|
||||
[assembly: AssemblyCopyright("Copyright ©2014 Mike Becker's Software")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("95def98c-f0db-4778-a823-ee69121b8a21")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{7BB04C9F-DC3F-448A-8FD3-9A6BB52BC886}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>UniversalEditor.Plugins.Gainax</RootNamespace>
|
||||
<AssemblyName>UniversalEditor.Plugins.Gainax</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\Debug\Plugins\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\Release\Plugins\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataFormats\LBX\LBXDataFormat.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
|
||||
<Project>{2d4737e6-6d95-408a-90db-8dff38147e85}</Project>
|
||||
<Name>UniversalEditor.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
|
||||
<Project>{30467e5c-05bc-4856-aadc-13906ef4cadd}</Project>
|
||||
<Name>UniversalEditor.Essential</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@ -133,6 +133,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Web
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Web.UserInterface.WindowsForms", "Engines\WindowsForms\Plugins\UniversalEditor.Plugins.Web.UserInterface.WindowsForms\UniversalEditor.Plugins.Web.UserInterface.WindowsForms.csproj", "{997FFB89-0ED6-47EB-BD97-68B3138F91AD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Gainax", "Plugins\UniversalEditor.Plugins.Gainax\UniversalEditor.Plugins.Gainax.csproj", "{7BB04C9F-DC3F-448A-8FD3-9A6BB52BC886}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -360,6 +362,10 @@ Global
|
||||
{997FFB89-0ED6-47EB-BD97-68B3138F91AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{997FFB89-0ED6-47EB-BD97-68B3138F91AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{997FFB89-0ED6-47EB-BD97-68B3138F91AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7BB04C9F-DC3F-448A-8FD3-9A6BB52BC886}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7BB04C9F-DC3F-448A-8FD3-9A6BB52BC886}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7BB04C9F-DC3F-448A-8FD3-9A6BB52BC886}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7BB04C9F-DC3F-448A-8FD3-9A6BB52BC886}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -404,6 +410,7 @@ Global
|
||||
{CC5C9010-83EF-491D-9262-2CED509D895D} = {71CFF024-26F7-4626-A526-B435FDF8D64E}
|
||||
{7C861D40-8214-4DC5-89D1-129F267C1D1B} = {71CFF024-26F7-4626-A526-B435FDF8D64E}
|
||||
{64089452-6A08-47A5-A857-BF418F80D4A3} = {71CFF024-26F7-4626-A526-B435FDF8D64E}
|
||||
{7BB04C9F-DC3F-448A-8FD3-9A6BB52BC886} = {71CFF024-26F7-4626-A526-B435FDF8D64E}
|
||||
{FE016EA3-DC31-4A92-8B0A-8C746EC117E1} = {46041F27-7C1C-4209-B72B-251EDB5D4C61}
|
||||
{ED627DF7-3E78-4428-AB31-810BA1586E62} = {46041F27-7C1C-4209-B72B-251EDB5D4C61}
|
||||
{C1F34183-7A2F-41A6-9958-F6F329099654} = {A846CA33-9CAA-4237-B14F-8721DBA89442}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user