Пример #1
0
        public static bool AddRomsFromDirectory(Platform platform, string directory)
        {
            if (platform == null)
            {
                return(false);
            }

            List <Rom> romList  = new List <Rom>();
            var        files    = Directory.GetFiles(directory);
            var        exts     = platform.DefaultRomExtensions.Split(',').ToList();
            bool       addedAny = false;

            foreach (var file in files)
            {
                var fileExt = GetFileExtension(file);
                if (!exts.Contains(fileExt.Replace(".", "")))
                {
                    continue;
                }

                var rom = RomBusiness.Get(platform.Name, RomFunctions.GetFileName(file));

                if (rom == null)
                {
                    romList.Add(RomBusiness.NewRom(file, platform));
                    addedAny = true;
                }
            }

            RomBusiness.SetRom(romList);

            return(addedAny);
        }
Пример #2
0
        public static List <string> GetPics(string platform, PicType type, bool getFullPath, bool skipExtension)
        {
            List <string> result    = new List <string>();
            string        picfolder = "";

            if (type == PicType.BoxArt)
            {
                picfolder = Values.BoxartFolder;
            }
            else if (type == PicType.Title)
            {
                picfolder = Values.TitleFolder;
            }
            else
            {
                picfolder = Values.GameplayFolder;
            }

            var path = Environment.CurrentDirectory + "\\" + Values.PlatformsPath + "\\" + platform + "\\" + picfolder;

            if (!Directory.Exists(path))
            {
                return(result);
            }

            var list = Directory.GetFiles(path).ToList();

            if (!getFullPath)
            {
                foreach (var item in list)
                {
                    if (skipExtension)
                    {
                        result.Add(RomFunctions.GetFileNameNoExtension(item));
                    }
                    else
                    {
                        result.Add(RomFunctions.GetFileName(item));
                    }
                }
            }
            else
            {
                result = list;
            }

            return(result);
        }
Пример #3
0
        public static bool AddRomsFiles(Platform platform, string[] files)
        {
            bool addedAny = false;

            foreach (var file in files)
            {
                var rom = RomBusiness.Get(platform.Name, RomFunctions.GetFileName(file));

                if (rom == null)
                {
                    rom      = RomBusiness.NewRom(file, platform);
                    addedAny = true;
                    RomBusiness.SetRom(rom);
                }
            }

            return(addedAny);
        }
Пример #4
0
        public static Rom NewRom(string file, Platform platform, bool rompack = false)
        {
            var rom = new Rom();

            rom.FileName      = RomFunctions.GetFileName(file, rompack);
            rom.FileNameNoExt = RomFunctions.GetFileNameNoExtension(file);
            rom.Platform      = platform;

            if (platform != null && platform.Id == "23")//arcade
            {
                rom.Name = RomFunctions.GetMAMENameFromCSV(RomFunctions.GetFileNameNoExtension(file));

                if (rom.Name == "")
                {
                    rom.Name = RomFunctions.GetFileNameNoExtension(file);
                }
            }
            else
            {
                rom.Name = RomFunctions.GetFileNameNoExtension(file);
            }

            return(rom);
        }
Пример #5
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);
        }