Add skip exterior for terrain set all

https://github.com/kwsch/NHSE/issues/122#issuecomment-619472394
This commit is contained in:
Kurt
2020-04-25 21:40:34 -07:00
parent b3629e9049
commit 214638ce2c
3 changed files with 26 additions and 2 deletions

View File

@@ -60,5 +60,27 @@ public void ImportAcre(int acre, byte[] data)
tile.CopyFrom(tiles[i]);
}
}
public void SetAll(TerrainTile tile, in bool interiorOnly)
{
if (interiorOnly)
{
// skip outermost ring of tiles
int xmin = GridWidth;
int ymin = GridHeight;
int xmax = MapWidth - GridWidth;
int ymax = MapHeight - GridHeight;
for (int x = xmin; x < xmax; x++)
{
for (int y = ymin; y < ymax; y++)
GetTile(x, y).CopyFrom(tile);
}
}
else
{
foreach (var t in Tiles)
t.CopyFrom(tile);
}
}
}
}

View File

@@ -216,9 +216,10 @@ private void B_SetAll_Click(object sender, EventArgs e)
{
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MessageStrings.MsgTerrainSetAll))
return;
var pgt = (TerrainTile)PG_Tile.SelectedObject;
foreach (var t in Terrain.Tiles)
t.CopyFrom(pgt);
bool interiorOnly = DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MessageStrings.MsgTerrainSetAllSkipExterior);
Terrain.SetAll(pgt, interiorOnly);
LoadGrid(X, Y);
System.Media.SystemSounds.Asterisk.Play();
}

View File

@@ -38,5 +38,6 @@ public static class MessageStrings
public static string MsgTerrainSetElevation0 { get; set; } = "Set the elevation of all tiles on the map to 0?";
public static string MsgTerrainSetAll { get; set; } = "Set the tile from the Tile Editor to all tiles on the map?";
public static string MsgTerrainSetAllSkipExterior { get; set; } = "Do you want to skip the tiles in exterior acres (beach/rocks)?";
}
}