Beispiel #1
0
        /// <summary>
        /// Sets the games to the given system.
        /// </summary>
        /// <param name="systemName">Name of the system.</param>
        /// <param name="dbName">Name of the database.</param>
        /// <returns></returns>
        public async Task <IEnumerable <Game> > SetGamesForSystem(string systemName, string dbName = "")
        {
            CurrentSystemsGames.Clear();

            var games = await _hsDataProvider.GetAllGames(_hyperspinFrontEnd.Path, systemName, dbName);

            //Map the original systems from a games.ini
            if (games != null && games.Count() > 0)
            {
                var dbPath = Path.Combine(_hyperspinFrontEnd.Path, "Databases", systemName);
                if (Directory.Exists(dbPath + "\\" + "MultiSystem"))
                {
                    var romMapper   = new RomMapperRl();
                    var mappedGames = await romMapper.GetGamesFromRocketLaunchGamesIniAsync(dbPath + "\\MultiSystem");

                    foreach (var game in mappedGames)
                    {
                        try
                        {
                            games.FirstOrDefault(x => x.RomName == game.RomName).OriginalSystem = game.System;
                        }
                        catch { }
                    }
                }
            }

            return(games);
        }
Beispiel #2
0
        /// <summary>
        /// Populates the main menu entries from a main menu xml
        /// </summary>
        /// <param name="dbName">Name of the database.</param>
        /// <returns></returns>
        public async Task PopulateMainMenuSystems(string dbName = "")
        {
            IEnumerable <MainMenu> _systems = null;

            Systems.Clear();
            if (CurrentSystemsGames.Count > 0)
            {
                CurrentSystemsGames.Clear();
            }

            await Task.Run(async() =>
            {
                if (string.IsNullOrEmpty(dbName))
                {
                    dbName = "Main Menu";
                }

                //Get systems from main menu xml
                _systems = await _hsDataProvider.GetAllSystems(_settingsRepo.HypermintSettings.HsPath, "Main Menu", dbName);
            });

            //Add to system list
            if (_systems?.Count() > 0)
            {
                foreach (var system in _systems)
                {
                    Systems.Add(new MenuItemViewModel(system));
                }

                await GetSystemIconsAsync();
            }
        }