diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/ChaosWorksEngine.uexml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Extensions/ChaosWorks/Associations/FileSystem/ChaosWorksEngine.uexml similarity index 100% rename from CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/FileSystem/ChaosWorksEngine.uexml rename to CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Extensions/ChaosWorks/Associations/FileSystem/ChaosWorksEngine.uexml diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Extensions/ChaosWorks/Associations/Multimedia/Palette/SPPDataFormat.uexml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Extensions/ChaosWorks/Associations/Multimedia/Palette/SPPDataFormat.uexml new file mode 100644 index 00000000..bfc5bf9b --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Extensions/ChaosWorks/Associations/Multimedia/Palette/SPPDataFormat.uexml @@ -0,0 +1,20 @@ + + + + + + + + *.spp + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index 25510b59..eeb02895 100644 --- a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -141,7 +141,6 @@ - @@ -669,6 +668,8 @@ + + @@ -705,6 +706,11 @@ + + + + + diff --git a/CSharp/Plugins/UniversalEditor.Plugins.ChaosWorks/DataFormats/Multimedia/Palette/SPPDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.ChaosWorks/DataFormats/Multimedia/Palette/SPPDataFormat.cs new file mode 100644 index 00000000..74b09b3d --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.ChaosWorks/DataFormats/Multimedia/Palette/SPPDataFormat.cs @@ -0,0 +1,80 @@ +// +// SPPDataFormat.cs +// +// Author: +// Mike Becker +// +// 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 . +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()); + } + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.ChaosWorks/UniversalEditor.Plugins.ChaosWorks.csproj b/CSharp/Plugins/UniversalEditor.Plugins.ChaosWorks/UniversalEditor.Plugins.ChaosWorks.csproj index d6dffacb..65aaaf36 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.ChaosWorks/UniversalEditor.Plugins.ChaosWorks.csproj +++ b/CSharp/Plugins/UniversalEditor.Plugins.ChaosWorks/UniversalEditor.Plugins.ChaosWorks.csproj @@ -41,6 +41,7 @@ + @@ -55,9 +56,19 @@ {30467E5C-05BC-4856-AADC-13906EF4CADD} UniversalEditor.Essential + + {BE4D0BA3-0888-42A5-9C09-FC308A4509D2} + UniversalEditor.Plugins.Multimedia + + + {00266B21-35C9-4A7F-A6BA-D54D7FDCC25C} + MBS.Framework + + +