Example #1
0
        public static bool MatchImagesExact(string[] images, string romName, out string imageFoundPath)
        {
            imageFoundPath = string.Empty;
            bool found = false;

            foreach (var image in images)
            {
                string imageTrimmed = RomFunctions.TrimRomName(image);

                if (imageTrimmed == romName)
                {
                    found          = true;
                    imageFoundPath = image;
                    break;
                }
            }

            return(found);
        }
        public static string DiscoverGameId(Rom rom)
        {
            if (rom.Platform == null)
            {
                return(string.Empty);
            }

            if (string.IsNullOrEmpty(rom.Platform.Id))
            {
                return(string.Empty);
            }

            var file = Values.JsonFolder + "\\" + rom.Platform.Name + ".json";
            var json = string.Empty;

            if (File.Exists(file))
            {
                json = File.ReadAllText(file);
            }

            var games = APIFunctions.GetGamesListByPlatform(rom.Platform.Id, json, rom.Platform.Name);

            if (games == null)
            {
                return(string.Empty);
            }

            var romName = RomFunctions.TrimRomName(rom.Name);

            foreach (var game in games)
            {
                var gameName = RomFunctions.TrimRomName(game.DBName);

                if (gameName == romName)
                {
                    return(game.Id);
                }
            }

            return(string.Empty);
        }
Example #3
0
        public static bool MatchImages(string[] images, Dictionary <string, Classes.Region> imageRegion, string romName, out string imageFoundPath)
        {
            imageFoundPath = string.Empty;
            bool   found      = false;
            string romTrimmed = RomFunctions.TrimRomName(romName);
            var    romRegion  = RomFunctions.DetectRegion(romName);

            foreach (var image in images)
            {
                string imageTrimmed = RomFunctions.TrimRomName(image);

                if (imageTrimmed == romTrimmed && imageRegion[RomFunctions.GetFileName(image)] == romRegion)
                {
                    found          = true;
                    imageFoundPath = image;
                    break;
                }
            }

            if (!found)
            {
                foreach (var image in images)
                {
                    string imageTrimmed = RomFunctions.TrimRomName(image);

                    if (imageTrimmed == romTrimmed)
                    {
                        found          = true;
                        imageFoundPath = image;
                        break;
                    }
                }
            }

            return(found);
        }