Add a command to hide replay UI (#19956)
This commit is contained in:
30
Content.Client/Ghost/GhostToggleSelfVisibility.cs
Normal file
30
Content.Client/Ghost/GhostToggleSelfVisibility.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Content.Shared.Ghost;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
|
namespace Content.Client.Ghost;
|
||||||
|
|
||||||
|
public sealed class GhostToggleSelfVisibility : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Command => "toggleselfghost";
|
||||||
|
public string Description => "Toggles seeing your own ghost.";
|
||||||
|
public string Help => "toggleselfghost";
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
var attachedEntity = shell.Player?.AttachedEntity;
|
||||||
|
if (!attachedEntity.HasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
if (!entityManager.HasComponent<GhostComponent>(attachedEntity))
|
||||||
|
{
|
||||||
|
shell.WriteError("Entity must be a ghost.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entityManager.TryGetComponent(attachedEntity, out SpriteComponent? spriteComponent))
|
||||||
|
return;
|
||||||
|
|
||||||
|
spriteComponent.Visible = !spriteComponent.Visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,6 +46,8 @@ public sealed class ContentReplayPlaybackManager
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Type? DefaultState;
|
public Type? DefaultState;
|
||||||
|
|
||||||
|
public bool IsScreenshotMode = false;
|
||||||
|
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
|
|||||||
35
Content.Client/Replay/ReplayToggleScreenshotModeCommand.cs
Normal file
35
Content.Client/Replay/ReplayToggleScreenshotModeCommand.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using Content.Client.UserInterface.Systems.Chat;
|
||||||
|
using Content.Shared.Chat;
|
||||||
|
using Robust.Client.Replays.Commands;
|
||||||
|
using Robust.Client.Replays.UI;
|
||||||
|
using Robust.Client.UserInterface;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
|
namespace Content.Client.Replay;
|
||||||
|
|
||||||
|
public sealed class ReplayToggleScreenshotModeCommand : BaseReplayCommand
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||||
|
[Dependency] private readonly ContentReplayPlaybackManager _replayManager = default!;
|
||||||
|
|
||||||
|
public override string Command => "replay_toggle_screenshot_mode";
|
||||||
|
|
||||||
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
var screen = _userInterfaceManager.ActiveScreen;
|
||||||
|
if (screen == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_replayManager.IsScreenshotMode = !_replayManager.IsScreenshotMode;
|
||||||
|
|
||||||
|
var showReplayWidget = _replayManager.IsScreenshotMode;
|
||||||
|
screen.ShowWidget<ReplayControlWidget>(showReplayWidget);
|
||||||
|
|
||||||
|
foreach (var chatBox in _userInterfaceManager.GetUIController<ChatUIController>().Chats)
|
||||||
|
{
|
||||||
|
chatBox.ChatInput.Visible = !showReplayWidget;
|
||||||
|
if (!showReplayWidget)
|
||||||
|
chatBox.ChatInput.ChannelSelector.Select(ChatSelectChannel.Local);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ namespace Content.Client.Replay.UI;
|
|||||||
[Virtual]
|
[Virtual]
|
||||||
public class ReplaySpectateEntityState : GameplayState
|
public class ReplaySpectateEntityState : GameplayState
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly ContentReplayPlaybackManager _replayManager = default!;
|
||||||
|
|
||||||
protected override void Startup()
|
protected override void Startup()
|
||||||
{
|
{
|
||||||
base.Startup();
|
base.Startup();
|
||||||
@@ -21,11 +23,13 @@ public class ReplaySpectateEntityState : GameplayState
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
screen.ShowWidget<GameTopMenuBar>(false);
|
screen.ShowWidget<GameTopMenuBar>(false);
|
||||||
SetAnchorAndMarginPreset(screen.GetOrAddWidget<ReplayControlWidget>(), LayoutPreset.TopLeft, margin: 10);
|
var replayWidget = screen.GetOrAddWidget<ReplayControlWidget>();
|
||||||
|
SetAnchorAndMarginPreset(replayWidget, LayoutPreset.TopLeft, margin: 10);
|
||||||
|
replayWidget.Visible = !_replayManager.IsScreenshotMode;
|
||||||
|
|
||||||
foreach (var chatbox in UserInterfaceManager.GetUIController<ChatUIController>().Chats)
|
foreach (var chatbox in UserInterfaceManager.GetUIController<ChatUIController>().Chats)
|
||||||
{
|
{
|
||||||
chatbox.ChatInput.Visible = false;
|
chatbox.ChatInput.Visible = _replayManager.IsScreenshotMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user