diff --git a/.editorconfig b/.editorconfig index 186026ff1f5..3e71517eba6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -115,6 +115,8 @@ csharp_new_line_before_finally = true csharp_new_line_before_members_in_object_initializers = false csharp_new_line_before_open_brace = all csharp_new_line_between_query_expression_clauses = true +resharper_csharp_place_simple_embedded_statement_on_same_line = never +resharper_csharp_keep_existing_embedded_arrangement = false # Indentation preferences #csharp_indent_block_contents = true diff --git a/Content.Client/Administration/AdminNameOverlay.cs b/Content.Client/Administration/AdminNameOverlay.cs index 01793a2fa1e..0d2526831de 100644 --- a/Content.Client/Administration/AdminNameOverlay.cs +++ b/Content.Client/Administration/AdminNameOverlay.cs @@ -1,3 +1,4 @@ +using Content.Client.Administration.Systems; using Robust.Client.Graphics; using Robust.Client.ResourceManagement; using Robust.Shared.Enums; diff --git a/Content.Client/Administration/Components/HeadstandComponent.cs b/Content.Client/Administration/Components/HeadstandComponent.cs new file mode 100644 index 00000000000..403d3260929 --- /dev/null +++ b/Content.Client/Administration/Components/HeadstandComponent.cs @@ -0,0 +1,10 @@ +using Content.Shared.Administration.Components; +using Robust.Shared.GameStates; + +namespace Content.Client.Administration.Components; + +[RegisterComponent, NetworkedComponent] +public sealed class HeadstandComponent : SharedHeadstandComponent +{ + +} diff --git a/Content.Client/Administration/QuickDialogSystem.cs b/Content.Client/Administration/QuickDialogSystem.cs new file mode 100644 index 00000000000..fcd439d9869 --- /dev/null +++ b/Content.Client/Administration/QuickDialogSystem.cs @@ -0,0 +1,154 @@ +using System.Linq; +using Content.Client.UserInterface; +using Content.Shared.Administration; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; + +namespace Content.Client.Administration; + +/// +/// This handles the client portion of quick dialogs. +/// +public sealed class QuickDialogSystem : EntitySystem +{ + /// + public override void Initialize() + { + SubscribeNetworkEvent(OpenDialog); + } + + private void OpenDialog(QuickDialogOpenEvent ev) + { + var window = new FancyWindow() + { + Title = ev.Title + }; + + var entryContainer = new BoxContainer() + { + Orientation = BoxContainer.LayoutOrientation.Vertical, + Margin = new Thickness(8), + }; + + var promptsDict = new Dictionary(); + + foreach (var entry in ev.Prompts) + { + var entryBox = new BoxContainer() + { + Orientation = BoxContainer.LayoutOrientation.Horizontal + }; + + entryBox.AddChild(new Label { Text = entry.Prompt, HorizontalExpand = true, SizeFlagsStretchRatio = 0.5f }); + var edit = new LineEdit() { HorizontalExpand = true}; + entryBox.AddChild(edit); + switch (entry.Type) + { + case QuickDialogEntryType.Integer: + edit.IsValid += VerifyInt; + edit.PlaceHolder = "Integer.."; + break; + case QuickDialogEntryType.Float: + edit.IsValid += VerifyFloat; + edit.PlaceHolder = "Float.."; + break; + case QuickDialogEntryType.ShortText: + edit.IsValid += VerifyShortText; + edit.PlaceHolder = "Short text.."; + break; + case QuickDialogEntryType.LongText: + edit.IsValid += VerifyLongText; + edit.PlaceHolder = "Long text.."; + break; + default: + throw new ArgumentOutOfRangeException(); + } + promptsDict.Add(entry.FieldId, edit); + entryContainer.AddChild(entryBox); + } + + var buttonsBox = new BoxContainer() + { + Orientation = BoxContainer.LayoutOrientation.Horizontal, + HorizontalAlignment = Control.HAlignment.Center, + }; + + var alreadyReplied = false; + + if ((ev.Buttons & QuickDialogButtonFlag.OkButton) != 0) + { + var okButton = new Button() + { + Text = "Ok", + }; + + okButton.OnPressed += _ => + { + RaiseNetworkEvent(new QuickDialogResponseEvent(ev.DialogId, + promptsDict.Select(x => (x.Key, x.Value.Text)).ToDictionary(x => x.Key, x => x.Text), + QuickDialogButtonFlag.OkButton)); + alreadyReplied = true; + window.Close(); + }; + + buttonsBox.AddChild(okButton); + } + + if ((ev.Buttons & QuickDialogButtonFlag.OkButton) != 0) + { + var cancelButton = new Button() + { + Text = "Cancel", + }; + + cancelButton.OnPressed += _ => + { + RaiseNetworkEvent(new QuickDialogResponseEvent(ev.DialogId, + new(), + QuickDialogButtonFlag.CancelButton)); + alreadyReplied = true; + window.Close(); + }; + + buttonsBox.AddChild(cancelButton); + } + + window.OnClose += () => + { + if (!alreadyReplied) + { + RaiseNetworkEvent(new QuickDialogResponseEvent(ev.DialogId, + new(), + QuickDialogButtonFlag.CancelButton)); + } + }; + + entryContainer.AddChild(buttonsBox); + + window.ContentsContainer.AddChild(entryContainer); + + window.MinWidth *= 2; // Just double it. + + window.OpenCentered(); + } + + private bool VerifyInt(string input) + { + return int.TryParse(input, out var _); + } + + private bool VerifyFloat(string input) + { + return float.TryParse(input, out var _); + } + + private bool VerifyShortText(string input) + { + return input.Length <= 100; + } + + private bool VerifyLongText(string input) + { + return input.Length <= 2000; + } +} diff --git a/Content.Client/Administration/AdminSystem.Menu.cs b/Content.Client/Administration/Systems/AdminSystem.Menu.cs similarity index 85% rename from Content.Client/Administration/AdminSystem.Menu.cs rename to Content.Client/Administration/Systems/AdminSystem.Menu.cs index 0def38a0990..c10cadd48a5 100644 --- a/Content.Client/Administration/AdminSystem.Menu.cs +++ b/Content.Client/Administration/Systems/AdminSystem.Menu.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; using Content.Client.Administration.Managers; using Content.Client.Administration.UI; +using Content.Client.Administration.UI.Tabs.ObjectsTab; using Content.Client.Administration.UI.Tabs.PlayerTab; using Content.Client.HUD; using Content.Client.Verbs; @@ -11,13 +11,11 @@ using Robust.Client.ResourceManagement; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; -using Robust.Shared.GameObjects; using Robust.Shared.Input; using Robust.Shared.Input.Binding; -using Robust.Shared.IoC; using Robust.Shared.Network; -namespace Content.Client.Administration +namespace Content.Client.Administration.Systems { public sealed partial class AdminSystem { @@ -101,13 +99,18 @@ public void Open() } _window.PlayerTabControl.OnEntryPressed += PlayerTabEntryPressed; + _window.ObjectsTabControl.OnEntryPressed += ObjectsTabEntryPressed; _window.OpenCentered(); } public void Close() { if (_window != null) + { _window.PlayerTabControl.OnEntryPressed -= PlayerTabEntryPressed; + _window.ObjectsTabControl.OnEntryPressed -= ObjectsTabEntryPressed; + } + _window?.Close(); foreach (var window in _commandWindows) @@ -163,5 +166,23 @@ private void PlayerTabEntryPressed(BaseButton.ButtonEventArgs args) args.Event.Handle(); } + + private void ObjectsTabEntryPressed(BaseButton.ButtonEventArgs args) + { + if (args.Button is not ObjectsTabEntry button) + return; + + var uid = button.AssocEntity; + var function = args.Event.Function; + + if (function == EngineKeyFunctions.UIClick) + _clientConsoleHost.ExecuteCommand($"vv {uid}"); + else if (function == ContentKeyFunctions.OpenContextMenu) + _verbSystem.VerbMenu.OpenVerbMenu(uid, true); + else + return; + + args.Event.Handle(); + } } } diff --git a/Content.Client/Administration/AdminSystem.Overlay.cs b/Content.Client/Administration/Systems/AdminSystem.Overlay.cs similarity index 96% rename from Content.Client/Administration/AdminSystem.Overlay.cs rename to Content.Client/Administration/Systems/AdminSystem.Overlay.cs index febb9d6421b..85611626d50 100644 --- a/Content.Client/Administration/AdminSystem.Overlay.cs +++ b/Content.Client/Administration/Systems/AdminSystem.Overlay.cs @@ -1,7 +1,7 @@ using Content.Client.Administration.Managers; using Robust.Client.Graphics; -namespace Content.Client.Administration +namespace Content.Client.Administration.Systems { public sealed partial class AdminSystem { diff --git a/Content.Client/Administration/AdminSystem.cs b/Content.Client/Administration/Systems/AdminSystem.cs similarity index 94% rename from Content.Client/Administration/AdminSystem.cs rename to Content.Client/Administration/Systems/AdminSystem.cs index 137a4ea3fb7..de62caa4ef4 100644 --- a/Content.Client/Administration/AdminSystem.cs +++ b/Content.Client/Administration/Systems/AdminSystem.cs @@ -1,13 +1,10 @@ -using System; -using System.Collections.Generic; using System.Linq; using Content.Shared.Administration; using Content.Shared.Administration.Events; using Content.Shared.GameTicking; -using Robust.Shared.GameObjects; using Robust.Shared.Network; -namespace Content.Client.Administration +namespace Content.Client.Administration.Systems { public sealed partial class AdminSystem : EntitySystem { diff --git a/Content.Client/Administration/AdminVerbSystem.cs b/Content.Client/Administration/Systems/AdminVerbSystem.cs similarity index 91% rename from Content.Client/Administration/AdminVerbSystem.cs rename to Content.Client/Administration/Systems/AdminVerbSystem.cs index cb440a92dac..9a6bfd705d5 100644 --- a/Content.Client/Administration/AdminVerbSystem.cs +++ b/Content.Client/Administration/Systems/AdminVerbSystem.cs @@ -1,10 +1,7 @@ using Content.Shared.Verbs; using Robust.Client.Console; -using Robust.Client.ViewVariables; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -namespace Content.Client.Verbs +namespace Content.Client.Administration.Systems { /// /// Client-side admin verb system. These usually open some sort of UIs. diff --git a/Content.Client/Administration/BwoinkSystem.cs b/Content.Client/Administration/Systems/BwoinkSystem.cs similarity index 96% rename from Content.Client/Administration/BwoinkSystem.cs rename to Content.Client/Administration/Systems/BwoinkSystem.cs index c04b5fdfd32..96076d96cf2 100644 --- a/Content.Client/Administration/BwoinkSystem.cs +++ b/Content.Client/Administration/Systems/BwoinkSystem.cs @@ -1,7 +1,5 @@ #nullable enable -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; using Content.Client.Administration.Managers; using Content.Client.Administration.UI; using Content.Client.Administration.UI.CustomControls; @@ -9,16 +7,13 @@ using Content.Shared.Administration; using JetBrains.Annotations; using Robust.Client.Graphics; -using Robust.Client.UserInterface.CustomControls; using Robust.Client.Player; -using Robust.Shared.GameObjects; -using Robust.Shared.Player; -using Robust.Shared.Localization; +using Robust.Client.UserInterface.CustomControls; using Robust.Shared.Audio; -using Robust.Shared.IoC; using Robust.Shared.Network; +using Robust.Shared.Player; -namespace Content.Client.Administration +namespace Content.Client.Administration.Systems { [UsedImplicitly] public sealed class BwoinkSystem : SharedBwoinkSystem diff --git a/Content.Client/Administration/Systems/HeadstandSystem.cs b/Content.Client/Administration/Systems/HeadstandSystem.cs new file mode 100644 index 00000000000..d0634e4ddd6 --- /dev/null +++ b/Content.Client/Administration/Systems/HeadstandSystem.cs @@ -0,0 +1,35 @@ +using Content.Client.Administration.Components; +using Robust.Client.GameObjects; + +namespace Content.Client.Administration.Systems; + +public sealed class HeadstandSystem : EntitySystem +{ + public override void Initialize() + { + SubscribeLocalEvent(OnHeadstandAdded); + SubscribeLocalEvent(OnHeadstandRemoved); + } + + private void OnHeadstandAdded(EntityUid uid, HeadstandComponent component, ComponentStartup args) + { + if (!TryComp(uid, out var sprite)) + return; + + foreach (var layer in sprite.AllLayers) + { + layer.Rotation += Angle.FromDegrees(180.0f); + } + } + + private void OnHeadstandRemoved(EntityUid uid, HeadstandComponent component, ComponentShutdown args) + { + if (!TryComp(uid, out var sprite)) + return; + + foreach (var layer in sprite.AllLayers) + { + layer.Rotation -= Angle.FromDegrees(180.0f); + } + } +} diff --git a/Content.Client/Administration/KillSignSystem.cs b/Content.Client/Administration/Systems/KillSignSystem.cs similarity index 96% rename from Content.Client/Administration/KillSignSystem.cs rename to Content.Client/Administration/Systems/KillSignSystem.cs index 2959593bb96..5d86c0d91ef 100644 --- a/Content.Client/Administration/KillSignSystem.cs +++ b/Content.Client/Administration/Systems/KillSignSystem.cs @@ -2,7 +2,7 @@ using Robust.Client.GameObjects; using Robust.Shared.Utility; -namespace Content.Client.Administration; +namespace Content.Client.Administration.Systems; public sealed class KillSignSystem : EntitySystem { diff --git a/Content.Client/Administration/UI/AdminAnnounceWindow.xaml b/Content.Client/Administration/UI/AdminAnnounceWindow.xaml index bb5c29bc788..a703a7f5e62 100644 --- a/Content.Client/Administration/UI/AdminAnnounceWindow.xaml +++ b/Content.Client/Administration/UI/AdminAnnounceWindow.xaml @@ -1,15 +1,15 @@ - + - + - public sealed class ParallaxControl : Control { + [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IParallaxManager _parallaxManager = default!; [Dependency] private readonly IRobustRandom _random = default!; - [ViewVariables(VVAccess.ReadWrite)] public Vector2i Offset { get; set; } + [ViewVariables(VVAccess.ReadWrite)] public Vector2 Offset { get; set; } public ParallaxControl() { @@ -24,20 +24,24 @@ public ParallaxControl() Offset = (_random.Next(0, 1000), _random.Next(0, 1000)); RectClipContent = true; + _parallaxManager.LoadParallaxByName("FastSpace"); } protected override void Draw(DrawingHandleScreen handle) { - foreach (var layer in _parallaxManager.ParallaxLayers) + foreach (var layer in _parallaxManager.GetParallaxLayers("FastSpace")) { var tex = layer.Texture; - var texSize = tex.Size * layer.Config.Scale.Floored(); + var texSize = (tex.Size.X * (int) Size.X, tex.Size.Y * (int) Size.X) * layer.Config.Scale.Floored() / 540; var ourSize = PixelSize; + var currentTime = (float) _timing.RealTime.TotalSeconds; + var offset = Offset + new Vector2(currentTime * 100f, currentTime * 0f); + if (layer.Config.Tiled) { // Multiply offset by slowness to match normal parallax - var scaledOffset = (Offset * layer.Config.Slowness).Floored(); + var scaledOffset = (offset * layer.Config.Slowness).Floored(); // Then modulo the scaled offset by the size to prevent drawing a bunch of offscreen tiles for really small images. scaledOffset.X %= texSize.X; diff --git a/Content.Client/Parallax/ParallaxOverlay.cs b/Content.Client/Parallax/ParallaxOverlay.cs index 89b27194263..1f401cde913 100644 --- a/Content.Client/Parallax/ParallaxOverlay.cs +++ b/Content.Client/Parallax/ParallaxOverlay.cs @@ -1,47 +1,55 @@ -using System; using Content.Client.Parallax.Managers; using Content.Shared.CCVar; using Robust.Client.Graphics; using Robust.Shared.Configuration; using Robust.Shared.Enums; -using Robust.Shared.IoC; -using Robust.Shared.Maths; +using Robust.Shared.Map; using Robust.Shared.Prototypes; +using Robust.Shared.Timing; namespace Content.Client.Parallax; public sealed class ParallaxOverlay : Overlay { - [Dependency] private readonly IParallaxManager _parallaxManager = default!; + [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!; + [Dependency] private readonly IParallaxManager _manager = default!; + private readonly ParallaxSystem _parallax; public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowWorld; - private readonly ShaderInstance _shader; public ParallaxOverlay() { IoCManager.InjectDependencies(this); - _shader = _prototypeManager.Index("unshaded").Instance(); + _parallax = IoCManager.Resolve().GetEntitySystem(); + } protected override void Draw(in OverlayDrawArgs args) { - if (args.Viewport.Eye == null) - { + if (args.MapId == MapId.Nullspace) return; - } if (!_configurationManager.GetCVar(CCVars.ParallaxEnabled)) - { return; - } + var position = args.Viewport.Eye?.Position.Position ?? Vector2.Zero; var screenHandle = args.WorldHandle; - screenHandle.UseShader(_shader); - foreach (var layer in _parallaxManager.ParallaxLayers) + var layers = _parallax.GetParallaxLayers(args.MapId); + var realTime = (float) _timing.RealTime.TotalSeconds; + + foreach (var layer in layers) { + ShaderInstance? shader; + + if (!string.IsNullOrEmpty(layer.Config.Shader)) + shader = _prototypeManager.Index(layer.Config.Shader).Instance(); + else + shader = null; + + screenHandle.UseShader(shader); var tex = layer.Texture; // Size of the texture in world units. @@ -52,10 +60,11 @@ protected override void Draw(in OverlayDrawArgs args) // The effects of this are such that a slowness of 1 anchors the layer to the centre of the screen, while a slowness of 0 anchors the layer to the world. // (For values 0.0 to 1.0 this is in effect a lerp, but it's deliberately unclamped.) // The ParallaxAnchor adapts the parallax for station positioning and possibly map-specific tweaks. - var home = layer.Config.WorldHomePosition + _parallaxManager.ParallaxAnchor; + var home = layer.Config.WorldHomePosition + _manager.ParallaxAnchor; + var scrolled = layer.Config.Scrolling * realTime; // Origin - start with the parallax shift itself. - var originBL = (args.Viewport.Eye.Position.Position - home) * layer.Config.Slowness; + var originBL = (position - home) * layer.Config.Slowness + scrolled; // Place at the home. originBL += home; @@ -90,6 +99,8 @@ protected override void Draw(in OverlayDrawArgs args) screenHandle.DrawTextureRect(tex, Box2.FromDimensions(originBL, size)); } } + + screenHandle.UseShader(null); } } diff --git a/Content.Client/Parallax/ParallaxSystem.cs b/Content.Client/Parallax/ParallaxSystem.cs new file mode 100644 index 00000000000..d3320ce1f97 --- /dev/null +++ b/Content.Client/Parallax/ParallaxSystem.cs @@ -0,0 +1,71 @@ +using Content.Client.Parallax.Managers; +using Content.Shared.Parallax; +using Robust.Client.Graphics; +using Robust.Shared.GameStates; +using Robust.Shared.Map; +using Robust.Shared.Prototypes; + +namespace Content.Client.Parallax; + +public sealed class ParallaxSystem : SharedParallaxSystem +{ + [Dependency] private readonly IMapManager _map = default!; + [Dependency] private readonly IOverlayManager _overlay = default!; + [Dependency] private readonly IParallaxManager _parallax = default!; + [Dependency] private readonly IPrototypeManager _protoManager = default!; + + private const string Fallback = "Default"; + + public override void Initialize() + { + base.Initialize(); + _overlay.AddOverlay(new ParallaxOverlay()); + SubscribeLocalEvent(OnParallaxHandleState); + _protoManager.PrototypesReloaded += OnReload; + } + + private void OnReload(PrototypesReloadedEventArgs obj) + { + _parallax.UnloadParallax(Fallback); + _parallax.LoadDefaultParallax(); + + foreach (var comp in EntityQuery(true)) + { + _parallax.UnloadParallax(comp.Parallax); + _parallax.LoadParallaxByName(comp.Parallax); + } + } + + public override void Shutdown() + { + base.Shutdown(); + _overlay.RemoveOverlay(); + _protoManager.PrototypesReloaded -= OnReload; + } + + private void OnParallaxHandleState(EntityUid uid, ParallaxComponent component, ref ComponentHandleState args) + { + if (args.Current is not ParallaxComponentState state) return; + component.Parallax = state.Parallax; + + if (!_parallax.IsLoaded(component.Parallax)) + { + _parallax.LoadParallaxByName(component.Parallax); + } + } + + public ParallaxLayerPrepared[] GetParallaxLayers(MapId mapId) + { + return _parallax.GetParallaxLayers(GetParallax(_map.GetMapEntityId(mapId))); + } + + public string GetParallax(MapId mapId) + { + return GetParallax(_map.GetMapEntityId(mapId)); + } + + public string GetParallax(EntityUid mapUid) + { + return TryComp(mapUid, out var parallax) ? parallax.Parallax : Fallback; + } +} diff --git a/Content.Client/Physics/Controllers/MoverController.cs b/Content.Client/Physics/Controllers/MoverController.cs index 6db507f00ee..51292f767bb 100644 --- a/Content.Client/Physics/Controllers/MoverController.cs +++ b/Content.Client/Physics/Controllers/MoverController.cs @@ -1,10 +1,7 @@ -using Content.Shared.MobState.Components; -using Content.Shared.Movement; using Content.Shared.Movement.Components; using Content.Shared.Movement.Systems; using Content.Shared.Pulling.Components; using Robust.Client.Player; -using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Player; using Robust.Shared.Timing; @@ -20,14 +17,47 @@ public override void UpdateBeforeSolve(bool prediction, float frameTime) { base.UpdateBeforeSolve(prediction, frameTime); - if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player || - !TryComp(player, out IMoverComponent? mover) || - !TryComp(player, out PhysicsComponent? body) || + if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player) + return; + + if (TryComp(player, out var relayMover)) + { + if (relayMover.RelayEntity != null) + HandleClientsideMovement(relayMover.RelayEntity.Value, frameTime); + } + + HandleClientsideMovement(player, frameTime); + } + + private void HandleClientsideMovement(EntityUid player, float frameTime) + { + if (!TryComp(player, out InputMoverComponent? mover) || !TryComp(player, out TransformComponent? xform)) { return; } + PhysicsComponent? body = null; + TransformComponent? xformMover = xform; + + if (mover.ToParent && HasComp(xform.ParentUid)) + { + if (!TryComp(xform.ParentUid, out body) || + !TryComp(xform.ParentUid, out xformMover)) + { + return; + } + + if (TryComp(xform.ParentUid, out var parentMover)) + { + mover.LastGridAngle = parentMover.LastGridAngle; + } + } + else if (!TryComp(player, out body)) + { + return; + } + if (xform.GridUid != null) mover.LastGridAngle = GetParentGridAngle(xform, mover); @@ -65,13 +95,7 @@ public override void UpdateBeforeSolve(bool prediction, float frameTime) } // Server-side should just be handled on its own so we'll just do this shizznit - if (TryComp(player, out IMobMoverComponent? mobMover)) - { - HandleMobMovement(mover, body, mobMover, xform, frameTime); - return; - } - - HandleKinematicMovement(mover, body); + HandleMobMovement(mover, body, xformMover, frameTime); } protected override Filter GetSoundPlayers(EntityUid mover) diff --git a/Content.Client/Popups/PopupSystem.cs b/Content.Client/Popups/PopupSystem.cs index aea17fec808..3841164bcbf 100644 --- a/Content.Client/Popups/PopupSystem.cs +++ b/Content.Client/Popups/PopupSystem.cs @@ -157,7 +157,8 @@ private static string GetStyleClass(PopupType type) => public override void FrameUpdate(float frameTime) { - if (_aliveWorldLabels.Count == 0) return; + if (_aliveWorldLabels.Count == 0 && _aliveCursorLabels.Count == 0) + return; var player = _playerManager.LocalPlayer?.ControlledEntity; var playerPos = player != null ? Transform(player.Value).MapPosition : MapCoordinates.Nullspace; @@ -234,13 +235,13 @@ private sealed class CursorPopupLabel : PopupLabel public CursorPopupLabel(ScreenCoordinates screenCoords) : base() { - InitialPos = screenCoords.Position / UIScale - DesiredSize / 2; + InitialPos = screenCoords.Position - DesiredSize / 2; } protected override void FrameUpdate(FrameEventArgs eventArgs) { base.FrameUpdate(eventArgs); - LayoutContainer.SetPosition(this, InitialPos - (0, 20 * (TotalTime * TotalTime + TotalTime))); + LayoutContainer.SetPosition(this, InitialPos / UIScale - (0, 20 * (TotalTime * TotalTime + TotalTime))); } } diff --git a/Content.Client/Research/UI/ResearchClientServerSelectionMenu.xaml.cs b/Content.Client/Research/UI/ResearchClientServerSelectionMenu.xaml.cs index 755e277b7f9..ceaa965e59f 100644 --- a/Content.Client/Research/UI/ResearchClientServerSelectionMenu.xaml.cs +++ b/Content.Client/Research/UI/ResearchClientServerSelectionMenu.xaml.cs @@ -2,8 +2,6 @@ using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; -using Robust.Shared.IoC; -using Robust.Shared.Localization; namespace Content.Client.Research.UI { @@ -11,8 +9,8 @@ namespace Content.Client.Research.UI public sealed partial class ResearchClientServerSelectionMenu : DefaultWindow { private int _serverCount; - private string[] _serverNames = System.Array.Empty(); - private int[] _serverIds = System.Array.Empty(); + private string[] _serverNames = Array.Empty(); + private int[] _serverIds = Array.Empty(); private int _selectedServerId = -1; private ResearchClientBoundUserInterface Owner { get; } diff --git a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs index 63f71f8dc2f..d4056584201 100644 --- a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs +++ b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs @@ -18,7 +18,6 @@ protected override void Open() { base.Open(); _window = new ShuttleConsoleWindow(); - _window.ShuttleModePressed += OnShuttleModePressed; _window.UndockPressed += OnUndockPressed; _window.StartAutodockPressed += OnAutodockPressed; _window.StopAutodockPressed += OnStopAutodockPressed; @@ -65,11 +64,6 @@ private void OnUndockPressed(EntityUid obj) SendMessage(new UndockRequestMessage() {DockEntity = obj}); } - private void OnShuttleModePressed(ShuttleMode obj) - { - SendMessage(new ShuttleModeRequestMessage() {Mode = obj}); - } - protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); diff --git a/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs b/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs index 7ae419c358b..f9e01c09fd8 100644 --- a/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs +++ b/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs @@ -1,16 +1,43 @@ +using Content.Shared.Input; using Content.Shared.Shuttles.Components; -using Content.Shared.Shuttles.Events; using Content.Shared.Shuttles.Systems; +using Robust.Client.Input; +using Robust.Client.Player; using Robust.Shared.GameStates; namespace Content.Client.Shuttles.Systems { public sealed class ShuttleConsoleSystem : SharedShuttleConsoleSystem { + [Dependency] private readonly IInputManager _input = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnHandleState); + var shuttle = _input.Contexts.New("shuttle", "common"); + shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeUp); + shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeDown); + shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeLeft); + shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeRight); + shuttle.AddFunction(ContentKeyFunctions.ShuttleRotateLeft); + shuttle.AddFunction(ContentKeyFunctions.ShuttleRotateRight); + shuttle.AddFunction(ContentKeyFunctions.ShuttleBrake); + } + + public override void Shutdown() + { + base.Shutdown(); + _input.Contexts.Remove("shuttle"); + } + + protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args) + { + base.HandlePilotShutdown(uid, component, args); + if (_playerManager.LocalPlayer?.ControlledEntity != uid) return; + + _input.Contexts.SetActiveContext("human"); } private void OnHandleState(EntityUid uid, PilotComponent component, ref ComponentHandleState args) @@ -21,6 +48,7 @@ private void OnHandleState(EntityUid uid, PilotComponent component, ref Componen if (!console.IsValid()) { component.Console = null; + _input.Contexts.SetActiveContext("human"); return; } @@ -32,6 +60,7 @@ private void OnHandleState(EntityUid uid, PilotComponent component, ref Componen component.Console = shuttleConsoleComponent; ActionBlockerSystem.UpdateCanMove(uid); + _input.Contexts.SetActiveContext("shuttle"); } } } diff --git a/Content.Client/Shuttles/UI/DockingControl.cs b/Content.Client/Shuttles/UI/DockingControl.cs index 2c37f623570..7daa9c18986 100644 --- a/Content.Client/Shuttles/UI/DockingControl.cs +++ b/Content.Client/Shuttles/UI/DockingControl.cs @@ -16,7 +16,6 @@ public class DockingControl : Control private readonly IEntityManager _entManager; private readonly IMapManager _mapManager; - private const int MinimapRadius = 384; private const int MinimapMargin = 4; private float _range = 8f; @@ -24,8 +23,8 @@ public class DockingControl : Control private const float GridLinesDistance = 32f; private int MidPoint => SizeFull / 2; - private int SizeFull => (int) ((MinimapRadius + MinimapMargin) * 2 * UIScale); - private int ScaledMinimapRadius => (int) (MinimapRadius * UIScale); + private int SizeFull => (int) ((RadarControl.MinimapRadius + MinimapMargin) * 2 * UIScale); + private int ScaledMinimapRadius => (int) (RadarControl.MinimapRadius * UIScale); private float MinimapScale => _range != 0 ? ScaledMinimapRadius / _range : 0f; public EntityUid? ViewedDock; diff --git a/Content.Client/Shuttles/UI/RadarControl.cs b/Content.Client/Shuttles/UI/RadarControl.cs index fd846746c03..01bd88fc25e 100644 --- a/Content.Client/Shuttles/UI/RadarControl.cs +++ b/Content.Client/Shuttles/UI/RadarControl.cs @@ -22,7 +22,7 @@ public sealed class RadarControl : Control private const float ScrollSensitivity = 8f; - private const int MinimapRadius = 320; + public const int MinimapRadius = 320; private const int MinimapMargin = 4; private const float GridLinesDistance = 32f; @@ -73,6 +73,7 @@ public RadarControl() { IoCManager.InjectDependencies(this); MinSize = (SizeFull, SizeFull); + RectClipContent = true; } public void SetMatrix(EntityCoordinates? coordinates, Angle? angle) diff --git a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml index 548c136d0aa..fe80948aa86 100644 --- a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml +++ b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml @@ -83,10 +83,6 @@ Align="Right"/> -