Merge branch 'master' into pre-commit

This commit is contained in:
Michael Becker 2022-04-11 21:20:46 -04:00
commit e310f374bd
No known key found for this signature in database
GPG Key ID: DA394832305DA332
10 changed files with 289 additions and 15 deletions

View File

@ -0,0 +1,43 @@
//
// DataFormatImplementationArea.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor
{
[Flags]
public enum DataFormatImplementationArea
{
None = 0,
/// <summary>
/// For FileSystem data formats. Indicates that a file list can be
/// retrieved, even if the files cannot be extracted.
/// </summary>
List,
/// <summary>
/// Indicates that the data format can properly read a file.
/// </summary>
Load,
/// <summary>
/// Indicates that the data format can properly save a file.
/// </summary>
Save,
All = List | Load | Save
}
}

View File

@ -0,0 +1,39 @@
//
// Implementationstatus.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
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;
}
}
}

View File

@ -0,0 +1,30 @@
//
// DataFormatImplementationStatus.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor
{
public enum ImplementationStatus
{
None = 0,
Incomplete,
Complete
}
}

View File

@ -101,6 +101,9 @@
<Compile Include="UserInterface\HostApplicationMessage.cs" />
<Compile Include="UserInterface\HostApplicationOutputWindow.cs" />
<Compile Include="CustomOptionCompatSettingsProvider.cs" />
<Compile Include="DataFormatImplementationStatusAttribute.cs" />
<Compile Include="ImplementationStatus.cs" />
<Compile Include="DataFormatImplementationArea.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>

View File

@ -209,7 +209,6 @@
<Compile Include="DataFormats\FileSystem\Apogee\DLTDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\PAC\PACDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\MechCommander\MechCommanderDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\Merscom\DPKDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\TechArts3D\TAHDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\SquareSoft\LGPDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\RealNetworks\RZTDataFormat.cs" />
@ -284,7 +283,6 @@
<Folder Include="DataFormats\FileSystem\Apogee\" />
<Folder Include="DataFormats\FileSystem\PAC\" />
<Folder Include="DataFormats\FileSystem\MechCommander\" />
<Folder Include="DataFormats\FileSystem\Merscom\" />
<Folder Include="DataFormats\FileSystem\TechArts3D\" />
<Folder Include="DataFormats\FileSystem\SquareSoft\" />
<Folder Include="DataFormats\FileSystem\RealNetworks\" />

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter HintComparison="MagicThenFilter" ContentType="application/x-merscom-dpk" Title="Merscom data package (DPK) archive">
<FileNameFilters>
<FileNameFilter>*.dpk</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">DPK4</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.FileSystem.FileSystemObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.Plugins.Merscom.DataFormats.FileSystem.DPK.DPKDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -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
{
/// <summary>
/// Provides a <see cref="DataFormat" />for manipulating archives in Merscom DPK format.
/// </summary>
[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();

View File

@ -0,0 +1,46 @@
//
// AssemblyInfo.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// 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 <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 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("")]

View File

@ -0,0 +1,66 @@
<?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>{29F3E82C-CF84-4966-91BF-152D3BCC2117}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>UniversalEditor.Plugins.Merscom</RootNamespace>
<AssemblyName>UniversalEditor.Plugins.Merscom</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<ReleaseVersion>4.0.2019.12</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="DataFormats\FileSystem\DPK\DPKDataFormat.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Associations\" />
<Folder Include="Associations\Merscom\" />
<Folder Include="DataFormats\" />
<Folder Include="DataFormats\FileSystem\" />
<Folder Include="DataFormats\FileSystem\DPK\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Associations\Merscom\DPK.uexml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Compression\UniversalEditor.Compression.csproj">
<Project>{3F664673-7E22-4486-9AD0-FC81861D0B78}</Project>
<Name>UniversalEditor.Compression</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Checksum\UniversalEditor.Checksum.csproj">
<Project>{0F7D5BD4-7970-412F-ABD7-0A098BB01ACE}</Project>
<Name>UniversalEditor.Checksum</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
<Project>{2D4737E6-6D95-408A-90DB-8DFF38147E85}</Project>
<Name>UniversalEditor.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -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