예제 #1
0
 MiniYaml SaveTerrainInfo(TerrainTypeInfo t)
 {
     return(FieldSaver.SaveDifferences(t, new TerrainTypeInfo(new MiniYaml("TerrainType"))));
 }
예제 #2
0
파일: Form1.cs 프로젝트: test71/OpenRA
        void ExportClicked(object sender, EventArgs e)
        {
            var dir = Path.Combine(Path.GetDirectoryName(srcfile), "output");

            Directory.CreateDirectory(dir);

            // Create a Tileset definition
            // Todo: Pull this info from the gui
            var tilesetFile = "tileset-arrakis.yaml";
            //var mixFile = "arrakis.mix";
            var tileset = new TileSet()
            {
                Name       = "Arrakis",
                Id         = "ARRAKIS",
                TileSize   = size,
                Palette    = "arrakis.pal",
                Extensions = new string[] { ".arr", ".shp" }
            };

            // List of files to add to the mix file
            List <string> fileList = new List <string>();

            // Export palette (use the embedded palette)
            var p = surface1.Image.Palette.Entries.ToList();

            fileList.Add(ExportPalette(p, Path.Combine(dir, tileset.Palette)));

            // Export tile artwork
            foreach (var t in surface1.Templates)
            {
                fileList.Add(ExportTemplate(t, surface1.Templates.IndexOf(t), tileset.Extensions.First(), dir));
            }

            // Add the terraintypes
            // Todo: add support for multiple/different terraintypes
            var terraintype = new TerrainTypeInfo()
            {
                Type         = "Clear",
                AcceptSmudge = true,
                IsWater      = false,
                Color        = Color.White
            };

            tileset.Terrain.Add("Clear", terraintype);

            // Add the templates
            ushort cur = 0;

            foreach (var tp in surface1.Templates)
            {
                var template = new TileTemplate()
                {
                    Id    = cur,
                    Image = "t{0:00}".F(cur),
                    Size  = new int2(tp.Width, tp.Height),
                };

                // Todo: add support for different terraintypes
                // Todo: restrict cells? this doesn't work: .Where( c => surface1.TerrainTypes[c.Key.X, c.Key.Y] != 0 )
                foreach (var t in tp.Cells)
                {
                    template.Tiles.Add((byte)((t.Key.X - tp.Left) + tp.Width * (t.Key.Y - tp.Top)), "Clear");
                }

                tileset.Templates.Add(cur, template);
                cur++;
            }

            tileset.Save(Path.Combine(dir, tilesetFile));
            throw new NotImplementedException("NotI");
            //PackageWriter.CreateMix(Path.Combine(dir, mixFile),fileList);

            /*
             * // Cleanup
             * foreach (var file in fileList)
             *      File.Delete(file);
             *
             * Console.WriteLine("Finished export");
             */
        }