From e0a2226228dedf0af255992e5de6a49fe2b2418e Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Tue, 5 Apr 2016 20:37:36 -0700 Subject: [PATCH] Add cache detection to other sav detection methods --- PKX/f1-Main.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 410f2acc4..7d1758ae3 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -103,6 +103,7 @@ public Main() // Load the arguments pathSDF = Util.GetSDFLocation(); path3DS = Util.get3DSLocation(); + string pathCache = Util.GetCacheFolder(); if (args.Length > 1) { foreach (string arg in args.Skip(1).Where(a => a.Length > 4)) @@ -112,6 +113,12 @@ public Main() openQuick(Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup", "main")); else if (pathSDF != null) openQuick(Path.Combine(pathSDF, "main")); + else if (Directory.Exists(pathCache)) + { + string file = Directory.GetFiles(pathCache).OrderByDescending(f => new FileInfo(f).LastWriteTime).FirstOrDefault(); + if (file != null) + openQuick(file); + } else if (File.Exists(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main")))) openQuick(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main"))); @@ -204,9 +211,9 @@ private void mainMenuOpen(object sender, EventArgs e) // Detect main string cyberpath = Util.GetTempFolder(); - string cachepath = Util.GetCacheFolder(); pathSDF = Util.GetSDFLocation(); path3DS = Util.get3DSLocation(); + string pathCache = Util.GetCacheFolder(); if (path3DS != null && File.Exists(Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup", "main"))) ofd.InitialDirectory = Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup"); else if (pathSDF != null) @@ -215,8 +222,8 @@ private void mainMenuOpen(object sender, EventArgs e) ofd.InitialDirectory = Path.GetPathRoot(path3DS); else if (Directory.Exists(Path.Combine(cyberpath, "root"))) ofd.InitialDirectory = Path.Combine(cyberpath, "root"); - else if (Directory.Exists(cachepath)) - ofd.InitialDirectory = cachepath; + else if (Directory.Exists(pathCache)) + ofd.InitialDirectory = pathCache; else if (Directory.Exists(cyberpath)) ofd.InitialDirectory = cyberpath; else if (File.Exists(Path.Combine(ofd.InitialDirectory, "main"))) { } @@ -3358,13 +3365,17 @@ private void clickSaveFileName(object sender, EventArgs e) // Get latest SaveDataFiler save location pathSDF = Util.GetSDFLocation(); path3DS = Util.get3DSLocation(); + string pathCache = Util.GetCacheFolder(); string path = null; if (path3DS != null && Directory.Exists(Path.Combine(path3DS, "SaveDataBackup")) && ModifierKeys != Keys.Control) path = Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup", "main"); else if (pathSDF != null && ModifierKeys != Keys.Shift) // if we have a result path = Path.Combine(pathSDF, "main"); - else if (File.Exists(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main")))) // else if cgse exists + else if (Directory.Exists(pathCache)) + path = Directory.GetFiles(pathCache).OrderByDescending(f => new FileInfo(f).LastWriteTime).FirstOrDefault(); + else if (File.Exists(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main")))) + // else if cgse exists path = Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main")); if (path == null || !File.Exists(path)) return;