示例#1
0
        private void LookupDAT()
        {
            // initial lookup to create the object
            var lookup = DATMerge.GetDAT(GameObj.CRC32);

            // psx
            if (GameObj.systemId == 9)
            {
                lookup = DATMerge.GetDATsBySN(9, GameObj.OtherFlags);
            }

            // saturn
            if (GameObj.systemId == 13)
            {
                lookup = DATMerge.GetDATsBySN(13, GameObj.OtherFlags);
            }


            if (lookup == null)
            {
                // no match found
            }
            else
            {
                tbDatData_Copyright.Text         = lookup.Copyright;
                tbDatData_Country.Text           = lookup.Country;
                tbDatData_Developer.Text         = lookup.Developer;
                tbDatData_DevelopmentStatus.Text = lookup.DevelopmentStatus;
                tbDatData_gameName.Text          = lookup.GameName;
                tbDatData_Language.Text          = lookup.Language;
                tbDatData_OtherFlags.Text        = lookup.OtherFlags;
                tbDatData_Publisher.Text         = lookup.Publisher;
                tbDatData_Year.Text = lookup.Year;

                // get other roms
                Roms = DAT_Rom.GetRoms(lookup.MD5);

                var staticItem = cmbRomChooser.Items[0];
                cmbRomChooser.Items.Clear();
                cmbRomChooser.Items.Add(staticItem);

                for (int i = 0; i < Roms.Count(); i++)
                {
                    ComboBoxItem cbi = new ComboBoxItem();
                    cbi.Content = Roms[i].romName;
                    cmbRomChooser.Items.Add(cbi);
                }
                cmbRomChooser.SelectedIndex = 0;
            }
        }
示例#2
0
        // constructor
        public GameScanner()
        {
            // load master dat
            DAT = DATMerge.GetDATs();

            //string filePath = AppDomain.CurrentDomain.BaseDirectory + @"Data\System\DATMaster.json";
            //DAT = JsonConvert.DeserializeObject<IEnumerable<DATMerge>>(File.ReadAllText(filePath));

            db = new MyDbContext();

            Games = (from g in db.Game
                     select g).ToList();

            Paths = (from p in db.Paths
                     where p.pathId == 1
                     select p).ToList().SingleOrDefault();

            Systems = GSystem.GetSystems();

            RomSystems  = new List <GSystem>();
            DiskSystems = new List <GSystem>();

            // populate RomSystems and DiskSystems
            foreach (GSystem gs in Systems)
            {
                // exlude non-path systems
                if (gs.systemId == 16 || gs.systemId == 17)
                {
                    continue;
                }

                // populate disksystems
                if (gs.systemId == 18 ||        // pcecd
                    gs.systemId == 8 ||         // pcfx
                    gs.systemId == 9 ||         // psx
                    gs.systemId == 13)          // Saturn
                {
                    DiskSystems.Add(gs);
                }
                else
                {
                    RomSystems.Add(gs);
                }
            }

            RomSystemsWithPaths  = new List <GSystem>();
            DiskSystemsWithPaths = new List <GSystem>();

            // populate RomSystemsWithPaths with only entries that only have Rom paths set (and are not non-path systems like snes_faust and pce_fast) and where ROM directories are valid
            foreach (var sys in RomSystems)
            {
                if (GetPath(sys.systemId) == null || GetPath(sys.systemId) == "" || !Directory.Exists(GetPath(sys.systemId)))
                {
                    continue;
                }
                RomSystemsWithPaths.Add(sys);
            }

            /*
             * for (int i = 1; RomSystems.Count >= i; i++)
             * {
             *  if (GetPath(i) == null || GetPath(i) == "")
             *      continue;
             *
             *  MessageBoxResult result2 = MessageBox.Show(RomSystems[i - 1].systemName);
             *  RomSystemsWithPaths.Add(RomSystems[i - 1]);
             * }
             */
            // populate DiskSystemsWithPaths with only entries that only have Disk paths set (and are not non-path systems like snes_faust and pce_fast)
            foreach (var sys in DiskSystems)
            {
                if (GetPath(sys.systemId) == null || GetPath(sys.systemId) == "")
                {
                    continue;
                }
                DiskSystemsWithPaths.Add(sys);
            }

            // per system lists
            GamesGB = (from g in Games
                       where g.systemId == 1
                       select g).ToList();

            GamesGBA = (from g in Games
                        where g.systemId == 2
                        select g).ToList();

            GamesLYNX = (from g in Games
                         where g.systemId == 3
                         select g).ToList();

            GamesMD = (from g in Games
                       where g.systemId == 4
                       select g).ToList();

            GamesGG = (from g in Games
                       where g.systemId == 5
                       select g).ToList();

            GamesNGP = (from g in Games
                        where g.systemId == 6
                        select g).ToList();

            GamesPCE = (from g in Games
                        where g.systemId == 7
                        select g).ToList();

            GamesPCFX = (from g in Games
                         where g.systemId == 8
                         select g).ToList();

            GamesPSX = (from g in Games
                        where g.systemId == 9
                        select g).ToList();

            GamesSMS = (from g in Games
                        where g.systemId == 10
                        select g).ToList();

            GamesNES = (from g in Games
                        where g.systemId == 11
                        select g).ToList();

            GamesSNES = (from g in Games
                         where g.systemId == 12
                         select g).ToList();

            GamesSS = (from g in Games
                       where g.systemId == 13
                       select g).ToList();

            GamesVB = (from g in Games
                       where g.systemId == 14
                       select g).ToList();

            GamesWSWAN = (from g in Games
                          where g.systemId == 15
                          select g).ToList();

            GamesPCECD = (from g in Games
                          where g.systemId == 18
                          select g).ToList();



            RomsToUpdate   = new List <Game>();
            RomsToAdd      = new List <Game>();
            DisksToUpdate  = new List <Game>();
            DisksToAdd     = new List <Game>();
            AddedStats     = 0;
            HiddenStats    = 0;
            UpdatedStats   = 0;
            UntouchedStats = 0;
        }
