private void openQuick(string path) { if (threadActive()) return; if (!Directory.Exists(path)) // File { FileInfo fi = new FileInfo(path); if (fi.Name.Contains("code.bin")) // Compress/Decompress .code.bin { if (fi.Length % 0x200 == 0 && (Util.Prompt(MessageBoxButtons.YesNo, "Detected Decompressed code.bin.", "Compress? File will be replaced.") == DialogResult.Yes)) new Thread(() => { threads++; new CTR.BLZCoder(new[] { "-en", path }, pBar1); threads--; Util.Alert("Compressed!"); }).Start(); else if (Util.Prompt(MessageBoxButtons.YesNo, "Detected Compressed code.bin.", "Decompress? File will be replaced.") == DialogResult.Yes) new Thread(() => { threads++; new CTR.BLZCoder(new[] { "-d", path }, pBar1); threads--; Util.Alert("Decompressed!"); }).Start(); } else if (fi.Name.ToLower().Contains("exe")) // Unpack exefs { if (fi.Length % 0x200 == 0 && (Util.Prompt(MessageBoxButtons.YesNo, "Detected ExeFS.bin.", "Unpack?") == DialogResult.Yes)) new Thread(() => { threads++; CTR.ExeFS.get(path, Path.GetDirectoryName(path)); threads--; Util.Alert("Unpacked!"); }).Start(); } else if (fi.Name.ToLower().Contains("rom")) { Util.Alert("RomFS unpacking not implemented."); } else { DialogResult dr = Util.Prompt(MessageBoxButtons.YesNo, "Unpack sub-files?", "Cancel: Abort"); if (dr == DialogResult.Cancel) return; bool recurse = dr == DialogResult.Yes; ToolsUI.openARC(path, pBar1, recurse); } } else // Directory { // Check for ROMFS/EXEFS/EXHEADER RomFSPath = ExeFSPath = null; // Reset Config = null; string[] folders = Directory.GetDirectories(path); int count = folders.Length; // Find RomFS folder foreach (string f in folders.Where(f => new DirectoryInfo(f).Name.ToLower().Contains("rom") && Directory.Exists(f))) checkIfRomFS(f); // Find ExeFS folder foreach (string f in folders.Where(f => new DirectoryInfo(f).Name.ToLower().Contains("exe") && Directory.Exists(f))) checkIfExeFS(f); if (count > 3) Util.Alert("pk3DS will function best if you keep your Game Files folder clean and free of unnecessary folders."); // Enable buttons if applicable Tab_RomFS.Enabled = Menu_Restore.Enabled = Tab_CRO.Enabled = Menu_CRO.Enabled = Menu_Shuffler.Enabled = RomFSPath != null; Tab_ExeFS.Enabled = RomFSPath != null && ExeFSPath != null; if (RomFSPath != null) { toggleSubEditors(); string newtext = $"Game Loaded: {Config.Version}"; if (L_Game.Text != newtext && Directory.Exists("personal")) { Directory.Delete("personal", true); } // Force reloading of personal data if the game is switched. L_Game.Text = newtext; TB_Path.Text = path; } else if (ExeFSPath != null) { L_Game.Text = "ExeFS loaded - no RomFS"; TB_Path.Text = path; } else { L_Game.Text = "No Game Loaded"; TB_Path.Text = ""; } if (RomFSPath != null) { // Trigger Data Loading if (RTB_Status.Text.Length > 0) RTB_Status.Clear(); updateStatus("Data found! Loading persistent data for subforms...", false); Config.Initialize(RomFSPath, ExeFSPath, Language); backupGARCs(false, Config.Files.Select(file => file.Name).ToArray()); backupCROs(false, RomFSPath); } // Enable Rebuilding options if all files have been found checkIfExHeader(path); Menu_ExeFS.Enabled = ExeFSPath != null; Menu_RomFS.Enabled = Menu_Restore.Enabled = Menu_GARCs.Enabled = RomFSPath != null; Menu_Patch.Enabled = RomFSPath != null && ExeFSPath != null; Menu_3DS.Enabled = ExHeaderPath != null && RomFSPath != null && ExeFSPath != null; // Change L_Game if RomFS and ExeFS exists to a better descriptor SMDH = ExeFSPath != null ? File.Exists(Path.Combine(ExeFSPath, "icon.bin")) ? new CTR.SMDH(Path.Combine(ExeFSPath, "icon.bin")) : null : null; HANSgameID = SMDH != null ? (SMDH.AppSettings?.StreetPassID ?? 0) : 0; L_Game.Visible = SMDH == null && RomFSPath != null; updateGameInfo(); TB_Path.Select(TB_Path.TextLength, 0); // Method finished. System.Media.SystemSounds.Asterisk.Play(); resetStatus(); Properties.Settings.Default.GamePath = path; Properties.Settings.Default.Save(); } }