/// <summary> /// Merge the temporary game set with the main game set. /// Add new games to the main set and remove missing games from the main set. /// </summary> /// <param name="tempGameSet">Instance of CTempGameSet containing new games</param> public static void MergeGameSets(CTempGameSet tempGameSet) { m_gameDictionary.Clear(); m_favourites.Clear(); // Find games that are missing from tempGameSet and remove them from m_allGames // Find games that are missing from m_allGames and add them to m_allGames HashSet <CGame> newGames = new HashSet <CGame>(tempGameSet); newGames.ExceptWith(m_allGames); HashSet <CGame> gamesToRemove = new HashSet <CGame>(m_allGames); gamesToRemove.ExceptWith(tempGameSet); foreach (CGame game in gamesToRemove) { m_allGames.Remove(game); } foreach (CGame game in newGames) { m_allGames.Add(game); } foreach (CGame game in m_allGames) { AddGame(game); } }
private static void FindCustomLinkFiles(ref CTempGameSet tempGameSet) { List <string> fileList = Directory.EnumerateFiles(Path.Combine(CDock.currentPath, CUSTOM_GAME_FOLDER), "*", SearchOption.TopDirectoryOnly).Where(s => s.EndsWith(".lnk")).ToList(); string strPlatform = GetPlatformString(ENUM); foreach (string file in fileList) { string strPathOnly = Path.GetDirectoryName(file); strPathOnly = Path.GetFullPath(strPathOnly); string strFilenameOnly = Path.GetFileName(file); Shell32.Shell shell = new(); Shell32.Folder folder = shell.NameSpace(strPathOnly); Shell32.FolderItem folderItem = folder.ParseName(strFilenameOnly); if (folderItem != null) { Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)folderItem.GetLink; string strID = Path.GetFileNameWithoutExtension(file); string strTitle = strID; CLogger.LogDebug($"- {strTitle}"); string strLaunch = link.Path; string strUninstall = ""; // N/A string strAlias = GetAlias(strTitle); if (strAlias.Equals(strTitle, CDock.IGNORE_CASE)) { strAlias = ""; } tempGameSet.InsertGame(strID, strTitle, strLaunch, strLaunch, strUninstall, true, false, true, false, strAlias, strPlatform, new List <string>(), DateTime.MinValue, 0, 0, 0f); } } }
public void GetGames(ref CTempGameSet tempGameSet) { if (OperatingSystem.IsWindows()) { FindCustomLinkFiles(ref tempGameSet); } FindCustomBinaries(ref tempGameSet); }
/// <summary> /// Search the "CustomGames" folder for binaries (.exe) files to import /// </summary> private static void FindCustomBinaries(ref CTempGameSet tempGameSet) { string strPlatform = GetPlatformString(ENUM); List <string> fileList = Directory.EnumerateFiles(Path.Combine(CDock.currentPath, CUSTOM_GAME_FOLDER), "*", SearchOption.AllDirectories).Where(s => s.EndsWith(".exe")).ToList(); // Big Fish Games may use .bfg for executables //fileList.AddRange(Directory.EnumerateFiles(Path.Combine(CDock.currentPath, CUSTOM_GAME_FOLDER), "*", SearchOption.AllDirectories).Where(s => s.EndsWith(".bfg")).ToList()); foreach (string file in fileList) { string strID = Path.GetFileNameWithoutExtension(file); string strTitle = strID; CLogger.LogDebug($"- {strTitle}"); string strLaunch = Path.GetFullPath(file); string strUninstall = ""; // N/A string strAlias = GetAlias(strTitle); if (strAlias.Equals(strTitle, CDock.IGNORE_CASE)) { strAlias = ""; } tempGameSet.InsertGame(strID, strTitle, strLaunch, strLaunch, strUninstall, true, false, true, false, strAlias, strPlatform, new List <string>(), DateTime.MinValue, 0, 0, 0f); } }