Exemple #1
0
        public ScraperGamePicker()
        {
            this.InitializeComponent();

            this.ShowCloseButton = false;
            btnSelect.IsEnabled  = false;

            // get the mainwindow
            mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();


            int GameId   = mw.InspGame.gameId;
            int systemId = mw.InspGame.systemId;

            // check for pcecd games
            if (systemId == 18)
            {
                systemId = 7;
            }


            string sysName = GSystem.GetSystemName(systemId);

            this.Title = "Fuzzy Search Results for " + sysName;
            this.Refresh();

            ScraperSearch gs = new ScraperSearch();
            // get a list of all games for this platform - higest match first
            //List<SearchOrdering> games = gs.ShowPlatformGames(systemId, row.Game);

            GamesLibraryModel row = new GamesLibraryModel();

            row.ID   = mw.InspGame.gameId;
            row.Game = mw.InspGame.gameName;

            List <SearchOrdering> games = gs.ShowPlatformGamesBySub(systemId, row);

            List <GameListItem> g = new List <GameListItem>();

            foreach (var gam in games)
            {
                if (gam.Matches == 0 || gam.Game.GDBTitle == "")
                {
                    continue;
                }
                GameListItem gli = new GameListItem();
                gli.GamesDBId = gam.Game.gid;
                gli.GameName  = gam.Game.GDBTitle;
                //gli.Matches = gam.Matches;
                int wordcount = row.Game.Split(' ').Length;
                gli.Percentage = Convert.ToInt32((Convert.ToDouble(gam.Matches) / Convert.ToDouble(wordcount)) * 100);
                gli.Platform   = gam.Game.GDBPlatformName;
                g.Add(gli);
            }
            // make sure list is ordered descending
            g.OrderByDescending(a => a.Matches);

            dgReturnedGames.ItemsSource = g;
        }
Exemple #2
0
        /// <summary>
        /// remove hidden systems from results set
        /// </summary>
        /// <param name="results"></param>
        /// <returns></returns>
        public static List <DataGridGamesView> RemoveHidden(List <DataGridGamesView> results)
        {
            bool[] visibilities = GlobalSettings.GetVisArray();

            // check whether there are actually any hidden systems
            bool systemsHidden = false;

            for (int i = 1; i <= visibilities.Length; i++)
            {
                if (i == 16 || i == 17)
                {
                    continue;
                }

                if (visibilities[i - 1] == false)
                {
                    systemsHidden = true;
                    break;
                }
            }

            if (systemsHidden == false)
            {
                // there are no hidden systems - just return the results as-is
                return(results);
            }
            else
            {
                // there are hidden systems - remove them from results
                for (int i = 1; i <= visibilities.Length; i++)
                {
                    if (i == 16 || i == 17) // skip fast and faust
                    {
                        continue;
                    }

                    if (visibilities[i - 1] == false)
                    {
                        results = (from a in results
                                   where a.System != GSystem.GetSystemName(i)
                                   select a).ToList();
                    }
                }

                return(results);
            }
        }
Exemple #3
0
        // remove all disk-based games from db for a certain system
        public static void RemoveDisks(int sysId)
        {
            MessageBoxResult result = MessageBox.Show("This operation will wipe out ALL the " + GSystem.GetSystemName(sysId) + " games in your library database (but they will not be deleted from disk)\n\nAre you sure you wish to continue?", "WARNING", MessageBoxButton.OKCancel, MessageBoxImage.Warning);

            if (result == MessageBoxResult.OK)
            {
                // get all disks for specific system
                using (var context = new MyDbContext())
                {
                    List <Game> disks = (from a in context.Game
                                         where a.systemId == sysId
                                         select a).ToList();
                    Game.DeleteGames(disks);
                    GameListBuilder.UpdateFlag();
                }
            }
        }
