Exemplo n.º 1
0
        private static bool LoadEmulator()
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after emulator", DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();
            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "name":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "version":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        private static bool LoadHeaderFromDat(ref RvDir tDir, ref FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadHeaderFromDat_not_found_after_clrmamepro, DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            string forceZipping = "";

            RvDat tDat = new RvDat();

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "name": tDat.AddData(RvDat.DatData.DatName, VarFix.CleanFileName(DatFileLoader.GnRest())); DatFileLoader.Gn(); break;

                case "description": tDat.AddData(RvDat.DatData.Description, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "category": tDat.AddData(RvDat.DatData.Category, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "version": tDat.AddData(RvDat.DatData.Version, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "date": tDat.AddData(RvDat.DatData.Date, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "author": tDat.AddData(RvDat.DatData.Author, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "email": tDat.AddData(RvDat.DatData.Email, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "homepage": tDat.AddData(RvDat.DatData.HomePage, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "url": tDat.AddData(RvDat.DatData.URL, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "comment": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "header": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "forcezipping": forceZipping = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "forcepacking": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;     // incorrect usage

                case "forcemerging": tDat.AddData(RvDat.DatData.MergeType, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "forcenodump": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "dir": tDat.AddData(RvDat.DatData.DirSetup, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                default:
                    DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadHeaderFromDat_not_known_in_clrmamepro, DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }

            thisFileType = forceZipping.ToLower() != "no" ? FileType.ZipFile : FileType.File;
            tDir.Dat     = tDat;
            return(true);
        }
Exemplo n.º 3
0
        private static bool LoadDirFromDat(RvDat rvDat, string rootName, HeaderFileType datFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after game", DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            if (DatFileLoader.Next.ToLower() != "name")
            {
                DatUpdate.SendAndShowDat("Name not found as first object in ( )", DatFileLoader.Filename);
                return(false);
            }
            string fullname = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            fullname = Path.Combine(rootName, fullname);

            DatFileLoader.Gn();

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "dir":
                    DatFileLoader.Gn();
                    if (!LoadDirFromDat(rvDat, fullname, datFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "game":
                    DatFileLoader.Gn();
                    if (!LoadGameFromDat(rvDat, fullname, datFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "resource":
                    DatFileLoader.Gn();
                    if (!LoadGameFromDat(rvDat, fullname, datFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat("Error Keyword " + DatFileLoader.Next + " not know in dir", DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }
            return(true);
        }
Exemplo n.º 4
0
        private static bool LoadHeaderFromDat(string Filename, long fileTimeStamp, RvDat rvDat)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after clrmamepro", DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            rvDat.Filename     = Filename;
            rvDat.DatTimeStamp = fileTimeStamp;

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "name": rvDat.Name = VarFix.CleanFileName(DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "description": rvDat.Description = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "category": rvDat.Category = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "version": rvDat.Version = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "date": rvDat.Date = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "author": rvDat.Author = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "email": rvDat.Email = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "homepage": rvDat.Homepage = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "url": rvDat.URL = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "comment": rvDat.Comment = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "header": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "forcezipping": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "forcepacking": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;     // incorrect usage

                case "forcemerging": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "forcenodump": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "dir": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                default:
                    DatUpdate.SendAndShowDat("Error: key word '" + DatFileLoader.Next + "' not known in clrmamepro", DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 5
0
        private static bool LoadRomFromDat(ref RvDir tGame, FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadRomFromDat_not_found_after_rom, DatFileLoader.Filename);
                return(false);
            }
            string line   = DatFileLoader.GnRest();
            string linelc = line.ToLower();

            int posName = linelc.IndexOf("name ", StringComparison.Ordinal);
            int posSize = linelc.IndexOf(" size ", posName + 5, StringComparison.Ordinal);
            int posDate = linelc.IndexOf(" date ", posSize + 6, StringComparison.Ordinal);
            int posCrc  = linelc.IndexOf(" crc ", posDate + 6, StringComparison.Ordinal);
            int posEnd  = linelc.IndexOf(" )", posCrc + 5, StringComparison.Ordinal);

            if (posName < 0 || posSize < 0 || posDate < 0 || posCrc < 0 || posEnd < 0)
            {
                DatFileLoader.Gn();
                return(false);
            }

            string name = line.Substring(posName + 5, posSize - (posName + 5));
            string size = line.Substring(posSize + 6, posDate - (posSize + 6));
            //string date = line.Substring(posDate + 6, posCrc - (posDate + 6));
            string crc = line.Substring(posCrc + 5, posEnd - (posCrc + 5));

            RvFile tRom = new RvFile(thisFileType)
            {
                Dat  = tGame.Dat,
                Name = VarFix.CleanFullFileName(name.Trim()),
                Size = VarFix.ULong(size.Trim()),
                CRC  = VarFix.CleanMD5SHA1(crc.Trim(), 8)
            };


            if (tRom.Size != null)
            {
                tRom.FileStatusSet(FileStatus.SizeFromDAT);
            }
            if (tRom.CRC != null)
            {
                tRom.FileStatusSet(FileStatus.CRCFromDAT);
            }

            tGame.ChildAdd(tRom);

            return(true);
        }
Exemplo n.º 6
0
        private static bool LoadHeaderFromDat(ref RvDir tDir, ref FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadHeaderFromDat_not_found_after_clrmamepro, DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            RvDat tDat = new RvDat();

            while (DatFileLoader.Next != ")")
            {
                string nextstr = DatFileLoader.Next.ToLower();
                if (nextstr.Length > 5 && nextstr.Substring(0, 5) == "name:")
                {
                    tDat.AddData(RvDat.DatData.DatName, VarFix.CleanFileName(DatFileLoader.Next.Substring(5) + " " + DatFileLoader.GnRest()).Trim()); DatFileLoader.Gn();
                }
                else
                {
                    switch (nextstr)
                    {
                    case "name:": tDat.AddData(RvDat.DatData.DatName, VarFix.CleanFileName(DatFileLoader.GnRest())); DatFileLoader.Gn(); break;

                    case "description:": tDat.AddData(RvDat.DatData.Description, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                    case "version:": tDat.AddData(RvDat.DatData.Version, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                    case "date:": tDat.AddData(RvDat.DatData.Date, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                    case "author:": tDat.AddData(RvDat.DatData.Author, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                    case "homepage:": tDat.AddData(RvDat.DatData.HomePage, DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                    case "comment:": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                    default:
                        DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadHeaderFromDat_not_known_in_clrmamepro, DatFileLoader.Filename);
                        DatFileLoader.Gn();
                        break;
                    }
                }
            }

            thisFileType = FileType.ZipFile;
            tDir.Dat     = tDat;
            return(true);
        }
Exemplo n.º 7
0
        private static bool LoadGameFromDat(ref RvDir tDat, FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_not_found_after_game, DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            string snext = DatFileLoader.Next.ToLower();

            if (snext != "name")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_Name_not_found_as_first_object_in, DatFileLoader.Filename);
                return(false);
            }

            RvDir parent = tDat;

            string fullname = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            if (_cleanFileNames)
            {
                fullname = fullname.Replace("/", "-");
            }

            while (fullname.Contains("/"))
            {
                int    firstSlash = fullname.IndexOf("/", StringComparison.Ordinal);
                string dir        = fullname.Substring(0, firstSlash);
                fullname = fullname.Substring(firstSlash + 1);
                int index;
                if (parent.ChildNameSearch(new RvDir(FileType.Dir)
                {
                    Name = dir
                }, out index) == 0)
                {
                    parent = (RvDir)parent.Child(index);
                }
                else
                {
                    RvDir tpDir = new RvDir(FileType.Dir)
                    {
                        Name      = dir,
                        DatStatus = DatStatus.InDatCollect,
                        Dat       = tDat.Dat,
                        Tree      = new RvTreeRow()
                    };
                    parent.ChildAdd(tpDir, index);
                    parent = tpDir;
                }
            }

            if (fullname.Length > 4 && fullname.ToLower().Substring(fullname.Length - 4, 4) == ".zip")
            {
                fullname = fullname.Substring(0, fullname.Length - 4);
            }

            RvDir tDir = new RvDir(thisFileType == FileType.File ? FileType.Dir : FileType.Zip)
            {
                Name = fullname
            };

            DatFileLoader.Gn();
            tDir.Game      = new RvGame();
            tDir.DatStatus = DatStatus.InDatCollect;
            tDir.Dat       = tDat.Dat;
            int index1;

            string testName  = tDir.Name;
            int    nameCount = 0;

            while (parent.ChildNameSearch(tDir, out index1) == 0)
            {
                tDir.Name = testName + "_" + nameCount;
                nameCount++;
            }
            parent.ChildAdd(tDir, index1);


            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "file":
                    DatFileLoader.Gn();
                    if (!LoadRomFromDat(ref tDir, thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadGameFromDat_not_known_in_game, DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }


            return(true);
        }
Exemplo n.º 8
0
        private static bool LoadGameFromDat(RvDat rvDat, string rootdir)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after game", DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            string snext = DatFileLoader.Next.ToLower();

            string pathextra = "";

            if (snext == "rebuildto")
            {
                pathextra = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn();
                snext     = DatFileLoader.Next.ToLower();
            }

            if (snext != "name")
            {
                DatUpdate.SendAndShowDat("Name not found as first object in ( )", DatFileLoader.Filename);
                return(false);
            }


            string name = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            if (!String.IsNullOrEmpty(pathextra))
            {
                name = pathextra + "/" + name;
            }

            DatFileLoader.Gn();

            RvGame rvGame = new RvGame();

            rvGame.Name = name;
            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "romof": rvGame.RomOf = VarFix.CleanFileName(DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "description": rvGame.Description = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "sourcefile": rvGame.SourceFile = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "cloneof": rvGame.CloneOf = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "sampleof": rvGame.SampleOf = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "board": rvGame.Board = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "year": rvGame.Year = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "manufacturer": rvGame.Manufacturer = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "serial": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "rebuildto": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "sample": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "biosset": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "chip": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "video": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "sound": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "input": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "dipswitch": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "driver": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;


                case "rom":
                    DatFileLoader.Gn();
                    if (!LoadRomFromDat(rvGame))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "disk":
                    DatFileLoader.Gn();
                    if (!LoadDiskFromDat(rvGame))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "archive":
                    DatFileLoader.Gn();
                    if (!LoadArchiveFromDat())
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat("Error: key word '" + DatFileLoader.Next + "' not known in game", DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }
            rvDat.AddGame(rvGame);
            return(true);
        }
Exemplo n.º 9
0
        private static bool LoadGameFromDat(ref RvDir tDat, bool bolresource, FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_not_found_after_game, DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            string snext = DatFileLoader.Next.ToLower();

            string pathextra = "";

            if (snext == "rebuildto")
            {
                pathextra = VarFix.CleanFullFileName(DatFileLoader.Gn());
                DatFileLoader.Gn();
                snext = DatFileLoader.Next.ToLower();
            }

            if (snext != "name")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_Name_not_found_as_first_object_in, DatFileLoader.Filename);
                return(false);
            }

            RvDir parent = tDat;

            string fullname = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            if (_cleanFileNames)
            {
                fullname = fullname.Replace("/", "-");
            }

            if (!string.IsNullOrEmpty(pathextra))
            {
                fullname = pathextra + "/" + fullname;
            }

            while (fullname.Contains("/"))
            {
                int    firstSlash = fullname.IndexOf("/", StringComparison.Ordinal);
                string dir        = fullname.Substring(0, firstSlash);
                fullname = fullname.Substring(firstSlash + 1);
                if (parent.ChildNameSearch(new RvDir(FileType.Dir)
                {
                    Name = dir
                }, out int index) == 0)
                {
                    parent = (RvDir)parent.Child(index);
                }
                else
                {
                    RvDir tpDir = new RvDir(FileType.Dir)
                    {
                        Name      = dir,
                        DatStatus = DatStatus.InDatCollect,
                        Dat       = tDat.Dat,
                        Tree      = new RvTreeRow()
                    };
                    parent.ChildAdd(tpDir, index);
                    parent = tpDir;
                }
            }

            RvDir tDir = new RvDir(thisFileType == FileType.File ? FileType.Dir : FileType.Zip)
            {
                Name      = fullname,
                DatStatus = DatStatus.InDatCollect,
                Dat       = tDat.Dat
            };

            string testName  = tDir.Name;
            int    nameCount = 0;
            int    index1;

            while (parent.ChildNameSearch(tDir, out index1) == 0)
            {
                tDir.Name = testName + "_" + nameCount;
                nameCount++;
            }

            DatFileLoader.Gn();
            tDir.Game = new RvGame();
            tDir.Game.AddData(RvGame.GameData.IsBios, bolresource ? "Yes" : "No");

            RvDir tDirCHD = new RvDir(FileType.Dir)
            {
                Name      = tDir.Name,
                DatStatus = tDir.DatStatus,
                Dat       = tDir.Dat,
                Game      = tDir.Game
            };

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "romof":
                    tDir.Game.AddData(RvGame.GameData.RomOf, VarFix.CleanFileName(DatFileLoader.GnRest()));
                    DatFileLoader.Gn();
                    break;

                case "description":
                    tDir.Game.AddData(RvGame.GameData.Description, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "sourcefile":
                    tDir.Game.AddData(RvGame.GameData.Sourcefile, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "cloneof":
                    tDir.Game.AddData(RvGame.GameData.CloneOf, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "sampleof":
                    tDir.Game.AddData(RvGame.GameData.SampleOf, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "board":
                    tDir.Game.AddData(RvGame.GameData.Board, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "year":
                    tDir.Game.AddData(RvGame.GameData.Year, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "manufacturer":
                    tDir.Game.AddData(RvGame.GameData.Manufacturer, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "serial":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "rebuildto":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sample":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "biosset":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "chip":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "video":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sound":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "input":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "dipswitch":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "driver":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;


                case "rom":
                    DatFileLoader.Gn();
                    if (!LoadRomFromDat(ref tDir, thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "disk":
                    DatFileLoader.Gn();
                    if (!LoadDiskFromDat(ref tDirCHD))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "archive":
                    DatFileLoader.Gn();
                    if (!LoadArchiveFromDat())
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadGameFromDat_not_known_in_game, DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }

            if (tDir.ChildCount > 0)
            {
                parent.ChildAdd(tDir, index1);
            }
            if (tDirCHD.ChildCount > 0)
            {
                parent.ChildAdd(tDirCHD);
            }

            return(true);
        }
Exemplo n.º 10
0
        private static bool LoadDirFromDat(ref RvDir tDat, ref FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_not_found_after_game, DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            if (DatFileLoader.Next.ToLower() != "name")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_Name_not_found_as_first_object_in, DatFileLoader.Filename);
                return(false);
            }

            RvDir parent = tDat;

            string fullname = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            while (fullname.Contains("/"))
            {
                int    firstSlash = fullname.IndexOf("/", StringComparison.Ordinal);
                string dir        = fullname.Substring(0, firstSlash);
                dir = VarFix.CleanFileName(dir);

                fullname = fullname.Substring(firstSlash + 1);
                if (parent.ChildNameSearch(new RvDir(FileType.Dir)
                {
                    Name = dir
                }, out int index) == 0)
                {
                    parent = (RvDir)parent.Child(index);
                }
                else
                {
                    RvDir tpDir = new RvDir(FileType.Dir)
                    {
                        Name      = dir,
                        DatStatus = DatStatus.InDatCollect,
                        Dat       = tDat.Dat,
                        Tree      = new RvTreeRow()
                    };
                    parent.ChildAdd(tpDir, index);
                    parent = tpDir;
                }
            }

            RvDir tDir = new RvDir(FileType.Dir)
            {
                Name = fullname
            };

            DatFileLoader.Gn();
            tDir.DatStatus = DatStatus.InDatCollect;
            tDir.Dat       = tDat.Dat;

            if (parent.ChildNameSearch(tDir, out int index1) == 0)
            {
                tDir = (RvDir)parent.Child(index1);
            }
            else
            {
                parent.ChildAdd(tDir, index1);
            }

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "dir":
                    DatFileLoader.Gn();
                    if (!LoadDirFromDat(ref tDir, ref thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "game":
                    DatFileLoader.Gn();
                    if (!LoadGameFromDat(ref tDir, false, thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "resource":
                    DatFileLoader.Gn();
                    if (!LoadGameFromDat(ref tDir, true, thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadDirFromDat_Error_Keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadDirFromDat_not_know_in_dir, DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }
            return(true);
        }
Exemplo n.º 11
0
        private static bool LoadHeaderFromDat(string filename, RvDat rvDat, out HeaderFileType datFileType)
        {
            datFileType = HeaderFileType.Nothing;

            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after clrmamepro on line " + DatFileLoader.LineNumber, DatFileLoader.Filename);
                return(false);
            }

            DatFileLoader.Gn();
            rvDat.Filename = filename;
            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "name:":
                    rvDat.Name = VarFix.CleanFileName(DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "description:":
                    rvDat.Description = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "category:":
                    rvDat.Category = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "version:":
                    rvDat.Version = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "date:":
                    rvDat.Date = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "author:":
                    rvDat.Author = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "email:":
                    rvDat.Email = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "homepage:":
                    rvDat.Homepage = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "url:":
                    rvDat.URL = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "comment:":
                    rvDat.Comment = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "header:":
                    datFileType = FileHeaderReader.FileHeaderReader.GetFileTypeFromHeader(DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "forcezipping:":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "forcepacking:":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                // incorrect usage
                case "forcemerging:":
                    rvDat.MergeType = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "forcenodump:":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                default:
                    if (DatFileLoader.Next.ToLower().StartsWith("name:"))
                    {
                        rvDat.Name = DatFileLoader.Next.Remove(0, 5);
                        DatFileLoader.GnRest();
                        DatFileLoader.Gn();
                    }
                    else
                    {
                        DatUpdate.SendAndShowDat("Error on line " + DatFileLoader.LineNumber + ": key word '" + DatFileLoader.Next + "' not known in clrmamepro", DatFileLoader.Filename);
                        DatFileLoader.Gn();
                    }
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 12
0
        private static bool LoadGameFromDat(RvDat rvDat, string rootName, HeaderFileType datFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after game on line " + DatFileLoader.LineNumber, DatFileLoader.Filename);
                return(false);
            }

            DatFileLoader.Gn();
            string snext     = DatFileLoader.Next.ToLower();
            string pathextra = "";

            if (snext == "rebuildto")
            {
                pathextra = VarFix.CleanFullFileName(DatFileLoader.Gn());
                DatFileLoader.Gn();
                snext = DatFileLoader.Next.ToLower();
            }

            if (snext != "name")
            {
                DatUpdate.SendAndShowDat("Name not found as first object in ( ) on line " + DatFileLoader.LineNumber, DatFileLoader.Filename);
                return(false);
            }

            string name = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            name = Path.Combine(pathextra, name);
            name = Path.Combine(rootName, name);
            name = (name.EndsWith(".zip") ? name.Remove(name.Length - 4) : name);

            DatFileLoader.Gn();
            RvGame rvGame = new RvGame {
                Name = name
            };

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "romof":
                    rvGame.RomOf = VarFix.CleanFileName(DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "description":
                    rvGame.Description = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sourcefile":
                    rvGame.SourceFile = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "cloneof":
                    rvGame.CloneOf = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sampleof":
                    rvGame.SampleOf = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "board":
                    rvGame.Board = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "year":
                    rvGame.Year = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "manufacturer":
                    rvGame.Manufacturer = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "serial":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "rebuildto":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sample":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "biosset":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "chip":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "video":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sound":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "input":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "dipswitch":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "driver":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "file":
                    DatFileLoader.Gn();
                    if (!LoadRomFromDat(rvGame, datFileType))
                    {
                        return(false);
                    }

                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat("Error on line " + DatFileLoader.LineNumber + ": key word '" + DatFileLoader.Next + "' not known in game", DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }

            rvDat.AddGame(rvGame);
            return(true);
        }