示例#1
0
        private void ExportAllUsedShapes()
        {
            // Reading Palette
            FDPalette palette = new FDPalette(@".\color");

            ShapeDataFile shapeData = new ShapeDataFile(@".\FDSHAP.DAT");

            shapeData.LoadData();

            FieldDataFile fieldData = new FieldDataFile(@".\FDFIELD.DAT");

            fieldData.LoadData();

            for (int m = 0; m < 33; m++)
            {
                FieldMap      map    = fieldData.GetField(m);
                HashSet <int> shapes = map.GetAllShapeIndexes();

                ShapePanel panel        = shapeData.GetPanel(m);
                string     outputFolder = string.Format(@"D:\GitRoot\toneyisnow\windingtale\Resources\Original\Shapes\ShapePanel{0}\Used", m);
                if (!Directory.Exists(outputFolder))
                {
                    Directory.CreateDirectory(outputFolder);
                }

                foreach (int shape in shapes)
                {
                    var shapeInfo = panel.Shapes[shape];

                    ImageDataExporter exporter = new ImageDataExporter(shapeInfo.Image.GenerateBitmap(palette));
                    exporter.ExportToPng(Path.Combine(outputFolder, string.Format(@"Shape_{0}_{1}.png", m, shape)));
                }
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Reading Palette
            FDPalette palette = new FDPalette(@".\color");

            ShapeDataFile shapeData = new ShapeDataFile(@".\FDSHAP.DAT");

            shapeData.LoadData();

            ImageDataExporter exporter = new ImageDataExporter(shapeData.GetPanel(1).Shapes[100].Image.GenerateBitmap(palette));

            exporter.ExportToPng(@"D:\Temp\FDII\Shape_1_100.png");
        }
示例#3
0
        private void GenerateAllVoxes()
        {
            FDPalette palette = new FDPalette(@".\color");

            ShapeDataFile shapeData = new ShapeDataFile(@".\FDSHAP.DAT");

            shapeData.LoadData();
            FieldDataFile fieldData = new FieldDataFile(@".\FDFIELD.DAT");

            fieldData.LoadData();

            byte[] header         = File.ReadAllBytes(@".\vox_header.dat");
            byte[] footer         = File.ReadAllBytes(@".\vox_footer.dat");
            var    paletteMapping = LoadVoxPaletteMapping();


            // For each map, generate the vox files
            for (int m = 1; m < 2; m++)
            {
                FieldMap      map    = fieldData.GetField(m);
                HashSet <int> shapes = map.GetAllShapeIndexes();

                ShapePanel panel        = shapeData.GetPanel(m);
                string     outputFolder = string.Format(@"D:\GitRoot\toneyisnow\windingtale\Resources\Remastered\Shapes\ShapePanel{0}", m);

                if (!Directory.Exists(outputFolder))
                {
                    Directory.CreateDirectory(outputFolder);
                }

                //string mappingText = File.ReadAllText(Path.Combine(outputFolder, "shape-mapping-1.json"));
                //ShapeMapping mapping = JsonConvert.DeserializeObject<ShapeMapping>(mappingText);

                foreach (int shape in shapes)
                {
                    //if (mapping.ContainsValue(shape))
                    {
                        // continue;
                    }

                    var    shapeInfo      = panel.Shapes[shape];
                    string outputFileName = string.Format(@"Shape_{0}_{1}.vox", m, shape);

                    GenerateShapeVoxFile(shapeInfo.Image, Path.Combine(outputFolder, outputFileName), header, footer, paletteMapping);
                }
            }
        }
示例#4
0
        private void MakeVoxPaletteMapping(ShapeDataFile shapeData, int panel, int shape, Dictionary <byte, byte> paletteMapping)
        {
            string voxFullName = string.Format(@"D:\Temp\FDII\Shapes\Shape_{0}_{1}.vox", panel, shape);

            byte[,] targetmatrix = new byte[24, 24];
            using (FileStream streamData = new FileStream(voxFullName, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader reader = new BinaryReader(streamData))
                {
                    reader.Skip(0x3C);
                    for (byte y = 0; y < 24; y++)
                    {
                        for (byte x = 0; x < 24; x++)
                        {
                            byte xx = reader.ReadByte();
                            byte yy = reader.ReadByte();
                            reader.ReadByte();

                            byte cIndex = reader.ReadByte();
                            targetmatrix[xx, yy] = cIndex;
                        }
                    }
                }
            }

            // Reading Palette
            FDImage image = shapeData.GetPanel(panel).Shapes[shape].Image;

            for (byte y = 0; y < 24; y++)
            {
                for (byte x = 0; x < 24; x++)
                {
                    byte color  = image.GetPixelColorIndex(x, y);
                    byte target = targetmatrix[x, 23 - y];

                    if (paletteMapping.ContainsKey(color) && paletteMapping[color] != target)
                    {
                        // Something wrong here
                        int error = 1;
                    }

                    paletteMapping[color] = target;
                }
            }
        }
示例#5
0
        private void ExportFieldMapData()
        {
            // Reading Palette
            FDPalette palette = new FDPalette(@".\color");

            ShapeDataFile shapeData = new ShapeDataFile(@".\FDSHAP.DAT");

            shapeData.LoadData();

            FieldDataFile fieldData = new FieldDataFile(@".\FDFIELD.DAT");

            fieldData.LoadData();

            for (int m = 0; m < 33; m++)
            {
                FieldMap      map    = fieldData.GetField(m);
                HashSet <int> shapes = new HashSet <int>();
                for (int i = 0; i < map.Width; i++)
                {
                    for (int j = 0; j < map.Height; j++)
                    {
                        var shapeIndex = map.GetShapeIndexAt(i, j);
                        shapes.Add(shapeIndex);
                    }
                }

                var shapePanel = shapeData.GetPanel(m);
                foreach (int shapeIndex in shapes)
                {
                    ShapeInfo shapeInfo = shapePanel.Shapes[shapeIndex];

                    FieldShape shape = new FieldShape();
                    shape.Type             = shapeInfo.Type;
                    shape.BattleGroundId   = shapeInfo.BattleGroundId;
                    map.Shapes[shapeIndex] = shape;
                }

                string mapString = JsonConvert.SerializeObject(map, Formatting.Indented);
                int    mm        = m + 1;
                File.WriteAllText(string.Format(@"D:\Temp\FDII\Chapter_{0}.txt", (mm < 10 ? "0" + mm.ToString() : mm.ToString())), mapString);
            }
        }
示例#6
0
        private Dictionary <byte, byte> CreateVoxPaletteMapping2()
        {
            Dictionary <byte, byte> paletteMapping = new Dictionary <byte, byte>();

            ShapeDataFile shapeData = new ShapeDataFile(@".\FDSHAP.DAT");

            shapeData.LoadData();

            MakeVoxPaletteMapping(shapeData, 1, 20, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 2, 205, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 3, 24, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 3, 144, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 7, 84, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 12, 237, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 13, 87, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 15, 64, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 18, 41, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 18, 79, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 19, 10, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 21, 57, paletteMapping);
            MakeVoxPaletteMapping(shapeData, 24, 10, paletteMapping);
            // MakeVoxPaletteMapping(shapeData, 25, 22, paletteMapping);

            using (StreamWriter writer = new StreamWriter(@"D:\Temp\FDII\paletteMapping3.txt"))
            {
                writer.WriteLine(paletteMapping.Count);
                List <byte> keys = paletteMapping.Keys.ToList();
                keys.Sort();

                foreach (byte key in keys)
                {
                    writer.WriteLine(key + " " + paletteMapping[key]);
                }
            }

            return(paletteMapping);
        }