static void UpdateMonsterNote(IO.IFileSystem filesystem, Encoding encoding)
        {
            Assert.IsNotNull(filesystem, nameof(filesystem));
            Assert.IsNotNull(encoding, nameof(encoding));

            Console.WriteLine("monsnote.dt2");

            using (var reader = filesystem.OpenFile(@"data\monsnote\monsnote.dt2", encoding))
            {
                var monsternote = new MonsterNoteFile(reader);

                foreach (var record in monsternote.Records)
                {
                    var filename = Path.Combine(@"data\battle\dat", "ms" + record.Id.Substring(3) + ".dat");

                    using (var monsterfilereader = filesystem.OpenFile(filename, encoding))
                    {
                        var monsterfile = OpenMonsterDefinitionFile(monsterfilereader);
                        record.MonsterDefinitionFile = monsterfile;
                    }
                }

                var filebuffer = monsternote.Write(encoding);
                filesystem.SaveFile(@"data\monsnote\monsnote.dt2", filebuffer);
            }
        }
        static void Run(IO.IFileSystem filesystem, Encoding encoding, String datapath)
        {
            Assert.IsNotNull(filesystem, nameof(filesystem));
            Assert.IsNotNull(encoding, nameof(encoding));
            Assert.IsValidString(datapath, nameof(datapath));

            var data_text = Text.TextFileDescription.GetTextFileData_AoK();

            var totalscenastringtable = new SortedSet <String>();

            Directory.CreateDirectory(datapath);
            Directory.CreateDirectory(Path.Combine(datapath, "text"));
            Directory.CreateDirectory(Path.Combine(datapath, "monster"));

            foreach (var item in data_text)
            {
                Console.WriteLine(item.FileName);

                var textfilepath = Path.Combine(@"data\text", item.FileName);
                var jsonfilepath = Path.ChangeExtension(Path.Combine(datapath, "text", item.FileName), ".json");

                using (var reader = filesystem.OpenFile(textfilepath, encoding))
                {
                    var strings = Text.TextFileIO.Read(reader, item.FilePointerDelegate, item.RecordCount);
                    JsonTextItemFileIO.WriteToFile(strings.Select(x => new TextItem(x)).ToList(), jsonfilepath);
                }
            }

            JsonTextItemFileIO.WriteToFile(totalscenastringtable.Select(x => new TextItem(x)).ToList(), Path.Combine(datapath, "stringtable.json"));

            foreach (var filepath in filesystem.GetChildren(@"data\battle\dat", "ms*.dat"))
            {
                var filename     = Path.GetFileName(filepath);
                var jsonfilepath = Path.ChangeExtension(Path.Combine(datapath, "monster", filename), ".json");

                Console.WriteLine(filename);

                using (var reader = filesystem.OpenFile(filepath, encoding))
                {
                    var monsterfile = OpenMonsterDefinitionFile(reader);
                    var strings     = monsterfile.GetStrings();

                    JsonTextItemFileIO.WriteToFile(strings.Select(x => new TextItem(x)).ToList(), jsonfilepath);
                }
            }

            Console.WriteLine();
            Console.WriteLine("Done.");
        }
