public async Task <IEnumerable <MainMenu> > GetAllSystems(string frontendPath, string systemName, string dbName = "")
        {
            _hsSerializer = new
                            HyperspinSerializer(frontendPath, systemName, dbName);

            return(await _hsSerializer.DeserializeMenusAsync());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the games from all favorites text files found in system database folders.
        /// </summary>
        /// <returns></returns>
        public async Task <IEnumerable <Game> > GetGamesFromAllFavorites()
        {
            if (_hsSerializer == null)
            {
                _hsSerializer = new HyperspinSerializer(_hyperspinFrontEnd.Path, "Main Menu", "");
            }

            _hsSerializer.ChangeSystemAndDatabase("Main Menu");

            return(await _hsSerializer.CreateGamesListFromAllFavoriteTexts(_hyperspinFrontEnd.Path, Systems.Select(x => x.MainMenu)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a system and all of its needed directories and settings for hyperspin to work.
        /// </summary>
        /// <param name="systemName">Name of the system.</param>
        /// <param name="existingDb">if set to <c>true</c> [existing database].</param>
        /// <returns></returns>
        public async Task <bool> CreateSystem(string systemName, string existingDb = "", string mainmenuName = "")
        {
            if (!await _systemCreator.CreateSystem(systemName, existingDb))
            {
                return(false);
            }

            Systems.Add(new MenuItemViewModel(new MainMenu(systemName, 1)));

            _hsSerializer = new HyperspinSerializer(_hyperspinFrontEnd.Path, systemName, mainmenuName);
            await SaveCurrentSystemsListToXmlAsync(mainmenuName, false);

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Saves the current games list to XML asynchronous.
        /// </summary>
        /// <param name="systemName"></param>
        /// <param name="dbName">Name of the database.</param>
        /// <returns></returns>
        public async Task <bool> SaveCurrentGamesListToXmlAsync(string systemName, string dbName)
        {
            return(await Task.Run(async() =>
            {
                try
                {
                    _hsSerializer = new HyperspinSerializer(_hyperspinFrontEnd.Path, systemName, dbName);

                    var games = CurrentSystemsGames.Select(x => x.Game);
                    await _hsSerializer.SerializeAsync(games, false);
                    return true;
                }
                catch (System.Exception)
                {
                    return false;
                }
            }));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates the multi system.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public Task <bool> CreateMultiSystem(MultiSystemOptions options)
        {
            IMediaCopier mc = new MediaCopier(_hyperspinFrontEnd);

            _hsSerializer = new HyperspinSerializer(_hyperspinFrontEnd.Path, options.MultiSystemName, "");
            IMultiSystem ms    = new MultiSystem(_hsSerializer, _systemCreator, mc, options);
            var          games = MultiSystemGamesList.Select(x => x.Game);

            if (!Systems.Any(x => x.Name == options.MultiSystemName))
            {
                Systems.Add(new MenuItemViewModel(new MainMenu(options.MultiSystemName, 1)));
            }

            //Group the games because we can't have duplicate romnames in the database.
            var filteredGames = games.GroupBy(x => x.RomName).Select(grp => grp.First());

            return(ms.CreateMultiSystem(filteredGames
                                        , _hyperspinFrontEnd.Path, _settingsRepo.HypermintSettings.RlPath));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the favorites for system.
        /// </summary>
        /// <param name="systemName">Name of the system.</param>
        /// <returns></returns>
        public async Task GetFavoritesForSystem(string systemName)
        {
            try
            {
                if (CurrentSystemsGames.Count > 0)
                {
                    _hsSerializer = new HyperspinSerializer(_hyperspinFrontEnd.Path, systemName);

                    var faves = await _hsSerializer.DeserializeFavoritesAsync();

                    if (faves != null)
                    {
                        foreach (var favorite in faves)
                        {
                            CurrentSystemsGames.FirstOrDefault(x => x.RomName == favorite.RomName)
                            .Game.IsFavorite = true;
                        }
                    }
                }
            }
            catch (Exception ex) { }
        }
Exemplo n.º 7
0
 public async Task <bool> SaveFavorites(string system)
 {
     _hsSerializer = new HyperspinSerializer(_hyperspinFrontEnd.Path, system);
     return(await _hsSerializer.SerializeFavoritesAsync(CurrentSystemsGames.Select(x => x.Game)));
 }
Exemplo n.º 8
0
        public async Task <bool> SaveCurrentSystemsListToXmlAsync(string currentMainMenu, bool isMultiSystem)
        {
            _hsSerializer = new HyperspinSerializer(_hyperspinFrontEnd.Path, "Main Menu", currentMainMenu);

            return(await _hsSerializer.SerializeAsync(Systems.Select(x => x.MainMenu), isMultiSystem));
        }
        public async Task <IEnumerable <Game> > SearchXmlAsync(string frontendPath, string systemName, string xmlPath, string searchText)
        {
            _hsSerializer = new HyperspinSerializer(frontendPath, systemName);

            return(await _searchGameXml.Search(systemName, xmlPath, new string[] { searchText }));
        }