/// <summary> /// Tries adding a game to the collection with the provided executable path /// </summary> /// <param name="exePath"></param> /// <returns></returns> public UserGameInfo TryAddGame(string exePath) { string lower = exePath.ToLower(); string fileName = Path.GetFileName(exePath).ToLower(); string dir = Path.GetDirectoryName(exePath); var possibilities = Games.Values.Where(c => c.ExecutableName.ToLower() == fileName); foreach (GenericGameInfo game in possibilities) { // check if the Context matches string[] context = game.ExecutableContext; bool notAdd = false; if (context != null) { for (int j = 0; j < context.Length; j++) { string con = Path.Combine(dir, context[j]); if (!File.Exists(con) && !Directory.Exists(con)) { notAdd = true; break; } } } if (notAdd) { continue; } // search for the same exe on the user profile if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower)) { continue; } #if RELEASE if (game.Debug) { continue; } #endif LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath); UserGameInfo uinfo = new UserGameInfo(); uinfo.InitializeDefault(game, exePath); GameManager.Instance.User.Games.Add(uinfo); GameManager.Instance.SaveUserProfile(); return(uinfo); } return(null); }
public UserGameInfo AddGame(GenericGameInfo game, string exePath) { UserGameInfo gInfo = new UserGameInfo(); gInfo.InitializeDefault(game, exePath); user.Games.Add(gInfo); SaveUserProfile(); return(gInfo); }
/// <summary> /// Tries adding a game to the collection with the provided IGameInfo /// </summary> /// <param name="exePath"></param> /// <returns></returns> public UserGameInfo TryAddGame(string exePath, GenericGameInfo game) { string lower = exePath.ToLower(); // search for the same exe on the user profile if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower)) { return(null); } LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath); UserGameInfo uinfo = new UserGameInfo(); uinfo.InitializeDefault(game, exePath); GameManager.Instance.User.Games.Add(uinfo); GameManager.Instance.SaveUserProfile(); return(uinfo); }
/// <summary> /// Tries adding a game to the collection with the provided IGameInfo /// </summary> /// <param name="exePath"></param> /// <returns></returns> public UserGameInfo TryAddGame(string exePath, GenericGameInfo game) { string lower = exePath.ToLower(); // search for the same exe on the user profile if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower)) { DialogResult dialogResult = MessageBox.Show("This game's executable is already in your library. Do you wish to add it anyway?\n\nExecutable Path: " + exePath, "Already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.No) { return(null); } } LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath); UserGameInfo uinfo = new UserGameInfo(); uinfo.InitializeDefault(game, exePath); GameManager.Instance.User.Games.Add(uinfo); GameManager.Instance.SaveUserProfile(); return(uinfo); }
public UserGameInfo AddGame(GameInfo game, string exePath) { UserGameInfo gInfo = new UserGameInfo(); gInfo.InitializeDefault(game, exePath); user.Games.Add(gInfo); SaveUserProfile(); return gInfo; }
public void ScanExes() { DriveInfo[] drives = DriveInfo.GetDrives(); Stopwatch stop = new Stopwatch(); for (int i = 0; i < drives.Length; i++) { DriveInfo d = drives[i]; if (d.DriveFormat != "NTFS") { continue; } LogManager.Log("> Searching drive {0} for game executables", d.Name); stop.Reset(); stop.Start(); Dictionary<ulong, FileNameAndParentFrn> mDict = new Dictionary<ulong, FileNameAndParentFrn>(); MFTReader mft = new MFTReader(); mft.Drive = d.RootDirectory.FullName; mft.EnumerateVolume(out mDict, new string[] { ".exe" }); foreach (KeyValuePair<UInt64, FileNameAndParentFrn> entry in mDict) { FileNameAndParentFrn file = (FileNameAndParentFrn)entry.Value; string name = file.Name; string lower = name.ToLower(); GameInfo game; if (gameManager.GameInfos.TryGetValue(lower, out game)) { string path = mft.GetFullPath(file); LogManager.Log("Found game: {0}, full path: {1}", game.GameName, path); UserGameInfo info = new UserGameInfo(); info.InitializeDefault(game, path); gameManager.User.Games.Add(info); } } stop.Stop(); LogManager.Log("> Took {0} seconds to search drive {1}", stop.Elapsed.TotalSeconds.ToString("0.00"), d.Name); } gameManager.SaveUserProfile(); gameManager.WaitSave(); }
/// <summary> /// Tries adding a game to the collection with the provided executable path /// </summary> /// <param name="exePath"></param> /// <returns></returns> public UserGameInfo TryAddGame(string exePath) { string lower = exePath.ToLower(); string fileName = Path.GetFileName(exePath).ToLower(); string dir = Path.GetDirectoryName(exePath); var possibilities = Games.Values.Where(c => c.ExecutableName == fileName); foreach (GameInfo game in possibilities) { // check if the Context matches string[] context = game.ExecutableContext.Split(';'); bool notAdd = false; for (int j = 0; j < context.Length; j++) { string con = Path.Combine(dir, context[j]); if (!File.Exists(con) && !Directory.Exists(con)) { notAdd = true; break; } } if (notAdd) { continue; } // search for the same exe on the user profile if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower)) { continue; } LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath); UserGameInfo uinfo = new UserGameInfo(); uinfo.InitializeDefault(game, exePath); GameManager.Instance.User.Games.Add(uinfo); GameManager.Instance.SaveUserProfile(); return uinfo; } return null; }