Exemplo n.º 3
0
        public static IProfile Read([NotNull] IO.IFileSystem fileSystem)
        {
            Assert.ArgumentNotNull(fileSystem, nameof(fileSystem));

            var profileFile  = fileSystem.ParseFile(ProfileFilePath);
            var deserializer = new XmlSerializer(typeof(Profile));

            using (var textReader = new StreamReader(profileFile.OpenRead()))
            {
                var profile = (Profile)deserializer.Deserialize(textReader);
                profile.FileSystem = fileSystem;

                return(profile);
            }
        }
        static void Run(IO.IFileSystem filesystem, Encoding encoding, String datapath)
        {
            Assert.IsNotNull(filesystem, nameof(filesystem));
            Assert.IsNotNull(encoding, nameof(encoding));
            Assert.IsValidString(datapath, nameof(datapath));

            var data_text = Text.TextFileDescription.GetTextFileData_AoK();

            var stringtableitems = JsonTextItemFileIO.ReadFromFile(Path.Combine(datapath, "stringtable.json"));

            foreach (var item in data_text)
            {
                var textfilepath = Path.Combine(@"data\text", item.FileName);
                var jsonfilepath = Path.ChangeExtension(Path.Combine(datapath, "text", item.FileName), ".json");

                if (File.Exists(jsonfilepath) == true)
                {
                    Console.WriteLine(item.FileName);

                    using (var reader = filesystem.OpenFile(textfilepath, encoding))
                    {
                        var buffer = UpdateTextFile(reader, item.FilePointerDelegate, item.RecordCount, jsonfilepath);
                        filesystem.SaveFile(textfilepath, buffer);
                    }
                }
            }

            foreach (var filepath in filesystem.GetChildren(@"data\battle\dat", "ms*.dat"))
            {
                var filename     = Path.GetFileName(filepath);
                var jsonfilepath = Path.ChangeExtension(Path.Combine(datapath, "monster", filename), ".json");

                if (File.Exists(jsonfilepath) == true)
                {
                    Console.WriteLine(filename);

                    using (var reader = filesystem.OpenFile(filepath, encoding))
                    {
                        var buffer = UpdateMonsterFile(reader, jsonfilepath);
                        filesystem.SaveFile(filepath, buffer);
                    }
                }
            }

            UpdateMonsterNote(filesystem, encoding);
        }
        static void UpdateMonsterNote(IO.IFileSystem filesystem, Encoding encoding)
        {
            Assert.IsNotNull(filesystem, nameof(filesystem));
            Assert.IsNotNull(encoding, nameof(encoding));

            Console.WriteLine("monsnote.dt2");

            var filelist = GetMonsterNoteFileList();

            var allbuffers = new List <Byte[]>();

            foreach (var monsterfilenumber in filelist)
            {
                var monsterfilepath = Path.Combine(@"data\battle\dat", "ms" + monsterfilenumber + ".dat");
                using (var monsterreader = filesystem.OpenFile(monsterfilepath, encoding))
                {
                    var monsterfiledata = monsterreader.ReadBytes((Int32)monsterreader.Length);

                    var buffer = new Byte[8 + monsterreader.Length];

                    var foo      = "300" + monsterfilenumber;
                    var foobytes = Enumerable.Range(0, 4).Select(i => foo.Substring(i * 2, 2)).Select(str => (Byte)Int32.Parse(str, System.Globalization.NumberStyles.HexNumber)).Reverse().ToArray();

                    Array.Copy(foobytes, 0, buffer, 0, 4);
                    BinaryIO.WriteIntoBuffer(buffer, 4, (UInt32)monsterreader.Length);
                    Array.Copy(monsterfiledata, 0, buffer, 8, monsterfiledata.Length);

                    allbuffers.Add(buffer);
                }
            }

            allbuffers.Add(new Byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF });

            var totalsize  = allbuffers.Sum(x => x.Length);
            var filebuffer = new Byte[totalsize];

            var memorystream = new MemoryStream(filebuffer);

            foreach (var item in allbuffers)
            {
                memorystream.Write(item, 0, item.Length);
            }

            filesystem.SaveFile(@"data\monsnote\monsnote.dt2", filebuffer);
        }
        static void FixFileReferences(Iso9660.IsoImage iso, IO.IFileSystem filesystem)
        {
            Assert.IsNotNull(iso, nameof(iso));
            Assert.IsNotNull(filesystem, nameof(filesystem));

            var data_text = Text.TextFileDescription.GetTextFileData();

            foreach (var item in data_text)
            {
                var textfilepath = Path.Combine(IsoFilePaths.DirectoryPath_Text, item.FileName);

                Update_datalst(iso, textfilepath);
                ClearFileReference(iso, IsoFilePaths.FilePath_sysstartbbc, item.FileName);
                ClearFileReference(iso, IsoFilePaths.FilePath_sysonmembbc, item.FileName);
            }

            foreach (var item in filesystem.GetChildren(@"data\scena", "*.bin"))
            {
                var scenariofilepath = Path.Combine(@"PSP_GAME\USRDIR", item);

                Update_datalst(iso, scenariofilepath);
            }

            foreach (var filepath in filesystem.GetChildren(@"data\battle\dat", "ms*.dat"))
            {
                var filename = Path.GetFileName(filepath);

                var filepath2 = Path.Combine(@"PSP_GAME\USRDIR", filepath);

                Update_datalst(iso, filepath2);
                ClearFileReference(iso, IsoFilePaths.FilePath_btasm1bbc, filename);
            }

            CleanAllMC1Files(iso);

            Update_datalst(iso, IsoFilePaths.FilePath_monsnotedt2);
            ClearFileReference(iso, IsoFilePaths.FilePath_sysonmembbc, "monsnote.dt2");
        }