Allows mass scanners and shuttle console radars to resize gracefully (#13241)
This commit is contained in:
@@ -16,15 +16,15 @@ public class DockingControl : Control
|
|||||||
private readonly IEntityManager _entManager;
|
private readonly IEntityManager _entManager;
|
||||||
private readonly IMapManager _mapManager;
|
private readonly IMapManager _mapManager;
|
||||||
|
|
||||||
private const int MinimapMargin = 4;
|
|
||||||
|
|
||||||
private float _range = 8f;
|
private float _range = 8f;
|
||||||
private float _rangeSquared = 0f;
|
private float _rangeSquared = 0f;
|
||||||
private const float GridLinesDistance = 32f;
|
private const float GridLinesDistance = 32f;
|
||||||
|
|
||||||
private int MidPoint => SizeFull / 2;
|
private int MinimapRadius => (int) Math.Min(Size.X, Size.Y) / 2;
|
||||||
private int SizeFull => (int) ((RadarControl.MinimapRadius + MinimapMargin) * 2 * UIScale);
|
|
||||||
private int ScaledMinimapRadius => (int) (RadarControl.MinimapRadius * UIScale);
|
private Vector2 MidPoint => Size / 2;
|
||||||
|
private int SizeFull => (int) (MinimapRadius * 2 * UIScale);
|
||||||
|
private int ScaledMinimapRadius => (int) (MinimapRadius * UIScale);
|
||||||
private float MinimapScale => _range != 0 ? ScaledMinimapRadius / _range : 0f;
|
private float MinimapScale => _range != 0 ? ScaledMinimapRadius / _range : 0f;
|
||||||
|
|
||||||
public EntityUid? ViewedDock;
|
public EntityUid? ViewedDock;
|
||||||
@@ -52,8 +52,8 @@ public class DockingControl : Control
|
|||||||
|
|
||||||
var fakeAA = new Color(0.08f, 0.08f, 0.08f);
|
var fakeAA = new Color(0.08f, 0.08f, 0.08f);
|
||||||
|
|
||||||
handle.DrawCircle((MidPoint, MidPoint), ScaledMinimapRadius + 1, fakeAA);
|
handle.DrawCircle((MidPoint.X, MidPoint.Y), ScaledMinimapRadius + 1, fakeAA);
|
||||||
handle.DrawCircle((MidPoint, MidPoint), ScaledMinimapRadius, Color.Black);
|
handle.DrawCircle((MidPoint.X, MidPoint.Y), ScaledMinimapRadius, Color.Black);
|
||||||
|
|
||||||
var gridLines = new Color(0.08f, 0.08f, 0.08f);
|
var gridLines = new Color(0.08f, 0.08f, 0.08f);
|
||||||
var gridLinesRadial = 8;
|
var gridLinesRadial = 8;
|
||||||
@@ -61,14 +61,14 @@ public class DockingControl : Control
|
|||||||
|
|
||||||
for (var i = 1; i < gridLinesEquatorial + 1; i++)
|
for (var i = 1; i < gridLinesEquatorial + 1; i++)
|
||||||
{
|
{
|
||||||
handle.DrawCircle((MidPoint, MidPoint), GridLinesDistance * MinimapScale * i, gridLines, false);
|
handle.DrawCircle((MidPoint.X, MidPoint.Y), GridLinesDistance * MinimapScale * i, gridLines, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < gridLinesRadial; i++)
|
for (var i = 0; i < gridLinesRadial; i++)
|
||||||
{
|
{
|
||||||
Angle angle = (Math.PI / gridLinesRadial) * i;
|
Angle angle = (Math.PI / gridLinesRadial) * i;
|
||||||
var aExtent = angle.ToVec() * ScaledMinimapRadius;
|
var aExtent = angle.ToVec() * ScaledMinimapRadius;
|
||||||
handle.DrawLine((MidPoint, MidPoint) - aExtent, (MidPoint, MidPoint) + aExtent, gridLines);
|
handle.DrawLine((MidPoint.X, MidPoint.Y) - aExtent, (MidPoint.X, MidPoint.Y) + aExtent, gridLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Coordinates == null ||
|
if (Coordinates == null ||
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||||
xmlns:ui="clr-namespace:Content.Client.Shuttles.UI"
|
xmlns:ui="clr-namespace:Content.Client.Shuttles.UI"
|
||||||
Title="{Loc 'radar-console-window-title'}">
|
Title="{Loc 'radar-console-window-title'}"
|
||||||
<ui:RadarControl Name="RadarScreen"/>
|
MinSize="256 256">
|
||||||
|
<ui:RadarControl Name="RadarScreen"
|
||||||
|
Margin="4"
|
||||||
|
HorizontalExpand = "True"
|
||||||
|
VerticalExpand = "True"/>
|
||||||
</controls:FancyWindow>
|
</controls:FancyWindow>
|
||||||
|
|||||||
@@ -23,9 +23,6 @@ public sealed class RadarControl : Control
|
|||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
|
||||||
private const float ScrollSensitivity = 8f;
|
private const float ScrollSensitivity = 8f;
|
||||||
|
|
||||||
public const int MinimapRadius = 320;
|
|
||||||
private const int MinimapMargin = 4;
|
|
||||||
private const float GridLinesDistance = 32f;
|
private const float GridLinesDistance = 32f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -49,8 +46,9 @@ public sealed class RadarControl : Control
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float MaxRadarRange { get; private set; } = 256f * 10f;
|
public float MaxRadarRange { get; private set; } = 256f * 10f;
|
||||||
|
|
||||||
private int MidPoint => SizeFull / 2;
|
private int MinimapRadius => (int) Math.Min(Size.X, Size.Y) / 2;
|
||||||
private int SizeFull => (int) ((MinimapRadius + MinimapMargin) * 2 * UIScale);
|
private Vector2 MidPoint => Size / 2;
|
||||||
|
private int SizeFull => (int) (MinimapRadius * 2 * UIScale);
|
||||||
private int ScaledMinimapRadius => (int) (MinimapRadius * UIScale);
|
private int ScaledMinimapRadius => (int) (MinimapRadius * UIScale);
|
||||||
private float MinimapScale => RadarRange != 0 ? ScaledMinimapRadius / RadarRange : 0f;
|
private float MinimapScale => RadarRange != 0 ? ScaledMinimapRadius / RadarRange : 0f;
|
||||||
|
|
||||||
@@ -130,8 +128,8 @@ public sealed class RadarControl : Control
|
|||||||
|
|
||||||
var fakeAA = new Color(0.08f, 0.08f, 0.08f);
|
var fakeAA = new Color(0.08f, 0.08f, 0.08f);
|
||||||
|
|
||||||
handle.DrawCircle((MidPoint, MidPoint), ScaledMinimapRadius + 1, fakeAA);
|
handle.DrawCircle((MidPoint.X, MidPoint.Y), ScaledMinimapRadius + 1, fakeAA);
|
||||||
handle.DrawCircle((MidPoint, MidPoint), ScaledMinimapRadius, Color.Black);
|
handle.DrawCircle((MidPoint.X, MidPoint.Y), ScaledMinimapRadius, Color.Black);
|
||||||
|
|
||||||
// No data
|
// No data
|
||||||
if (_coordinates == null || _rotation == null)
|
if (_coordinates == null || _rotation == null)
|
||||||
@@ -146,14 +144,14 @@ public sealed class RadarControl : Control
|
|||||||
|
|
||||||
for (var i = 1; i < gridLinesEquatorial + 1; i++)
|
for (var i = 1; i < gridLinesEquatorial + 1; i++)
|
||||||
{
|
{
|
||||||
handle.DrawCircle((MidPoint, MidPoint), GridLinesDistance * MinimapScale * i, gridLines, false);
|
handle.DrawCircle((MidPoint.X, MidPoint.Y), GridLinesDistance * MinimapScale * i, gridLines, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < gridLinesRadial; i++)
|
for (var i = 0; i < gridLinesRadial; i++)
|
||||||
{
|
{
|
||||||
Angle angle = (Math.PI / gridLinesRadial) * i;
|
Angle angle = (Math.PI / gridLinesRadial) * i;
|
||||||
var aExtent = angle.ToVec() * ScaledMinimapRadius;
|
var aExtent = angle.ToVec() * ScaledMinimapRadius;
|
||||||
handle.DrawLine((MidPoint, MidPoint) - aExtent, (MidPoint, MidPoint) + aExtent, gridLines);
|
handle.DrawLine((MidPoint.X, MidPoint.Y) - aExtent, (MidPoint.X, MidPoint.Y) + aExtent, gridLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
var metaQuery = _entManager.GetEntityQuery<MetaDataComponent>();
|
var metaQuery = _entManager.GetEntityQuery<MetaDataComponent>();
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||||
xmlns:ui="clr-namespace:Content.Client.Shuttles.UI"
|
xmlns:ui="clr-namespace:Content.Client.Shuttles.UI"
|
||||||
Title="{Loc 'shuttle-console-window-title'}">
|
Title="{Loc 'shuttle-console-window-title'}"
|
||||||
|
SetSize="1180 648"
|
||||||
|
MinSize="788 320">
|
||||||
<GridContainer Columns="3"
|
<GridContainer Columns="3"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Margin="5 5 5 5">
|
Margin="5 5 5 5">
|
||||||
@@ -9,6 +11,7 @@
|
|||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
MinWidth="256"
|
MinWidth="256"
|
||||||
|
MaxWidth="256"
|
||||||
Align="Center"
|
Align="Center"
|
||||||
Orientation="Vertical">
|
Orientation="Vertical">
|
||||||
<BoxContainer Orientation="Vertical">
|
<BoxContainer Orientation="Vertical">
|
||||||
@@ -26,17 +29,27 @@
|
|||||||
Orientation="Vertical"/>
|
Orientation="Vertical"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<PanelContainer>
|
<PanelContainer MinSize="256 256"
|
||||||
|
HorizontalAlignment = "Stretch"
|
||||||
|
HorizontalExpand = "True"
|
||||||
|
VerticalExpand = "True">
|
||||||
<ui:RadarControl Name="RadarScreen"
|
<ui:RadarControl Name="RadarScreen"
|
||||||
MouseFilter="Stop"/>
|
MouseFilter="Stop"
|
||||||
|
Margin="4"
|
||||||
|
HorizontalExpand = "True"
|
||||||
|
VerticalExpand = "True"/>
|
||||||
<ui:DockingControl Name="DockingScreen"
|
<ui:DockingControl Name="DockingScreen"
|
||||||
Visible="False"
|
Visible="False"
|
||||||
MouseFilter="Stop"/>
|
MouseFilter="Stop"
|
||||||
|
Margin="4"
|
||||||
|
HorizontalExpand = "True"
|
||||||
|
VerticalExpand = "True"/>
|
||||||
</PanelContainer>
|
</PanelContainer>
|
||||||
<BoxContainer Name="RightDisplay"
|
<BoxContainer Name="RightDisplay"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
MinWidth="256"
|
MinWidth="256"
|
||||||
|
MaxWidth="256"
|
||||||
Align="Center"
|
Align="Center"
|
||||||
Orientation="Vertical">
|
Orientation="Vertical">
|
||||||
<controls:StripeBack>
|
<controls:StripeBack>
|
||||||
|
|||||||
Reference in New Issue
Block a user