diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Multimedia3D/Model/SegaAuth3D.uexml b/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Multimedia3D/Model/SegaAuth3D.uexml index 937029f4..56205c3f 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Multimedia3D/Model/SegaAuth3D.uexml +++ b/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Associations/Multimedia3D/Model/SegaAuth3D.uexml @@ -1,31 +1,11 @@  - - - - - *.a3da - - - - #A3DA__________ - - - - - - - - - - - - *.a3da + *.a3d diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Extensions/SEGA/Associations/SegaA3DA.uexml b/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Extensions/SEGA/Associations/SegaA3DA.uexml new file mode 100644 index 00000000..d22cfa48 --- /dev/null +++ b/Content/UniversalEditor.Content.PlatformIndependent/Extensions/GameDeveloper/Extensions/SEGA/Associations/SegaA3DA.uexml @@ -0,0 +1,25 @@ + + + + + + + + *.a3da + + + + #A3DA__________ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index 6fde6864..4c6e42ba 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -719,6 +719,7 @@ + diff --git a/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Auth3D/ASCII/A3DADataFormat.cs b/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Auth3D/ASCII/A3DADataFormat.cs deleted file mode 100644 index 2568d72b..00000000 --- a/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Auth3D/ASCII/A3DADataFormat.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -// A3DADataFormat.cs - provides a DataFormat for manipulating 3D model files in Auth3D ASCII (A3DA) format -// -// Author: -// Michael Becker -// -// Copyright (c) 2011-2020 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.Multimedia3D.Model; - -namespace UniversalEditor.DataFormats.Multimedia3D.Model.Auth3D.ASCII -{ - /// - /// Provides a for manipulating 3D model files in Auth3D ASCII (A3DA) format. - /// - public class A3DADataFormat : DataFormat - { - private static DataFormatReference _dfr = null; - protected override DataFormatReference MakeReferenceInternal() - { - if (_dfr == null) - { - _dfr = base.MakeReferenceInternal(); - _dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); - } - return _dfr; - } - - protected override void LoadInternal(ref ObjectModel objectModel) - { - IO.Reader tr = base.Accessor.Reader; - - string A3DAsignature = tr.ReadLine(); - if (A3DAsignature != "#A3DA__________") throw new InvalidDataFormatException("File does not begin with #A3DA__________"); - - - } - - protected override void SaveInternal(ObjectModel objectModel) - { - throw new NotImplementedException(); - } - } -} diff --git a/Plugins/UniversalEditor.Plugins.Multimedia3D/UniversalEditor.Plugins.Multimedia3D.csproj b/Plugins/UniversalEditor.Plugins.Multimedia3D/UniversalEditor.Plugins.Multimedia3D.csproj index 6157934a..fc85e6db 100644 --- a/Plugins/UniversalEditor.Plugins.Multimedia3D/UniversalEditor.Plugins.Multimedia3D.csproj +++ b/Plugins/UniversalEditor.Plugins.Multimedia3D/UniversalEditor.Plugins.Multimedia3D.csproj @@ -61,7 +61,6 @@ - diff --git a/Plugins/UniversalEditor.Plugins.Sega/DataFormats/PropertyList/A3DA/A3DADataFormat.cs b/Plugins/UniversalEditor.Plugins.Sega/DataFormats/PropertyList/A3DA/A3DADataFormat.cs new file mode 100644 index 00000000..3eba7073 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Sega/DataFormats/PropertyList/A3DA/A3DADataFormat.cs @@ -0,0 +1,140 @@ +// +// A3DADataFormat.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 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.IO; +using UniversalEditor.ObjectModels.PropertyList; + +namespace UniversalEditor.Plugins.Sega.DataFormats.PropertyList.A3DA +{ + public class A3DADataFormat : DataFormat + { + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(PropertyListObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } + + public string OriginalFileName { get; set; } = null; + + protected override void LoadInternal(ref ObjectModel objectModel) + { + PropertyListObjectModel plom = (objectModel as PropertyListObjectModel); + if (plom == null) + throw new ObjectModelNotSupportedException(); + + Reader reader = Accessor.Reader; + + string signature = reader.ReadLine(); + if (signature != "#A3DA__________") + throw new InvalidDataFormatException("File does not begin with '#A3DA__________'"); + + while (!reader.EndOfStream) + { + string line = reader.ReadLine(); + line = line.Trim(); + if (line.Contains("#")) + line = line.Substring(0, line.IndexOf('#')); + + if (String.IsNullOrEmpty(line)) + continue; + + string[] values = line.Split(new char[] { '=' }, 2); + string key = values[0]; + string value = values[1]; + string[] paths = key.Split(new char[] { '.' }); + + Group parent = null; + for (int i = 0; i < paths.Length - 1; i++) + { + if (parent == null) + { + Group ng = plom.Groups[paths[i]]; + if (ng == null) + ng = plom.Groups.Add(paths[i]); + + parent = ng; + } + else + { + Group ng = parent.Groups[paths[i]]; + if (ng == null) + ng = parent.Groups.Add(paths[i]); + + parent = ng; + } + } + + if (parent != null) + { + parent.Properties.Add(paths[paths.Length - 1], value); + } + else + { + plom.Properties.Add(paths[paths.Length - 1], value); + } + } + } + + protected override void SaveInternal(ObjectModel objectModel) + { + PropertyListObjectModel plom = (objectModel as PropertyListObjectModel); + if (plom == null) + throw new ObjectModelNotSupportedException(); + + Writer writer = Accessor.Writer; + writer.WriteLine("#A3DA__________"); + writer.WriteLine(String.Format("#{0}", DateTime.Now.ToString("ddd MMM dd HH:mm:ss YYYY"))); + writer.WriteLine("_.converter.version=20050823"); + writer.WriteLine(String.Format("_.file_name={0}", OriginalFileName == null ? System.IO.Path.GetFileName(Accessor.GetFileName()) : OriginalFileName)); + writer.WriteLine("_.property.version=20050706"); + for (int i = 0; i < plom.Groups.Count; i++) + { + WriteGroupRecursive(writer, plom.Groups[i]); + } + for (int i = 0; i < plom.Properties.Count; i++) + { + WritePropertyRecursive(writer, plom.Properties[i]); + } + } + + private void WriteGroupRecursive(Writer writer, Group group, string prefix = "") + { + for (int i = 0; i < group.Groups.Count; i++) + { + WriteGroupRecursive(writer, group.Groups[i], prefix + group.Name + '.'); + } + for (int i = 0; i < group.Properties.Count; i++) + { + WritePropertyRecursive(writer, group.Properties[i], prefix + group.Name + '.'); + } + } + + private void WritePropertyRecursive(Writer writer, Property property, string prefix = "") + { + writer.WriteLine(String.Format("{0}={1}", prefix + property.Name, property.Value)); + } + } +} diff --git a/Plugins/UniversalEditor.Plugins.Sega/UniversalEditor.Plugins.Sega.csproj b/Plugins/UniversalEditor.Plugins.Sega/UniversalEditor.Plugins.Sega.csproj index a103a1fb..e0d1bf95 100644 --- a/Plugins/UniversalEditor.Plugins.Sega/UniversalEditor.Plugins.Sega.csproj +++ b/Plugins/UniversalEditor.Plugins.Sega/UniversalEditor.Plugins.Sega.csproj @@ -33,12 +33,15 @@ + + +