Ejemplo n.º 1
0
        public void TestFieldParsing()
        {
            var parser = new VDFParser();
            var result = parser.ParseContent($"\"name\" \"Kurisu\"{Environment.NewLine}\"surname\" \"Makise\"");

            Assert.Equal("Kurisu", result.GetString("name"));
            Assert.Equal("Makise", result.GetString("surname"));
        }
Ejemplo n.º 2
0
        public void TestObjectParsing()
        {
            var parser = new VDFParser();
            var result = parser.ParseContent($"\"info\"{Environment.NewLine}{{{Environment.NewLine}\"name\" \"Kurisu\"{Environment.NewLine}\"surname\" \"Makise\"{Environment.NewLine}}}");
            var info   = result.GetObject("info");

            Assert.Equal("Kurisu", info.GetString("name"));
            Assert.Equal("Makise", info.GetString("surname"));
        }
Ejemplo n.º 3
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <ControllerComponentObject> controllerComponents = new List <ControllerComponentObject>();
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                desktopVDFFileLoc = ofd.FileName;
            }
            VDFParser parser = new VDFParser();
            ParentKey parent = parser.Parse(new StreamReader(File.Open(desktopVDFFileLoc, FileMode.Open)));


            controllerMapping = new ControllerMapping();
            controllerMapping.ParseParentKey(parent);
        }
Ejemplo n.º 4
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                VDFParser parser = new VDFParser();
                ParentKey parent = parser.Parse(new StreamReader(File.Open(desktopVDFFileLoc, FileMode.Open)));
                controllerMapping = new ControllerMapping();
                controllerMapping.ParseParentKey(parent);

                a = new A_Button(controllerMapping);
                b = new B_Button(controllerMapping);
                x = new X_Button(controllerMapping);
                y = new Y_Button(controllerMapping);
                lbl_A_Button.Text = a.action;
                lbl_B_Button.Text = b.action;
                lbl_X_Button.Text = x.action;
                lbl_Y_Button.Text = y.action;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not read file");
                Console.WriteLine(ex.Message);
            }
        }
        public static Dictionary <string, object> ParseVDF(string vdf)
        {
            var parser = new VDFParser(vdf);

            return(parser.Parse());
        }
Ejemplo n.º 6
0
        private static void ScanFiles()
        {
            var parsers = new List <Action <BinaryReader, string> >();

            if (_checkAll || _checkTim)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var timParser = new TIMParser((tmdEntity, fp) =>
                    {
                        AllTextures.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Texture {tmdEntity.Width}x{tmdEntity.Height} {tmdEntity.Bpp}bpp");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for TIM at file {0}", fileTitle);
                    timParser.LookForTim(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkCroc)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var crocModelReader = new CrocModelReader((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for Croc at file {0}", fileTitle);
                    crocModelReader.LookForCrocModel(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkBff)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var crocModelReader = new BFFModelReader((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for BFF at file {0}", fileTitle);
                    crocModelReader.LookForBFF(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkPsx)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var psxParser = new PSXParser((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for PSX at file {0}", fileTitle);
                    psxParser.LookForPSX(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkTmd)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var tmdParser = new TMDParser((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for TMD at file {0}", fileTitle);
                    tmdParser.LookForTmd(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkVdf)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var vdfParser = new VDFParser((vdfEntity, fp) =>
                    {
                        AllAnimations.Add(vdfEntity);
                        UpdateProgress(fp, $"Found Animation with {vdfEntity.ObjectCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for VDF at file {0}", fileTitle);
                    vdfParser.LookForVDF(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkAn)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var anParser = new ANParser((vdfEntity, fp) =>
                    {
                        AllAnimations.Add(vdfEntity);
                        UpdateProgress(fp, $"Found Animation with {vdfEntity.ObjectCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for AN at file {0}", fileTitle);
                    anParser.LookForAN(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkPmd)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var pmdParser = new PMDParser((pmdEntity, fp) =>
                    {
                        AllEntities.Add(pmdEntity);
                        UpdateProgress(fp, $"Found Model with {pmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for PMD at file {0}", fileTitle);
                    pmdParser.LookForPMD(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkTod)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var todParser = new TODParser((todEntity, fp) =>
                    {
                        AllAnimations.Add(todEntity);
                        UpdateProgress(fp, $"Found Animation with {todEntity.ObjectCount} objects and {todEntity.FrameCount} frames");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for TOD at file {0}", fileTitle);
                    todParser.LookForTOD(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkHmd)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var hmdParser = new HMDParser((hmdEntity, fp) =>
                    {
                        AllEntities.Add(hmdEntity);
                        UpdateProgress(fp, $"Found Model with {hmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    }, (hmdAnimation, fp) =>
                    {
                        AllAnimations.Add(hmdAnimation);
                        UpdateProgress(fp, $"Found Animation with {hmdAnimation.ObjectCount} objects and {hmdAnimation.FrameCount} frames");
                        PreviewForm.ReloadItems();
                    }, delegate(Texture texture, long fp)
                    {
                        AllTextures.Add(texture);
                        UpdateProgress(fp, $"Found Texture {texture.Width}x{texture.Height} {texture.Bpp}bpp");
                        PreviewForm.ReloadItems();
                    }
                                                  );
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for HMD at file {0}", fileTitle);
                    hmdParser.LookForHMDEntities(binaryReader, fileTitle);
                });
            }

            if (File.Exists(_path))
            {
                Parallel.ForEach(parsers, parser =>
                {
                    using (var fs = File.Open(_path, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        ProcessFile(fs, _path, parser);
                    }
                });
            }
            else
            {
                ProcessFiles(_path, Filter, parsers);
            }
        }