the CPK data format should be in a separate CRI plugin after all...
This commit is contained in:
parent
52c8c050f3
commit
8f797ee03f
@ -3,7 +3,7 @@
|
||||
<Associations>
|
||||
<Association>
|
||||
<Filters>
|
||||
<Filter Title="SEGA Universal Media Disc CPK archive">
|
||||
<Filter Title="CRI Middleware CPK archive">
|
||||
<FileNameFilters>
|
||||
<FileNameFilter>*.cpk</FileNameFilter>
|
||||
</FileNameFilters>
|
||||
@ -18,7 +18,7 @@
|
||||
<ObjectModel TypeName="UniversalEditor.ObjectModels.FileSystem.FileSystemObjectModel" />
|
||||
</ObjectModels>
|
||||
<DataFormats>
|
||||
<DataFormat TypeName="UniversalEditor.DataFormats.FileSystem.SEGA.CPK.CPKDataFormat" />
|
||||
<DataFormat TypeName="UniversalEditor.Plugins.CRI.DataFormats.FileSystem.CPK.CPKDataFormat" />
|
||||
</DataFormats>
|
||||
</Association>
|
||||
</Associations>
|
||||
@ -650,7 +650,7 @@
|
||||
<Content Include="ProjectTypes\{B37FAACC-9946-454A-B4DB-4FAB8D044316}.uexml" />
|
||||
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\SlightlyMadStudiosBFF.uexml" />
|
||||
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\SquareSoftLGP.uexml" />
|
||||
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\SegaCPK.uexml" />
|
||||
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\CRICPK.uexml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Configuration\Application.upl" />
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
namespace UniversalEditor.DataFormats.FileSystem.SEGA.CPK
|
||||
namespace UniversalEditor.Plugins.CRI.DataFormats.FileSystem.CPK
|
||||
{
|
||||
enum CPKColumnDataType : byte
|
||||
{
|
||||
@ -19,7 +19,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
namespace UniversalEditor.DataFormats.FileSystem.SEGA.CPK
|
||||
namespace UniversalEditor.Plugins.CRI.DataFormats.FileSystem.CPK
|
||||
{
|
||||
enum CPKColumnStorageType : byte
|
||||
{
|
||||
@ -1,330 +1,331 @@
|
||||
// Universal Editor file format module for SEGA UMD CPK archive files
|
||||
// Copyright (C) 2011 Mike Becker
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
using System;
|
||||
// Universal Editor file format module for SEGA UMD CPK archive files
|
||||
// Copyright (C) 2011 Mike Becker
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
using System;
|
||||
|
||||
using UniversalEditor.ObjectModels.Database;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
namespace UniversalEditor.DataFormats.FileSystem.SEGA.CPK
|
||||
{
|
||||
public class CPKDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
namespace UniversalEditor.Plugins.CRI.DataFormats.FileSystem.CPK
|
||||
{
|
||||
public class CPKDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
protected override DataFormatReference MakeReferenceInternal()
|
||||
{
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReferenceInternal();
|
||||
{
|
||||
_dfr = base.MakeReferenceInternal();
|
||||
_dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All);
|
||||
}
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
private struct UTFTABLEINFO
|
||||
{
|
||||
public long utfOffset;
|
||||
public int tableSize;
|
||||
public int schemaOffset;
|
||||
public int rowsOffset;
|
||||
public int stringTableOffset;
|
||||
public int dataOffset;
|
||||
public uint tableNameStringIndex;
|
||||
public short tableColumns;
|
||||
public short rowWidth;
|
||||
public int tableRows;
|
||||
public int stringTableSize;
|
||||
}
|
||||
|
||||
private UTFTABLEINFO ReadUTFTableInfo(IO.Reader br)
|
||||
{
|
||||
UTFTABLEINFO info = new UTFTABLEINFO();
|
||||
info.utfOffset = Accessor.Position;
|
||||
info.tableSize = br.ReadInt32();
|
||||
info.schemaOffset = 0x20;
|
||||
info.rowsOffset = br.ReadInt32();
|
||||
info.stringTableOffset = br.ReadInt32();
|
||||
info.dataOffset = br.ReadInt32();
|
||||
info.tableNameStringIndex = br.ReadUInt32();
|
||||
info.tableColumns = br.ReadInt16();
|
||||
info.rowWidth = br.ReadInt16();
|
||||
info.tableRows = br.ReadInt32();
|
||||
info.stringTableSize = info.dataOffset - info.stringTableOffset;
|
||||
return info;
|
||||
}
|
||||
|
||||
private DatabaseTable ReadUTFTable(IO.Reader br)
|
||||
{
|
||||
DatabaseTable dt = new DatabaseTable();
|
||||
dt.Name = "@UTF";
|
||||
|
||||
string utfSignal = br.ReadFixedLengthString(4);
|
||||
|
||||
if (utfSignal != "@UTF")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
UTFTABLEINFO info = ReadUTFTableInfo(br);
|
||||
|
||||
int[] columnNameIndices = new int[info.tableColumns];
|
||||
long[] constantOffsets = new long[info.tableColumns];
|
||||
CPKColumnStorageType[] storageTypes = new CPKColumnStorageType[info.tableColumns];
|
||||
CPKColumnDataType[] dataTypes = new CPKColumnDataType[info.tableColumns];
|
||||
|
||||
for (int i = 0; i < info.tableColumns; i++)
|
||||
{
|
||||
byte schema = br.ReadByte();
|
||||
columnNameIndices[i] = br.ReadInt32();
|
||||
|
||||
storageTypes[i] = (CPKColumnStorageType)(schema & (byte)CPKColumnStorageType.Mask);
|
||||
dataTypes[i] = (CPKColumnDataType)(schema & (byte)CPKColumnDataType.Mask);
|
||||
|
||||
if (storageTypes[i] == CPKColumnStorageType.Constant)
|
||||
{
|
||||
constantOffsets[i] = Accessor.Position;
|
||||
switch (dataTypes[i])
|
||||
{
|
||||
case CPKColumnDataType.Long:
|
||||
case CPKColumnDataType.Long2:
|
||||
case CPKColumnDataType.Data:
|
||||
{
|
||||
long dummy = br.ReadInt64();
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Float:
|
||||
{
|
||||
float dummy = br.ReadSingle();
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.String:
|
||||
case CPKColumnDataType.Int:
|
||||
case CPKColumnDataType.Int2:
|
||||
{
|
||||
int dummy = br.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Short:
|
||||
case CPKColumnDataType.Short2:
|
||||
{
|
||||
short dummy = br.ReadInt16();
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Byte:
|
||||
case CPKColumnDataType.Byte2:
|
||||
{
|
||||
byte dummy = br.ReadByte();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Console.WriteLine("cpk: ReadUTFTable: unknown data type for column " + i.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dt.Fields.Add("Field" + i.ToString(), null);
|
||||
}
|
||||
|
||||
// Read string table
|
||||
|
||||
Accessor.Seek(info.stringTableOffset + 8 + 0x10, IO.SeekOrigin.Begin);
|
||||
|
||||
string[] stringTable = br.ReadNullTerminatedStringArray(info.stringTableSize);
|
||||
|
||||
string tableName = stringTable[info.tableNameStringIndex];
|
||||
|
||||
|
||||
// Seek to string table offset
|
||||
Accessor.Seek(info.stringTableOffset + 4 + info.utfOffset, IO.SeekOrigin.Begin);
|
||||
for (short i = 0; i < info.tableColumns; i++)
|
||||
{
|
||||
string columnName = br.ReadNullTerminatedString();
|
||||
dt.Fields[i].Name = columnName;
|
||||
}
|
||||
|
||||
for (int i = 0; i < info.tableRows; i++)
|
||||
{
|
||||
uint rowOffset = (uint)(info.utfOffset + 8 + info.rowsOffset + (i * info.rowWidth));
|
||||
uint rowStartOffset = rowOffset;
|
||||
|
||||
DatabaseRecord record = new DatabaseRecord();
|
||||
|
||||
for (int j = 0; j < info.tableColumns; j++)
|
||||
{
|
||||
CPKColumnStorageType storageType = storageTypes[j];
|
||||
CPKColumnDataType dataType = dataTypes[j];
|
||||
long constantOffset = constantOffsets[j];
|
||||
|
||||
switch (storageType)
|
||||
{
|
||||
case CPKColumnStorageType.PerRow:
|
||||
break;
|
||||
case CPKColumnStorageType.Constant:
|
||||
break;
|
||||
case CPKColumnStorageType.Zero:
|
||||
record.Fields.Add(dt.Fields[j].Name, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
long dataOffset1 = 0;
|
||||
if (storageType == CPKColumnStorageType.Constant)
|
||||
{
|
||||
dataOffset1 = constantOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataOffset1 = rowOffset;
|
||||
}
|
||||
|
||||
Accessor.Seek(dataOffset1, IO.SeekOrigin.Begin);
|
||||
switch (dataType)
|
||||
{
|
||||
case CPKColumnDataType.String:
|
||||
{
|
||||
uint stringOffset = br.ReadUInt32();
|
||||
string value = null;
|
||||
if (stringOffset < stringTable.Length)
|
||||
{
|
||||
value = stringTable[stringOffset];
|
||||
}
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Data:
|
||||
{
|
||||
uint varDataOffset = br.ReadUInt32();
|
||||
uint varDataSize = br.ReadUInt32();
|
||||
|
||||
byte[] value = new byte[0];
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
|
||||
// Is the data in another table??
|
||||
// ReadUTFTable(br);
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Long:
|
||||
case CPKColumnDataType.Long2:
|
||||
{
|
||||
ulong value = br.ReadUInt64();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Int:
|
||||
case CPKColumnDataType.Int2:
|
||||
{
|
||||
uint value = br.ReadUInt32();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Short:
|
||||
case CPKColumnDataType.Short2:
|
||||
{
|
||||
ushort value = br.ReadUInt16();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Float:
|
||||
{
|
||||
float value = br.ReadSingle();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Byte:
|
||||
case CPKColumnDataType.Byte2:
|
||||
{
|
||||
byte value = br.ReadByte();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dt.Records.Add(record);
|
||||
}
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
private string[] ReadUTFStringTable(IO.Reader br)
|
||||
{
|
||||
Accessor.Seek(12, IO.SeekOrigin.Current);
|
||||
|
||||
UTFTABLEINFO info = ReadUTFTableInfo(br);
|
||||
string[] value = br.ReadNullTerminatedStringArray(info.stringTableSize);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
protected override void LoadInternal (ref ObjectModel objectModel)
|
||||
{
|
||||
ObjectModels.FileSystem.FileSystemObjectModel fsom = (objectModel as ObjectModels.FileSystem.FileSystemObjectModel);
|
||||
if (fsom == null)
|
||||
throw new ObjectModelNotSupportedException();
|
||||
}
|
||||
|
||||
IO.Reader br = Accessor.Reader;
|
||||
br.Endianness = IO.Endianness.BigEndian;
|
||||
|
||||
// Rebuilt based on cpk_unpack
|
||||
Accessor.Seek(0, IO.SeekOrigin.Begin);
|
||||
|
||||
string CPK = br.ReadFixedLengthString (4);
|
||||
Accessor.Seek(0x10, IO.SeekOrigin.Begin);
|
||||
|
||||
DatabaseTable dtUTF = ReadUTFTable(br);
|
||||
|
||||
// For now, just hardcode the TOC offset
|
||||
long tocOffset = 2048; // (long)dtUTF.Records[0].Fields["TocOffset"].Value;
|
||||
Accessor.Seek(tocOffset, IO.SeekOrigin.Begin);
|
||||
|
||||
string tocSignature = br.ReadFixedLengthString(4);
|
||||
long tocEntries = (long)dtUTF.Records.Count;
|
||||
|
||||
string[] tocStringTable = ReadUTFStringTable(br);
|
||||
|
||||
Accessor.Seek(2064, IO.SeekOrigin.Begin);
|
||||
DatabaseTable dtUTF2 = ReadUTFTable(br);
|
||||
|
||||
if (objectModel is DatabaseObjectModel)
|
||||
{
|
||||
(objectModel as DatabaseObjectModel).Tables.Add (dtUTF);
|
||||
}
|
||||
else if (objectModel is FileSystemObjectModel)
|
||||
{
|
||||
for (int i = 0; i < dtUTF.Fields.Count; i++)
|
||||
{
|
||||
fsom.Files.Add (dtUTF.Fields[i].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void SaveInternal (ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null)
|
||||
private struct UTFTABLEINFO
|
||||
{
|
||||
public long utfOffset;
|
||||
public int tableSize;
|
||||
public int schemaOffset;
|
||||
public int rowsOffset;
|
||||
public int stringTableOffset;
|
||||
public int dataOffset;
|
||||
public uint tableNameStringIndex;
|
||||
public short tableColumns;
|
||||
public short rowWidth;
|
||||
public int tableRows;
|
||||
public int stringTableSize;
|
||||
}
|
||||
|
||||
private UTFTABLEINFO ReadUTFTableInfo(IO.Reader br)
|
||||
{
|
||||
UTFTABLEINFO info = new UTFTABLEINFO();
|
||||
info.utfOffset = Accessor.Position;
|
||||
info.tableSize = br.ReadInt32();
|
||||
info.schemaOffset = 0x20;
|
||||
info.rowsOffset = br.ReadInt32();
|
||||
info.stringTableOffset = br.ReadInt32();
|
||||
info.dataOffset = br.ReadInt32();
|
||||
info.tableNameStringIndex = br.ReadUInt32();
|
||||
info.tableColumns = br.ReadInt16();
|
||||
info.rowWidth = br.ReadInt16();
|
||||
info.tableRows = br.ReadInt32();
|
||||
info.stringTableSize = info.dataOffset - info.stringTableOffset;
|
||||
return info;
|
||||
}
|
||||
|
||||
private DatabaseTable ReadUTFTable(IO.Reader br)
|
||||
{
|
||||
DatabaseTable dt = new DatabaseTable();
|
||||
dt.Name = "@UTF";
|
||||
|
||||
string utfSignal = br.ReadFixedLengthString(4);
|
||||
|
||||
if (utfSignal != "@UTF")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
UTFTABLEINFO info = ReadUTFTableInfo(br);
|
||||
|
||||
int[] columnNameIndices = new int[info.tableColumns];
|
||||
long[] constantOffsets = new long[info.tableColumns];
|
||||
CPKColumnStorageType[] storageTypes = new CPKColumnStorageType[info.tableColumns];
|
||||
CPKColumnDataType[] dataTypes = new CPKColumnDataType[info.tableColumns];
|
||||
|
||||
for (int i = 0; i < info.tableColumns; i++)
|
||||
{
|
||||
byte schema = br.ReadByte();
|
||||
columnNameIndices[i] = br.ReadInt32();
|
||||
|
||||
storageTypes[i] = (CPKColumnStorageType)(schema & (byte)CPKColumnStorageType.Mask);
|
||||
dataTypes[i] = (CPKColumnDataType)(schema & (byte)CPKColumnDataType.Mask);
|
||||
|
||||
if (storageTypes[i] == CPKColumnStorageType.Constant)
|
||||
{
|
||||
constantOffsets[i] = Accessor.Position;
|
||||
switch (dataTypes[i])
|
||||
{
|
||||
case CPKColumnDataType.Long:
|
||||
case CPKColumnDataType.Long2:
|
||||
case CPKColumnDataType.Data:
|
||||
{
|
||||
long dummy = br.ReadInt64();
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Float:
|
||||
{
|
||||
float dummy = br.ReadSingle();
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.String:
|
||||
case CPKColumnDataType.Int:
|
||||
case CPKColumnDataType.Int2:
|
||||
{
|
||||
int dummy = br.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Short:
|
||||
case CPKColumnDataType.Short2:
|
||||
{
|
||||
short dummy = br.ReadInt16();
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Byte:
|
||||
case CPKColumnDataType.Byte2:
|
||||
{
|
||||
byte dummy = br.ReadByte();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Console.WriteLine("cpk: ReadUTFTable: unknown data type for column " + i.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dt.Fields.Add("Field" + i.ToString(), null);
|
||||
}
|
||||
|
||||
// Read string table
|
||||
|
||||
Accessor.Seek(info.stringTableOffset + 8 + 0x10, IO.SeekOrigin.Begin);
|
||||
|
||||
string[] stringTable = br.ReadNullTerminatedStringArray(info.stringTableSize);
|
||||
|
||||
string tableName = stringTable[info.tableNameStringIndex];
|
||||
|
||||
|
||||
// Seek to string table offset
|
||||
Accessor.Seek(info.stringTableOffset + 4 + info.utfOffset, IO.SeekOrigin.Begin);
|
||||
for (short i = 0; i < info.tableColumns; i++)
|
||||
{
|
||||
string columnName = br.ReadNullTerminatedString();
|
||||
dt.Fields[i].Name = columnName;
|
||||
}
|
||||
|
||||
for (int i = 0; i < info.tableRows; i++)
|
||||
{
|
||||
uint rowOffset = (uint)(info.utfOffset + 8 + info.rowsOffset + (i * info.rowWidth));
|
||||
uint rowStartOffset = rowOffset;
|
||||
|
||||
DatabaseRecord record = new DatabaseRecord();
|
||||
|
||||
for (int j = 0; j < info.tableColumns; j++)
|
||||
{
|
||||
CPKColumnStorageType storageType = storageTypes[j];
|
||||
CPKColumnDataType dataType = dataTypes[j];
|
||||
long constantOffset = constantOffsets[j];
|
||||
|
||||
switch (storageType)
|
||||
{
|
||||
case CPKColumnStorageType.PerRow:
|
||||
break;
|
||||
case CPKColumnStorageType.Constant:
|
||||
break;
|
||||
case CPKColumnStorageType.Zero:
|
||||
record.Fields.Add(dt.Fields[j].Name, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
long dataOffset1 = 0;
|
||||
if (storageType == CPKColumnStorageType.Constant)
|
||||
{
|
||||
dataOffset1 = constantOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataOffset1 = rowOffset;
|
||||
}
|
||||
|
||||
Accessor.Seek(dataOffset1, IO.SeekOrigin.Begin);
|
||||
switch (dataType)
|
||||
{
|
||||
case CPKColumnDataType.String:
|
||||
{
|
||||
uint stringOffset = br.ReadUInt32();
|
||||
string value = null;
|
||||
if (stringOffset < stringTable.Length)
|
||||
{
|
||||
value = stringTable[stringOffset];
|
||||
}
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Data:
|
||||
{
|
||||
uint varDataOffset = br.ReadUInt32();
|
||||
uint varDataSize = br.ReadUInt32();
|
||||
|
||||
byte[] value = new byte[0];
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
|
||||
// Is the data in another table??
|
||||
// ReadUTFTable(br);
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Long:
|
||||
case CPKColumnDataType.Long2:
|
||||
{
|
||||
ulong value = br.ReadUInt64();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Int:
|
||||
case CPKColumnDataType.Int2:
|
||||
{
|
||||
uint value = br.ReadUInt32();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Short:
|
||||
case CPKColumnDataType.Short2:
|
||||
{
|
||||
ushort value = br.ReadUInt16();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Float:
|
||||
{
|
||||
float value = br.ReadSingle();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
break;
|
||||
}
|
||||
case CPKColumnDataType.Byte:
|
||||
case CPKColumnDataType.Byte2:
|
||||
{
|
||||
byte value = br.ReadByte();
|
||||
record.Fields.Add(dt.Fields[j].Name, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dt.Records.Add(record);
|
||||
}
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
private string[] ReadUTFStringTable(IO.Reader br)
|
||||
{
|
||||
Accessor.Seek(12, IO.SeekOrigin.Current);
|
||||
|
||||
UTFTABLEINFO info = ReadUTFTableInfo(br);
|
||||
string[] value = br.ReadNullTerminatedStringArray(info.stringTableSize);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
protected override void LoadInternal (ref ObjectModel objectModel)
|
||||
{
|
||||
ObjectModels.FileSystem.FileSystemObjectModel fsom = (objectModel as ObjectModels.FileSystem.FileSystemObjectModel);
|
||||
if (fsom == null)
|
||||
throw new ObjectModelNotSupportedException();
|
||||
|
||||
IO.Writer bw = Accessor.Writer;
|
||||
|
||||
bw.Flush ();
|
||||
bw.Close ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IO.Reader br = Accessor.Reader;
|
||||
br.Endianness = IO.Endianness.BigEndian;
|
||||
|
||||
// Rebuilt based on cpk_unpack
|
||||
Accessor.Seek(0, IO.SeekOrigin.Begin);
|
||||
|
||||
string CPK = br.ReadFixedLengthString (4);
|
||||
Accessor.Seek(0x10, IO.SeekOrigin.Begin);
|
||||
|
||||
DatabaseTable dtUTF = ReadUTFTable(br);
|
||||
|
||||
// For now, just hardcode the TOC offset
|
||||
long tocOffset = 2048; // (long)dtUTF.Records[0].Fields["TocOffset"].Value;
|
||||
Accessor.Seek(tocOffset, IO.SeekOrigin.Begin);
|
||||
|
||||
string tocSignature = br.ReadFixedLengthString(4);
|
||||
long tocEntries = (long)dtUTF.Records.Count;
|
||||
|
||||
string[] tocStringTable = ReadUTFStringTable(br);
|
||||
|
||||
Accessor.Seek(2064, IO.SeekOrigin.Begin);
|
||||
DatabaseTable dtUTF2 = ReadUTFTable(br);
|
||||
|
||||
if (objectModel is DatabaseObjectModel)
|
||||
{
|
||||
(objectModel as DatabaseObjectModel).Tables.Add (dtUTF);
|
||||
}
|
||||
else if (objectModel is FileSystemObjectModel)
|
||||
{
|
||||
for (int i = 0; i < dtUTF.Fields.Count; i++)
|
||||
{
|
||||
fsom.Files.Add (dtUTF.Fields[i].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void SaveInternal (ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null)
|
||||
throw new ObjectModelNotSupportedException();
|
||||
|
||||
IO.Writer bw = Accessor.Writer;
|
||||
|
||||
bw.Flush ();
|
||||
bw.Close ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
//
|
||||
// AssemblyInfo.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2019 Mike Becker
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("Universal Editor plugin for CRI Middleware")]
|
||||
[assembly: AssemblyDescription("Provides data formats for CRI Middleware, including CPK, ADX, and Sofdec2")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Mike Becker's Software")]
|
||||
[assembly: AssemblyProduct("Universal Editor Plugin Pack")]
|
||||
[assembly: AssemblyCopyright("Mike Becker")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{DBA93D1B-01BC-4218-8309-85FA0D5402FC}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>UniversalEditor.Plugins.CRI</RootNamespace>
|
||||
<AssemblyName>UniversalEditor.Plugins.CRI</AssemblyName>
|
||||
<AssemblyOriginatorKeyFile>..\..\..\..\MichaelBecker.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DocumentationFile>..\..\..\Output\Debug\Plugins\UniversalEditor.Plugins.CRI.xml</DocumentationFile>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\Debug\Plugins</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\Release\Plugins</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<IntermediateOutputPath></IntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\CPK\CPKColumnDataType.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\CPK\CPKColumnStorageType.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\CPK\CPKDataFormat.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="DataFormats\" />
|
||||
<Folder Include="DataFormats\FileSystem\" />
|
||||
<Folder Include="DataFormats\FileSystem\CPK\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
|
||||
<Project>{2D4737E6-6D95-408A-90DB-8DFF38147E85}</Project>
|
||||
<Name>UniversalEditor.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Libraries\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
|
||||
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
|
||||
<Name>UniversalEditor.Essential</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@ -232,9 +232,6 @@
|
||||
<Compile Include="DataFormats\FileSystem\WinAce\ACEHeaderFlags.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\SlightlyMadStudios\BFFDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\SlightlyMadStudios\BFFCompressionType.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\SEGA\CPK\CPKDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\SEGA\CPK\CPKColumnStorageType.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\SEGA\CPK\CPKColumnDataType.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
|
||||
|
||||
@ -145,6 +145,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MBS.Framework", "..\..\MBS.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Synalysis", "Plugins\UniversalEditor.Plugins.Synalysis\UniversalEditor.Plugins.Synalysis.csproj", "{0EEC3646-9749-48AF-848E-0F699247E76F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.CRI", "Plugins\UniversalEditor.Plugins.CRI\UniversalEditor.Plugins.CRI.csproj", "{DBA93D1B-01BC-4218-8309-85FA0D5402FC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -417,6 +419,10 @@ Global
|
||||
{0EEC3646-9749-48AF-848E-0F699247E76F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0EEC3646-9749-48AF-848E-0F699247E76F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0EEC3646-9749-48AF-848E-0F699247E76F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DBA93D1B-01BC-4218-8309-85FA0D5402FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DBA93D1B-01BC-4218-8309-85FA0D5402FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DBA93D1B-01BC-4218-8309-85FA0D5402FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DBA93D1B-01BC-4218-8309-85FA0D5402FC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{6F0AB1AF-E1A1-4D19-B19C-05BBB15C94B2} = {05D15661-E684-4EC9-8FBD-C014BA433CC5}
|
||||
@ -484,6 +490,7 @@ Global
|
||||
{EA724755-2670-4520-86AA-657C8A124DB7} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
|
||||
{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C} = {20F315E0-52AE-479F-AF43-3402482C1FC8}
|
||||
{0EEC3646-9749-48AF-848E-0F699247E76F} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
|
||||
{DBA93D1B-01BC-4218-8309-85FA0D5402FC} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
Policies = $0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user