Added data format and object model for KA Actor (ATR)... I have no idea how to parse this
This commit is contained in:
parent
51e0957cca
commit
9fcdb2e4c3
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UniversalEditor Version="4.0">
|
||||
<Associations>
|
||||
<Association>
|
||||
<Filters>
|
||||
<Filter Title="Knowledge Adventure actor">
|
||||
<FileNameFilters>
|
||||
<FileNameFilter>*.atr</FileNameFilter>
|
||||
</FileNameFilters>
|
||||
</Filter>
|
||||
</Filters>
|
||||
<ObjectModels>
|
||||
<ObjectModel TypeName="UniversalEditor.ObjectModels.KnowledgeAdventure.Actor.ActorObjectModel" />
|
||||
</ObjectModels>
|
||||
<DataFormats>
|
||||
<DataFormat TypeName="UniversalEditor.DataFormats.KnowledgeAdventure.Actor.ATRDataFormat" />
|
||||
</DataFormats>
|
||||
</Association>
|
||||
</Associations>
|
||||
</UniversalEditor>
|
||||
@ -41,6 +41,7 @@
|
||||
<Content Include="Associations\Markup.xml" />
|
||||
<Content Include="Associations\DataLink.xml" />
|
||||
<Content Include="Associations\PropertyList.xml" />
|
||||
<Content Include="Extensions\KnowledgeAdventure\Associations\ATRDataFormat.xml" />
|
||||
<Content Include="Extensions\KnowledgeAdventure\Associations\RSCDataFormat.xml" />
|
||||
<Content Include="Extensions\KnowledgeAdventure\Associations\BALDataFormat.xml" />
|
||||
<Content Include="Extensions\SoftwarePublisher\Associations\Setup\ArkAngles\Setup.xml" />
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.KnowledgeAdventure.Actor;
|
||||
|
||||
namespace UniversalEditor.DataFormats.KnowledgeAdventure.Actor
|
||||
{
|
||||
public class ATRDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
protected override DataFormatReference MakeReferenceInternal()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReferenceInternal();
|
||||
_dfr.Capabilities.Add(typeof(ActorObjectModel), DataFormatCapabilities.All);
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
ActorObjectModel actor = (objectModel as ActorObjectModel);
|
||||
if (actor == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
|
||||
string signature = reader.ReadFixedLengthString(5);
|
||||
if (signature != "ATR11") throw new InvalidDataFormatException("File does not begin with 'ATR11'");
|
||||
|
||||
actor.Name = reader.ReadFixedLengthString(16).TrimNull();
|
||||
actor.ImageFileName = reader.ReadFixedLengthString(32).TrimNull();
|
||||
}
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
ActorObjectModel actor = (objectModel as ActorObjectModel);
|
||||
if (actor == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Writer writer = base.Accessor.Writer;
|
||||
|
||||
writer.WriteFixedLengthString("ATR11");
|
||||
|
||||
writer.WriteFixedLengthString(actor.Name, 16);
|
||||
writer.WriteFixedLengthString(actor.ImageFileName, 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.KnowledgeAdventure.Actor
|
||||
{
|
||||
public class ActorObjectModel : ObjectModel
|
||||
{
|
||||
private static ObjectModelReference _omr = null;
|
||||
protected override ObjectModelReference MakeReferenceInternal()
|
||||
{
|
||||
if (_omr == null)
|
||||
{
|
||||
_omr = base.MakeReferenceInternal();
|
||||
_omr.Title = "Actor";
|
||||
_omr.Path = new string[] { "Knowledge Adventure" };
|
||||
}
|
||||
return _omr;
|
||||
}
|
||||
|
||||
private string mvarName = String.Empty;
|
||||
/// <summary>
|
||||
/// The name used in scripts to identify this <see cref="Actor" />.
|
||||
/// </summary>
|
||||
public string Name { get { return mvarName; } set { mvarName = value; } }
|
||||
|
||||
private string mvarImageFileName = String.Empty;
|
||||
/// <summary>
|
||||
/// The file name of the image file.
|
||||
/// </summary>
|
||||
public string ImageFileName { get { return mvarImageFileName; } set { mvarImageFileName = value; } }
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
mvarName = String.Empty;
|
||||
mvarImageFileName = String.Empty;
|
||||
}
|
||||
|
||||
public override void CopyTo(ObjectModel where)
|
||||
{
|
||||
ActorObjectModel clone = (where as ActorObjectModel);
|
||||
if (clone == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
clone.Name = (mvarName.Clone() as string);
|
||||
clone.ImageFileName = (mvarImageFileName.Clone() as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,6 +39,8 @@
|
||||
<Compile Include="DataFormats\FileSystem\KnowledgeAdventure\BAL\BALDirectoryEntry.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\KnowledgeAdventure\BAL\BALDirectoryEntryAttributes.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\KnowledgeAdventure\RSC\RSCDataFormat.cs" />
|
||||
<Compile Include="ObjectModels\KnowledgeAdventure\Actor\ActorObjectModel.cs" />
|
||||
<Compile Include="DataFormats\KnowledgeAdventure\Actor\ATRDataFormat.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -51,6 +53,7 @@
|
||||
<Name>UniversalEditor.Essential</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user