Example #1
0
        public static bool ImportTerrainAll(TerrainLayer m)
        {
            using var ofd = new OpenFileDialog
                  {
                      Filter   = "New Horizons Terrain (*.nht)|*.nht|All files (*.*)|*.*",
                      FileName = "terrainAcres.nht",
                  };
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            var path = ofd.FileName;
            var fi   = new FileInfo(path);

            int expect = m.MaxTileCount * TerrainTile.SIZE;

            if (fi.Length != expect)
            {
                WinFormsUtil.Error(string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expect));
                return(false);
            }

            var data = File.ReadAllBytes(path);

            m.ImportAll(data);
            return(true);
        }