Example #1
0
        private void Test_Click(object sender, RoutedEventArgs e)
        {
            var ddd   = db.Records.Where(x => true).Select(x => x.RecordDate).OrderBy(x => x).ToList();
            var dates = ddd.Select(x => x.Date).Distinct();
            var id    = 1;
            List <RecordGroup> list = new List <RecordGroup>();

            foreach (var d in dates)
            {
                var ids = GetDisplayRecords(d);
                if (string.IsNullOrEmpty(ids))
                {
                    continue;
                }
                var groups = new RecordGroup()
                {
                    //Id = id,
                    RecordIds = ids,
                    Date      = d,
                    Info      = string.Empty
                };

                db.RecordGroups.Add(groups);

                db.SaveChanges();
                id++;
            }
            db.SaveChanges();
        }
Example #2
0
        private void Refresh()
        {
            var         dat = new List <RecordGroup>();
            RecordGroup g   = null;

            foreach (Note note in Persister
                     .Where(d => IsShowAll || d.IsDeleted == false)
                     .OrderBy(d => $"{d.CaptionRubi1}--{d.CaptionRubi}")
                     )
            {
                if (g == null)
                {
                    dat.Add(g = new RecordGroup
                    {
                        Rubi1 = note.CaptionRubi1,
                    });
                }
                else
                {
                    if (note.CaptionRubi1 != g.Rubi1)
                    {
                        dat.Add(g = new RecordGroup
                        {
                            Rubi1 = note.CaptionRubi1,
                        });
                    }
                }
                g.Add(note);
            }
            listView.ItemsSource = dat;
        }
Example #3
0
        public static void ReadNonfixed(BinaryFileReader r, Header header, RecordGroup group)
        {
            var world = int.Parse(header.Label);

            // header
            r.Skip(4 * 5);
            var width  = r.ReadUInt32();
            var height = r.ReadUInt32();

            r.Skip(4);
            var indexSize = (int)(width * height);
            var indices   = r.ReadTArray <uint>(indexSize * 4, indexSize);

            r.Skip(4);
            // pages
            var page     = r.ReadT <Page>(28); r.Skip(4 * 7);
            var entities = new Entity[page.EntityCount];

            for (var i = 0; i < entities.Length; i++)
            {
                entities[i] = r.ReadT <Entity>(64);
            }
        }
Example #4
0
        public static void ReadFixed(BinaryFileReader r, Header header, RecordGroup group)
        {
            var world     = int.Parse(header.Label);
            var head      = r.ReadT <Head>(32);
            var indexSize = (int)(head.Width * head.Height);
            // These are either 0 or a number in the form nnnn001h, where nnnn is a number that may be a page index. This may be in [x + y * width] order, but that doesn't seem to corroborate with where objects are located in the maps
            var       indices      = r.ReadTArray <uint>(indexSize * 4, indexSize);
            const int POINT_STRIDE = 32;
            var       pages        = new Page[head.PageSize / 4096];

            for (var i = 0; i < pages.Length; i++)
            {
                var page = pages[i] = new Page();
                r.Skip(4 * 0x3);
                page.BaseX = r.ReadUInt32();
                page.BaseY = r.ReadUInt32();
                r.Skip(4 * 0x13);
                page.FixedObjects = r.ReadTArray <FixedObject>(0x18 * 166, 166);
                r.Skip(0x10);
            }
            var data = new Data
            {
                Width   = head.Width,
                Height  = head.Height,
                Indices = indices,
                Pages   = pages,
            };

            group.Tag = data;

            // transform
            const int CELL_STRIDE = 64;
            var       records     = new List <Record>();

            for (var y = 0; y < data.Height; y += 2)
            {
                for (var x = 0; x < data.Width; x += 2)
                {
                    //var vhgt = new ushort[CELL_STRIDE * CELL_STRIDE];
                    //var vtex = new ushort[CELL_STRIDE * CELL_STRIDE];
                    //var vtexf = new byte[CELL_STRIDE * CELL_STRIDE];
                    //for (var sy = 0; sy < 2; sy++)
                    //    for (var sx = 0; sx < 2; sx++)
                    //    {
                    //        var index = indices[x + sx + ((y + sy) * data.Width)];
                    //        if (index >= chunks.Length)
                    //            continue;
                    //        var chunk = chunks[index];
                    //        var offset = (sx * POINT_STRIDE) + (sy * POINT_STRIDE * CELL_STRIDE);
                    //        for (var i = 0; i < POINT_STRIDE; i++)
                    //        {
                    //            Buffer.BlockCopy(chunk.VHGT, i * POINT_STRIDE * 2, vhgt, offset + (i * CELL_STRIDE * 2), POINT_STRIDE * 2);
                    //            Buffer.BlockCopy(chunk.VTEX, i * POINT_STRIDE * 2, vtex, offset + (i * CELL_STRIDE * 2), POINT_STRIDE * 2);
                    //            Buffer.BlockCopy(chunk.VTEXF, i * POINT_STRIDE, vtexf, offset + (i * CELL_STRIDE), POINT_STRIDE);
                    //        }
                    //    }
                    records.Add(new CELLRecord
                    {
                        GridId = new Vector3Int(x / 2, y / 2, world),
                    });
                }
            }

            // insert
            group.CELLsById = records.ToDictionary(x => ((CELLRecord)x).GridId, x => (CELLRecord)x);
            group.Records.AddRange(records);
        }
