|
|
|
@ -5,12 +5,11 @@ public partial class TerrainEditingControls |
|
|
|
|
public (ToolMode , Button)[] ToolModeButtons { get; private set; } |
|
|
|
|
public (ToolShape, Button)[] ToolShapeButtons { get; private set; } |
|
|
|
|
public Button[] PaintTextureButtons { get; private set; } |
|
|
|
|
|
|
|
|
|
public Slider DrawSizeSlider { get; private set; } |
|
|
|
|
|
|
|
|
|
ToolMode _toolMode; |
|
|
|
|
ToolShape _toolShape; |
|
|
|
|
int _texture; |
|
|
|
|
ToolMode _toolMode = ToolMode.Height; |
|
|
|
|
ToolShape _toolShape = ToolShape.Circle; |
|
|
|
|
int _texture = 1; |
|
|
|
|
|
|
|
|
|
public ToolMode ToolMode { get => _toolMode ; set => SetToolMode (value); } |
|
|
|
|
public ToolShape ToolShape { get => _toolShape; set => SetToolShape(value); } |
|
|
|
@ -52,16 +51,17 @@ public partial class TerrainEditingControls |
|
|
|
|
DrawSizeSlider = GetNode<Slider>("SizeSlider"); |
|
|
|
|
DrawSizeSlider.ValueChanged += (_) => drawSizeLabel.Text = $"{DrawSize}"; |
|
|
|
|
|
|
|
|
|
SetToolMode(ToolMode.Height); |
|
|
|
|
SetToolShape(ToolShape.Circle); |
|
|
|
|
SetTexture(1); |
|
|
|
|
|
|
|
|
|
OnEditingReady(); |
|
|
|
|
SetToolMode(_toolMode); |
|
|
|
|
SetToolShape(_toolShape); |
|
|
|
|
SetTexture(_texture); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SetToolMode(ToolMode value) |
|
|
|
|
{ |
|
|
|
|
// Ignore if _Ready hasn't been called yet. |
|
|
|
|
if (ToolModeButtons == null) return; |
|
|
|
|
|
|
|
|
|
foreach (var (mode, button) in ToolModeButtons) |
|
|
|
|
button.Flat = button.ButtonPressed = value != mode; |
|
|
|
|
foreach (var button in PaintTextureButtons) |
|
|
|
@ -71,6 +71,9 @@ public partial class TerrainEditingControls |
|
|
|
|
|
|
|
|
|
void SetToolShape(ToolShape value) |
|
|
|
|
{ |
|
|
|
|
// Ignore if _Ready hasn't been called yet. |
|
|
|
|
if (ToolShapeButtons == null) return; |
|
|
|
|
|
|
|
|
|
foreach (var (shape, button) in ToolShapeButtons) |
|
|
|
|
button.Flat = button.ButtonPressed = value != shape; |
|
|
|
|
DrawSizeSlider.Editable = value != ToolShape.Corner; |
|
|
|
@ -79,6 +82,9 @@ public partial class TerrainEditingControls |
|
|
|
|
|
|
|
|
|
void SetTexture(int value) |
|
|
|
|
{ |
|
|
|
|
// Ignore if _Ready hasn't been called yet. |
|
|
|
|
if (PaintTextureButtons == null) return; |
|
|
|
|
|
|
|
|
|
if ((value < 1) || (value > PaintTextureButtons.Length)) |
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(value)); |
|
|
|
|
foreach (var (i, button) in PaintTextureButtons.Select((b, i) => (i, b))) |
|
|
|
|