Escape sequences are now a problem of the past

This commit is contained in:
2021-11-29 20:41:24 +01:00
parent 151fc22069
commit b58a289561
3 changed files with 22 additions and 51 deletions

View File

@@ -1234,12 +1234,7 @@ namespace BMGEditor
{ {
public byte length; public byte length;
public byte unk1; public byte unk1;
public UInt16 binValue1; public List<Byte> binValue = new List<Byte>();
public UInt16 binValue2;
public UInt16 binValue3;
public UInt16 binValue4;
public UInt16 binValue5;
public List<Byte> bigBinValue;
} }
public List<Byte> BytesFromEscapeSequence(EscapeSequence escSeq) public List<Byte> BytesFromEscapeSequence(EscapeSequence escSeq)
@@ -1250,35 +1245,9 @@ namespace BMGEditor
ret.Add(escSeq.length); ret.Add(escSeq.length);
ret.Add(escSeq.unk1); ret.Add(escSeq.unk1);
switch (escSeq.length) foreach (Byte b in escSeq.binValue)
{ {
case 0x06: ret.Add(b);
byte[] binVal1case6 = BitConverter.GetBytes(escSeq.binValue1);
foreach (byte by in binVal1case6) ret.Add(by);
break;
case 0x08:
byte[] binVal1case8 = BitConverter.GetBytes(escSeq.binValue1);
foreach (byte by in binVal1case8) ret.Add(by);
byte[] binVal2case8 = BitConverter.GetBytes(escSeq.binValue2);
foreach (byte by in binVal2case8) ret.Add(by);
break;
case 0x0E:
byte[] binVal1caseE = BitConverter.GetBytes(escSeq.binValue1);
foreach (byte by in binVal1caseE) ret.Add(by);
byte[] binVal2caseE = BitConverter.GetBytes(escSeq.binValue2);
foreach (byte by in binVal2caseE) ret.Add(by);
byte[] binVal3caseE = BitConverter.GetBytes(escSeq.binValue3);
foreach (byte by in binVal3caseE) ret.Add(by);
byte[] binVal4caseE = BitConverter.GetBytes(escSeq.binValue4);
foreach (byte by in binVal4caseE) ret.Add(by);
byte[] binVal5caseE = BitConverter.GetBytes(escSeq.binValue5);
foreach (byte by in binVal5caseE) ret.Add(by);
break;
case 0x36: //TODO: Implement this
break;
} }
return ret; return ret;
} }
@@ -1331,7 +1300,7 @@ namespace BMGEditor
} }
public void NukeFile() //It's almost ready to be copied to WriteToFile() since it doesn't destroy the file anymore! public void NukeFile() //Makin' it to WriteToFile() soon !!
{ {
//File header //File header
m_File.Stream.Position = 0; m_File.Stream.Position = 0;
@@ -1388,7 +1357,23 @@ namespace BMGEditor
{ {
if (strToWrite[i].Equals('*')) if (strToWrite[i].Equals('*'))
{ {
//TODO: Rewrite escape sequence parser EscapeSequence escSeq = new EscapeSequence();
escSeq.length = Byte.Parse(String.Concat(strToWrite[i + 1], strToWrite[i + 2]), NumberStyles.HexNumber);
escSeq.unk1 = Byte.Parse(String.Concat(strToWrite[i + 3], strToWrite[i + 4]), NumberStyles.HexNumber);
i += 0x05;
for (int j = 0; j < escSeq.length * 2 - 8; j += 2)
{
escSeq.binValue.Add(Byte.Parse(String.Concat(strToWrite[i + j], strToWrite[i+j+1]), NumberStyles.HexNumber));
}
List<Byte> seqToWrite = BytesFromEscapeSequence(escSeq);
foreach (Byte b in seqToWrite)
{
m_File.Writer.Write(b);
}
i += escSeq.length * 2 - 8;
} }
else else
m_File.Writer.Write(strToWrite[i]); m_File.Writer.Write(strToWrite[i]);

View File

@@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace BMGEditor namespace BMGEditor
@@ -99,15 +94,6 @@ namespace BMGEditor
private void sortBtn_Click(object sender, EventArgs e) private void sortBtn_Click(object sender, EventArgs e)
{ {
//foreach (DataGridViewCell cell in dgvBcsv.Columns[0]) { }
/*for (int i = 0; i < dgvBcsv.RowCount; i++)
{
DataGridViewCell curCell = dgvBcsv.Rows[i].Cells[0];
DataGridViewCell nextCell = dgvBcsv.Rows[i+1].Cells[0];
}*/
dgvBcsv.Sort(new RowCompare(SortOrder.Ascending)); dgvBcsv.Sort(new RowCompare(SortOrder.Ascending));
} }

View File

@@ -55,7 +55,7 @@ namespace BMGEditor
return; return;
} }
openBcsvEditorBtn.Enabled = true; //openBcsvEditorBtn.Enabled = true;
openTextEditorBtn.Enabled = true; openTextEditorBtn.Enabled = true;
closeFileBtn.Enabled = true; closeFileBtn.Enabled = true;
arcOpen = true; arcOpen = true;