From 8f797ee03f3ab044b4e7fb53c614038f03c55cc9 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Thu, 14 Nov 2019 23:08:50 -0500 Subject: [PATCH] the CPK data format should be in a separate CRI plugin after all... --- .../{SegaCPK.uexml => CRICPK.uexml} | 4 +- ...lEditor.Content.PlatformIndependent.csproj | 2 +- .../FileSystem}/CPK/CPKColumnDataType.cs | 2 +- .../FileSystem}/CPK/CPKColumnStorageType.cs | 2 +- .../FileSystem}/CPK/CPKDataFormat.cs | 641 +++++++++--------- .../Properties/AssemblyInfo.cs | 46 ++ .../UniversalEditor.Plugins.CRI.csproj | 56 ++ .../UniversalEditor.Plugins.FileSystem.csproj | 3 - CSharp/UniversalEditor.sln | 7 + 9 files changed, 435 insertions(+), 328 deletions(-) rename CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/{SegaCPK.uexml => CRICPK.uexml} (77%) rename CSharp/Plugins/{UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA => UniversalEditor.Plugins.CRI/DataFormats/FileSystem}/CPK/CPKColumnDataType.cs (94%) rename CSharp/Plugins/{UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA => UniversalEditor.Plugins.CRI/DataFormats/FileSystem}/CPK/CPKColumnStorageType.cs (93%) rename CSharp/Plugins/{UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA => UniversalEditor.Plugins.CRI/DataFormats/FileSystem}/CPK/CPKDataFormat.cs (97%) create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.CRI/Properties/AssemblyInfo.cs create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.CRI/UniversalEditor.Plugins.CRI.csproj diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/SegaCPK.uexml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/CRICPK.uexml similarity index 77% rename from CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/SegaCPK.uexml rename to CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/CRICPK.uexml index 3005ad9c..a47e4058 100644 --- a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/SegaCPK.uexml +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/CRICPK.uexml @@ -3,7 +3,7 @@ - + *.cpk @@ -18,7 +18,7 @@ - + diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index 2d65651f..75a3f775 100644 --- a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -650,7 +650,7 @@ - + diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA/CPK/CPKColumnDataType.cs b/CSharp/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKColumnDataType.cs similarity index 94% rename from CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA/CPK/CPKColumnDataType.cs rename to CSharp/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKColumnDataType.cs index ba7613df..996b6b62 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA/CPK/CPKColumnDataType.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKColumnDataType.cs @@ -19,7 +19,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; -namespace UniversalEditor.DataFormats.FileSystem.SEGA.CPK +namespace UniversalEditor.Plugins.CRI.DataFormats.FileSystem.CPK { enum CPKColumnDataType : byte { diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA/CPK/CPKColumnStorageType.cs b/CSharp/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKColumnStorageType.cs similarity index 93% rename from CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA/CPK/CPKColumnStorageType.cs rename to CSharp/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKColumnStorageType.cs index ab80718c..107501f1 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA/CPK/CPKColumnStorageType.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKColumnStorageType.cs @@ -19,7 +19,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; -namespace UniversalEditor.DataFormats.FileSystem.SEGA.CPK +namespace UniversalEditor.Plugins.CRI.DataFormats.FileSystem.CPK { enum CPKColumnStorageType : byte { diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA/CPK/CPKDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKDataFormat.cs similarity index 97% rename from CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA/CPK/CPKDataFormat.cs rename to CSharp/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKDataFormat.cs index ebbbeae4..800dd841 100755 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/SEGA/CPK/CPKDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKDataFormat.cs @@ -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 (); + } + } +} + diff --git a/CSharp/Plugins/UniversalEditor.Plugins.CRI/Properties/AssemblyInfo.cs b/CSharp/Plugins/UniversalEditor.Plugins.CRI/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..651a6c48 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.CRI/Properties/AssemblyInfo.cs @@ -0,0 +1,46 @@ +// +// AssemblyInfo.cs +// +// Author: +// Mike Becker +// +// 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 . +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("")] diff --git a/CSharp/Plugins/UniversalEditor.Plugins.CRI/UniversalEditor.Plugins.CRI.csproj b/CSharp/Plugins/UniversalEditor.Plugins.CRI/UniversalEditor.Plugins.CRI.csproj new file mode 100644 index 00000000..56ebcdf3 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.CRI/UniversalEditor.Plugins.CRI.csproj @@ -0,0 +1,56 @@ + + + + Debug + AnyCPU + {DBA93D1B-01BC-4218-8309-85FA0D5402FC} + Library + UniversalEditor.Plugins.CRI + UniversalEditor.Plugins.CRI + ..\..\..\..\MichaelBecker.snk + + + ..\..\..\Output\Debug\Plugins\UniversalEditor.Plugins.CRI.xml + true + full + false + ..\..\Output\Debug\Plugins + DEBUG; + prompt + 4 + false + + + true + ..\..\Output\Release\Plugins + prompt + 4 + false + + + + + + + + + + + + + + + + + + + {2D4737E6-6D95-408A-90DB-8DFF38147E85} + UniversalEditor.Core + + + {30467E5C-05BC-4856-AADC-13906EF4CADD} + UniversalEditor.Essential + + + + \ No newline at end of file diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj index a352073a..5ff1d0e7 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj +++ b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj @@ -232,9 +232,6 @@ - - - diff --git a/CSharp/UniversalEditor.sln b/CSharp/UniversalEditor.sln index e39e2cc3..838da99c 100644 --- a/CSharp/UniversalEditor.sln +++ b/CSharp/UniversalEditor.sln @@ -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