Skip to content

Commit

Permalink
Merge branch 'master' into nfsd-criminal-records
Browse files Browse the repository at this point in the history
  • Loading branch information
Qulibly authored Aug 12, 2024
2 parents 9260aab + 4291674 commit f72e196
Show file tree
Hide file tree
Showing 461 changed files with 20,114 additions and 21,887 deletions.
7 changes: 7 additions & 0 deletions Content.Client/IconSmoothing/IconSmoothComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,12 @@ public enum IconSmoothingMode : byte
/// Where this component contributes to our neighbors being calculated but we do not update our own sprite.
/// </summary>
NoSprite,

// Frontier: pretty diagonal windows
/// <summary>
/// The icon represents a triangular sprite with 5 states, representing which combinations of South and East are being occupied or not.
/// </summary>
DiagonalNF,
// End Frontier
}
}
108 changes: 88 additions & 20 deletions Content.Client/IconSmoothing/IconSmoothSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Numerics;
using Content.Client.Anomaly.Ui;
using Content.Client.Overlays;
using Content.Shared.IconSmoothing;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
Expand Down Expand Up @@ -154,7 +156,7 @@ public void DirtyNeighbours(EntityUid uid, IconSmoothComponent? comp = null, Tra
DirtyEntities(grid.GetAnchoredEntitiesEnumerator(pos + new Vector2i(0, 1)));
DirtyEntities(grid.GetAnchoredEntitiesEnumerator(pos + new Vector2i(0, -1)));

if (comp.Mode is IconSmoothingMode.Corners or IconSmoothingMode.NoSprite or IconSmoothingMode.Diagonal)
if (comp.Mode is IconSmoothingMode.Corners or IconSmoothingMode.NoSprite or IconSmoothingMode.Diagonal or IconSmoothingMode.DiagonalNF) // Frontier: add DiagonalNF
{
DirtyEntities(grid.GetAnchoredEntitiesEnumerator(pos + new Vector2i(1, 1)));
DirtyEntities(grid.GetAnchoredEntitiesEnumerator(pos + new Vector2i(-1, -1)));
Expand Down Expand Up @@ -208,13 +210,13 @@ private void CalculateNewSprite(EntityUid uid,
{
var pos = grid.TileIndicesFor(xform.Coordinates);

if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.North)), smoothQuery))
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.North)), smoothQuery, new(0, 1))) // Frontier: added (0, 1) vector
directions |= DirectionFlag.North;
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.South)), smoothQuery))
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.South)), smoothQuery, new(0, -1))) // Frontier: added (0, -1) vector
directions |= DirectionFlag.South;
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.East)), smoothQuery))
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.East)), smoothQuery, new(1, 0))) // Frontier: added (1, 0) vector
directions |= DirectionFlag.East;
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.West)), smoothQuery))
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.West)), smoothQuery, new(-1, 0))) // Frontier: added (-1, 0) vector
directions |= DirectionFlag.West;
}

Expand Down Expand Up @@ -256,6 +258,9 @@ private void CalculateNewSprite(EntityUid uid,
case IconSmoothingMode.Diagonal:
CalculateNewSpriteDiagonal(grid, smooth, spriteEnt, xform, smoothQuery);
break;
case IconSmoothingMode.DiagonalNF: // Frontier
CalculateNewSpriteDiagonalNF(grid, smooth, spriteEnt, xform, smoothQuery); // Frontier
break; // Frontier
default:
throw new ArgumentOutOfRangeException();
}
Expand Down Expand Up @@ -284,7 +289,7 @@ private void CalculateNewSpriteDiagonal(MapGridComponent? grid, IconSmoothCompon
for (var i = 0; i < neighbors.Length; i++)
{
var neighbor = (Vector2i) rotation.RotateVec(neighbors[i]);
matching = matching && MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos + neighbor), smoothQuery);
matching = matching && MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos + neighbor), smoothQuery, pos); // Frontier: add pos
}

