Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
 internal void AddClone(PinMameGame game)
 {
     _clones.Add(game);
 }
Ejemplo n.º 5
0
 public void GetGameNotFound()
 {
     PinMameGame game = _pinMame.GetGame("unknown");
 }
Ejemplo n.º 6
0
        public void GetGame()
        {
            PinMameGame game = _pinMame.GetGame("tf_180h");

            Assert.IsTrue(game != null);
        }