diff --git a/Content.Client/Medical/CrewMonitoring/CrewMonitoringNavMapControl.cs b/Content.Client/Medical/CrewMonitoring/CrewMonitoringNavMapControl.cs index e6adf13bed..fcecbad465 100644 --- a/Content.Client/Medical/CrewMonitoring/CrewMonitoringNavMapControl.cs +++ b/Content.Client/Medical/CrewMonitoring/CrewMonitoringNavMapControl.cs @@ -9,7 +9,6 @@ public sealed partial class CrewMonitoringNavMapControl : NavMapControl public NetEntity? Focus; public Dictionary LocalizedNames = new(); - private Color _backgroundColor; private Label _trackedEntityLabel; private PanelContainer _trackedEntityPanel; @@ -17,8 +16,7 @@ public sealed partial class CrewMonitoringNavMapControl : NavMapControl { WallColor = new Color(192, 122, 196); TileColor = new(71, 42, 72); - - _backgroundColor = Color.FromSrgb(TileColor.WithAlpha(0.8f)); + _backgroundColor = Color.FromSrgb(TileColor.WithAlpha(_backgroundOpacity)); _trackedEntityLabel = new Label { diff --git a/Content.Client/Pinpointer/UI/NavMapControl.cs b/Content.Client/Pinpointer/UI/NavMapControl.cs index d3c505e49f..320c5f899a 100644 --- a/Content.Client/Pinpointer/UI/NavMapControl.cs +++ b/Content.Client/Pinpointer/UI/NavMapControl.cs @@ -1,5 +1,6 @@ using Content.Client.Stylesheets; using Content.Client.UserInterface.Controls; +using Content.Shared.Input; using Content.Shared.Pinpointer; using Robust.Client.Graphics; using Robust.Client.ResourceManagement; @@ -48,16 +49,21 @@ public partial class NavMapControl : MapGridControl protected float MaxSelectableDistance = 10f; protected float RecenterMinimum = 0.05f; protected float MinDragDistance = 5f; + protected static float MinDisplayedRange = 8f; + protected static float MaxDisplayedRange = 128f; + protected static float DefaultDisplayedRange = 48f; // Local variables private Vector2 _offset; private bool _draggin; private Vector2 _startDragPosition = default!; private bool _recentering = false; - private readonly Font _font; private float _updateTimer = 0.25f; private Dictionary _sRGBLookUp = new Dictionary(); - private Color _beaconColor; + public Color _backgroundColor; + public float _backgroundOpacity = 0.9f; + private int _targetFontsize = 8; + private IResourceCache _cache; // Components private NavMapComponent? _navMap; @@ -91,14 +97,13 @@ public partial class NavMapControl : MapGridControl Pressed = false, }; - public NavMapControl() : base(8f, 128f, 48f) + public NavMapControl() : base(MinDisplayedRange, MaxDisplayedRange, DefaultDisplayedRange) { IoCManager.InjectDependencies(this); - var cache = IoCManager.Resolve(); + _cache = IoCManager.Resolve(); _transformSystem = _entManager.System(); - _font = new VectorFont(cache.GetResource("/EngineFonts/NotoSans/NotoSans-Regular.ttf"), 12); - _beaconColor = Color.FromSrgb(TileColor.WithAlpha(0.8f)); + _backgroundColor = Color.FromSrgb(TileColor.WithAlpha(_backgroundOpacity)); RectClipContent = true; HorizontalExpand = true; @@ -185,11 +190,11 @@ public partial class NavMapControl : MapGridControl if (args.Function == EngineKeyFunctions.Use) _draggin = false; - if (TrackedEntitySelectedAction == null) - return; - - if (args.Function == EngineKeyFunctions.Use) + if (args.Function == EngineKeyFunctions.UIClick) { + if (TrackedEntitySelectedAction == null) + return; + if (_xform == null || _physics == null || TrackedEntities.Count == 0) return; @@ -234,6 +239,12 @@ public partial class NavMapControl : MapGridControl // Clear current selection with right click TrackedEntitySelectedAction?.Invoke(null); } + + else if (args.Function == ContentKeyFunctions.ExamineEntity) + { + // Toggle beacon labels + _beacons.Pressed = !_beacons.Pressed; + } } protected override void MouseMove(GUIMouseMoveEventArgs args) @@ -282,7 +293,7 @@ public partial class NavMapControl : MapGridControl } } - _zoom.Text = Loc.GetString("navmap-zoom", ("value", $"{(WorldRange / WorldMaxRange * 100f):0.00}")); + _zoom.Text = Loc.GetString("navmap-zoom", ("value", $"{(DefaultDisplayedRange / WorldRange ):0.0}")); if (_navMap == null || _xform == null) return; @@ -400,14 +411,18 @@ public partial class NavMapControl : MapGridControl { var rectBuffer = new Vector2(5f, 3f); + // Calculate font size for current zoom level + var fontSize = (int) Math.Round(1 / WorldRange * DefaultDisplayedRange * UIScale * _targetFontsize , 0); + var font = new VectorFont(_cache.GetResource("/Fonts/NotoSans/NotoSans-Bold.ttf"), fontSize); + foreach (var beacon in _navMap.Beacons) { var position = beacon.Position - offset; position = Scale(position with { Y = -position.Y }); - var textDimensions = handle.GetDimensions(_font, beacon.Text, 1f); - handle.DrawRect(new UIBox2(position - textDimensions / 2 - rectBuffer, position + textDimensions / 2 + rectBuffer), _beaconColor); - handle.DrawString(_font, position - textDimensions / 2, beacon.Text, beacon.Color); + var textDimensions = handle.GetDimensions(font, beacon.Text, 1f); + handle.DrawRect(new UIBox2(position - textDimensions / 2 - rectBuffer, position + textDimensions / 2 + rectBuffer), _backgroundColor); + handle.DrawString(font, position - textDimensions / 2, beacon.Text, beacon.Color); } } diff --git a/Content.Client/Power/PowerMonitoringConsoleNavMapControl.cs b/Content.Client/Power/PowerMonitoringConsoleNavMapControl.cs index ac2700564d..9f537f3858 100644 --- a/Content.Client/Power/PowerMonitoringConsoleNavMapControl.cs +++ b/Content.Client/Power/PowerMonitoringConsoleNavMapControl.cs @@ -33,6 +33,7 @@ public sealed partial class PowerMonitoringConsoleNavMapControl : NavMapControl // Set colors TileColor = new Color(30, 57, 67); WallColor = new Color(102, 164, 217); + _backgroundColor = Color.FromSrgb(TileColor.WithAlpha(_backgroundOpacity)); PostWallDrawingAction += DrawAllCableNetworks; } diff --git a/Resources/Locale/en-US/medical/components/crew-monitoring-component.ftl b/Resources/Locale/en-US/medical/components/crew-monitoring-component.ftl index f77f334c7e..7fd7f4608e 100644 --- a/Resources/Locale/en-US/medical/components/crew-monitoring-component.ftl +++ b/Resources/Locale/en-US/medical/components/crew-monitoring-component.ftl @@ -15,5 +15,5 @@ crew-monitoring-user-interface-no-server = Server not found crew-monitoring-user-interface-no-department = Unknown -crew-monitoring-user-interface-flavor-left = In case of an emergancy, contact station medical staff immediately -crew-monitoring-user-interface-flavor-right = v1.7 \ No newline at end of file +crew-monitoring-user-interface-flavor-left = In case of an emergency, contact station medical staff immediately +crew-monitoring-user-interface-flavor-right = v1.7 diff --git a/Resources/Locale/en-US/ui/navmap.ftl b/Resources/Locale/en-US/ui/navmap.ftl index e600e7a1f2..3c2aad1271 100644 --- a/Resources/Locale/en-US/ui/navmap.ftl +++ b/Resources/Locale/en-US/ui/navmap.ftl @@ -1,3 +1,3 @@ -navmap-zoom = Zoom: {$value}% +navmap-zoom = Zoom: {$value}x navmap-recenter = Recenter -navmap-toggle-beacons = Show departments \ No newline at end of file +navmap-toggle-beacons = Show departments