public StarterProfile(string name) { var folder = GetAnyGameFolder(); Directory.CreateDirectory(folder); var fileName = Path.Combine(folder, name + ".profile"); using (var reader = new StreamReader(fileName)) { var version = reader.ReadLine(); if (version == "Version 1") { this.Locale = reader.ReadLine(); var line = reader.ReadLine(); this.Executable = GameUtils.UnifiedExe; this.VirtualAppDataFolder = reader.ReadLine(); this.InstalledGames = new List<string>(); while (!reader.EndOfStream) { InstalledGames.Add(reader.ReadLine()); } } else if (version == "Version 2") { this.Locale = reader.ReadLine(); this.Executable = reader.ReadLine(); this.VirtualAppDataFolder = reader.ReadLine(); this.InstalledGames = new List<string>(); while (!reader.EndOfStream) { InstalledGames.Add(reader.ReadLine()); } } else { throw new ArgumentException("Profile has illegal version"); } } this.Name = name; this.CreationTime = new FileInfo(fileName).CreationTime; }
static async Task ParseGuildMessage(SocketUserMessage msg) { // Is this a leisure command? var splits = msg.Content.Split(":"); var start = splits[0]; // If someone doesn't understand what <game> means in the help, they'll figure out the hard way if (start == "leisure" || start == "<game>") { await ParseLeisureCommand(msg, splits[0].Length + 1); } // Search through installed InstalledGames to find one with the prefix. If one is found, try and parse the command if (InstalledGames.TryGetValue(start, out var game)) { await ParseGameCommand(game, msg, splits[0].Length + 1); } }
public void Refresh() { gamesLibraryProviders.Clear(); InstalledGames.Clear(); // Update installed games foreach (var libraryProvider in libraryProviders) { try { var collectedGames = libraryProvider.CollectInstalledGames(); var tempList = new List <GameDescriptor>(); foreach (var gameDescriptor in collectedGames) { var appId = gameDescriptor.AppId; if (!gamesData.ContainsKey(appId)) { gamesData.Add(appId, new GameData { AppId = appId }); } if (!gamesLibraryProviders.TryAdd(gameDescriptor, libraryProvider)) { Logger.Warn("Game descriptor already present in gamesLibraryProviders dictionary", gameDescriptor); } if (tempList.Contains(gameDescriptor)) { Logger.Warn("Game descriptor already present in tempList list", gameDescriptor); } else { tempList.Add(gameDescriptor); } } tempList.Sort(); InstalledGames.AddRange(tempList); } catch (Exception e) { Logger.Error("Unhandled exception thrown during installed games collection", e); } } // Remove orphaned games data var tempGamesData = new Dictionary <string, GameData>(); foreach (var(appId, gameData) in gamesData) { if (InstalledGames.Exists(gameDescriptor => gameDescriptor.AppId == appId)) { tempGamesData.Add(appId, gameData); } } gamesData = tempGamesData; SaveGamesData(); RefreshDynamicLists(); }
private GameDescriptor GetGameDescriptorByAppId(string appId) => InstalledGames.Find(gameDescriptor => gameDescriptor.AppId == appId);