Improve vv /c/enthover and add keybind (#20127)

This commit is contained in:
Leon Friedrich
2023-09-16 16:09:51 +12:00
committed by GitHub
parent 8e351bbf68
commit 411fc8e27b
11 changed files with 74 additions and 27 deletions

View File

@@ -344,7 +344,7 @@ public sealed class ListContainer : Control
}
}
public sealed class ListContainerButton : ContainerButton
public sealed class ListContainerButton : ContainerButton, IEntityControl
{
public readonly ListData Data;
// public PanelContainer Background;
@@ -359,6 +359,8 @@ public sealed class ListContainerButton : ContainerButton
// PanelOverride = new StyleBoxFlat {BackgroundColor = new Color(55, 55, 68)}
// });
}
public EntityUid? UiEntity => (Data as EntityListData)?.Uid;
}
#region Data

View File

@@ -8,7 +8,7 @@ using Robust.Shared.Input;
namespace Content.Client.UserInterface.Controls
{
[Virtual]
public abstract class SlotControl : Control
public abstract class SlotControl : Control, IEntityControl
{
public static int DefaultButtonSize = 64;
@@ -20,7 +20,7 @@ namespace Content.Client.UserInterface.Controls
public TextureButton StorageButton { get; }
public CooldownGraphic CooldownDisplay { get; }
public EntityUid? Entity => SpriteView.Sprite?.Owner;
public EntityUid? Entity => SpriteView.Entity;
private bool _slotNameSet;
@@ -232,5 +232,7 @@ namespace Content.Client.UserInterface.Controls
ButtonRect.Texture = Theme.ResolveTextureOrNull(_buttonTexturePath)?.Texture;
HighlightRect.Texture = Theme.ResolveTextureOrNull(_highlightTexturePath)?.Texture;
}
EntityUid? IEntityControl.UiEntity => Entity;
}
}

View File

@@ -0,0 +1,10 @@
namespace Content.Client.UserInterface;
/// <summary>
/// Simple interface that indicates that the given control is associated with some entity.
/// This is primarily intended to be used with VV, so that you can easily open the VV window to examine an entity.
/// </summary>
public interface IEntityControl
{
EntityUid? UiEntity { get; }
}

View File

@@ -19,7 +19,7 @@ using Direction = Robust.Shared.Maths.Direction;
namespace Content.Client.UserInterface.Systems.Actions.Controls;
public sealed class ActionButton : Control
public sealed class ActionButton : Control, IEntityControl
{
private IEntityManager? _entities;
@@ -197,7 +197,7 @@ public sealed class ActionButton : Control
private void UpdateItemIcon()
{
if (!Actions.TryGetActionData(ActionId, out var action) ||
action is not { EntityIcon: { } entity } ||
action is not {EntityIcon: { } entity} ||
!Entities.HasComponent<SpriteComponent>(entity))
{
_bigItemSpriteView.Visible = false;
@@ -344,7 +344,7 @@ public sealed class ActionButton : Control
public void Depress(GUIBoundKeyEventArgs args, bool depress)
{
// action can still be toggled if it's allowed to stay selected
if (!Actions.TryGetActionData(ActionId, out var action) || action is not { Enabled: true })
if (!Actions.TryGetActionData(ActionId, out var action) || action is not {Enabled: true})
return;
if (_depressed && !depress)
@@ -401,4 +401,6 @@ public sealed class ActionButton : Control
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassNormal);
}
EntityUid? IEntityControl.UiEntity => ActionId;
}