private void mnuNewFile_Click(object sender, EventArgs e)
{
EditPakItem f = new EditPakItem(EditPakItemType.New);
if (f.ShowDialog(this) == DialogResult.OK)
{
if (f.PakItemFilename.Trim().Length == 0)
{
MessageBox.Show(this, "The pak item filename was not specified", "New File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (pakItemExists(f.PakItemFilename, null))
{
MessageBox.Show(this, string.Format("'{0}' already exists", f.PakItemFilename), "New File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
selectPakItem(f.PakItemFilename);
return;
}
//get the unknown value from another file
byte[] unknown = new byte[] { 0x1C, 0x08, 0x02, 0x04, 0x10, 0x04, 0x08, 0x0C, 0x0C, 0x08, 0x02, 0x04, 0x14, 0x02, 0x04, 0x0C, 0x10, 0x10, 0x0C, 0x00 };
QbFile qbf = null;
QbKey qbType = QbKey.Create(".qb");
foreach (PakHeaderItem phi in _pakFile.Headers.Values)
{
if (phi.FileType == qbType)
{
qbf = _pakFile.ReadQbFile(phi.Filename);
unknown = (byte[])((QbItemUnknown)qbf.Items[0]).UnknownData.Clone();
break;
}
}
//some hard coded values rather than ask the user for them... Always the same update if required
_pakFile.NewFile(f.PakItemFilename, f.ItemType, f.IncludeFileNameInHeader, 0, unknown);
reloadPak();
selectPakItem(f.PakItemFilename);
}
}