Ejemplo n.º 1
0
        private void newMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (NewMapDialog dlg = new NewMapDialog())
            {
                DialogResult result;

                result = dlg.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return;
                }

                int tw = (dlg.MapWidth + WorldMap.tileSize - 1) / WorldMap.tileSize;
                int th = (dlg.MapHeight + WorldMap.tileSize - 1) / WorldMap.tileSize;

                imageGrid.WidthCells  = tw;
                imageGrid.HeightCells = th;
                imageGrid.Enabled     = true;

                int tx, tz;

                if ((tw <= WorldMap.tilesPerSection) && (th <= WorldMap.tilesPerSection))
                {
                    // if the world fits in a single section, then center it in section 0,0
                    tx = (WorldMap.tilesPerSection - tw) / 2;
                    tz = (WorldMap.tilesPerSection - th) / 2;
                }
                else
                {
                    // if the world doesn't fit in a single section, then center on the origin
                    tx = -tw / 2;
                    tz = -th / 2;
                }

                CoordXZ minTile = new CoordXZ(tx, tz, WorldMap.tileSize);
                CoordXZ maxTile = new CoordXZ(tx + tw - 1, tz + th - 1, WorldMap.tileSize);

                worldMap = new WorldMap(dlg.MapName, minTile, maxTile, dlg.MinTerrainHeight, dlg.MaxTerrainHeight, dlg.DefaultTerrainHeight);

                currentViewLayer = worldMap.GetLayer("heightfield");

                gridOffset = minTile;

                InitTreeView();
            }
        }
        private void newMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (NewMapDialog dlg = new NewMapDialog())
            {
                DialogResult result;

                result = dlg.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return;
                }

                int tw = (dlg.MapWidth + WorldMap.tileSize - 1) / WorldMap.tileSize;
                int th = (dlg.MapHeight + WorldMap.tileSize - 1) / WorldMap.tileSize;

                imageGrid.WidthCells = tw;
                imageGrid.HeightCells = th;
                imageGrid.Enabled = true;

                int tx, tz;

                if ((tw <= WorldMap.tilesPerSection) && (th <= WorldMap.tilesPerSection))
                {
                    // if the world fits in a single section, then center it in section 0,0
                    tx = (WorldMap.tilesPerSection - tw) / 2;
                    tz = (WorldMap.tilesPerSection - th) / 2;
                }
                else
                {
                    // if the world doesn't fit in a single section, then center on the origin
                    tx = -tw / 2;
                    tz = -th / 2;
                }

                CoordXZ minTile = new CoordXZ(tx, tz, WorldMap.tileSize);
                CoordXZ maxTile = new CoordXZ(tx + tw - 1, tz + th - 1, WorldMap.tileSize);

                worldMap = new WorldMap(dlg.MapName, minTile, maxTile, dlg.MinTerrainHeight, dlg.MaxTerrainHeight, dlg.DefaultTerrainHeight);

                currentViewLayer = worldMap.GetLayer("heightfield");

                gridOffset = minTile;

                InitTreeView();
            }
        }