implement Sega Auth3D A3DA property list format

This commit is contained in:
Michael Becker 2020-05-03 19:27:10 -04:00
parent 255e61deb3
commit 1983582990
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7
7 changed files with 170 additions and 81 deletions

View File

@ -1,31 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Auth3D model (ASCII format)">
<FileNameFilters>
<FileNameFilter>*.a3da</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">#A3DA__________</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Auth3D.ASCII.A3DADataFormat" />
</DataFormats>
</Association>
<Association>
<Filters>
<Filter Title="Auth3D model (compiled)">
<FileNameFilters>
<FileNameFilter>*.a3da</FileNameFilter>
<FileNameFilter>*.a3d</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Sega A3DA configuration file">
<FileNameFilters>
<FileNameFilter>*.a3da</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">#A3DA__________</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.PropertyList.PropertyListObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.Plugins.Sega.DataFormats.PropertyList.A3DA.A3DADataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -719,6 +719,7 @@
<Content Include="Extensions\GameDeveloper\Extensions\Ultra3D\Associations\TBV.uexml" />
<Content Include="Extensions\GameDeveloper\Extensions\Webfoot\Associations\DAT.uexml" />
<Content Include="Extensions\GameDeveloper\Extensions\CRI\CRIFileSystemEditorExtensions.uexml" />
<Content Include="Extensions\GameDeveloper\Extensions\SEGA\Associations\SegaA3DA.uexml" />
<Content Include="Editors\PropertyList\PropertyListEditor.glade" />
</ItemGroup>
<ItemGroup>

View File

@ -1,59 +0,0 @@
//
// A3DADataFormat.cs - provides a DataFormat for manipulating 3D model files in Auth3D ASCII (A3DA) format
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
using System;
using UniversalEditor.ObjectModels.Multimedia3D.Model;
namespace UniversalEditor.DataFormats.Multimedia3D.Model.Auth3D.ASCII
{
/// <summary>
/// Provides a <see cref="DataFormat" /> for manipulating 3D model files in Auth3D ASCII (A3DA) format.
/// </summary>
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();
}
}
}

View File

@ -61,7 +61,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DataFormats\Multimedia3D\Accessory\QAvimator\PRPAccessoryDataFormat.cs" />
<Compile Include="DataFormats\Multimedia3D\Model\Auth3D\ASCII\A3DADataFormat.cs" />
<Compile Include="DataFormats\Multimedia3D\Model\Auth3D\Compiled\A3DCDataFormat.cs" />
<Compile Include="DataFormats\Multimedia3D\Model\GLB\GLBObjectType.cs" />
<Compile Include="DataFormats\Multimedia3D\Model\Inivis\AC3DDataFormat.cs" />

View File

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

View File

@ -33,12 +33,15 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="DataFormats\FileSystem\Sega\FARC\FARCDataFormat.cs" />
<Compile Include="DataFormats\PropertyList\A3DA\A3DADataFormat.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="DataFormats\" />
<Folder Include="DataFormats\FileSystem\" />
<Folder Include="DataFormats\FileSystem\Sega\" />
<Folder Include="DataFormats\FileSystem\Sega\FARC\" />
<Folder Include="DataFormats\PropertyList\" />
<Folder Include="DataFormats\PropertyList\A3DA\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">