public override void Save(Stream fileStream) { // Header var header = new BINAv1Header(); var writer = new BINAWriter(fileStream, header); writer.WriteSignature(Signature); // Texture writer.AddString("textureName", Texture); // Placeholders writer.Write((uint)Entries.Count); writer.AddOffset("placeholderEntriesPos"); writer.FillInOffset("placeholderEntriesPos", false); for (int i = 0; i < Entries.Count; i++) { writer.AddString($"placeholderName{i}", Entries[i].Placeholder); writer.Write(Entries[i].X); writer.Write(Entries[i].Y); writer.Write(Entries[i].Width); writer.Write(Entries[i].Height); } writer.FinishWrite(header); }
public override void Save(Stream fileStream) { // Header var header = new BINAv1Header(); var writer = new BINAWriter(fileStream, header); uint filesCount = 0; for (int i = 0; i < Types.Count; i++) { for (int c = 0; c < Types[i].Files.Count; c++) { filesCount++; } } writer.Write(filesCount); writer.AddOffset("fileEntriesPos"); writer.Write(Types.Count); writer.AddOffset("typeEntriesPos"); writer.FillInOffset("typeEntriesPos", false); for (int i = 0; i < Types.Count; i++) { writer.AddString($"typeName{i}", Types[i].TypeName); writer.Write(Types[i].Files.Count); writer.AddOffset($"typeFilesOffset{i}"); } writer.FillInOffset("fileEntriesPos", false); int objectNum = 0; for (int i = 0; i < Types.Count; i++) { writer.FillInOffset($"typeFilesOffset{i}", false); for (int f = 0; f < Types[i].Files.Count; f++) { writer.AddString($"friendlyName{objectNum}", Types[i].Files[f].FriendlyName); writer.AddString($"filePath{objectNum}", Types[i].Files[f].FilePath); objectNum++; } } writer.FinishWrite(header); }
void Btn_Convert_Click(object sender, EventArgs e) { if (modes_SBKStudio.Checked == true) { /* UNFINISHED CODE - SBK USES BINA */ try { //Gets all checked boxes from the CheckedListBox and builds a string for each AT3. foreach (string selectedSBK in clb_Debug.CheckedItems) { var readSBK = new BINAv1Header(); } } catch (Exception ex) { MessageBox.Show($"An error occurred when decoding the selected SBKs.\n\n{ex}", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public override void Save(Stream fileStream) { // Header var header = new BINAv1Header(); var writer = new BINAWriter(fileStream, header); writer.Write((uint)Files.Count); writer.AddOffset("fileEntriesPos"); writer.Write((uint)Types.Count); writer.AddOffset("typeEntriesPos"); // Types writer.FillInOffset("typeEntriesPos", false); for (int i = 0; i < Types.Count; i++) { writer.AddString($"typeName{i}", Types[i].TypeName); writer.Write(Types[i].FileCount); writer.AddOffset($"typeFilesOffset{i}"); } // Files uint fileEntriesPos = (uint)writer.BaseStream.Position; writer.FillInOffset("fileEntriesPos", false); for (int i = 0; i < Files.Count; i++) { writer.AddString($"friendlyName{i}", Files[i].FriendlyName); writer.AddString($"filePath{i}", Files[i].FilePath); } // Fill-in type file offsets for (int i = 0; i < Types.Count; i++) { writer.FillInOffset($"typeFilesOffset{i}", (fileEntriesPos + (Types[i].FileStartIndex * 8U)), false, false); } writer.FinishWrite(header); }