if (matching)
Expand All @@ -297,6 +302,68 @@ private void CalculateNewSpriteDiagonal(MapGridComponent? grid, IconSmoothCompon
}
}

// New Frontiers - Better icon smoothing - icon smoothing that supports more diagonal window states
// and respects the empty sides of diagonal walls/windows
// This code is licensed under AGPLv3. See AGPLv3.txt

// Frontier: 5-state diagonal windows
private void CalculateNewSpriteDiagonalNF(MapGridComponent? grid, IconSmoothComponent smooth,
Entity<SpriteComponent> sprite, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
{
if (grid == null)
{
sprite.Comp.LayerSetState(0, $"{smooth.StateBase}0");
return;
}

var neighbors = new Vector2[]
{
new(1, 0),
new(0, -1),
};

var pos = grid.TileIndicesFor(xform.Coordinates);
var rotation = xform.LocalRotation;
int value = 0;

for (var i = 0; i < neighbors.Length; i++)
{
var neighbor = (Vector2i) rotation.RotateVec(neighbors[i]);
if(MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos + neighbor), smoothQuery, neighbor))
value |= 1 << i;
}

// both walls checked, check the corner
if (value == 3)
{
var neighbor = (Vector2i) rotation.RotateVec(new(1, -1));
if(MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos + neighbor), smoothQuery, neighbor))
value = 4;
}

sprite.Comp.LayerSetState(0, $"{smooth.StateBase}{value}");
}

// Check if a particular window/wall allows smoothing on a given edge
private bool EntityIsSmoothOnEdge(EntityUid? target, IconSmoothComponent targetComp, Vector2 sourceDir)
{
var xformQuery = GetEntityQuery<TransformComponent>();
xformQuery.TryGetComponent(target, out var xform);
if (xform is null)
return false;

if (targetComp.Mode is IconSmoothingMode.Diagonal or IconSmoothingMode.DiagonalNF)
{
var rot = -xform.LocalRotation; // Source direction must be transformed into our reference.
var angle = new Angle(rot.RotateVec(-sourceDir)); // Direction is given from sourge to target, we need the direction from target to source.
angle += Math.PI / 2; // Cardinal directions start at north(?), but positive X angle is 0.
var dir = angle.GetCardinalDir();
return dir is Direction.South or Direction.SouthEast or Direction.East;
}
return true; // All other target components use all sides
}
// End of modified code

private void CalculateNewSpriteCardinal(MapGridComponent? grid, IconSmoothComponent smooth, Entity<SpriteComponent> sprite, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
{
var dirs = CardinalConnectDirs.None;
Expand All @@ -308,13 +375,13 @@ private void CalculateNewSpriteCardinal(MapGridComponent? grid, IconSmoothCompon
}

var pos = grid.TileIndicesFor(xform.Coordinates);
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.North)), smoothQuery))
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.North)), smoothQuery, new(0, 1))) // Frontier: add vector
dirs |= CardinalConnectDirs.North;
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.South)), smoothQuery))
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.South)), smoothQuery, new(0, -1))) // Frontier: add vector
dirs |= CardinalConnectDirs.South;
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.East)), smoothQuery))
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.East)), smoothQuery, new(1, 0))) // Frontier: add vector
dirs |= CardinalConnectDirs.East;
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.West)), smoothQuery))
if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.West)), smoothQuery, new(-1, 0))) // Frontier: add vector
dirs |= CardinalConnectDirs.West;

sprite.Comp.LayerSetState(0, $"{smooth.StateBase}{(int) dirs}");
Expand All @@ -333,13 +400,14 @@ private void CalculateNewSpriteCardinal(MapGridComponent? grid, IconSmoothCompon
CalculateEdge(sprite, directions, sprite);
}

