Adding new entries doesn't work as expected
This commit is contained in:
@@ -238,8 +238,23 @@ namespace BMGEditor
|
|||||||
TextEntry newEntry = new TextEntry();
|
TextEntry newEntry = new TextEntry();
|
||||||
newEntry.entryName = newEntryName;
|
newEntry.entryName = newEntryName;
|
||||||
newEntry.entryNo = INF1itemNumber;
|
newEntry.entryNo = INF1itemNumber;
|
||||||
|
newEntry.text = "";
|
||||||
|
newEntry.unk1 = 0x00; newEntry.cameraOpt = 0x00; newEntry.sndEffectOpt = 0x00;
|
||||||
|
newEntry.unk2 = 0x00; newEntry.messageTriggerOpt = 0x00; newEntry.messageLayoutOpt = 0x00;
|
||||||
|
newEntry.messageAreaOpt = 0xFF;
|
||||||
INF1itemNumber++;
|
INF1itemNumber++;
|
||||||
Entries.Add(newEntry);
|
Entries.Add(newEntry);
|
||||||
|
|
||||||
|
/* Entries.Sort((x, y) =>
|
||||||
|
{
|
||||||
|
string entryNameA = x.entryName, entryNameB = y.entryName;
|
||||||
|
return String.CompareOrdinal(entryNameA, entryNameB);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (int i = 0; i < INF1itemNumber; i++)
|
||||||
|
{
|
||||||
|
Entries[i].entryNo = i;
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
[Obsolete]
|
||||||
@@ -263,7 +278,7 @@ namespace BMGEditor
|
|||||||
//INF1 section
|
//INF1 section
|
||||||
Int64 INF1start = m_File.Stream.Position;
|
Int64 INF1start = m_File.Stream.Position;
|
||||||
m_File.Writer.Write((Int32)INF1magic);
|
m_File.Writer.Write((Int32)INF1magic);
|
||||||
m_File.Writer.Write((UInt32)(0x10 + (INF1itemNumber * INF1itemLength)));
|
m_File.Writer.Write((UInt32)(0x00)); //Section size
|
||||||
m_File.Writer.Write((UInt16)INF1itemNumber);
|
m_File.Writer.Write((UInt16)INF1itemNumber);
|
||||||
m_File.Writer.Write((UInt16)INF1itemLength);
|
m_File.Writer.Write((UInt16)INF1itemLength);
|
||||||
m_File.Writer.Write((UInt32)0x00);
|
m_File.Writer.Write((UInt32)0x00);
|
||||||
@@ -281,6 +296,10 @@ namespace BMGEditor
|
|||||||
}
|
}
|
||||||
while (m_File.Stream.Position % 16 != 0x00)
|
while (m_File.Stream.Position % 16 != 0x00)
|
||||||
m_File.Writer.Write((Byte)0x00);
|
m_File.Writer.Write((Byte)0x00);
|
||||||
|
Int64 INF1end = m_File.Stream.Position;
|
||||||
|
m_File.Stream.Position = INF1start + 0x04;
|
||||||
|
m_File.Writer.Write((UInt32)(INF1end - INF1start));
|
||||||
|
|
||||||
|
|
||||||
//DAT1
|
//DAT1
|
||||||
Int64 DAT1start = m_File.Stream.Position;
|
Int64 DAT1start = m_File.Stream.Position;
|
||||||
@@ -333,7 +352,7 @@ namespace BMGEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (m_File.Stream.Position % 16 != 0x00)
|
while (m_File.Stream.Position % 16 != 0x00)
|
||||||
m_File.Stream.Position += 0x01;
|
m_File.Writer.Write((Byte)0x00);
|
||||||
Int64 DAT1size = m_File.Stream.Position - DAT1start;
|
Int64 DAT1size = m_File.Stream.Position - DAT1start;
|
||||||
Int64 DAT1end = m_File.Stream.Position;
|
Int64 DAT1end = m_File.Stream.Position;
|
||||||
m_File.Stream.Position = DAT1start + 0x04;
|
m_File.Stream.Position = DAT1start + 0x04;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace BMGEditor
|
|||||||
entriesListBox.Items.Add(txtEntry.entryName);
|
entriesListBox.Items.Add(txtEntry.entryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
addEntryBtn.Enabled = false;
|
//addEntryBtn.Enabled = false;
|
||||||
deleteEntryBtn.Enabled = false;
|
deleteEntryBtn.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,8 +48,15 @@ namespace BMGEditor
|
|||||||
|
|
||||||
private void addEntryBtn_Click(object sender, EventArgs e)
|
private void addEntryBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Form newEntryForm = new NewEntryForm();
|
Form newEntryForm = new NewEntryForm(m_File);
|
||||||
newEntryForm.Show();
|
newEntryForm.Show();
|
||||||
|
|
||||||
|
entriesListBox.Items.Clear();
|
||||||
|
foreach (BMG.TextEntry txtEntry in m_File.Entries)
|
||||||
|
{
|
||||||
|
entriesListBox.Items.Add(txtEntry.entryName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteEntryBtn_Click(object sender, EventArgs e)
|
private void deleteEntryBtn_Click(object sender, EventArgs e)
|
||||||
|
|||||||
27
BMGEditor/UI/NewEntryForm.Designer.cs
generated
27
BMGEditor/UI/NewEntryForm.Designer.cs
generated
@@ -29,7 +29,7 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.createEntryBtn = new System.Windows.Forms.Button();
|
this.createEntryBtn = new System.Windows.Forms.Button();
|
||||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
this.newEntryNameTxtBox = new System.Windows.Forms.TextBox();
|
||||||
this.groupBox = new System.Windows.Forms.GroupBox();
|
this.groupBox = new System.Windows.Forms.GroupBox();
|
||||||
this.cancelBtn = new System.Windows.Forms.Button();
|
this.cancelBtn = new System.Windows.Forms.Button();
|
||||||
this.groupBox.SuspendLayout();
|
this.groupBox.SuspendLayout();
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
//
|
//
|
||||||
// createEntryBtn
|
// createEntryBtn
|
||||||
//
|
//
|
||||||
this.createEntryBtn.Location = new System.Drawing.Point(694, 409);
|
this.createEntryBtn.Location = new System.Drawing.Point(193, 56);
|
||||||
this.createEntryBtn.Name = "createEntryBtn";
|
this.createEntryBtn.Name = "createEntryBtn";
|
||||||
this.createEntryBtn.Size = new System.Drawing.Size(94, 29);
|
this.createEntryBtn.Size = new System.Drawing.Size(94, 29);
|
||||||
this.createEntryBtn.TabIndex = 0;
|
this.createEntryBtn.TabIndex = 0;
|
||||||
@@ -45,37 +45,38 @@
|
|||||||
this.createEntryBtn.UseVisualStyleBackColor = true;
|
this.createEntryBtn.UseVisualStyleBackColor = true;
|
||||||
this.createEntryBtn.Click += new System.EventHandler(this.createEntryBtn_Click);
|
this.createEntryBtn.Click += new System.EventHandler(this.createEntryBtn_Click);
|
||||||
//
|
//
|
||||||
// textBox1
|
// newEntryNameTxtBox
|
||||||
//
|
//
|
||||||
this.textBox1.Location = new System.Drawing.Point(34, 56);
|
this.newEntryNameTxtBox.Location = new System.Drawing.Point(6, 26);
|
||||||
this.textBox1.Name = "textBox1";
|
this.newEntryNameTxtBox.Name = "newEntryNameTxtBox";
|
||||||
this.textBox1.Size = new System.Drawing.Size(125, 27);
|
this.newEntryNameTxtBox.Size = new System.Drawing.Size(125, 27);
|
||||||
this.textBox1.TabIndex = 1;
|
this.newEntryNameTxtBox.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// groupBox
|
// groupBox
|
||||||
//
|
//
|
||||||
this.groupBox.Controls.Add(this.textBox1);
|
this.groupBox.Controls.Add(this.newEntryNameTxtBox);
|
||||||
this.groupBox.Location = new System.Drawing.Point(46, 38);
|
this.groupBox.Location = new System.Drawing.Point(12, 12);
|
||||||
this.groupBox.Name = "groupBox";
|
this.groupBox.Name = "groupBox";
|
||||||
this.groupBox.Size = new System.Drawing.Size(250, 125);
|
this.groupBox.Size = new System.Drawing.Size(168, 74);
|
||||||
this.groupBox.TabIndex = 2;
|
this.groupBox.TabIndex = 2;
|
||||||
this.groupBox.TabStop = false;
|
this.groupBox.TabStop = false;
|
||||||
this.groupBox.Text = "Entry name";
|
this.groupBox.Text = "Entry name";
|
||||||
//
|
//
|
||||||
// cancelBtn
|
// cancelBtn
|
||||||
//
|
//
|
||||||
this.cancelBtn.Location = new System.Drawing.Point(594, 409);
|
this.cancelBtn.Location = new System.Drawing.Point(193, 21);
|
||||||
this.cancelBtn.Name = "cancelBtn";
|
this.cancelBtn.Name = "cancelBtn";
|
||||||
this.cancelBtn.Size = new System.Drawing.Size(94, 29);
|
this.cancelBtn.Size = new System.Drawing.Size(94, 29);
|
||||||
this.cancelBtn.TabIndex = 3;
|
this.cancelBtn.TabIndex = 3;
|
||||||
this.cancelBtn.Text = "Cancel";
|
this.cancelBtn.Text = "Cancel";
|
||||||
this.cancelBtn.UseVisualStyleBackColor = true;
|
this.cancelBtn.UseVisualStyleBackColor = true;
|
||||||
|
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
|
||||||
//
|
//
|
||||||
// NewEntryForm
|
// NewEntryForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(299, 111);
|
||||||
this.Controls.Add(this.cancelBtn);
|
this.Controls.Add(this.cancelBtn);
|
||||||
this.Controls.Add(this.groupBox);
|
this.Controls.Add(this.groupBox);
|
||||||
this.Controls.Add(this.createEntryBtn);
|
this.Controls.Add(this.createEntryBtn);
|
||||||
@@ -90,7 +91,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.Button createEntryBtn;
|
private System.Windows.Forms.Button createEntryBtn;
|
||||||
private System.Windows.Forms.TextBox textBox1;
|
private System.Windows.Forms.TextBox newEntryNameTxtBox;
|
||||||
private System.Windows.Forms.GroupBox groupBox;
|
private System.Windows.Forms.GroupBox groupBox;
|
||||||
private System.Windows.Forms.Button cancelBtn;
|
private System.Windows.Forms.Button cancelBtn;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,28 @@ namespace BMGEditor.UI
|
|||||||
{
|
{
|
||||||
public partial class NewEntryForm : Form
|
public partial class NewEntryForm : Form
|
||||||
{
|
{
|
||||||
public NewEntryForm()
|
private BMG m_File;
|
||||||
|
public NewEntryForm(BMG file)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
Text = $"New Entry - {Variables.softwareName} {Variables.softwareVersion}";
|
||||||
|
if (Variables.isBeta) Text += " [BETA]";
|
||||||
|
m_File = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createEntryBtn_Click(object sender, EventArgs e)
|
private void createEntryBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (newEntryNameTxtBox.Text == "") { }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_File.AddNewEntry(newEntryNameTxtBox.Text);
|
||||||
|
this.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user