From bb0b4323d4db75ab45a14fd083d6611ff3d7f398 Mon Sep 17 00:00:00 2001 From: alcexhim Date: Wed, 2 Apr 2014 00:36:36 -0400 Subject: [PATCH] Various fixes and updates --- .../Concert/ConcertBinaryDataFormat.cs | 2 +- .../FileSystem/ALTools/EGG/EGGDataFormat.cs | 14 +++--- .../FileSystem/FAT/FATDataFormat.cs | 4 +- .../Moosta/Container/MCHADataFormat.cs | 19 ++++--- .../Moosta/ImageCollection/IMCDataFormat.cs | 19 +++---- .../MotionPack/MoPkg/MoPkgDataFormat.cs | 50 ++++++++++--------- 6 files changed, 55 insertions(+), 53 deletions(-) diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Concertroid/DataFormats/Concertroid/Concert/ConcertBinaryDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Concertroid/DataFormats/Concertroid/Concert/ConcertBinaryDataFormat.cs index e1095d19..1398c071 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Concertroid/DataFormats/Concertroid/Concert/ConcertBinaryDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Concertroid/DataFormats/Concertroid/Concert/ConcertBinaryDataFormat.cs @@ -23,7 +23,7 @@ namespace UniversalEditor.DataFormats.Concertroid.Concert _dfr = new DataFormatReference(GetType()); _dfr.Capabilities.Add(typeof(VersatileContainerObjectModel), DataFormatCapabilities.Bootstrap); _dfr.Capabilities.Add(typeof(ConcertObjectModel), DataFormatCapabilities.All); - _dfr.Filters.Add("Concertroid compiled binary", new string[] { "*.cvb" }); + _dfr.Filters.Add("Concertroid compili hed binary", new string[] { "*.cvb" }); } return _dfr; } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/ALTools/EGG/EGGDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/ALTools/EGG/EGGDataFormat.cs index 769b7485..b59e4df7 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/ALTools/EGG/EGGDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/ALTools/EGG/EGGDataFormat.cs @@ -325,13 +325,13 @@ namespace UniversalEditor.DataFormats.FileSystem.ALTools.EGG if ((flag & ALZipFileNameFlags.UseAreaCode) == ALZipFileNameFlags.UseAreaCode) { short locale = 0; - bw.Write(locale); + bw.WriteInt16(locale); } if ((flag & ALZipFileNameFlags.RelativePath) == ALZipFileNameFlags.RelativePath) { uint parentID = 0; - bw.Write(parentID); + bw.WriteUInt32(parentID); } bw.WriteFixedLengthString(fi.name); @@ -351,15 +351,15 @@ namespace UniversalEditor.DataFormats.FileSystem.ALTools.EGG // 0 - store, 1 - deflate, 2 - bzip2, 3 - AZO, 4 - LZMA bw.WriteByte((byte)bi.compressionMethod); - bw.Write(bi.hint); + bw.WriteByte(bi.hint); - bw.Write(bi.decompressedSize); - bw.Write(bi.compressedSize); - bw.Write(bi.crc32); + bw.WriteUInt32(bi.decompressedSize); + bw.WriteUInt32(bi.compressedSize); + bw.WriteUInt32(bi.crc32); bw.WriteUInt32((uint)0x08E28222); - bw.Write(bi.compressedData); + bw.WriteBytes(bi.compressedData); } } #endregion diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/FAT/FATDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/FAT/FATDataFormat.cs index a4cfbe93..77c22ed5 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/FAT/FATDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/FAT/FATDataFormat.cs @@ -704,7 +704,7 @@ namespace UniversalEditor.DataFormats.FileSystem.FAT extendedBootSignature = 0x28; } } - bw.Write(extendedBootSignature); + bw.WriteByte(extendedBootSignature); if (extendedBootSignature == 0x29 || extendedBootSignature == 0x28) { @@ -714,7 +714,7 @@ namespace UniversalEditor.DataFormats.FileSystem.FAT // number. Alternatively, some DR-DOS disk utilities provide a /# option to generate a // human-readable time stamp "mmdd-hhmm" build from BCD-encoded 8-bit values for the month, day, // hour and minute instead of a serial number. - bw.Write(mvarExtendedBiosParameterBlock.ExtendedBootSignature.VolumeSerialNumber); + bw.WriteInt32(mvarExtendedBiosParameterBlock.ExtendedBootSignature.VolumeSerialNumber); } if (extendedBootSignature == 0x29) { diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/FileSystem/Moosta/Container/MCHADataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/FileSystem/Moosta/Container/MCHADataFormat.cs index b7d5473e..ede2a520 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/FileSystem/Moosta/Container/MCHADataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/FileSystem/Moosta/Container/MCHADataFormat.cs @@ -7,7 +7,6 @@ using UniversalEditor.IO; using UniversalEditor.ObjectModels.FileSystem; using UniversalEditor.ObjectModels.Multimedia.Picture; using UniversalEditor.ObjectModels.Multimedia3D.Model; -using UniversalEditor.UserInterface; namespace UniversalEditor.DataFormats.FileSystem.Moosta.Container { @@ -132,7 +131,7 @@ namespace UniversalEditor.DataFormats.FileSystem.Moosta.Container } - // br.BaseStream.Position = 0; + // br.Accessor.Position = 0; // model.Surfaces.Clear(); #region Load Surfaces { @@ -200,7 +199,7 @@ namespace UniversalEditor.DataFormats.FileSystem.Moosta.Container for (uint j = 0; j < deformerCount; j++) { ModelSkin skin = new ModelSkin(); - skin.Name = br.ReadInt16UnicodeString(); + skin.Name = br.ReadInt16String(); uint deformerVertexCount = br.ReadUInt32(); for (uint k = 0; k < deformerVertexCount; k++) { @@ -230,17 +229,17 @@ namespace UniversalEditor.DataFormats.FileSystem.Moosta.Container ModelMaterial mat = new ModelMaterial(); int unknown1 = br.ReadInt32(); int unknown2 = br.ReadInt32(); - mat.Name = br.ReadInt16UnicodeString(); + mat.Name = br.ReadInt16String(); mat.AmbientColor = br.ReadColorARGBSingle(); mat.DiffuseColor = br.ReadColorARGBSingle(); mat.SpecularColor = br.ReadColorARGBSingle(); mat.Shininess = br.ReadSingle(); - string textureFileName = br.ReadInt16UnicodeString(); - string toonFileName = br.ReadInt16UnicodeString(); - string unknown5 = br.ReadInt16UnicodeString(); - string unknown6 = br.ReadInt16UnicodeString(); - string unknown7 = br.ReadInt16UnicodeString(); + string textureFileName = br.ReadInt16String(); + string toonFileName = br.ReadInt16String(); + string unknown5 = br.ReadInt16String(); + string unknown6 = br.ReadInt16String(); + string unknown7 = br.ReadInt16String(); // mat.ToonFileName = toonFileName; mat.Textures.Add(textureFileName, null, ModelTextureFlags.Texture); model.Materials.Add(mat); @@ -255,7 +254,7 @@ namespace UniversalEditor.DataFormats.FileSystem.Moosta.Container for (uint i = 0; i < boneCount; i++) { ModelBone bone = new ModelBone(); - bone.Name = br.ReadInt16UnicodeString(); + bone.Name = br.ReadInt16String(); #region Bone Matrix #1 { diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/FileSystem/Moosta/ImageCollection/IMCDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/FileSystem/Moosta/ImageCollection/IMCDataFormat.cs index d95f40a6..b89e350f 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/FileSystem/Moosta/ImageCollection/IMCDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/FileSystem/Moosta/ImageCollection/IMCDataFormat.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using UniversalEditor.IO; using UniversalEditor.ObjectModels.FileSystem; namespace UniversalEditor.DataFormats.FileSystem.Moosta.ImageCollection @@ -26,18 +27,18 @@ namespace UniversalEditor.DataFormats.FileSystem.Moosta.ImageCollection if (fsom == null) throw new ObjectModelNotSupportedException(); List files = new List(); - IO.Reader br = base.Stream.Reader; + IO.Reader br = base.Accessor.Reader; int fileCount = br.ReadInt32(); for (int i = 0; i < fileCount; i++) { - string fileName = br.ReadString(); + string fileName = br.ReadLengthPrefixedString(); files.Add(fsom.AddFile(fileName)); } for (int i = 0; i < fileCount; i++) { int length = br.ReadInt32(); int unknown1 = br.ReadInt32(); - long offset = br.BaseStream.Position; + long offset = br.Accessor.Position; files[i].Properties.Add("length", length); files[i].Properties.Add("offset", offset); @@ -45,7 +46,7 @@ namespace UniversalEditor.DataFormats.FileSystem.Moosta.ImageCollection files[i].Size = length; files[i].DataRequest += IMCDataFormat_DataRequest; - br.BaseStream.Seek(length, System.IO.SeekOrigin.Current); + br.Accessor.Seek(length, SeekOrigin.Current); } } @@ -55,7 +56,7 @@ namespace UniversalEditor.DataFormats.FileSystem.Moosta.ImageCollection IO.Reader br = (IO.Reader)file.Properties["reader"]; int length = (int)file.Properties["length"]; long offset = (long)file.Properties["offset"]; - br.BaseStream.Seek(offset, System.IO.SeekOrigin.Begin); + br.Accessor.Seek(offset, SeekOrigin.Begin); e.Data = br.ReadBytes(length); } protected override void SaveInternal(ObjectModel objectModel) @@ -63,18 +64,18 @@ namespace UniversalEditor.DataFormats.FileSystem.Moosta.ImageCollection FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel); if (fsom == null) throw new ObjectModelNotSupportedException(); - IO.Writer bw = base.Stream.Writer; + IO.Writer bw = base.Accessor.Writer; File[] files = fsom.GetAllFiles(); - bw.Write(files.Length); + bw.WriteInt32(files.Length); foreach (File file in files) { bw.Write(file.Name); } foreach (File file in files) { - bw.Write(file.Size); - bw.Write(file.GetDataAsByteArray()); + bw.WriteInt64(file.Size); + bw.WriteBytes(file.GetDataAsByteArray()); } bw.Flush(); } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/Moosta/MotionPack/MoPkg/MoPkgDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/Moosta/MotionPack/MoPkg/MoPkgDataFormat.cs index 09d58651..0e8bd375 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/Moosta/MotionPack/MoPkg/MoPkgDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Moosta/DataFormats/Moosta/MotionPack/MoPkg/MoPkgDataFormat.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; +using UniversalEditor.IO; using UniversalEditor.ObjectModels.Moosta.MotionPack; using UniversalEditor.ObjectModels.Multimedia.Picture; @@ -42,7 +42,9 @@ namespace UniversalEditor.DataFormats.Moosta.MotionPack.MoPkg MotionPackObjectModel mopkg = (objectModel as MotionPackObjectModel); if (mopkg == null) throw new ObjectModelNotSupportedException(); - IO.Reader br = base.Stream.Reader; + IO.Reader br = base.Accessor.Reader; + base.Accessor.DefaultEncoding = Encoding.UTF16LittleEndian; + string signature = br.ReadFixedLengthString(5); if (signature != "MoPkg") throw new InvalidDataFormatException("File does not begin with \"MoPkg\""); @@ -55,7 +57,7 @@ namespace UniversalEditor.DataFormats.Moosta.MotionPack.MoPkg for (int i = 0; i < packageInfoCount1; i++) { int langID = br.ReadInt32(); - string value = br.ReadInt16UnicodeString(); + string value = br.ReadInt16String(); PackageInformation ste = new PackageInformation(); ste.LanguageID = langID; @@ -66,7 +68,7 @@ namespace UniversalEditor.DataFormats.Moosta.MotionPack.MoPkg for (int i = 0; i < packageInfoCount2; i++) { int langID = br.ReadInt32(); - string value = br.ReadInt16UnicodeString(); + string value = br.ReadInt16String(); if (i < mopkg.PackageInformation.Count) { mopkg.PackageInformation[i].PackageDescription = value; @@ -75,7 +77,7 @@ namespace UniversalEditor.DataFormats.Moosta.MotionPack.MoPkg int copyrightCount = br.ReadInt32(); for (int i = 0; i < copyrightCount; i++) { - string copyright = br.ReadInt16UnicodeString(); + string copyright = br.ReadInt16String(); mvarCopyrights.Add(copyright); } @@ -109,50 +111,50 @@ namespace UniversalEditor.DataFormats.Moosta.MotionPack.MoPkg MotionPackObjectModel mopkg = (objectModel as MotionPackObjectModel); if (mopkg == null) throw new ObjectModelNotSupportedException(); - IO.Writer bw = base.Stream.Writer; + IO.Writer bw = base.Accessor.Writer; bw.WriteFixedLengthString("MoPkg"); - bw.Write(FormatVersion); - bw.Write(mvarPackageVersion); + bw.WriteSingle(FormatVersion); + bw.WriteSingle(mvarPackageVersion); // bw.Write(mopkg.Animations.Count); - bw.Write(mopkg.PackageInformation.Count); + bw.WriteInt32(mopkg.PackageInformation.Count); foreach (PackageInformation packageName in mopkg.PackageInformation) { - bw.Write(packageName.LanguageID); - bw.Write(packageName.PackageName); + bw.WriteInt32(packageName.LanguageID); + bw.WriteLengthPrefixedString(packageName.PackageName); } - bw.Write(mopkg.PackageInformation.Count); + bw.WriteInt32(mopkg.PackageInformation.Count); foreach (PackageInformation packageName in mopkg.PackageInformation) { - bw.Write(packageName.LanguageID); - bw.Write(packageName.PackageDescription); + bw.WriteInt32(packageName.LanguageID); + bw.WriteLengthPrefixedString(packageName.PackageDescription); } foreach (string copyright in mopkg.Copyrights) { bw.WriteUInt16SizedString(copyright); } - bw.Write(mvarIsRemovable); + bw.WriteBoolean(mvarIsRemovable); if (mvarThumbnail != null) { - bw.Write(mvarThumbnail.Width); - bw.Write(mvarThumbnail.Height); + bw.WriteInt32(mvarThumbnail.Width); + bw.WriteInt32(mvarThumbnail.Height); for (int y = 0; y < mvarThumbnail.Height; y++) { for (int x = 0; x < mvarThumbnail.Width; x++) { Color pixel = mvarThumbnail.GetPixel(x, y); - bw.Write((byte)(pixel.Alpha * 255)); - bw.Write((byte)(pixel.Red * 255)); - bw.Write((byte)(pixel.Green * 255)); - bw.Write((byte)(pixel.Blue * 255)); + bw.WriteByte((byte)(pixel.Alpha * 255)); + bw.WriteByte((byte)(pixel.Red * 255)); + bw.WriteByte((byte)(pixel.Green * 255)); + bw.WriteByte((byte)(pixel.Blue * 255)); } } } else { - bw.Write(0); - bw.Write(0); + bw.WriteInt32(0); + bw.WriteInt32(0); } - bw.Write(mvarCompressionMode); + bw.WriteByte(mvarCompressionMode); } } }