So many stuff
Forgot to commit it all while working
This commit is contained in:
58
BMGEditor/BMG.cs
Normal file
58
BMGEditor/BMG.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BMGEditor
|
||||
{
|
||||
public class BMG
|
||||
{
|
||||
private FileBase m_File;
|
||||
private Int32 m_Signature = 0x4D455347;
|
||||
private Int32 m_FileType = 0x626D6731;
|
||||
private Byte m_ExpectedEncoding = 0x02;
|
||||
|
||||
public BMG(FileBase file)
|
||||
{
|
||||
m_File = file;
|
||||
m_File.BigEndian = true;
|
||||
m_File.Stream.Position = 0;
|
||||
|
||||
Int32 headermagic1 = m_File.Reader.ReadInt32();
|
||||
Int32 headermagic2 = m_File.Reader.ReadInt32();
|
||||
if (headermagic1 == m_Signature && headermagic2 == m_FileType) { Console.WriteLine("Nice"); } else { Console.WriteLine("not nice");}
|
||||
|
||||
UInt32 fileSize = m_File.Reader.ReadUInt32();
|
||||
UInt32 numberOfSections = m_File.Reader.ReadUInt32();
|
||||
Byte fileEncoding = m_File.Reader.ReadByte();
|
||||
Console.WriteLine("File size: " + fileSize);
|
||||
Console.WriteLine("File sections: " + numberOfSections);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
m_File.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/*public class BMGSection
|
||||
{
|
||||
Int32 sectionMagic;
|
||||
public BMGSection()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class INF1Section : BMGSection
|
||||
{
|
||||
public INF1Section()
|
||||
{
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
39
BMGEditor/BMGEditForm.Designer.cs
generated
Normal file
39
BMGEditor/BMGEditForm.Designer.cs
generated
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace BMGEditor
|
||||
{
|
||||
partial class BMGEditForm
|
||||
{
|
||||
/// <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.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "BMGEditForm";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
20
BMGEditor/BMGEditForm.cs
Normal file
20
BMGEditor/BMGEditForm.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
|
||||
namespace BMGEditor
|
||||
{
|
||||
public partial class BMGEditForm : Form
|
||||
{
|
||||
public BMGEditForm(RarcFilesystem arcFs)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
BMGEditor/BMGEditForm.resx
Normal file
120
BMGEditor/BMGEditForm.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>
|
||||
@@ -1,12 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -12,7 +12,7 @@ namespace BMGEditor
|
||||
{
|
||||
m_File = file;
|
||||
m_File.BigEndian = true;
|
||||
m_File.Encoding = Encoding.GetEncoding("shift-jis");
|
||||
m_File.Encoding = Encoding.GetEncoding(20127);
|
||||
|
||||
Fields = new Dictionary<uint, Field>();
|
||||
Entries = new List<Entry>();
|
||||
@@ -37,7 +37,6 @@ namespace BMGEditor
|
||||
field.Type = m_File.Reader.ReadByte();
|
||||
|
||||
string fieldname = Bcsv.HashToFieldName(field.NameHash);
|
||||
field.Name = fieldname;
|
||||
Fields.Add(field.NameHash, field);
|
||||
}
|
||||
|
||||
@@ -344,17 +343,7 @@ namespace BMGEditor
|
||||
public static void PopulateHashtable()
|
||||
{
|
||||
m_HashTable = new Dictionary<uint, string>();
|
||||
|
||||
string[] lines = new string[1];
|
||||
foreach (string _line in lines)
|
||||
{
|
||||
string line = _line.Trim();
|
||||
|
||||
if (line.Length == 0) continue;
|
||||
if (line[0] == '#') continue;
|
||||
|
||||
AddHash(line);
|
||||
}
|
||||
AddHash("wowHowDidYouFindThis");
|
||||
}
|
||||
|
||||
public static Dictionary<uint, string> m_HashTable;
|
||||
|
||||
99
BMGEditor/BcsvEditorForm.Designer.cs
generated
Normal file
99
BMGEditor/BcsvEditorForm.Designer.cs
generated
Normal file
@@ -0,0 +1,99 @@
|
||||
namespace BMGEditor
|
||||
{
|
||||
partial class BcsvEditorForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable nécessaire au concepteur.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Nettoyage des ressources utilisées.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Code généré par le Concepteur Windows Form
|
||||
|
||||
/// <summary>
|
||||
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
|
||||
/// le contenu de cette méthode avec l'éditeur de code.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BcsvEditorForm));
|
||||
this.tsToolbar = new System.Windows.Forms.ToolStrip();
|
||||
this.btnSave = new System.Windows.Forms.ToolStripButton();
|
||||
this.dgvBcsv = new System.Windows.Forms.DataGridView();
|
||||
this.tsToolbar.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvBcsv)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tsToolbar
|
||||
//
|
||||
this.tsToolbar.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.tsToolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.btnSave});
|
||||
this.tsToolbar.Location = new System.Drawing.Point(0, 0);
|
||||
this.tsToolbar.Name = "tsToolbar";
|
||||
this.tsToolbar.Size = new System.Drawing.Size(1039, 27);
|
||||
this.tsToolbar.TabIndex = 0;
|
||||
this.tsToolbar.Text = "toolStrip1";
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
this.btnSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||
this.btnSave.Enabled = false;
|
||||
this.btnSave.Image = ((System.Drawing.Image)(resources.GetObject("btnSave.Image")));
|
||||
this.btnSave.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.Size = new System.Drawing.Size(44, 24);
|
||||
this.btnSave.Text = "Save";
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// dgvBcsv
|
||||
//
|
||||
this.dgvBcsv.AllowUserToResizeRows = false;
|
||||
this.dgvBcsv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvBcsv.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dgvBcsv.Location = new System.Drawing.Point(0, 27);
|
||||
this.dgvBcsv.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.dgvBcsv.MultiSelect = false;
|
||||
this.dgvBcsv.Name = "dgvBcsv";
|
||||
this.dgvBcsv.RowHeadersWidth = 51;
|
||||
this.dgvBcsv.Size = new System.Drawing.Size(1039, 731);
|
||||
this.dgvBcsv.TabIndex = 1;
|
||||
//
|
||||
// BcsvEditorForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1039, 758);
|
||||
this.Controls.Add(this.dgvBcsv);
|
||||
this.Controls.Add(this.tsToolbar);
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.Name = "BcsvEditorForm";
|
||||
this.Text = "[DEBUG] BCSV editor";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BcsvEditorForm_FormClosing);
|
||||
this.tsToolbar.ResumeLayout(false);
|
||||
this.tsToolbar.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvBcsv)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ToolStrip tsToolbar;
|
||||
private System.Windows.Forms.DataGridView dgvBcsv;
|
||||
private System.Windows.Forms.ToolStripButton btnSave;
|
||||
}
|
||||
}
|
||||
98
BMGEditor/BcsvEditorForm.cs
Normal file
98
BMGEditor/BcsvEditorForm.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BMGEditor
|
||||
{
|
||||
public partial class BcsvEditorForm : Form
|
||||
{
|
||||
public BcsvEditorForm(RarcFilesystem arcFs)
|
||||
{
|
||||
InitializeComponent();
|
||||
m_File = new Bcsv(arcFs.OpenFile($"{arcFs.rootName}/messageid.tbl"));
|
||||
|
||||
dgvBcsv.Rows.Clear();
|
||||
dgvBcsv.Columns.Clear();
|
||||
|
||||
foreach (Bcsv.Field field in m_File.Fields.Values)
|
||||
{
|
||||
dgvBcsv.Columns.Add(field.NameHash.ToString("X8"), field.Name);
|
||||
}
|
||||
|
||||
foreach (Bcsv.Entry entry in m_File.Entries)
|
||||
{
|
||||
object[] row = new object[entry.Count];
|
||||
int i = 0;
|
||||
|
||||
foreach (KeyValuePair<uint, object> _val in entry)
|
||||
{
|
||||
object val = _val.Value;
|
||||
row[i++] = val;
|
||||
}
|
||||
|
||||
dgvBcsv.Rows.Add(row);
|
||||
}
|
||||
|
||||
btnSave.Enabled = true;
|
||||
}
|
||||
|
||||
private Bcsv m_File = null;
|
||||
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
m_File.Entries.Clear();
|
||||
|
||||
foreach (DataGridViewRow row in dgvBcsv.Rows)
|
||||
{
|
||||
if (row.IsNewRow) continue;
|
||||
|
||||
Bcsv.Entry entry = new Bcsv.Entry();
|
||||
m_File.Entries.Add(entry);
|
||||
|
||||
foreach (Bcsv.Field field in m_File.Fields.Values)
|
||||
{
|
||||
uint hash = field.NameHash;
|
||||
string valstring = row.Cells[hash.ToString("X8")].FormattedValue.ToString();
|
||||
|
||||
try
|
||||
{
|
||||
switch (field.Type)
|
||||
{
|
||||
case 0:
|
||||
case 3: entry.Add(hash, uint.Parse(valstring)); break;
|
||||
case 4: entry.Add(hash, ushort.Parse(valstring)); break;
|
||||
case 5: entry.Add(hash, byte.Parse(valstring)); break;
|
||||
case 2: entry.Add(hash, float.Parse(valstring)); break;
|
||||
case 6: entry.Add(hash, valstring); break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
switch (field.Type)
|
||||
{
|
||||
case 0:
|
||||
case 3: entry.Add(hash, (uint)0); break;
|
||||
case 4: entry.Add(hash, (ushort)0); break;
|
||||
case 5: entry.Add(hash, (byte)0); break;
|
||||
case 2: entry.Add(hash, 0f); break;
|
||||
case 6: entry.Add(hash, ""); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_File.Flush();
|
||||
}
|
||||
|
||||
private void BcsvEditorForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
m_File.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
79
BMGEditor/BcsvEditorForm.resx
Normal file
79
BMGEditor/BcsvEditorForm.resx
Normal file
@@ -0,0 +1,79 @@
|
||||
<root>
|
||||
<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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="tsToolbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="btnSave.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
|
||||
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
|
||||
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
|
||||
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
|
||||
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
|
||||
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -29,6 +29,12 @@ namespace BMGEditor
|
||||
return (Int32)((val >> 24) | ((val & 0xFF0000) >> 8) | ((val & 0xFF00) << 8) | (val << 24));
|
||||
}
|
||||
|
||||
/*public override long ReadInt64()
|
||||
{
|
||||
UInt64 val = base.ReadUInt64();
|
||||
return (Int64)()
|
||||
}*/
|
||||
|
||||
|
||||
public override ushort ReadUInt16()
|
||||
{
|
||||
|
||||
73
BMGEditor/ExternalFilesystem.cs
Normal file
73
BMGEditor/ExternalFilesystem.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace BMGEditor
|
||||
{
|
||||
public class ExternalFilesystem : FilesystemBase
|
||||
{
|
||||
public ExternalFilesystem(string basedir)
|
||||
{
|
||||
if (basedir.EndsWith("/") || basedir.EndsWith("\\"))
|
||||
basedir = basedir.Substring(0, basedir.Length - 1);
|
||||
|
||||
m_BaseDirectory = basedir;
|
||||
if (!Directory.Exists(basedir)) throw new Exception("Directory '" + basedir + "' doesn't exist");
|
||||
}
|
||||
|
||||
|
||||
public override string[] GetDirectories(string directory)
|
||||
{
|
||||
string[] ret = Directory.GetDirectories(m_BaseDirectory + directory);
|
||||
|
||||
for (int i = 0; i < ret.Length; i++)
|
||||
{
|
||||
ret[i] = ret[i].Substring(ret[i].LastIndexOfAny(new char[] { '/', '\\' }) + 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override bool DirectoryExists(string directory)
|
||||
{
|
||||
return Directory.Exists(m_BaseDirectory + directory);
|
||||
}
|
||||
|
||||
|
||||
public override string[] GetFiles(string directory)
|
||||
{
|
||||
string[] ret = Directory.GetFiles(m_BaseDirectory + directory);
|
||||
|
||||
for (int i = 0; i < ret.Length; i++)
|
||||
{
|
||||
ret[i] = ret[i].Substring(ret[i].LastIndexOfAny(new char[] { '/', '\\' }) + 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override bool FileExists(string filename)
|
||||
{
|
||||
return File.Exists(m_BaseDirectory + filename);
|
||||
}
|
||||
|
||||
public override FileBase OpenFile(string filename)
|
||||
{
|
||||
return new ExternalFile(m_BaseDirectory + filename, false);
|
||||
}
|
||||
|
||||
|
||||
private string m_BaseDirectory;
|
||||
}
|
||||
|
||||
|
||||
public class ExternalFile : FileBase
|
||||
{
|
||||
public ExternalFile(string filename, bool create)
|
||||
{
|
||||
Stream = File.Open(filename, create ? FileMode.Create : FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
|
||||
}
|
||||
}
|
||||
}
|
||||
87
BMGEditor/MainForm.Designer.cs
generated
87
BMGEditor/MainForm.Designer.cs
generated
@@ -32,12 +32,95 @@ namespace BMGEditor
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.openFileBtn = new System.Windows.Forms.Button();
|
||||
this.closeFileBtn = new System.Windows.Forms.Button();
|
||||
this.openTextEditorBtn = new System.Windows.Forms.Button();
|
||||
this.openBcsvEditorBtn = new System.Windows.Forms.Button();
|
||||
this.openARCFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// openFileBtn
|
||||
//
|
||||
this.openFileBtn.Location = new System.Drawing.Point(12, 12);
|
||||
this.openFileBtn.Name = "openFileBtn";
|
||||
this.openFileBtn.Size = new System.Drawing.Size(94, 29);
|
||||
this.openFileBtn.TabIndex = 0;
|
||||
this.openFileBtn.Text = "Open file";
|
||||
this.openFileBtn.UseVisualStyleBackColor = true;
|
||||
this.openFileBtn.Click += new System.EventHandler(this.openFileBtn_Click);
|
||||
//
|
||||
// closeFileBtn
|
||||
//
|
||||
this.closeFileBtn.Enabled = false;
|
||||
this.closeFileBtn.Location = new System.Drawing.Point(220, 12);
|
||||
this.closeFileBtn.Name = "closeFileBtn";
|
||||
this.closeFileBtn.Size = new System.Drawing.Size(94, 29);
|
||||
this.closeFileBtn.TabIndex = 1;
|
||||
this.closeFileBtn.Text = "Close file";
|
||||
this.closeFileBtn.UseVisualStyleBackColor = true;
|
||||
this.closeFileBtn.Click += new System.EventHandler(this.closeFileBtn_Click);
|
||||
//
|
||||
// openTextEditorBtn
|
||||
//
|
||||
this.openTextEditorBtn.Enabled = false;
|
||||
this.openTextEditorBtn.Location = new System.Drawing.Point(12, 60);
|
||||
this.openTextEditorBtn.Name = "openTextEditorBtn";
|
||||
this.openTextEditorBtn.Size = new System.Drawing.Size(94, 29);
|
||||
this.openTextEditorBtn.TabIndex = 2;
|
||||
this.openTextEditorBtn.Text = "Text edit";
|
||||
this.openTextEditorBtn.UseVisualStyleBackColor = true;
|
||||
this.openTextEditorBtn.Click += new System.EventHandler(this.openTextEditorBtn_Click);
|
||||
//
|
||||
// openBcsvEditorBtn
|
||||
//
|
||||
this.openBcsvEditorBtn.Enabled = false;
|
||||
this.openBcsvEditorBtn.Location = new System.Drawing.Point(220, 60);
|
||||
this.openBcsvEditorBtn.Name = "openBcsvEditorBtn";
|
||||
this.openBcsvEditorBtn.Size = new System.Drawing.Size(94, 29);
|
||||
this.openBcsvEditorBtn.TabIndex = 3;
|
||||
this.openBcsvEditorBtn.Text = "Entries editor";
|
||||
this.openBcsvEditorBtn.UseVisualStyleBackColor = true;
|
||||
this.openBcsvEditorBtn.Click += new System.EventHandler(this.openBcsvEditorBtn_Click);
|
||||
//
|
||||
// openARCFileDialog
|
||||
//
|
||||
this.openARCFileDialog.FileName = "Message.arc";
|
||||
this.openARCFileDialog.Filter = "Nintendo archive files|*.arc";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(112, 26);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(102, 50);
|
||||
this.button1.TabIndex = 4;
|
||||
this.button1.Text = "button1";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.ClientSize = new System.Drawing.Size(326, 101);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.openBcsvEditorBtn);
|
||||
this.Controls.Add(this.openTextEditorBtn);
|
||||
this.Controls.Add(this.closeFileBtn);
|
||||
this.Controls.Add(this.openFileBtn);
|
||||
this.Name = "MainForm";
|
||||
this.Text = "MainForm";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button openFileBtn;
|
||||
private Button closeFileBtn;
|
||||
private Button openTextEditorBtn;
|
||||
private Button openBcsvEditorBtn;
|
||||
private OpenFileDialog openARCFileDialog;
|
||||
private Button button1;
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,72 @@ namespace BMGEditor
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
RarcFilesystem arc;
|
||||
bool arcOpen = false;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void openBcsvEditorBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Form bcsvEdit = new BcsvEditorForm(arc);
|
||||
bcsvEdit.Show();
|
||||
}
|
||||
|
||||
private void openFileBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (arcOpen) {
|
||||
MessageBox.Show("Please close the current file first.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string fileName;
|
||||
if (openARCFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = openARCFileDialog.FileName;
|
||||
arc = new RarcFilesystem(new ExternalFile(fileName, false));
|
||||
if (arc.FileExists($"{arc.rootName}/message.bmg") && arc.FileExists($"{arc.rootName}/messageid.tbl"))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Selected archive doesn\'t contain all the required files. Please check your file.",
|
||||
"Error while loading file",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
openBcsvEditorBtn.Enabled = true;
|
||||
openTextEditorBtn.Enabled = true;
|
||||
closeFileBtn.Enabled = true;
|
||||
arcOpen = true;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
private void closeFileBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
arc.Close();
|
||||
arcOpen = false;
|
||||
openBcsvEditorBtn.Enabled = false;
|
||||
openTextEditorBtn.Enabled = false;
|
||||
closeFileBtn.Enabled = false;
|
||||
}
|
||||
|
||||
private void openTextEditorBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Form bmgEdit = new BMGEditForm(arc);
|
||||
bmgEdit.Show();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("BMG Editor by Bussun", "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +1,4 @@
|
||||
<?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.
|
||||
-->
|
||||
<root>
|
||||
<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">
|
||||
@@ -117,4 +57,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="openARCFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -14,6 +14,7 @@ namespace BMGEditor
|
||||
static void Main()
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
Bcsv.PopulateHashtable();
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BMGEditor
|
||||
m_File.Stream.Position = m_StringTableOffset + rnoffset;
|
||||
root.Name = m_File.ReadString();
|
||||
root.FullName = "/" + root.Name;
|
||||
|
||||
rootName = root.FullName;
|
||||
m_DirEntries.Add(0, root);
|
||||
|
||||
for (uint i = 0; i < m_NumDirNodes; i++)
|
||||
@@ -237,6 +237,7 @@ namespace BMGEditor
|
||||
private uint m_DirNodesOffset;
|
||||
private uint m_FileEntriesOffset;
|
||||
private uint m_StringTableOffset;
|
||||
public string rootName;
|
||||
|
||||
private Dictionary<uint, FileEntry> m_FileEntries;
|
||||
private Dictionary<uint, DirEntry> m_DirEntries;
|
||||
|
||||
Reference in New Issue
Block a user