diff --git a/Plugins/UniversalEditor.Plugins.Dweep/Associations/FileSystem/DAT.uexml b/Plugins/UniversalEditor.Plugins.Dweep/Associations/FileSystem/DAT.uexml new file mode 100644 index 00000000..e52ee515 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Dweep/Associations/FileSystem/DAT.uexml @@ -0,0 +1,20 @@ + + + + + + + + *.dat + + + + + + + + + + + + diff --git a/Plugins/UniversalEditor.Plugins.Dweep/DataFormats/FileSystem/DAT/DweepDATDataFormat.cs b/Plugins/UniversalEditor.Plugins.Dweep/DataFormats/FileSystem/DAT/DweepDATDataFormat.cs new file mode 100644 index 00000000..0f070381 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Dweep/DataFormats/FileSystem/DAT/DweepDATDataFormat.cs @@ -0,0 +1,95 @@ +// +// DweepDATDataFormat.cs - provides a DataFormat for reading and writing Dweep DAT archives +// +// 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; +using UniversalEditor.ObjectModels.FileSystem; +using UniversalEditor.ObjectModels.FileSystem.FileSources; + +namespace UniversalEditor.Plugins.Dweep.DataFormats.FileSystem.DAT +{ + /// + /// Provides a for reading and writing Dweep + /// DAT archives. + /// + [DataFormatImplementationStatus(ImplementationStatus.Complete)] + public class DweepDATDataFormat : DataFormat + { + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } + + protected override void LoadInternal(ref ObjectModel objectModel) + { + FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel); + if (fsom == null) + throw new ObjectModelNotSupportedException(); + + uint filecount = Accessor.Reader.ReadUInt32(); + + uint thisFileOffset = Accessor.Reader.ReadUInt32(); + for (uint i = 0; i < filecount - 1; i++) + { + string filename = Accessor.Reader.ReadFixedLengthString(13).TrimNull(); + uint nextFileOffset = Accessor.Reader.ReadUInt32(); + + uint length = nextFileOffset - thisFileOffset; + + File file = fsom.AddFile(filename); + file.Source = new EmbeddedFileSource(Accessor.Reader, thisFileOffset, length); + + thisFileOffset = nextFileOffset; + } + } + + protected override void SaveInternal(ObjectModel objectModel) + { + FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel); + if (fsom == null) + throw new ObjectModelNotSupportedException(); + + File[] files = fsom.GetAllFiles(); + Accessor.Writer.WriteUInt32((uint)(files.Length + 1)); + + uint offset = (uint)(((files.Length + 1) * 17) + 4); + Accessor.Writer.WriteUInt32(offset); + + for (int i = 0; i < files.Length; i++) + { + Accessor.Writer.WriteFixedLengthString(files[i].Name, 13); + Accessor.Writer.WriteUInt32((uint)(offset + files[i].Size)); + offset += (uint)files[i].Size; + } + + Accessor.Writer.WriteFixedLengthString(String.Empty, 13); + + for (int i = 0; i < files.Length; i++) + { + Accessor.Writer.WriteBytes(files[i].GetData()); + } + } + } +} diff --git a/Plugins/UniversalEditor.Plugins.Dweep/Properties/AssemblyInfo.cs b/Plugins/UniversalEditor.Plugins.Dweep/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a2ca5523 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Dweep/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 Dweep")] +[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.Dweep/UniversalEditor.Plugins.Dweep.csproj b/Plugins/UniversalEditor.Plugins.Dweep/UniversalEditor.Plugins.Dweep.csproj new file mode 100644 index 00000000..73641f87 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Dweep/UniversalEditor.Plugins.Dweep.csproj @@ -0,0 +1,58 @@ + + + + Debug + AnyCPU + {9496A94E-F386-4787-818F-FFB04A8EA892} + Library + UniversalEditor.Plugins.Dweep + UniversalEditor.Plugins.Dweep + v4.7 + 4.0.2019.12 + + + 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 + + + + + + + diff --git a/UniversalEditor.sln b/UniversalEditor.sln index 55a6a403..49221a11 100644 --- a/UniversalEditor.sln +++ b/UniversalEditor.sln @@ -219,6 +219,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Sha EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.SwarmAssault", "Plugins\UniversalEditor.Plugins.SwarmAssault\UniversalEditor.Plugins.SwarmAssault.csproj", "{A3D15C91-8D55-4F02-87DC-A1C5E63B8C56}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Dweep", "Plugins\UniversalEditor.Plugins.Dweep\UniversalEditor.Plugins.Dweep.csproj", "{9496A94E-F386-4787-818F-FFB04A8EA892}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -635,6 +637,10 @@ Global {A3D15C91-8D55-4F02-87DC-A1C5E63B8C56}.Debug|Any CPU.Build.0 = Debug|Any CPU {A3D15C91-8D55-4F02-87DC-A1C5E63B8C56}.Release|Any CPU.ActiveCfg = Release|Any CPU {A3D15C91-8D55-4F02-87DC-A1C5E63B8C56}.Release|Any CPU.Build.0 = Release|Any CPU + {9496A94E-F386-4787-818F-FFB04A8EA892}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9496A94E-F386-4787-818F-FFB04A8EA892}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9496A94E-F386-4787-818F-FFB04A8EA892}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9496A94E-F386-4787-818F-FFB04A8EA892}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {6F0AB1AF-E1A1-4D19-B19C-05BBB15C94B2} = {05D15661-E684-4EC9-8FBD-C014BA433CC5} @@ -739,6 +745,7 @@ Global {29F3E82C-CF84-4966-91BF-152D3BCC2117} = {2ED32D16-6C06-4450-909A-40D32DA67FB4} {5763E226-26B9-4FAA-8305-4F48E61357E9} = {2ED32D16-6C06-4450-909A-40D32DA67FB4} {A3D15C91-8D55-4F02-87DC-A1C5E63B8C56} = {2ED32D16-6C06-4450-909A-40D32DA67FB4} + {9496A94E-F386-4787-818F-FFB04A8EA892} = {2ED32D16-6C06-4450-909A-40D32DA67FB4} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0