Skip to content

Commit

Permalink
Cherry-picked commit a41772a from space-wizards/space-station-14/master
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth authored and SimpleStation14 committed Apr 21, 2024
1 parent 3bf08c7 commit 7a3349e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
14 changes: 11 additions & 3 deletions Content.Client/Shuttles/UI/MapScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,22 @@ private void RebuildMapObjects()

foreach (var grid in _mapManager.GetAllMapGrids(mapComp.MapId))
{
_entManager.TryGetComponent(grid.Owner, out IFFComponent? iffComp);

var gridObj = new GridMapObject()
{
Name = _entManager.GetComponent<MetaDataComponent>(grid.Owner).EntityName,
Entity = grid.Owner
Entity = grid.Owner,
HideButton = iffComp != null && (iffComp.Flags & IFFFlags.HideLabel) != 0x0,
};

// Always show our shuttle immediately
if (grid.Owner == _shuttleEntity)
{
AddMapObject(mapComp.MapId, gridObj);
}
else
else if (iffComp == null ||
(iffComp.Flags & IFFFlags.Hide) == 0x0)
{
_pendingMapObjects.Add((mapComp.MapId, gridObj));
}
Expand Down Expand Up @@ -423,10 +427,14 @@ public void SetMap(MapId mapId, Vector2 position)
/// </summary>
private void AddMapObject(MapId mapId, IMapObject mapObj)
{
var gridContents = _mapHeadings[mapId];
var existing = _mapObjects.GetOrNew(mapId);
existing.Add(mapObj);

if (mapObj.HideButton)
return;

var gridContents = _mapHeadings[mapId];

var gridButton = new Button()
{
Text = mapObj.Name,
Expand Down
5 changes: 4 additions & 1 deletion Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ protected override void Draw(DrawingHandleScreen handle)
// Rudimentary IFF for now, if IFF hiding on then we don't show on the map at all
if (grid.Owner != _shuttleEntity &&
EntManager.TryGetComponent(grid, out iffComp) &&
(iffComp.Flags & (IFFFlags.Hide | IFFFlags.HideLabel)) != 0x0)
(iffComp.Flags & IFFFlags.Hide) != 0x0)
{
continue;
}
Expand All @@ -367,6 +367,9 @@ protected override void Draw(DrawingHandleScreen handle)
AddMapObject(existingEdges, existingVerts, mapObject);

// Text
if (iffComp != null && (iffComp.Flags & IFFFlags.HideLabel) != 0x0)
continue;

// Force drawing it at this point.
var iffText = _shuttles.GetIFFLabel(grid, self: true, component: iffComp);

Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/Shuttles/Systems/SharedShuttleSystem.IFF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void SetIFFColor(EntityUid gridUid, Color color, IFFComponent? component
return;

component.Color = color;
Dirty(component);
Dirty(gridUid, component);
UpdateIFFInterfaces(gridUid, component);
}

Expand All @@ -73,7 +73,7 @@ public void AddIFFFlag(EntityUid gridUid, IFFFlags flags, IFFComponent? componen
return;

component.Flags |= flags;
Dirty(component);
Dirty(gridUid, component);
UpdateIFFInterfaces(gridUid, component);
}

Expand All @@ -87,7 +87,7 @@ public void RemoveIFFFlag(EntityUid gridUid, IFFFlags flags, IFFComponent? compo
return;

component.Flags &= ~flags;
Dirty(component);
Dirty(gridUid, component);
UpdateIFFInterfaces(gridUid, component);
}
}
1 change: 1 addition & 0 deletions Content.Shared/Shuttles/UI/MapObjects/GridMapObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ namespace Content.Shared.Shuttles.UI.MapObjects;
public record struct GridMapObject : IMapObject
{
public string Name { get; set; }
public bool HideButton { get; init; }
public EntityUid Entity;
}
5 changes: 5 additions & 0 deletions Content.Shared/Shuttles/UI/MapObjects/IMapObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ namespace Content.Shared.Shuttles.UI.MapObjects;
public interface IMapObject
{
string Name { get; }

/// <summary>
/// Should we hide the button from being shown (AKA just draw it).
/// </summary>
bool HideButton { get; }
}
5 changes: 4 additions & 1 deletion Content.Shared/Shuttles/UI/MapObjects/ShuttleBeaconObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
namespace Content.Shared.Shuttles.UI.MapObjects;

[Serializable, NetSerializable]
public readonly record struct ShuttleBeaconObject(NetEntity Entity, NetCoordinates Coordinates, string Name) : IMapObject;
public readonly record struct ShuttleBeaconObject(NetEntity Entity, NetCoordinates Coordinates, string Name) : IMapObject
{
public bool HideButton => false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
namespace Content.Shared.Shuttles.UI.MapObjects;

[Serializable, NetSerializable]
public record struct ShuttleExclusionObject(NetCoordinates Coordinates, float Range, string Name = "") : IMapObject;
public record struct ShuttleExclusionObject(NetCoordinates Coordinates, float Range, string Name = "") : IMapObject
{
public bool HideButton => false;
}

0 comments on commit 7a3349e

Please sign in to comment.