Start to add MSBT support
This commit is contained in:
parent
690028328f
commit
dff727ff0f
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,10 +6,12 @@ using System.Threading.Tasks;
|
||||
using Switch_Toolbox;
|
||||
using System.Windows.Forms;
|
||||
using Switch_Toolbox.Library;
|
||||
using FirstPlugin.Forms;
|
||||
using Switch_Toolbox.Library.IO;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class MSBT : IFileFormat
|
||||
public class MSBT : IEditor<MSBTEditor>, IFileFormat
|
||||
{
|
||||
public bool CanSave { get; set; }
|
||||
public string[] Description { get; set; } = new string[] { "Message Binary Text" };
|
||||
@ -35,8 +37,23 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public MSBTEditor OpenForm()
|
||||
{
|
||||
MSBTEditor editor = new MSBTEditor();
|
||||
editor.LoadMSBT(this);
|
||||
editor.Text = FileName;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
return editor;
|
||||
}
|
||||
|
||||
public Header header;
|
||||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
CanSave = true;
|
||||
|
||||
header = new Header();
|
||||
header.Read(new FileReader(stream));
|
||||
}
|
||||
public void Unload()
|
||||
{
|
||||
@ -46,5 +63,106 @@ namespace FirstPlugin
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public class Header
|
||||
{
|
||||
public ushort ByteOrderMark;
|
||||
public ushort Padding;
|
||||
public EncodingType StringEncoding;
|
||||
public byte Version;
|
||||
public List<MSBTEntry> entries = new List<MSBTEntry>();
|
||||
|
||||
byte[] Reserved;
|
||||
|
||||
public enum EncodingType : byte
|
||||
{
|
||||
UTF8 = 0,
|
||||
UTF16 = 1,
|
||||
}
|
||||
|
||||
public void Read(FileReader reader)
|
||||
{
|
||||
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
reader.ReadSignature(8, "MsgStdBn");
|
||||
ByteOrderMark = reader.ReadUInt16();
|
||||
reader.CheckByteOrderMark(ByteOrderMark);
|
||||
Padding = reader.ReadUInt16();
|
||||
StringEncoding = reader.ReadEnum<EncodingType>(true);
|
||||
Version = reader.ReadByte();
|
||||
ushort SectionCount = reader.ReadUInt16();
|
||||
ushort Unknown = reader.ReadUInt16();
|
||||
uint FileSize = reader.ReadUInt32();
|
||||
Reserved = reader.ReadBytes(10);
|
||||
|
||||
for (int i = 0; i < SectionCount; i++)
|
||||
{
|
||||
long pos = reader.Position;
|
||||
|
||||
string Signature = reader.ReadString(4, Encoding.ASCII);
|
||||
uint SectionSize = reader.ReadUInt32();
|
||||
byte[] Padding = reader.ReadBytes(8);
|
||||
uint EntryCount = reader.ReadUInt32();
|
||||
|
||||
Console.WriteLine("Signature " + Signature);
|
||||
|
||||
switch (Signature)
|
||||
{
|
||||
case "LBL1":
|
||||
case "NLI1":
|
||||
case "ATR1":
|
||||
case "TXT2":
|
||||
case "ATO1":
|
||||
case "TSY1":
|
||||
default:
|
||||
MSBTEntry entry = new MSBTEntry();
|
||||
entry.Signature = Signature;
|
||||
entry.Data = reader.ReadBytes((int)SectionSize + 8);
|
||||
entries.Add(entry);
|
||||
break;
|
||||
}
|
||||
|
||||
reader.Seek(pos + SectionSize + 0x1C, System.IO.SeekOrigin.Begin);
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.WriteSignature("MsgStdBn");
|
||||
writer.Write(ByteOrderMark);
|
||||
writer.Write(Padding);
|
||||
writer.Write(StringEncoding, true);
|
||||
writer.Write(Version);
|
||||
|
||||
long _ofsFileSize = writer.Position;
|
||||
writer.Write(0); //FileSize reserved for later
|
||||
writer.Write(Reserved);
|
||||
|
||||
foreach (var entry in entries)
|
||||
entry.Write(writer, this);
|
||||
|
||||
//Write file size
|
||||
using (writer.TemporarySeek(_ofsFileSize, System.IO.SeekOrigin.Begin))
|
||||
{
|
||||
writer.Write(writer.BaseStream.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MSBTEntry
|
||||
{
|
||||
public byte[] Data;
|
||||
public string Signature;
|
||||
|
||||
public virtual void Read(FileReader reader, Header header)
|
||||
{
|
||||
|
||||
}
|
||||
public virtual void Write(FileWriter writer, Header header)
|
||||
{
|
||||
writer.Write(Signature);
|
||||
writer.Write(Data.Length);
|
||||
writer.Write(Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
87
Switch_FileFormatsMain/GUI/Message/MSBTEditor.Designer.cs
generated
Normal file
87
Switch_FileFormatsMain/GUI/Message/MSBTEditor.Designer.cs
generated
Normal file
@ -0,0 +1,87 @@
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
partial class MSBTEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.textEditor1 = new Switch_Toolbox.Library.Forms.TextEditor();
|
||||
this.listViewCustom1 = new Switch_Toolbox.Library.Forms.ListViewCustom();
|
||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.contentContainer.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// contentContainer
|
||||
//
|
||||
this.contentContainer.Controls.Add(this.listViewCustom1);
|
||||
this.contentContainer.Controls.Add(this.textEditor1);
|
||||
this.contentContainer.Controls.SetChildIndex(this.textEditor1, 0);
|
||||
this.contentContainer.Controls.SetChildIndex(this.listViewCustom1, 0);
|
||||
//
|
||||
// textEditor1
|
||||
//
|
||||
this.textEditor1.IsXML = false;
|
||||
this.textEditor1.Location = new System.Drawing.Point(204, 31);
|
||||
this.textEditor1.Name = "textEditor1";
|
||||
this.textEditor1.Size = new System.Drawing.Size(336, 359);
|
||||
this.textEditor1.TabIndex = 11;
|
||||
//
|
||||
// listViewCustom1
|
||||
//
|
||||
this.listViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.listViewCustom1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1});
|
||||
this.listViewCustom1.Location = new System.Drawing.Point(3, 31);
|
||||
this.listViewCustom1.Name = "listViewCustom1";
|
||||
this.listViewCustom1.OwnerDraw = true;
|
||||
this.listViewCustom1.Size = new System.Drawing.Size(195, 359);
|
||||
this.listViewCustom1.TabIndex = 12;
|
||||
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
|
||||
this.listViewCustom1.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Width = 177;
|
||||
//
|
||||
// MSBTEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(549, 398);
|
||||
this.Name = "MSBTEditor";
|
||||
this.Text = "MSBTEditor";
|
||||
this.contentContainer.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Switch_Toolbox.Library.Forms.TextEditor textEditor1;
|
||||
private Switch_Toolbox.Library.Forms.ListViewCustom listViewCustom1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
}
|
||||
}
|
36
Switch_FileFormatsMain/GUI/Message/MSBTEditor.cs
Normal file
36
Switch_FileFormatsMain/GUI/Message/MSBTEditor.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Switch_Toolbox.Library.Forms;
|
||||
using Switch_Toolbox.Library;
|
||||
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
public partial class MSBTEditor : STForm, IFIleEditor
|
||||
{
|
||||
public List<IFileFormat> GetFileFormats()
|
||||
{
|
||||
return new List<IFileFormat>() { activeMessageFile };
|
||||
}
|
||||
|
||||
public MSBTEditor()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
listViewCustom1.HeaderStyle = ColumnHeaderStyle.None;
|
||||
}
|
||||
|
||||
MSBT activeMessageFile;
|
||||
|
||||
public void LoadMSBT(MSBT msbt)
|
||||
{
|
||||
activeMessageFile = msbt;
|
||||
}
|
||||
}
|
||||
}
|
120
Switch_FileFormatsMain/GUI/Message/MSBTEditor.resx
Normal file
120
Switch_FileFormatsMain/GUI/Message/MSBTEditor.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -372,6 +372,12 @@
|
||||
<Compile Include="GUI\KCL\CollisionMaterialEditor.Designer.cs">
|
||||
<DependentUpon>CollisionMaterialEditor.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GUI\Message\MSBTEditor.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\Message\MSBTEditor.Designer.cs">
|
||||
<DependentUpon>MSBTEditor.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MarioCostumeEditor.cs" />
|
||||
<Compile Include="GUI\AAMP\AampV1Editor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
@ -1026,6 +1032,9 @@
|
||||
<EmbeddedResource Include="GUI\Editors\VertexAttributeDataList.resx">
|
||||
<DependentUpon>VertexAttributeDataList.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GUI\Message\MSBTEditor.resx">
|
||||
<DependentUpon>MSBTEditor.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GUI\PreviewFormatList.resx">
|
||||
<DependentUpon>PreviewFormatList.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
7c84633eaa36420d4ca6a3cb60a7e5117cc8630b
|
||||
9b54d576b7ab53a1cb0beb8579692014c8a39e74
|
||||
|
@ -320,3 +320,4 @@ C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Toolbox\bin\Release\Lib\Plugins
|
||||
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Toolbox\bin\Release\Lib\Plugins\FirstPlugin.Plg.pdb
|
||||
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\Switch_FileFormatsMain.csproj.CopyComplete
|
||||
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.CollisionMaterialEditor.resources
|
||||
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.MSBTEditor.resources
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user