From aa801e5361dcf3e8ffb7b37a881a50a90b722cc6 Mon Sep 17 00:00:00 2001 From: MattNL Date: Wed, 8 Mar 2023 12:45:59 -0500 Subject: [PATCH] Made changes to OpenPCK OpenPCK now attempts to open pck files with the opposite endian when confronted with an OverflowException which makes it possible to open little endian pck files from outside the program --- PCK-Studio/MainForm.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index b3520e61..59146ad2 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -155,7 +155,7 @@ namespace PckStudio } } - private PCKFile openPck(string filePath) + private PCKFile openPck(string filePath, bool firstAttempt = true) { PCKFile pck = null; using (var fileStream = File.OpenRead(filePath)) @@ -169,13 +169,25 @@ namespace PckStudio } catch (OverflowException ex) { - MessageBox.Show("Failed to open pck\n" + - $"Try {(LittleEndianCheckBox.Checked ? "unchecking" : "checking")} the 'Open/Save as Vita/PS4 pck' check box in the upper right corner.", - "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - Debug.WriteLine(ex.Message); + if(firstAttempt) + { + LittleEndianCheckBox.Checked = !LittleEndianCheckBox.Checked; + pck = openPck(filePath, false); + } + else + { + LittleEndianCheckBox.Checked = false; + CloseEditorTab(); + MessageBox.Show("Failed to open pck\n" + + $"Try {(LittleEndianCheckBox.Checked ? "unchecking" : "checking")} the 'Open/Save as Vita/PS4 pck' check box in the upper right corner.", + "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + Debug.WriteLine(ex.Message); + } } catch (Exception ex) { + LittleEndianCheckBox.Checked = false; + CloseEditorTab(); MessageBox.Show("Failed to open pck\n" + "If this is an Audio/Music Cues pck, please use the specialized editor while inside of the parent pck.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);