From bb9e698bbe6c4e7807d954bbe5bc81e3ddf18a1d Mon Sep 17 00:00:00 2001 From: alcexhim Date: Wed, 4 Jun 2014 15:31:38 -0400 Subject: [PATCH] Added NamcoTales plugin and re-included FileSystem plugin --- .../FileSystem/NamcoTales/TLZCDataFormat.cs | 97 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 +++++++ .../UniversalEditor.Plugins.NamcoTales.csproj | 58 +++++++++++ CSharp/UniversalEditor.sln | 18 ++++ 4 files changed, 209 insertions(+) create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/DataFormats/FileSystem/NamcoTales/TLZCDataFormat.cs create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/Properties/AssemblyInfo.cs create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/UniversalEditor.Plugins.NamcoTales.csproj diff --git a/CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/DataFormats/FileSystem/NamcoTales/TLZCDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/DataFormats/FileSystem/NamcoTales/TLZCDataFormat.cs new file mode 100644 index 00000000..81155617 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/DataFormats/FileSystem/NamcoTales/TLZCDataFormat.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UniversalEditor.Accessors; +using UniversalEditor.ObjectModels.FileSystem; + +namespace UniversalEditor.DataFormats.FileSystem.NamcoTales +{ + public class TLZCDataFormat : 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("Namco Tales Studio TLZC archive", new byte?[][] { new byte?[] { (byte)'T', (byte)'L', (byte)'Z', (byte)'C' } }, new string[] { "*.dat" }); + } + return _dfr; + } + + private uint mvarBlockSize = 10000; + public uint BlockSize { get { return mvarBlockSize; } set { mvarBlockSize = value; } } + + protected override void LoadInternal(ref ObjectModel objectModel) + { + FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel); + + IO.Reader reader = base.Accessor.Reader; + string TLZC = reader.ReadFixedLengthString(4); + if (TLZC != "TLZC") throw new InvalidDataFormatException(); + + string filename = "FILENAME.FPS4"; + if (base.Accessor is FileAccessor) + { + filename = System.IO.Path.GetFileName((base.Accessor as FileAccessor).FileName); + filename = System.IO.Path.ChangeExtension(filename, ".fps4"); + } + + // comtype MSF + uint version = reader.ReadUInt32(); + uint compressedSize = reader.ReadUInt32(); + uint decompressedSize = reader.ReadUInt32(); + byte[] filedata = new byte[decompressedSize]; + + reader.Seek(0x1D, IO.SeekOrigin.Begin); + uint blockcount = decompressedSize; + blockcount += 0xFFFF; + blockcount /= mvarBlockSize; + short[] zsizes = new short[blockcount]; + for (uint i = 0; i < blockcount; i++) + { + short zsize = reader.ReadInt16(); + zsizes[i] = zsize; + } + for (uint i = 0; i < blockcount; i++) + { + long offset = base.Accessor.Position; + short zsize = zsizes[i]; + if (decompressedSize >= mvarBlockSize) + { + byte[] block = reader.ReadBytes(mvarBlockSize); + // block = decompress(block); + Array.Copy(block, 0, filedata, i * mvarBlockSize, block.Length); + } + else + { + // append + if (zsize == 0) + { + // log MEMORY_FILE OFFSET tsize + } + else + { + // clog MEMORY_FILE OFFSET ZSIZE tsize + } + // append + } + decompressedSize -= 0x10000; + offset += zsize; + base.Accessor.Seek(offset, IO.SeekOrigin.Begin); + } + + fsom.Files.Add(filename, filedata); + + // get SIZE asize MEMORY_FILE + // log name 0 SIZE MEMORY_FILE + } + + protected override void SaveInternal(ObjectModel objectModel) + { + throw new NotImplementedException(); + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/Properties/AssemblyInfo.cs b/CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..cdf08a69 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/Properties/AssemblyInfo.cs @@ -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("UniversalEditor.Plugins.NamcoTales")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("City of Orlando")] +[assembly: AssemblyProduct("UniversalEditor.Plugins.NamcoTales")] +[assembly: AssemblyCopyright("Copyright © City of Orlando 2014")] +[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("fac0ad65-d944-4ada-be44-a05293996f19")] + +// 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")] diff --git a/CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/UniversalEditor.Plugins.NamcoTales.csproj b/CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/UniversalEditor.Plugins.NamcoTales.csproj new file mode 100644 index 00000000..40f86e4f --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.NamcoTales/UniversalEditor.Plugins.NamcoTales.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {19AEFD28-37E8-4FFD-B879-FEE57824689D} + Library + Properties + UniversalEditor + UniversalEditor.Plugins.NamcoTales + v3.5 + 512 + + + true + full + false + ..\..\Output\Debug\Plugins\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\Output\Release\Plugins\ + TRACE + prompt + 4 + + + + + + + + + + + + {2d4737e6-6d95-408a-90db-8dff38147e85} + UniversalEditor.Core + + + {30467e5c-05bc-4856-aadc-13906ef4cadd} + UniversalEditor.Essential + + + + + \ No newline at end of file diff --git a/CSharp/UniversalEditor.sln b/CSharp/UniversalEditor.sln index 4289f061..1bfb3859 100644 --- a/CSharp/UniversalEditor.sln +++ b/CSharp/UniversalEditor.sln @@ -49,6 +49,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{5A423A3E-51C5-4188-8AD5-FB5C0CB76C6A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.NamcoTales", "Plugins\UniversalEditor.Plugins.NamcoTales\UniversalEditor.Plugins.NamcoTales.csproj", "{19AEFD28-37E8-4FFD-B879-FEE57824689D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.FileSystem", "Plugins\UniversalEditor.Plugins.FileSystem\UniversalEditor.Plugins.FileSystem.csproj", "{76FD1306-9CA4-428F-993B-B7E4EEEACBF3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -155,6 +159,18 @@ Global {118E40C4-323E-4B4B-8EF4-38EED6CC5E83}.Release|Any CPU.ActiveCfg = Release|Any CPU {118E40C4-323E-4B4B-8EF4-38EED6CC5E83}.Release|Any CPU.Build.0 = Release|Any CPU {118E40C4-323E-4B4B-8EF4-38EED6CC5E83}.Release|x86.ActiveCfg = Release|Any CPU + {19AEFD28-37E8-4FFD-B879-FEE57824689D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19AEFD28-37E8-4FFD-B879-FEE57824689D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19AEFD28-37E8-4FFD-B879-FEE57824689D}.Debug|x86.ActiveCfg = Debug|Any CPU + {19AEFD28-37E8-4FFD-B879-FEE57824689D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19AEFD28-37E8-4FFD-B879-FEE57824689D}.Release|Any CPU.Build.0 = Release|Any CPU + {19AEFD28-37E8-4FFD-B879-FEE57824689D}.Release|x86.ActiveCfg = Release|Any CPU + {76FD1306-9CA4-428F-993B-B7E4EEEACBF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76FD1306-9CA4-428F-993B-B7E4EEEACBF3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76FD1306-9CA4-428F-993B-B7E4EEEACBF3}.Debug|x86.ActiveCfg = Debug|Any CPU + {76FD1306-9CA4-428F-993B-B7E4EEEACBF3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76FD1306-9CA4-428F-993B-B7E4EEEACBF3}.Release|Any CPU.Build.0 = Release|Any CPU + {76FD1306-9CA4-428F-993B-B7E4EEEACBF3}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -172,6 +188,8 @@ Global {30A2F772-8EC1-425A-8D5D-36A0BE4D6B66} = {71CFF024-26F7-4626-A526-B435FDF8D64E} {3DC2C1F6-F332-4E55-BF6A-AED78A7C3FD2} = {71CFF024-26F7-4626-A526-B435FDF8D64E} {899E3DD6-EA65-4168-AAE3-867A4F9650A6} = {71CFF024-26F7-4626-A526-B435FDF8D64E} + {19AEFD28-37E8-4FFD-B879-FEE57824689D} = {71CFF024-26F7-4626-A526-B435FDF8D64E} + {76FD1306-9CA4-428F-993B-B7E4EEEACBF3} = {71CFF024-26F7-4626-A526-B435FDF8D64E} {FE016EA3-DC31-4A92-8B0A-8C746EC117E1} = {46041F27-7C1C-4209-B72B-251EDB5D4C61} {C1F34183-7A2F-41A6-9958-F6F329099654} = {A846CA33-9CAA-4237-B14F-8721DBA89442} {2013757E-4240-4E07-AD22-91219AD9B74F} = {C1F34183-7A2F-41A6-9958-F6F329099654}