add data format for Ken Silverman's GRP archive
This commit is contained in:
parent
630644ab46
commit
a4f15f985a
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UniversalEditor Version="4.0">
|
||||
<Associations>
|
||||
<Association>
|
||||
<Filters>
|
||||
<Filter Title="Ken Silverman GRP archive">
|
||||
<FileNameFilters>
|
||||
<FileNameFilter>*.grp</FileNameFilter>
|
||||
</FileNameFilters>
|
||||
<MagicByteSequences>
|
||||
<MagicByteSequence>
|
||||
<MagicByte Type="String">KenSilverman</MagicByte>
|
||||
</MagicByteSequence>
|
||||
</MagicByteSequences>
|
||||
</Filter>
|
||||
</Filters>
|
||||
<ObjectModels>
|
||||
<ObjectModel TypeName="UniversalEditor.ObjectModels.FileSystem.FileSystemObjectModel" />
|
||||
</ObjectModels>
|
||||
<DataFormats>
|
||||
<DataFormat TypeName="UniversalEditor.DataFormats.FileSystem.KenSilverman.KenSilvermanGRPDataFormat" />
|
||||
</DataFormats>
|
||||
</Association>
|
||||
</Associations>
|
||||
</UniversalEditor>
|
||||
@ -668,6 +668,7 @@
|
||||
<Content Include="Extensions\FileSystem\Associations\TexasInstruments\DSK.uexml" />
|
||||
<Content Include="Extensions\FileSystem\Associations\AIN.uexml" />
|
||||
<Content Include="Editors\Multimedia\Audio\Voicebank\Commands.uexml" />
|
||||
<Content Include="Extensions\GameDeveloper\Associations\FileSystem\KenSilverman\GRP.uexml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Configuration\Application.upl" />
|
||||
@ -703,6 +704,7 @@
|
||||
<Folder Include="Documentation\Executable\DataFormats\Executable\" />
|
||||
<Folder Include="Documentation\Executable\DataFormats\Executable\Microsoft\" />
|
||||
<Folder Include="Editors\Multimedia\Audio\Voicebank\" />
|
||||
<Folder Include="Extensions\GameDeveloper\Associations\FileSystem\KenSilverman\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Extensions\SoftwareDeveloper\Templates\Project\Software Development\Arduino\Images\Blink.xcf" />
|
||||
|
||||
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
namespace UniversalEditor.DataFormats.FileSystem.KenSilverman
|
||||
{
|
||||
public class KenSilvermanGRPDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
protected override DataFormatReference MakeReferenceInternal()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReferenceInternal();
|
||||
_dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All);
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null)
|
||||
throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = Accessor.Reader;
|
||||
string signature = reader.ReadFixedLengthString(12);
|
||||
if (signature != "KenSilverman")
|
||||
throw new InvalidDataFormatException("file does not begin with 'KenSilverman'");
|
||||
|
||||
uint fileCount = reader.ReadUInt32();
|
||||
uint offset = (16 * (fileCount + 1));
|
||||
for (uint i = 0; i < fileCount; i++)
|
||||
{
|
||||
string filename = reader.ReadFixedLengthString(12);
|
||||
filename = filename.TrimNull();
|
||||
|
||||
uint size = reader.ReadUInt32();
|
||||
File f = fsom.AddFile(filename);
|
||||
f.Size = size;
|
||||
f.Properties.Add("reader", reader);
|
||||
f.Properties.Add("offset", offset);
|
||||
f.Properties.Add("length", size);
|
||||
f.DataRequest += f_DataRequest;
|
||||
|
||||
offset += size;
|
||||
}
|
||||
}
|
||||
|
||||
private void f_DataRequest(object sender, DataRequestEventArgs e)
|
||||
{
|
||||
File f = (sender as File);
|
||||
Reader reader = (Reader)f.Properties["reader"];
|
||||
uint offset = (uint)f.Properties["offset"];
|
||||
uint length = (uint)f.Properties["length"];
|
||||
|
||||
reader.Seek(offset, SeekOrigin.Begin);
|
||||
e.Data = reader.ReadBytes(length);
|
||||
}
|
||||
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
|
||||
if (fsom == null)
|
||||
throw new ObjectModelNotSupportedException();
|
||||
|
||||
Writer writer = Accessor.Writer;
|
||||
writer.WriteFixedLengthString("KenSilverman");
|
||||
|
||||
uint filecount = (uint)fsom.Files.Count;
|
||||
writer.WriteUInt32(filecount);
|
||||
|
||||
for (uint i = 0; i < filecount; i++)
|
||||
{
|
||||
writer.WriteFixedLengthString(fsom.Files[(int)i].Name, 12);
|
||||
writer.WriteUInt32((uint)fsom.Files[(int)i].Size);
|
||||
}
|
||||
for (uint i = 0; i < filecount; i++)
|
||||
{
|
||||
writer.WriteBytes(fsom.Files[(int)i].GetData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,6 +239,7 @@
|
||||
<Compile Include="DataFormats\FileSystem\TexasInstruments\TIFiles\TIFilesFlags.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\TexasInstruments\DSK\DSKDataFormat.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\TexasInstruments\DSK\DSKFileStatusFlags.cs" />
|
||||
<Compile Include="DataFormats\FileSystem\KenSilverman\KenSilvermanGRPDataFormat.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
|
||||
@ -281,6 +282,7 @@
|
||||
<Folder Include="DataFormats\FileSystem\TexasInstruments\" />
|
||||
<Folder Include="DataFormats\FileSystem\TexasInstruments\TIFiles\" />
|
||||
<Folder Include="DataFormats\FileSystem\TexasInstruments\DSK\" />
|
||||
<Folder Include="DataFormats\FileSystem\KenSilverman\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user