diff --git a/Libraries/UniversalEditor.Core/DataFormatImplementationArea.cs b/Libraries/UniversalEditor.Core/DataFormatImplementationArea.cs new file mode 100644 index 00000000..db0e268c --- /dev/null +++ b/Libraries/UniversalEditor.Core/DataFormatImplementationArea.cs @@ -0,0 +1,43 @@ +// +// DataFormatImplementationArea.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2022 Mike Becker's Software +// +// 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; +namespace UniversalEditor +{ + [Flags] + public enum DataFormatImplementationArea + { + None = 0, + /// + /// For FileSystem data formats. Indicates that a file list can be + /// retrieved, even if the files cannot be extracted. + /// + List, + /// + /// Indicates that the data format can properly read a file. + /// + Load, + /// + /// Indicates that the data format can properly save a file. + /// + Save, + All = List | Load | Save + } +} diff --git a/Libraries/UniversalEditor.Core/DataFormatImplementationStatusAttribute.cs b/Libraries/UniversalEditor.Core/DataFormatImplementationStatusAttribute.cs new file mode 100644 index 00000000..602721ea --- /dev/null +++ b/Libraries/UniversalEditor.Core/DataFormatImplementationStatusAttribute.cs @@ -0,0 +1,39 @@ +// +// Implementationstatus.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2022 Mike Becker's Software +// +// 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; +namespace UniversalEditor +{ + public class DataFormatImplementationStatusAttribute : Attribute + { + public DataFormatImplementationArea Area { get; } = DataFormatImplementationArea.None; + public ImplementationStatus Status { get; }= ImplementationStatus.None; + + public DataFormatImplementationStatusAttribute(ImplementationStatus status) + : this(DataFormatImplementationArea.All, status) + { + } + public DataFormatImplementationStatusAttribute(DataFormatImplementationArea area, ImplementationStatus status) + { + Area = area; + Status = status; + } + } +} diff --git a/Libraries/UniversalEditor.Core/ImplementationStatus.cs b/Libraries/UniversalEditor.Core/ImplementationStatus.cs new file mode 100644 index 00000000..52e82555 --- /dev/null +++ b/Libraries/UniversalEditor.Core/ImplementationStatus.cs @@ -0,0 +1,30 @@ +// +// DataFormatImplementationStatus.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2022 Mike Becker's Software +// +// 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; +namespace UniversalEditor +{ + public enum ImplementationStatus + { + None = 0, + Incomplete, + Complete + } +} diff --git a/Libraries/UniversalEditor.Core/UniversalEditor.Core.csproj b/Libraries/UniversalEditor.Core/UniversalEditor.Core.csproj index 020f4c42..6eaa9eb8 100644 --- a/Libraries/UniversalEditor.Core/UniversalEditor.Core.csproj +++ b/Libraries/UniversalEditor.Core/UniversalEditor.Core.csproj @@ -101,6 +101,9 @@ + + + diff --git a/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj b/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj index d35edc4a..183a622f 100644 --- a/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj +++ b/Plugins/UniversalEditor.Plugins.FileSystem/UniversalEditor.Plugins.FileSystem.csproj @@ -209,7 +209,6 @@ - @@ -284,7 +283,6 @@ - diff --git a/Plugins/UniversalEditor.Plugins.Merscom/Associations/Merscom/DPK.uexml b/Plugins/UniversalEditor.Plugins.Merscom/Associations/Merscom/DPK.uexml new file mode 100644 index 00000000..fb191951 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Merscom/Associations/Merscom/DPK.uexml @@ -0,0 +1,25 @@ + + + + + + + + *.dpk + + + + DPK4 + + + + + + + + + + + + + diff --git a/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/Merscom/DPKDataFormat.cs b/Plugins/UniversalEditor.Plugins.Merscom/DataFormats/FileSystem/DPK/DPKDataFormat.cs similarity index 60% rename from Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/Merscom/DPKDataFormat.cs rename to Plugins/UniversalEditor.Plugins.Merscom/DataFormats/FileSystem/DPK/DPKDataFormat.cs index c8da3b13..4871037d 100644 --- a/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/Merscom/DPKDataFormat.cs +++ b/Plugins/UniversalEditor.Plugins.Merscom/DataFormats/FileSystem/DPK/DPKDataFormat.cs @@ -23,11 +23,12 @@ using System; using UniversalEditor.IO; using UniversalEditor.ObjectModels.FileSystem; -namespace UniversalEditor.DataFormats.FileSystem.Merscom +namespace UniversalEditor.Plugins.Merscom.DataFormats.FileSystem.DPK { /// /// Provides a for manipulating archives in Merscom DPK format. /// + [DataFormatImplementationStatus(DataFormatImplementationArea.Load, ImplementationStatus.Complete)] public class DPKDataFormat : DataFormat { private static DataFormatReference _dfr; @@ -53,27 +54,43 @@ namespace UniversalEditor.DataFormats.FileSystem.Merscom if (DPK4 != "DPK4") throw new InvalidDataFormatException(); - uint u1 = br.ReadUInt32(); - uint u2 = br.ReadUInt32(); + uint archiveLength = br.ReadUInt32(); + uint tocLength = br.ReadUInt32(); uint u3 = br.ReadUInt32(); - uint u4 = br.ReadUInt32(); - uint uFileCount = br.ReadUInt32(); - for (int i = 0; i < uFileCount; i++) + for (int i = 0; i < u3; i++) { - br.SeekUntilFirstNonNull(); + uint u4 = br.ReadUInt32(); + uint decompressedLength = br.ReadUInt32(); + uint compressedLength = br.ReadUInt32(); // 371 39325 + uint offset = br.ReadUInt32(); // 292196 292567 - uint u6 = br.ReadUInt32(); - uint u7 = br.ReadUInt32(); + string nam = br.ReadNullTerminatedString(); // action.accfg + br.Align(4); - string nam = br.ReadNullTerminatedString(); File file = fsom.AddFile(nam); - ushort u8 = br.ReadUInt16(); - uint u9 = br.ReadUInt32(); - uint u10 = br.ReadUInt32(); + file.Properties["compressedLength"] = compressedLength; + file.Properties["offset"] = offset; + + file.Size = decompressedLength; + + file.DataRequest += File_DataRequest; } } + void File_DataRequest(object sender, DataRequestEventArgs e) + { + File file = (File)sender; + uint compressedLength = (uint)file.Properties["compressedLength"]; + uint offset = (uint)file.Properties["offset"]; + + Accessor.Reader.Seek(offset, SeekOrigin.Begin); + byte[] compressedData = Accessor.Reader.ReadBytes(compressedLength); + byte[] decompressedData = Compression.CompressionModule.FromKnownCompressionMethod(Compression.CompressionMethod.Zlib).Decompress(compressedData); + e.Data = decompressedData; + } + + protected override void SaveInternal(ObjectModel objectModel) { throw new NotImplementedException(); diff --git a/Plugins/UniversalEditor.Plugins.Merscom/Properties/AssemblyInfo.cs b/Plugins/UniversalEditor.Plugins.Merscom/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..f75b53fb --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Merscom/Properties/AssemblyInfo.cs @@ -0,0 +1,46 @@ +// +// AssemblyInfo.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2022 Mike Becker's Software +// +// 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 Merscom games")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Mike Becker's Software")] +[assembly: AssemblyProduct("Universal Editor Plugin Pack")] +[assembly: AssemblyCopyright("Mike Becker's Software")] +[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/Plugins/UniversalEditor.Plugins.Merscom/UniversalEditor.Plugins.Merscom.csproj b/Plugins/UniversalEditor.Plugins.Merscom/UniversalEditor.Plugins.Merscom.csproj new file mode 100644 index 00000000..b16ea645 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Merscom/UniversalEditor.Plugins.Merscom.csproj @@ -0,0 +1,66 @@ + + + + Debug + AnyCPU + {29F3E82C-CF84-4966-91BF-152D3BCC2117} + Library + UniversalEditor.Plugins.Merscom + UniversalEditor.Plugins.Merscom + v4.7 + 4.0.2019.12 + + + true + full + false + ..\..\Output\Debug\Plugins + DEBUG; + prompt + 4 + false + + + true + ..\..\Output\Release\Plugins + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + {3F664673-7E22-4486-9AD0-FC81861D0B78} + UniversalEditor.Compression + + + {0F7D5BD4-7970-412F-ABD7-0A098BB01ACE} + UniversalEditor.Checksum + + + {30467E5C-05BC-4856-AADC-13906EF4CADD} + UniversalEditor.Essential + + + {2D4737E6-6D95-408A-90DB-8DFF38147E85} + UniversalEditor.Core + + + + diff --git a/UniversalEditor.sln b/UniversalEditor.sln index cf1a5d3d..f96160e0 100644 --- a/UniversalEditor.sln +++ b/UniversalEditor.sln @@ -213,6 +213,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Mic EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MBS.Framework.UserInterface.Engines.GTK3", "..\MBS.Framework.UserInterface\Engines\GTK3\MBS.Framework.UserInterface.Engines.GTK3\MBS.Framework.UserInterface.Engines.GTK3.csproj", "{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Merscom", "Plugins\UniversalEditor.Plugins.Merscom\UniversalEditor.Plugins.Merscom.csproj", "{29F3E82C-CF84-4966-91BF-152D3BCC2117}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -617,6 +619,10 @@ Global {62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Release|Any CPU.Build.0 = Release|Any CPU + {29F3E82C-CF84-4966-91BF-152D3BCC2117}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29F3E82C-CF84-4966-91BF-152D3BCC2117}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29F3E82C-CF84-4966-91BF-152D3BCC2117}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29F3E82C-CF84-4966-91BF-152D3BCC2117}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {6F0AB1AF-E1A1-4D19-B19C-05BBB15C94B2} = {05D15661-E684-4EC9-8FBD-C014BA433CC5} @@ -718,6 +724,7 @@ Global {D4AEC562-0FA7-48C4-9E46-C706AFCFA015} = {7B535D74-5496-4802-B809-89ED88274A91} {94059860-1F0B-453D-AFAB-EEDBB0AA25BB} = {2ED32D16-6C06-4450-909A-40D32DA67FB4} {62DC7CF9-C608-49E5-8C39-305B2E3E93F6} = {20F315E0-52AE-479F-AF43-3402482C1FC8} + {29F3E82C-CF84-4966-91BF-152D3BCC2117} = {2ED32D16-6C06-4450-909A-40D32DA67FB4} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0