Can now open PCK files regardless of endianness.

The "PS4/Switch/Xbox One" checkbox now only handles which endianness format the pck is being saved in and what format to open the audio.pck files in.
This commit is contained in:
MattN-L
2025-03-01 17:55:54 -05:00
parent 17ebe6c015
commit 0106df06db

View File

@@ -291,23 +291,39 @@ namespace PckStudio
}
}
private PckFile ReadPck(string filePath, bool isLittleEndian)
{
var pckReader = new PckFileReader(isLittleEndian ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian);
return pckReader.FromFile(filePath);
}
private PckFile OpenPck(string filePath)
{
isTemplateFile = false;
saveLocation = filePath;
SaveToRecentFiles(filePath);
var reader = new PckFileReader(LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian);
try
PckFile pck;
try
{
PckFile pck = reader.FromFile(filePath);
pck = ReadPck(filePath, LittleEndianCheckBox.Checked);
return pck;
}
catch (OverflowException ex)
}
catch (OverflowException c)
{
MessageBox.Show(this, "Failed to open pck\n" +
try
{
// if failed, attempt again in the reverse. THEN throw an error if failed
pck = ReadPck(filePath, !LittleEndianCheckBox.Checked);
LittleEndianCheckBox.Checked = !LittleEndianCheckBox.Checked;
return pck;
}
catch (OverflowException ex)
{
MessageBox.Show(this, "Failed to open pck\n" +
$"Try {(LittleEndianCheckBox.Checked ? "unchecking" : "checking")} the 'Open/Save as Switch/Vita/PS4/Xbox One pck' check box in the upper right corner.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Debug.WriteLine(ex.Message);
Debug.WriteLine(ex.Message);
}
}
catch
{