/// <summary> /// Scan the registry for games, add new games to memory and export into JSON document /// </summary> public static void ScanGames() { CGameData.CTempGameSet tempGameSet = new CGameData.CTempGameSet(); List <CRegScanner.RegistryGameData> gameDataList = CRegScanner.GetGames(); foreach (CRegScanner.RegistryGameData data in gameDataList) { tempGameSet.InsertGame(data.m_strTitle, data.m_strLaunch, false, data.m_strPlatform); } CGameFinder.ImportFromFolder(ref tempGameSet); CGameData.MergeGameSets(tempGameSet); CJsonWrapper.Export(CGameData.GetPlatformGameList(CGameData.GamePlatform.All).ToList()); }
/// <summary> /// Import games from the game.json config file /// </summary> /// <returns>True if successful, otherwise false</returns> public static bool ImportFromJSON() { int nGameCount = 0; if (!DoesFileExist()) { CLogger.LogDebug("JSON file missing - create file and scan..."); Console.WriteLine("games.json missing. Creating new..."); CreateEmptyFile(); } else { ImportGames(ref nGameCount); } if (nGameCount < 1) { CLogger.LogDebug("JSON file is empty - scanning for games..."); Console.WriteLine("games.json is empty. Scanning for games..."); CRegScanner.ScanGames(); } return(true); }
/// <summary> /// Run the main program loop. /// Return when game is launched or the user decided to exit. /// </summary> public void MainLoop() { CJsonWrapper.ImportFromJSON(); CGameFinder.CheckCustomFolder(); int nSelectionCode, nSelectionIndex; for (; ;) { MenuSwitchboard(out nSelectionCode, out nSelectionIndex); switch ((DockSelection)nSelectionCode) { case DockSelection.cSel_Help: DisplayHelp(); continue; case DockSelection.cSel_Exit: // Exit application return; case DockSelection.cSel_Back: // Go back to first menu m_nFirstSelection = -1; continue; case DockSelection.cSel_Fav: // Toggle game favourite if (m_nFirstSelection > -1) { CGameData.ToggleFavourite((CGameData.GamePlatform)m_nFirstSelection, nSelectionIndex); CJsonWrapper.Export(CGameData.GetPlatformGameList(CGameData.GamePlatform.All).ToList()); } continue; case DockSelection.cSel_Rescan: // Rescan the game list if (m_nFirstSelection < 0) { Console.Clear(); Console.Write("Scanning for games..."); Logger.CLogger.LogInfo("Scanning for games..."); CRegScanner.ScanGames(); } continue; case DockSelection.cSel_Default: // Possible valid platform/game selection default: break; } if (nSelectionIndex > -1) { if (m_nFirstSelection < 0) { m_nFirstSelection = nSelectionIndex; } else if (m_nSecondSelection < 0) { m_nSecondSelection = nSelectionIndex; } } if (m_nSecondSelection > -1) { CGameData.CGame selectedGame = CGameData.GetPlatformGame((CGameData.GamePlatform)m_nFirstSelection, m_nSecondSelection); if (StartGame(selectedGame)) { return; } else { CGameData.RemoveGame(selectedGame); CJsonWrapper.Export(CGameData.GetPlatformGameList(CGameData.GamePlatform.All).ToList()); } } } }