Add toggle ghost visibility button to ghost GUI (#12325)
* Add toggle ghost visibility button to ghosts * Rename to toggleghosts
This commit is contained in:
@@ -155,5 +155,10 @@ namespace Content.Client.Ghost
|
|||||||
{
|
{
|
||||||
_console.RemoteExecuteCommand(null, "ghostroles");
|
_console.RemoteExecuteCommand(null, "ghostroles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ToggleGhostVisibility()
|
||||||
|
{
|
||||||
|
_console.RemoteExecuteCommand(null, "toggleghosts");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSyst
|
|||||||
Gui.RequestWarpsPressed += RequestWarps;
|
Gui.RequestWarpsPressed += RequestWarps;
|
||||||
Gui.ReturnToBodyPressed += ReturnToBody;
|
Gui.ReturnToBodyPressed += ReturnToBody;
|
||||||
Gui.GhostRolesPressed += GhostRolesPressed;
|
Gui.GhostRolesPressed += GhostRolesPressed;
|
||||||
|
Gui.ToggleGhostVisibility += ToggleGhostVisibility;
|
||||||
Gui.TargetWindow.WarpClicked += OnWarpClicked;
|
Gui.TargetWindow.WarpClicked += OnWarpClicked;
|
||||||
|
|
||||||
UpdateGui();
|
UpdateGui();
|
||||||
@@ -112,6 +113,7 @@ public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSyst
|
|||||||
Gui.RequestWarpsPressed -= RequestWarps;
|
Gui.RequestWarpsPressed -= RequestWarps;
|
||||||
Gui.ReturnToBodyPressed -= ReturnToBody;
|
Gui.ReturnToBodyPressed -= ReturnToBody;
|
||||||
Gui.GhostRolesPressed -= GhostRolesPressed;
|
Gui.GhostRolesPressed -= GhostRolesPressed;
|
||||||
|
Gui.ToggleGhostVisibility -= ToggleGhostVisibility;
|
||||||
Gui.TargetWindow.WarpClicked -= OnWarpClicked;
|
Gui.TargetWindow.WarpClicked -= OnWarpClicked;
|
||||||
|
|
||||||
Gui.Hide();
|
Gui.Hide();
|
||||||
@@ -133,4 +135,9 @@ public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSyst
|
|||||||
{
|
{
|
||||||
_system?.OpenGhostRoles();
|
_system?.OpenGhostRoles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ToggleGhostVisibility()
|
||||||
|
{
|
||||||
|
_system?.ToggleGhostVisibility();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,6 @@
|
|||||||
<Button Name="ReturnToBodyButton" Text="{Loc ghost-gui-return-to-body-button}" />
|
<Button Name="ReturnToBodyButton" Text="{Loc ghost-gui-return-to-body-button}" />
|
||||||
<Button Name="GhostWarpButton" Text="{Loc ghost-gui-ghost-warp-button}" />
|
<Button Name="GhostWarpButton" Text="{Loc ghost-gui-ghost-warp-button}" />
|
||||||
<Button Name="GhostRolesButton" />
|
<Button Name="GhostRolesButton" />
|
||||||
|
<Button Name="ToggleGhostVisibilityButton" Text="{Loc ghost-gui-toggle-ghost-visibility-button}" />
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</widgets:GhostGui>
|
</widgets:GhostGui>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public sealed partial class GhostGui : UIWidget
|
|||||||
public event Action? RequestWarpsPressed;
|
public event Action? RequestWarpsPressed;
|
||||||
public event Action? ReturnToBodyPressed;
|
public event Action? ReturnToBodyPressed;
|
||||||
public event Action? GhostRolesPressed;
|
public event Action? GhostRolesPressed;
|
||||||
|
public event Action? ToggleGhostVisibility;
|
||||||
|
|
||||||
public GhostGui()
|
public GhostGui()
|
||||||
{
|
{
|
||||||
@@ -26,6 +27,7 @@ public sealed partial class GhostGui : UIWidget
|
|||||||
GhostWarpButton.OnPressed += _ => RequestWarpsPressed?.Invoke();
|
GhostWarpButton.OnPressed += _ => RequestWarpsPressed?.Invoke();
|
||||||
ReturnToBodyButton.OnPressed += _ => ReturnToBodyPressed?.Invoke();
|
ReturnToBodyButton.OnPressed += _ => ReturnToBodyPressed?.Invoke();
|
||||||
GhostRolesButton.OnPressed += _ => GhostRolesPressed?.Invoke();
|
GhostRolesButton.OnPressed += _ => GhostRolesPressed?.Invoke();
|
||||||
|
ToggleGhostVisibilityButton.OnPressed += _ => ToggleGhostVisibility?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Hide()
|
public void Hide()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Content.Server.Storage.Components;
|
|||||||
using Content.Server.Visible;
|
using Content.Server.Visible;
|
||||||
using Content.Server.Warps;
|
using Content.Server.Warps;
|
||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
|
using Content.Shared.Administration;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Follower;
|
using Content.Shared.Follower;
|
||||||
using Content.Shared.Ghost;
|
using Content.Shared.Ghost;
|
||||||
@@ -17,6 +18,7 @@ using Content.Shared.Movement.Events;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.Physics.Components;
|
using Robust.Shared.Physics.Components;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -296,4 +298,27 @@ namespace Content.Server.Ghost
|
|||||||
return ghostBoo.Handled;
|
return ghostBoo.Handled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AnyCommand]
|
||||||
|
public sealed class ToggleGhostVisibility : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Command => "toggleghosts";
|
||||||
|
public string Description => "Toggles ghost visibility";
|
||||||
|
public string Help => $"{Command}";
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
if (shell.Player == null)
|
||||||
|
shell.WriteLine("You can only open the ghost roles UI on a client.");
|
||||||
|
|
||||||
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
|
||||||
|
var uid = shell.Player?.AttachedEntity;
|
||||||
|
if (uid == null
|
||||||
|
|| !entityManager.HasComponent<GhostComponent>(uid)
|
||||||
|
|| !entityManager.TryGetComponent<EyeComponent>(uid, out var eyeComponent))
|
||||||
|
return;
|
||||||
|
|
||||||
|
eyeComponent.VisibilityMask ^= (uint) VisibilityFlags.Ghost;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
ghost-gui-return-to-body-button = Return to body
|
ghost-gui-return-to-body-button = Return to body
|
||||||
ghost-gui-ghost-warp-button = Ghost Warp
|
ghost-gui-ghost-warp-button = Ghost Warp
|
||||||
ghost-gui-ghost-roles-button = Ghost Roles ({$count})
|
ghost-gui-ghost-roles-button = Ghost Roles ({$count})
|
||||||
|
ghost-gui-toggle-ghost-visibility-button = Toggle Ghosts
|
||||||
|
|
||||||
ghost-target-window-title = Ghost Warp
|
ghost-target-window-title = Ghost Warp
|
||||||
ghost-target-window-current-button = Warp: {$name}
|
ghost-target-window-current-button = Warp: {$name}
|
||||||
|
|||||||
Reference in New Issue
Block a user