private bool MatchingEntity(IconSmoothComponent smooth, AnchoredEntitiesEnumerator candidates, EntityQuery<IconSmoothComponent> smoothQuery)
private bool MatchingEntity(IconSmoothComponent smooth, AnchoredEntitiesEnumerator candidates, EntityQuery<IconSmoothComponent> smoothQuery, Vector2 offset)
{
while (candidates.MoveNext(out var entity))
{
if (smoothQuery.TryGetComponent(entity, out var other) &&
other.SmoothKey == smooth.SmoothKey &&
other.Enabled)
other.Enabled &&
EntityIsSmoothOnEdge(entity, other, offset)) // Frontier: added EntityIsSmo
{
return true;
}
Expand Down Expand Up @@ -385,14 +453,14 @@ private void CalculateNewSpriteCorners(MapGridComponent? grid, IconSmoothCompone
private (CornerFill ne, CornerFill nw, CornerFill sw, CornerFill se) CalculateCornerFill(MapGridComponent grid, IconSmoothComponent smooth, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
{
var pos = grid.TileIndicesFor(xform.Coordinates);
var n = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.North)), smoothQuery);
var ne = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.NorthEast)), smoothQuery);
var e = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.East)), smoothQuery);
var se = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.SouthEast)), smoothQuery);
var s = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.South)), smoothQuery);
var sw = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.SouthWest)), smoothQuery);
var w = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.West)), smoothQuery);
var nw = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.NorthWest)), smoothQuery);
var n = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.North)), smoothQuery, new(0, 1)); // Frontier: add vector
var ne = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.NorthEast)), smoothQuery, new(1, 1)); // Frontier: add vector
var e = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.East)), smoothQuery, new(1, 0)); // Frontier: add vector
var se = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.SouthEast)), smoothQuery, new(1, -1)); // Frontier: add vector
var s = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.South)), smoothQuery, new(0, -1)); // Frontier: add vector
var sw = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.SouthWest)), smoothQuery, new(-1, -1)); // Frontier: add vector
var w = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.West)), smoothQuery, new(-1, 0)); // Frontier: add vector
var nw = MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.NorthWest)), smoothQuery, new(-1, 1)); // Frontier: add vector

// ReSharper disable InconsistentNaming
var cornerNE = CornerFill.None;
Expand Down
5 changes: 5 additions & 0 deletions Content.Client/PDA/PdaMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@
<ContainerButton Name="StationAlertLevelInstructionsButton">
<RichTextLabel Name="StationAlertLevelInstructions" Access="Public"/>
</ContainerButton>
<!-- Frontier -->
<ContainerButton Name="BalanceButton">
<RichTextLabel Name="BalanceLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="ShuttleDeedButton">
<RichTextLabel Name="ShuttleDeedLabel" Access="Public"/>
</ContainerButton>
<!-- End Frontier -->
</BoxContainer>
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True">
<BoxContainer Orientation="Vertical"
Expand Down
13 changes: 12 additions & 1 deletion Content.Client/PDA/PdaMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public sealed partial class PdaMenu : PdaWindow
private string _instructions = Loc.GetString("comp-pda-ui-unknown");

private string _balance = Loc.GetString("comp-pda-ui-unknown"); // Frontier
private string _shuttleDeed = Loc.GetString("comp-pda-ui-unknown"); // Frontier

private int _currentView;

Expand Down Expand Up @@ -116,10 +117,16 @@ public PdaMenu()
_clipboard.SetText(_alertLevel);
};

BalanceButton.OnPressed += _ => // Frontier
// Frontier
BalanceButton.OnPressed += _ =>
{
_clipboard.SetText(_balance);
};
ShuttleDeedButton.OnPressed += _ =>
{
_clipboard.SetText(_shuttleDeed);
};
// End Frontier