Example #5
0
        public static void ReadTerrain(BinaryFileReader r, Header header, RecordGroup group)
        {
            var world = int.Parse(header.Label);
            var data  = new Data
            {
                Width         = r.ReadUInt32(),
                Height        = r.ReadUInt32(),
                Name          = r.ReadASCIIString(0x80, ASCIIFormat.ZeroTerminated),
                WaterLevel    = r.ReadUInt32(),
                WaveAmplitude = r.ReadUInt32(),
                Flags         = r.ReadUInt32(),
            };
            var       chunkCount   = (int)r.ReadUInt32();
            var       widthHeight  = (int)(data.Width * data.Height);
            var       indices      = data.Indices = r.ReadTArray <ushort>(widthHeight << 1, widthHeight);
            var       chunks       = data.Chunks = new Chunk[chunkCount];
            const int POINT_STRIDE = 16;

            for (var i = 0; i < chunks.Length; i++)
            {
                var points = r.ReadTArray <uint>(POINT_STRIDE * POINT_STRIDE * 4, POINT_STRIDE * POINT_STRIDE);
                chunks[i] = new Chunk
                {
                    VHGT  = points.Select(x => (ushort)(x & 0xFFF)).ToArray(),
                    VTEXF = points.Select(x => (byte)((x >> 16) & 0x1F)).ToArray(),
                    VTEX  = points.Select(x => (ushort)((x >> 22) & 0x3FF)).ToArray(), //: sky, >> 21?
                };
            }
            group.Tag = data;

            // transform
            //const int LAND_STRIDE = 64;
            //var records = new List<Record>();
            //var VHGTs = new Dictionary<int, ushort[]>();
            //for (var i = 0; i < POINT_STRIDE; i++)
            //    VHGTs.Add(i, Enumerable.Repeat((ushort)(i * 10), POINT_STRIDE * POINT_STRIDE).ToArray());
            //for (var y = 0; y < data.Height; y += 4)
            //    for (var x = 0; x < data.Width; x += 4)
            //    {
            //        var vhgt = new ushort[LAND_STRIDE * LAND_STRIDE];
            //        var vtex = new ushort[LAND_STRIDE * LAND_STRIDE];
            //        var vtexf = new byte[LAND_STRIDE * LAND_STRIDE];
            //        for (var sy = 0; sy < 4; sy++)
            //            for (var sx = 0; sx < 4; sx++)
            //            {
            //                var offset = ((sx * POINT_STRIDE) + (sy * POINT_STRIDE * LAND_STRIDE)) << 1;
            //                for (var i = 0; i < POINT_STRIDE; i++)
            //                {
            //                    Buffer.BlockCopy(VHGTs[i], i * POINT_STRIDE << 1, vhgt, offset + (i * LAND_STRIDE << 1), POINT_STRIDE << 1);
            //                }
            //            }
            //        records.Add(new LANDRecord
            //        {
            //            VHGT = vhgt,
            //            VTEX = vtex,
            //            VTEXF = vtexf,
            //            GridId = new Vector3Int(x / 4, y / 4, world),
            //        });
            //    }

            // transform
            const int LAND_STRIDE = 64;
            var       records     = new List <Record>();

            for (var y = 0; y < data.Height; y += 4)
            {
                for (var x = 0; x < data.Width; x += 4)
                {
                    var vhgt  = new ushort[LAND_STRIDE * LAND_STRIDE];
                    var vtex  = new ushort[LAND_STRIDE * LAND_STRIDE];
                    var vtexf = new byte[LAND_STRIDE * LAND_STRIDE];
                    for (var sy = 0; sy < 4; sy++)
                    {
                        for (var sx = 0; sx < 4; sx++)
                        {
                            var index = indices[x + sx + ((y + sy) * data.Width)];
                            if (index >= chunks.Length)
                            {
                                continue;
                            }
                            var chunk  = chunks[index];
                            var offset = ((sx * POINT_STRIDE) + (sy * POINT_STRIDE * LAND_STRIDE)) << 1;
                            for (var i = 0; i < POINT_STRIDE; i++)
                            {
                                Buffer.BlockCopy(chunk.VHGT, i * POINT_STRIDE << 1, vhgt, offset + (i * LAND_STRIDE << 1), POINT_STRIDE << 1);
                                Buffer.BlockCopy(chunk.VTEX, i * POINT_STRIDE << 1, vtex, offset + (i * LAND_STRIDE << 1), POINT_STRIDE << 1);
                                //Buffer.BlockCopy(chunk.VTEXF, i * POINT_STRIDE, vtexf, offset + (i * LAND_STRIDE), POINT_STRIDE);
                            }
                        }
                    }
                    records.Add(new LANDRecord
                    {
                        VHGT   = vhgt,
                        VTEX   = vtex,
                        VTEXF  = vtexf,
                        GridId = new Vector3Int(x / 4, y / 4, world),
                    });
                }
            }

            // insert
            group.LANDsById = records.ToDictionary(x => ((LANDRecord)x).GridId, x => (LANDRecord)x);
            group.Records.AddRange(records);
        }