Beispiel #1
0
        private static void TestNinokuniExportImport(string romPath, string filePath)
        {
            DataStream romStream      = new DataStream(romPath, FileMode.Open, FileAccess.Read);
            Format     romFormat      = FileManager.GetFormat("Rom");
            Format     subtitleFormat = FileManager.GetFormat("Subtitle");

            GameFile rom = new GameFile(Path.GetFileName(romPath), romStream, romFormat);

            romFormat.Initialize(rom);

            XDocument xmlGame = XDocument.Load(Path.Combine(AppPath, "ExampleGame.xml"));
            XDocument xmlEdit = XDocument.Load(Path.Combine(AppPath, "ExampleEdition.xml"));

            FileManager.Initialize(rom, FileInfoCollection.FromXml(xmlGame));
            Configuration.Initialize(xmlEdit);

            GameFile file = FileManager.GetInstance().RescueFile(filePath);

            subtitleFormat.Initialize(file);
            file.Format.Read();
            file.Format.Import("/home/benito/Dropbox/Ninokuni español/Texto/Subs peli/s01.xml");
            file.Format.Write();

            romFormat.Write();
            rom.Stream.WriteTo("/lab/nds/projects/generic/test.nds");
            romStream.Dispose();
        }
Beispiel #2
0
        private void InitializeFileTypes(FileContainer root, XDocument xmlGame)
        {
            FileInfoCollection fileInfo = FileInfoCollection.FromXml(xmlGame);

            // Add the parameters to each file format.
            // They can be used to add specific properties of the project to the formats parsers.
            // E.g.: to pass the key of the GoogleSpreadsheets to parse.
            foreach (XElement fileEdit in edit.Root.Element("Files").Elements("File"))
            {
                // In order to set parameters the type must be defined in the XML. Otherwise it will defined in run-time
                string filePath = fileEdit.Element("Path").Value;
                if (!fileInfo.Contains(filePath))
                {
                    continue;
                }

                FileInfo info = fileInfo[filePath];
                if (info.Parameters == null)
                {
                    info.Parameters = fileEdit.Element("Parameters");
                }
                else
                {
                    info.Parameters.Add(fileEdit.Element("Parameters")?.Elements());
                }
            }

            FileManager.Initialize(root, fileInfo);
        }
Beispiel #3
0
        private static void TestNdsRomRead(string romPath, string filePath, string outPath)
        {
            DataStream romStream = new DataStream(romPath, FileMode.Open, FileAccess.Read);
            Format     romFormat = FileManager.GetFormat("Rom");

            GameFolder main = new GameFolder("main");
            GameFile   rom  = new GameFile(Path.GetFileName(romPath), romStream, romFormat);

            main.AddFile(rom);
            romFormat.Initialize(rom);

            XDocument xmlGame = new XDocument();                // TODO: Replace with ExampleGame.xml

            xmlGame.Add(new XElement("GameInfo", new XElement("Files")));
            FileManager.Initialize(main, FileInfoCollection.FromXml(xmlGame));

            GameFile file = FileManager.GetInstance().RescueFile(filePath);

            if (file != null)
            {
                file.Stream.WriteTo(outPath);
            }

            romStream.Dispose();
        }