示例#3
0
        public void ProcessGame(string romName, string hash, string relPath, string fileName, string extension)
        {
            Game newGame = new Game();

            // check whether game already exists (by gameName and systemId)
            Game chkGame = (from g in Games
                            where g.systemId == systemId && g.gameName == romName //&& g.archiveGame == archiveGame
                            select g).FirstOrDefault();

            // filter DAT by systemId
            List <DATMerge> lookup = DATMerge.FilterByMedLaunchSystemId(DAT, systemId);

            // lookup game in master dat - order by DATProviderId (so NoIntro first)
            string nHash = hash.ToUpper().Trim().ToString();
            //List<DATMerge> look = lookup.Where(a => a.MD5.ToUpper().Trim() == nHash || a.CRC.ToUpper().Trim() == nHash || a.SHA1.ToUpper().Trim() == nHash).OrderBy(a => a.DatProviderId).ToList();
            List <DATMerge> look = lookup.Where(a =>
                                                (a.MD5 != null && a.MD5.ToUpper().Trim() == nHash) ||
                                                (a.CRC != null && a.CRC.ToUpper().Trim() == nHash) ||
                                                (a.SHA1 != null && a.SHA1.ToUpper().Trim() == nHash)).OrderBy(a => a.DatProviderId).ToList();

            int subSysId = GSystem.GetSubSystemId(systemId, extension);

            if (chkGame == null)
            {
                // does not already exist - create new game
                newGame.configId = 1;

                if (look != null && look.Count > 0)
                {
                    newGame.gameNameFromDAT = look.First().GameName;
                    //newGame.Publisher = look.First().Publisher;
                    //newGame.Year = look.First().Year;
                    newGame.romNameFromDAT    = look.First().RomName;
                    newGame.Copyright         = look.First().Copyright;
                    newGame.Country           = look.First().Country;
                    newGame.DevelopmentStatus = look.First().DevelopmentStatus;
                    newGame.Language          = look.First().Language;
                    newGame.OtherFlags        = look.First().OtherFlags;
                    //newGame.Publisher = look.First().Publisher;
                    //newGame.Year = look.First().Year;
                    //newGame.Developer = look.First().Developer;

                    if (look.First().Year != null && look.First().Year != "")
                    {
                        newGame.Year = look.First().Year;
                    }
                    if (look.First().Publisher != null && look.First().Publisher != "")
                    {
                        newGame.Publisher = look.First().Publisher;
                    }
                    if (look.First().Developer != null && look.First().Developer != "")
                    {
                        newGame.Developer = look.First().Developer;
                    }
                }

                newGame.gameName    = romName;
                newGame.gamePath    = relPath;
                newGame.hidden      = false;
                newGame.isDiskBased = false;
                newGame.isFavorite  = false;
                newGame.systemId    = systemId;
                newGame.CRC32       = hash;

                // check for subsystemid
                if (subSysId > 0)
                {
                    // sub system found
                    newGame.subSystemId = subSysId;
                }

                // add to finaGames list
                RomsToAdd.Add(newGame);
                // increment the added counter
                AddedStats++;
            }
            else
            {
                // matching game found - update it
                if (chkGame.gamePath == relPath && chkGame.hidden == false && (chkGame.CRC32 == hash || chkGame.CRC == hash || chkGame.SHA1 == hash) && chkGame.subSystemId == subSysId)
                {
                    //nothing to update - increment untouched counter
                    UntouchedStats++;
                }
                else
                {
                    newGame = chkGame;
                    // update path in case it has changed location
                    newGame.gamePath = relPath;
                    // mark as not hidden
                    newGame.hidden = false;

                    newGame.CRC32 = hash;
                    if (look != null && look.Count > 0)
                    {
                        newGame.gameNameFromDAT = look.First().GameName;
                        //newGame.Publisher = look.First().Publisher;
                        //newGame.Year = look.First().Year;
                        //newGame.Developer = look.First().Developer;
                        newGame.romNameFromDAT    = look.First().RomName;
                        newGame.Copyright         = look.First().Copyright;
                        newGame.Country           = look.First().Country;
                        newGame.DevelopmentStatus = look.First().DevelopmentStatus;
                        newGame.Language          = look.First().Language;
                        newGame.OtherFlags        = look.First().OtherFlags;

                        if (look.First().Year != null && look.First().Year != "")
                        {
                            newGame.Year = look.First().Year;
                        }
                        if (look.First().Publisher != null && look.First().Publisher != "")
                        {
                            newGame.Publisher = look.First().Publisher;
                        }
                        if (look.First().Developer != null && look.First().Developer != "")
                        {
                            newGame.Developer = look.First().Developer;
                        }
                    }

                    // check for subsystemid
                    if (subSysId > 0)
                    {
                        // sub system found
                        newGame.subSystemId = subSysId;
                    }

                    // add to finalGames list
                    RomsToUpdate.Add(newGame);
                    // increment updated counter
                    UpdatedStats++;
                }

                // remove game from presentGames list - remaining games in this list will be marked as hidden at the end
                presentGames.Remove(chkGame);
            }
        }