/// <summary> /// Retrieves a game by game name. /// </summary> /// <exception cref="InvalidOperationException">If the configuration has not been set or the game name is not found.</exception> public PinMameGame GetGame(string name) { Logger.Info($"GetGame: name={name}"); PinMameGame game = null; var status = PinMameApi.PinmameGetGame(name, gamePtr => { game = new PinMameGame(gamePtr); }); if (status != PinMameApi.PinmameStatus.OK) { throw new InvalidOperationException($"Unable to get game, name={name}, status={status}"); } return(game); }
/// <summary> /// Retrieves all games found in roms folder. Clones array will not be populated. /// </summary> /// <exception cref="InvalidOperationException">If the configuration has not been set.</exception> public IEnumerable <PinMameGame> GetFoundGames() { var games = new List <PinMameGame>(); var status = PinMameApi.PinmameGetGames(gamePtr => { var game = new PinMameGame(gamePtr); if (game.RomFound) { games.Add(game); } }); if (status != PinMameApi.PinmameStatus.OK) { throw new InvalidOperationException($"Unable to get games, status={status}"); } return(games); }
/// <summary> /// Retrieves all supported games. /// </summary> /// <exception cref="InvalidOperationException">If the configuration has not been set.</exception> public IEnumerable <PinMameGame> GetGames() { var games = new Dictionary <string, PinMameGame>(); // game name -> game var clones = new List <(string, PinMameGame)>(); // parent game name -> game var status = PinMameApi.PinmameGetGames(gamePtr => { var game = new PinMameGame(gamePtr); if (string.IsNullOrEmpty(game.CloneOf)) { games[game.Name] = game; } else { clones.Add((game.CloneOf, game)); } }); if (status != PinMameApi.PinmameStatus.OK) { throw new InvalidOperationException($"Unable to get games, status={status}"); } foreach (var(cloneName, clone) in clones) { if (games.ContainsKey(cloneName)) { games[cloneName].AddClone(clone); } else { games[cloneName] = clone; } } return(games.Values); }
internal void AddClone(PinMameGame game) { _clones.Add(game); }
public void GetGameNotFound() { PinMameGame game = _pinMame.GetGame("unknown"); }
public void GetGame() { PinMameGame game = _pinMame.GetGame("tf_180h"); Assert.IsTrue(game != null); }