public static string GetSaveFilePath(GameVersion version) { string installDir = LotdArchive.GetInstallDirectory(version); if (!string.IsNullOrEmpty(installDir)) { try { int steamAppId = 0; string appIdFile = Path.Combine(installDir, "steam_appid.txt"); if (File.Exists(appIdFile)) { string[] lines = File.ReadAllLines(appIdFile); if (lines.Length > 0) { int.TryParse(lines[0], out steamAppId); } } if (steamAppId > 0) { string userdataDir = Path.Combine(installDir, "../../../userdata/"); if (Directory.Exists(userdataDir)) { string[] dirs = Directory.GetDirectories(userdataDir); for (int i = 0; i < dirs.Length; i++) { string dirName = new DirectoryInfo(dirs[i]).Name; long userid; if (long.TryParse(dirName, out userid)) { string saveDataDir = Path.Combine(dirs[i], string.Empty + steamAppId, "remote"); if (Directory.Exists(saveDataDir)) { string saveDataFile = Path.Combine(saveDataDir, "savegame.dat"); if (File.Exists(saveDataFile)) { return(Path.GetFullPath(saveDataFile)); } } break; } } } } } catch { } } return(null); }
static void Main() { //TestModifyCardNamedBin(GameVersion.LinkEvolution2); //UnlockDLC(GameVersion.LinkEvolution2); //Dump(GameVersion.LinkEvolution2); if (System.Diagnostics.Debugger.IsAttached) { NativeScriptCompiler.CompileIfChanged(); } Dictionary <GameVersion, string> installedVersions = new Dictionary <GameVersion, string>(); foreach (GameVersion version in Enum.GetValues(typeof(GameVersion))) { if (version == GameVersion.LinkEvolution1) { continue; } string dir = LotdArchive.GetInstallDirectory(version); if (!string.IsNullOrEmpty(dir) && Directory.Exists(dir)) { installedVersions[version] = dir; } } if (installedVersions.Count == 0) { MessageBox.Show("Failed to find LOTD install directory. Make sure you have LOTD installed via Steam (and hopefully not pirated!)"); return; } else if (installedVersions.Count == 1) { Version = installedVersions.First().Key; } else { if (MessageBox.Show("Target LOTD original version from 2016?", "LOTD", MessageBoxButtons.YesNo) == DialogResult.Yes) { Version = GameVersion.Lotd; } else { Version = GameVersion.LinkEvolution2; } } Manager = new Manager(Version); Manager.Load(); YdkHelper.LoadIdMap(); //YdkHelper.GenerateIdMap(); MemTools = new MemTools(Version); MemTools.UseScreenStateTransitions = true; MemTools.CustomYdcBattlePacksEnabled = true; MemTools.RunProcessWatcher(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DuelStarterForm()); MemTools.StopProcessWatcher(); }