Exemple #4
0
        public static GamesLibraryModel CreateModelFromGame(Game game)//, List<LibraryDataGDBLink> links)
        {
            /*
             * if (links == null)
             *  links = LibraryDataGDBLink.GetLibraryData().ToList();
             */

            GamesLibraryModel d = new GamesLibraryModel();

            d.ID = game.gameId;

            // check for subsystem
            if (game.subSystemId != null && game.subSystemId > 0)
            {
                string subName = GSystem.GetSubSystemName(game.subSystemId.Value);
                d.System = subName;
            }
            else
            {
                d.System = GSystem.GetSystemName(game.systemId);
            }



            d.LastPlayed = DbEF.FormatDate(game.gameLastPlayed);
            d.Favorite   = game.isFavorite;

            d.Country = game.Country;

            if (game.romNameFromDAT != null)
            {
                /*
                 * if (game.romNameFromDAT.Contains("(USA)"))
                 *  d.Country = "USA";
                 * if (game.romNameFromDAT.Contains("(Europe)"))
                 *  d.Country = "EUR";
                 * if (game.romNameFromDAT.Contains("(Japan)"))
                 *  d.Country = "JPN";
                 */
            }

            d.Flags     = game.OtherFlags;
            d.Language  = game.Language;
            d.Publisher = game.Publisher;
            d.Developer = game.Developer;
            d.Year      = game.Year;
            d.Coop      = game.Coop;
            d.ESRB      = game.ESRB;
            d.Players   = game.Players;
            d.Year      = game.Year;

            if (game.ManualEditSet == true)
            {
                if (game.gameNameEdited != null && game.gameNameEdited != "")
                {
                    d.Game = game.gameNameEdited;
                }
            }
            else
            {
                if (game.gameNameFromDAT != null && game.gameNameFromDAT != "")
                {
                    d.Game = game.gameNameFromDAT;
                }
                else
                {
                    d.Game = game.gameName;
                }
            }

            //d.Game = game.gameName;

            /*
             * if (game.gameNameFromDAT != null && game.gameNameFromDAT != "")
             *  d.Game = game.gameNameFromDAT;
             * else
             *  d.Game = game.gameName;
             */

            //d.DatName = game.gameNameFromDAT;
            d.DatRom = game.romNameFromDAT;

            /*
             * if (game.gdbId != null && game.gdbId > 0)
             * {
             *  var link = links.Where(x => x.GDBId == game.gdbId).SingleOrDefault(); // LibraryDataGDBLink.GetLibraryData(game.gdbId.Value);
             *  if (link != null)
             *  {
             *      if (link.Publisher != null && link.Publisher != "")
             *          d.Publisher = link.Publisher;
             *
             *      d.Developer = link.Developer;
             *
             *      if (link.Year != null && link.Year != "")
             *          d.Year = DbEF.ReturnYear(link.Year);
             *      d.Players = link.Players;
             *      d.Coop = link.Coop;
             *      d.ESRB = link.ESRB;
             *  }
             * }
             */
            //d.Year = "2914";

            // last minute region detection
            if ((d.Country == null || d.Country.Trim() == "") && d.Game != null)
            {
                if (d.Game.Contains("(Japan)"))
                {
                    d.Country = "Japan";
                }
                if (d.Game.Contains("(Europe)"))
                {
                    d.Country = "Europe";
                }
                if (d.Game.Contains("(USA)"))
                {
                    d.Country = "USA";
                }
                if (d.Game.Contains("(Usa, Europe)"))
                {
                    d.Country = "USA, Europe";
                }

                // goodtools
                if (d.Game.Contains("(W)"))
                {
                    d.Country = "World";
                }
                if (d.Game.Contains("(U)"))
                {
                    d.Country = "USA";
                }
                if (d.Game.Contains("(As)"))
                {
                    d.Country = "Asia";
                }
                if (d.Game.Contains("(E)"))
                {
                    d.Country = "Europe";
                }
            }

            return(d);
        }
        public static List <DataGridGamesView> Update(List <DataGridGamesView> AllGames)
        {
            using (var cnt = new MyDbContext())
            {
                List <LibraryDataGDBLink> links = LibraryDataGDBLink.GetLibraryData().ToList();
                List <DataGridGamesView>  q     = new List <DataGridGamesView>();
                var games = (from g in cnt.Game
                             where g.hidden != true
                             select g).ToList();
                foreach (var game in games)
                {
                    DataGridGamesView d = new DataGridGamesView();
                    d.ID = game.gameId;

                    d.System     = GSystem.GetSystemName(game.systemId);
                    d.LastPlayed = DbEF.FormatDate(game.gameLastPlayed);
                    d.Favorite   = game.isFavorite;

                    d.Country = game.Country;

                    if (game.romNameFromDAT != null)
                    {
                        if (game.romNameFromDAT.Contains("(USA)"))
                        {
                            d.Country = "US";
                        }
                        if (game.romNameFromDAT.Contains("(Europe)"))
                        {
                            d.Country = "EU";
                        }
                    }


                    d.Flags     = game.OtherFlags;
                    d.Language  = game.Language;
                    d.Publisher = game.Publisher;
                    d.Year      = game.Year;

                    if (game.gameNameFromDAT != null && game.gameNameFromDAT != "")
                    {
                        d.Game = game.gameNameFromDAT;
                    }
                    else
                    {
                        d.Game = game.gameName;
                    }

                    //d.DatName = game.gameNameFromDAT;
                    d.DatRom = game.romNameFromDAT;

                    if (game.gdbId != null && game.gdbId > 0)
                    {
                        var link = links.Where(x => x.GDBId == game.gdbId).SingleOrDefault(); // LibraryDataGDBLink.GetLibraryData(game.gdbId.Value);
                        if (link != null)
                        {
                            if (link.Publisher != null && link.Publisher != "")
                            {
                                d.Publisher = link.Publisher;
                            }

                            d.Developer = link.Developer;

                            if (link.Year != null && link.Year != "")
                            {
                                d.Year = DbEF.ReturnYear(link.Year);
                            }
                            d.Players = link.Players;
                            d.Coop    = link.Coop;
                            d.ESRB    = link.ESRB;
                        }
                    }

                    q.Add(d);
                }


                return(q);

                //AllGames = ng;
            }
        }