implemented chaos works engine SPP palette data format

This commit is contained in:
Michael Becker 2020-03-15 17:33:35 -04:00
parent f285a5061a
commit 664a4a1fd4
No known key found for this signature in database
GPG Key ID: 389DFF5D73781A12
5 changed files with 118 additions and 1 deletions

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Chaos Works Engine palette">
<FileNameFilters>
<FileNameFilter>*.spp</FileNameFilter>
</FileNameFilters>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia.Palette.PaletteObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.Plugins.ChaosWorks.DataFormats.Multimedia.Palette.SPPDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -141,7 +141,6 @@
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\AquarnoidGOB.uexml" />
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\Arcanum.uexml" />
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\BurikoGeneralInterpreter.uexml" />
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\ChaosWorksEngine.uexml" />
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\CompressedHunks.uexml" />
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\Kronosaur.uexml" />
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\DoomWAD.uexml" />
@ -669,6 +668,8 @@
<Content Include="Extensions\FileSystem\Associations\AIN.uexml" />
<Content Include="Editors\Multimedia\Audio\Voicebank\Commands.uexml" />
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\KenSilverman\GRP.uexml" />
<Content Include="Extensions\GameDeveloper\Extensions\ChaosWorks\Associations\FileSystem\ChaosWorksEngine.uexml" />
<Content Include="Extensions\GameDeveloper\Extensions\ChaosWorks\Associations\Multimedia\Palette\SPPDataFormat.uexml" />
</ItemGroup>
<ItemGroup>
<Content Include="Configuration\Application.upl" />
@ -705,6 +706,11 @@
<Folder Include="Documentation\Executable\DataFormats\Executable\Microsoft\" />
<Folder Include="Editors\Multimedia\Audio\Voicebank\" />
<Folder Include="Extensions\GameDeveloper\Associations\FileSystem\KenSilverman\" />
<Folder Include="Extensions\GameDeveloper\Extensions\ChaosWorks\" />
<Folder Include="Extensions\GameDeveloper\Extensions\ChaosWorks\Associations\" />
<Folder Include="Extensions\GameDeveloper\Extensions\ChaosWorks\Associations\FileSystem\" />
<Folder Include="Extensions\GameDeveloper\Extensions\ChaosWorks\Associations\Multimedia\" />
<Folder Include="Extensions\GameDeveloper\Extensions\ChaosWorks\Associations\Multimedia\Palette\" />
</ItemGroup>
<ItemGroup>
<Content Include="Extensions\SoftwareDeveloper\Templates\Project\Software Development\Arduino\Images\Blink.xcf" />

View File

@ -0,0 +1,80 @@
//
// SPPDataFormat.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 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 <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework.Drawing;
using UniversalEditor.IO;
using UniversalEditor.ObjectModels.Multimedia.Palette;
namespace UniversalEditor.Plugins.ChaosWorks.DataFormats.Multimedia.Palette
{
public class SPPDataFormat : DataFormat
{
private static DataFormatReference _dfr = null;
protected override DataFormatReference MakeReferenceInternal()
{
if (_dfr == null)
{
_dfr = base.MakeReferenceInternal();
_dfr.Capabilities.Add(typeof(PaletteObjectModel), DataFormatCapabilities.All);
}
return _dfr;
}
protected override void LoadInternal(ref ObjectModel objectModel)
{
PaletteObjectModel palette = (objectModel as PaletteObjectModel);
if (palette == null)
throw new ObjectModelNotSupportedException();
Reader reader = Accessor.Reader;
uint version = reader.ReadUInt32();
while (!reader.EndOfStream)
{
byte r = reader.ReadByte();
byte g = reader.ReadByte();
byte b = reader.ReadByte();
byte a = reader.ReadByte();
a = (byte)(255 - a); // always 0 ?
palette.Entries.Add(new PaletteEntry(Color.FromRGBAByte(r, g, b, a)));
}
}
protected override void SaveInternal(ObjectModel objectModel)
{
PaletteObjectModel palette = (objectModel as PaletteObjectModel);
if (palette == null)
throw new ObjectModelNotSupportedException();
Writer writer = Accessor.Writer;
writer.WriteUInt32(1);
for (int i = 0; i < palette.Entries.Count; i++)
{
writer.WriteByte(palette.Entries[i].Color.GetRedByte());
writer.WriteByte(palette.Entries[i].Color.GetGreenByte());
writer.WriteByte(palette.Entries[i].Color.GetBlueByte());
writer.WriteByte(palette.Entries[i].Color.GetAlphaByte());
}
}
}
}

View File

@ -41,6 +41,7 @@
<Compile Include="DataFormats\FileSystem\ChaosWorks\ChaosWorksVOLFormatVersion.cs" />
<Compile Include="DataFormats\FileSystem\ChaosWorks\Internal\ChaosWorksVOLV2FileInfo.cs" />
<Compile Include="DataFormats\FileSystem\ChaosWorks\Internal\ChaosWorksVOLV2ChunkInfo.cs" />
<Compile Include="DataFormats\Multimedia\Palette\SPPDataFormat.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Compression\UniversalEditor.Compression.csproj">
@ -55,9 +56,19 @@
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
<ProjectReference Include="..\UniversalEditor.Plugins.Multimedia\UniversalEditor.Plugins.Multimedia.csproj">
<Project>{BE4D0BA3-0888-42A5-9C09-FC308A4509D2}</Project>
<Name>UniversalEditor.Plugins.Multimedia</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="DataFormats\FileSystem\ChaosWorks\Internal\" />
<Folder Include="DataFormats\Multimedia\" />
<Folder Include="DataFormats\Multimedia\Palette\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.