예제 #1
0
        public static void SaveData(Models.Collision collision, string targetFile)
        {
            // Don't erase file, we just want to write what we have.
            // This ensures extra bytes at the end (if any) are not lost.
            using var writer = new BinaryWriter(File.Open(targetFile, FileMode.Open, FileAccess.Write));

            writer.Write(collision.magicCol1);
            writer.Write(collision.nameCol.ToCharArray());
            writer.Write(collision.magicCol2);
            writer.Write(collision.unk1);
            writer.Write(collision.unk2);
            writer.Write(collision.nameCount);
            WriteNames(collision.names, writer);
            WriteClnd(collision.clnd, writer);
            writer.Write(collision.magicAtk1);
            writer.Write(collision.nameAtk.ToCharArray());
            writer.Write(collision.magicAtk2);
            writer.Write(collision.atkCount);
            writer.Write(collision.atkType);
            WriteAtks(collision.atks, collision.atkType, writer);
            writer.Write(collision.magicOap1);
            writer.Write(collision.magicOap2);
            writer.Write(collision.nameOap.ToCharArray());
            writer.Write(collision.magicOap3);
            writer.Write(collision.oapType);
            writer.Write(collision.oapInnerCount);
            WriteOapInners(collision.oapInner, collision.oapType, writer);
            writer.Write(collision.unk10);
            writer.Write(collision.unk11);
            writer.Write(collision.unk12);
        }
예제 #2
0
        public static Models.Collision LoadData(string targetFile)
        {
            Debug.Assert(Marshal.SizeOf(typeof(Atk0)) == 179);
            Debug.Assert(Marshal.SizeOf(typeof(Atk1)) == 218);
            Debug.Assert(Marshal.SizeOf(typeof(Atk2)) == 171);
            Debug.Assert(Marshal.SizeOf(typeof(Atk3)) == 199);
            Debug.Assert(Marshal.SizeOf(typeof(ClgmInner)) == 72);
            Debug.Assert(Marshal.SizeOf(typeof(OapInner1)) == 16);
            Debug.Assert(Marshal.SizeOf(typeof(OapInner2)) == 13);
            Debug.Assert(Marshal.SizeOf(typeof(OapInner3)) == 48);

            using var reader = new BinaryReader(File.OpenRead(targetFile));

            var collision = new Models.Collision {
                magicCol1 = reader.ReadUInt32(),
                nameCol   = new string(reader.ReadChars(4)),
                magicCol2 = reader.ReadUInt32(),
                unk1      = reader.ReadUInt32(),
                unk2      = reader.ReadUInt32(),
                nameCount = reader.ReadUInt32()
            };

            collision.names         = ReadNames(collision.nameCount, reader, targetFile);
            collision.clnd          = ReadClnd(reader);
            collision.magicAtk1     = reader.ReadUInt32();
            collision.nameAtk       = new string(reader.ReadChars(4));
            collision.magicAtk2     = reader.ReadUInt32();
            collision.atkCount      = reader.ReadUInt32();
            collision.atkType       = reader.ReadUInt32();
            collision.atks          = ReadAtks(collision.atkCount, collision.atkType, reader);
            collision.magicOap1     = reader.ReadUInt32();
            collision.magicOap2     = reader.ReadUInt32();
            collision.nameOap       = new string(reader.ReadChars(4));
            collision.magicOap3     = reader.ReadUInt32();
            collision.oapType       = reader.ReadUInt32();
            collision.oapInnerCount = reader.ReadUInt32();
            collision.oapInner      = ReadOapInners(collision.oapInnerCount, collision.oapType, reader);
            collision.unk10         = reader.ReadUInt32();
            collision.unk11         = reader.ReadUInt32();
            collision.unk12         = reader.ReadUInt32();

            return(collision);
        }
예제 #3
0
        public static void SetupViews(Models.Collision collision, Grid grid, MainWindow main)
        {
            if (MainWindow.showAll)
            {
                grid.AddControl(new Label {
                    Content = "Collision", FontSize = FONT_SIZE
                });
                main.AddDataGrid(new List <Models.Collision> {
                    collision
                });

                grid.AddControl(new Label {
                    Content = "CLND", FontSize = FONT_SIZE
                });
                main.AddDataGrid(new List <Clnd> {
                    collision.clnd
                });

                for (var i = 0; i < collision.clnd.clgm.Count; i++)
                {
                    grid.AddControl(new Label {
                        Content = $"CLGM {i + 1}", FontSize = FONT_SIZE
                    });
                    main.AddDataGrid(new List <Clgm> {
                        collision.clnd.clgm[i]
                    });

                    if (collision.clnd.clgm[i].clgmInner.Any())
                    {
                        grid.AddControl(new Label {
                            Content = $"CLGM {i + 1}: Inner Array", FontSize = FONT_SIZE
                        });
                        main.AddDataGrid(collision.clnd.clgm[i].clgmInner);
                    }
                }
            }

            foreach (var name in collision.names.Where(name => name.moveId > -1).OrderBy(name => name.moveId))
            {
                var nameString = $"Name & Move [{name.TranslatedName}{(string.IsNullOrEmpty(name.Description) ? "" : $", {name.Description}")}]"