StationTimeButton.OnPressed += _ =>
{
Expand Down Expand Up @@ -171,6 +178,10 @@ public void UpdateState(PdaUpdateState state)
_balance = state.Balance.ToString(); // Frontier
BalanceLabel.SetMarkup(Loc.GetString("comp-pda-ui-balance", ("balance", _balance))); // Frontier

_shuttleDeed = state.OwnedShipName ?? ""; // Frontier
ShuttleDeedLabel.SetMarkup(Loc.GetString("comp-pda-ui-shuttle-deed", ("shipname", _shuttleDeed))); // Frontier
ShuttleDeedLabel.Visible = !string.IsNullOrEmpty(state.OwnedShipName); // Frontier

var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);

StationTimeLabel.SetMarkup(Loc.GetString("comp-pda-ui-station-time",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Content.Client.Shuttles.BUI;

[UsedImplicitly]
public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
public sealed partial class ShuttleConsoleBoundUserInterface : BoundUserInterface // Frontier: added partial
{
[ViewVariables]
private ShuttleConsoleWindow? _window;
Expand All @@ -27,6 +27,7 @@ protected override void Open()
_window.RequestBeaconFTL += OnFTLBeaconRequest;
_window.DockRequest += OnDockRequest;
_window.UndockRequest += OnUndockRequest;
NfOpen(); // Frontier
}

private void OnUndockRequest(NetEntity entity)
Expand Down
46 changes: 36 additions & 10 deletions Content.Client/Shuttles/UI/NavScreen.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,48 @@
Text="{controls:Loc 'shuttle-console-dock-toggle'}"
TextAlign="Center"
ToggleMode="True"/>

<!-- Frontier - Inertia dampener controls-->
<controls:BoxContainer Name="DampenerModeButtons"
Orientation="Horizontal"
HorizontalAlignment="Stretch"
Margin="5">
<controls:Button Name="DampenerOff"
Text="{controls:Loc 'shuttle-console-inertia-dampener-off'}"
TextAlign="Center"
ToggleMode="True"
MinWidth="82"
MaxWidth="82"/>
<controls:Button Name="DampenerOn"
Text="{controls:Loc 'shuttle-console-inertia-dampener-dampen'}"
TextAlign="Center"
ToggleMode="True"
MinWidth="82"
MaxWidth="82"/>
<controls:Button Name="AnchorOn"
Text="{controls:Loc 'shuttle-console-inertia-dampener-anchor'}"
TextAlign="Center"
ToggleMode="True"
MinWidth="82"
MaxWidth="82"/>
</controls:BoxContainer>
<!-- End Frontier - Inertia dampener controls-->
<!-- Frontier - IFF search -->
<controls:BoxContainer Orientation="Vertical" HorizontalExpand="True" Name="IffSearchBox">
<controls:Label Text="{controls:Loc 'shuttle-console-iff-search'}"></controls:Label>
<controls:LineEdit Name="IffSearchCriteria" Access="Public" HorizontalExpand="True"></controls:LineEdit>
<controls:Label Text="{controls:Loc 'shuttle-console-iff-search'}"/>
<controls:LineEdit Name="IffSearchCriteria" Access="Public" HorizontalExpand="True"/>
</controls:BoxContainer>

<!-- End Frontier - IFF search -->

<!-- Frontier - Maximum IFF Distance -->
<controls:BoxContainer Orientation="Vertical" HorizontalExpand="True" Name="MaximumIFFDistanceBox">
<controls:Label Text="{controls:Loc 'shuttle-console-maximum-iff-distance'}"/>
<controls:SliderIntInput Name="MaximumIFFDistanceValue"
Access="Public"
MinValue="0"
MaxValue="3000"
Value="3000"
HorizontalExpand="True"/>
Access="Public"
MinValue="0"
MaxValue="3000"
Value="3000"
HorizontalExpand="True"/>
</controls:BoxContainer>
<!-- End Frontier - Maximum IFF Distance -->
</controls:BoxContainer>
</controls:BoxContainer>
</controls:BoxContainer>
Loading

0 comments on commit f72e196

Please sign in to comment.