Show current rotation in entity spawn window (#2129)

This commit is contained in:
20kdc
2021-10-21 13:24:56 +01:00
committed by GitHub
parent d18bf3d5ac
commit 079702347d
3 changed files with 41 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
using System;
using Robust.Shared.Enums;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
namespace Robust.Client.Placement
@@ -12,6 +13,16 @@ namespace Robust.Client.Placement
PlacementMode? CurrentMode { get; set; }
PlacementInformation? CurrentPermission { get; set; }
/// <summary>
/// The direction to spawn the entity in (presently exposed for EntitySpawnWindow UI)
/// </summary>
Direction Direction { get; set; }
/// <summary>
/// Gets called when Direction changed (presently for EntitySpawnWindow UI)
/// </summary>
event EventHandler DirectionChanged;
/// <summary>
/// Gets called when the PlacementManager changed its build/erase mode or when the hijacks changed
/// </summary>

View File

@@ -143,10 +143,21 @@ namespace Robust.Client.Placement
set => _colliderAABB = value;
}
/// <summary>
/// The directional to spawn the entity in
/// </summary>
public Direction Direction { get; set; } = Direction.South;
private Direction _direction = Direction.South;
/// <inheritdoc />
public Direction Direction
{
get => _direction;
set
{
_direction = value;
DirectionChanged?.Invoke(this, EventArgs.Empty);
}
}
/// <inheritdoc />
public event EventHandler? DirectionChanged;
private PlacementOverlay _drawOverlay = default!;
private bool _isActive;

View File

@@ -28,6 +28,7 @@ namespace Robust.Client.UserInterface.CustomControls
private OptionButton OverrideMenu;
private Button ClearButton;
private Button EraseButton;
private Label RotationLabel;
private EntitySpawnButton MeasureButton;
@@ -122,6 +123,7 @@ namespace Robust.Client.UserInterface.CustomControls
})
}
},
(RotationLabel = new Label()),
new DoNotMeasure
{
Visible = false,
@@ -149,6 +151,8 @@ namespace Robust.Client.UserInterface.CustomControls
BuildEntityList();
this.placementManager.PlacementChanged += OnPlacementCanceled;
this.placementManager.DirectionChanged += OnDirectionChanged;
UpdateDirectionLabel();
SearchBar.GrabKeyboardFocus();
}
@@ -162,6 +166,7 @@ namespace Robust.Client.UserInterface.CustomControls
placementManager.Clear();
placementManager.PlacementChanged -= OnPlacementCanceled;
placementManager.DirectionChanged -= OnDirectionChanged;
}
private void OnSearchBarTextChanged(LineEdit.LineEditEventArgs args)
@@ -512,6 +517,16 @@ namespace Robust.Client.UserInterface.CustomControls
OverrideMenu.Disabled = false;
}
private void OnDirectionChanged(object? sender, EventArgs e)
{
UpdateDirectionLabel();
}
private void UpdateDirectionLabel()
{
RotationLabel.Text = placementManager.Direction.ToString();
}
private class DoNotMeasure : Control
{
protected override Vector2 MeasureOverride(Vector2 availableSize)