Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream merge #337

Merged
merged 38 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b2cb813
Include container ents in examine (#32267)
metalgearsloth Sep 23, 2024
ad6c5a1
Automatic changelog update
PJBot Sep 23, 2024
3d2aadd
L6 Fits in the Suit Storage Slot (#30525)
Cojoke-dot Sep 23, 2024
c4b8260
Automatic changelog update
PJBot Sep 23, 2024
caf34be
Entity menu lookup changes (#32395)
ElectroJr Sep 23, 2024
b6845de
Automatic changelog update
PJBot Sep 23, 2024
a7e29f2
Computer wirepanel (#32273)
Errant-4 Sep 23, 2024
0a3273a
Automatic changelog update
PJBot Sep 23, 2024
aab4236
Fix guidebook books don't have damage (#32403)
lzk228 Sep 23, 2024
16c46af
Automatic changelog update
PJBot Sep 23, 2024
24140d8
VIM have Passenger Access. (#32302)
Jophire Sep 23, 2024
31db37e
Automatic changelog update
PJBot Sep 23, 2024
5e9a0c9
Omega Minor Sec Update (#32410)
spanky-spanky Sep 23, 2024
20bb9ed
fix(contraband): Make contraband work with chameleon items (#30986)
Brandon-Huu Sep 23, 2024
95104de
Fix cadet pda (#32399)
lzk228 Sep 23, 2024
d0bb408
Automatic changelog update
PJBot Sep 23, 2024
594aad0
Paper QOL improvements (#32418)
eoineoineoin Sep 23, 2024
1450d76
Fix OOC not re-enabling if restartroundnow is used (#32401)
PJB3005 Sep 23, 2024
f1bd0be
Remove all command age requirements (#32340)
VasilisThePikachu Sep 24, 2024
dc4d638
Automatic changelog update
PJBot Sep 24, 2024
9d75a22
Add missing LV cables in Omega atmos (#32417)
spanky-spanky Sep 24, 2024
50395e2
Allow AreaInsert pickups for one item (#32153)
dvir001 Sep 24, 2024
49d4e4c
Automatic changelog update
PJBot Sep 24, 2024
efd9894
Antimov in both Traitor & Nukie Uplinks (#31916)
LordEclipse Sep 24, 2024
b883f79
Automatic changelog update
PJBot Sep 24, 2024
87932bc
craftable freezers (#32277)
lzk228 Sep 24, 2024
057de0c
Automatic changelog update
PJBot Sep 24, 2024
042f0d3
fix paper staying on fire forever (#32412)
MilonPL Sep 24, 2024
f3e185c
Automatic changelog update
PJBot Sep 24, 2024
241be37
AstroNav GPS Cartridge (#32194)
ArchRBX Sep 24, 2024
4bca634
Automatic changelog update
PJBot Sep 24, 2024
e36d735
Fix cartesian explosion in pref loading (#32434)
PJB3005 Sep 24, 2024
89dbef7
Automatic changelog update
PJBot Sep 24, 2024
95a159f
fix(BatterySelfRecharger): Fully charge BatterySelfRechargers (#30627)
Brandon-Huu Sep 24, 2024
55366dc
Most papers are no longer trash (#32343)
Moomoobeef Sep 24, 2024
52e85fe
Automatic changelog update
PJBot Sep 24, 2024
e4fbf34
Merge branch 'master' of https://github.com/space-wizards/space-stati…
formlessnameless Sep 24, 2024
ab9b53f
Merge branch 'master' of https://github.com/impstation/imp-station-14…
formlessnameless Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions Content.Client/GPS/Components/HandheldGPSComponent.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Content.Client/GPS/Systems/HandheldGpsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.GPS.Components;
using Content.Shared.GPS.Components;
using Content.Client.GPS.UI;
using Content.Client.Items;

Expand Down
15 changes: 11 additions & 4 deletions Content.Client/GPS/UI/HandheldGpsStatusControl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.GPS.Components;
using Content.Shared.GPS.Components;
using Content.Client.Message;
using Content.Client.Stylesheets;
using Robust.Client.GameObjects;
Expand Down Expand Up @@ -30,6 +30,13 @@ protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

// don't display the label if the gps component is being removed
if (_parent.Comp.LifeStage > ComponentLifeStage.Running)
{
_label.Visible = false;
return;
}

_updateDif += args.DeltaSeconds;
if (_updateDif < _parent.Comp.UpdateRate)
return;
Expand All @@ -44,9 +51,9 @@ private void UpdateGpsDetails()
var posText = "Error";
if (_entMan.TryGetComponent(_parent, out TransformComponent? transComp))
{
var pos = _transform.GetMapCoordinates(_parent.Owner, xform: transComp);
var x = (int) pos.X;
var y = (int) pos.Y;
var pos = _transform.GetMapCoordinates(_parent.Owner, xform: transComp);
var x = (int)pos.X;
var y = (int)pos.Y;
posText = $"({x}, {y})";
}
_label.SetMarkup(Loc.GetString("handheld-gps-coordinates-title", ("coordinates", posText)));
Expand Down
5 changes: 5 additions & 0 deletions Content.Client/Paper/UI/PaperBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Utility;
using Content.Shared.Paper;
using static Content.Shared.Paper.PaperComponent;

namespace Content.Client.Paper.UI;
Expand All @@ -23,6 +24,10 @@ protected override void Open()
_window = this.CreateWindow<PaperWindow>();
_window.OnSaved += InputOnTextEntered;

if (EntMan.TryGetComponent<PaperComponent>(Owner, out var paper))
{
_window.MaxInputLength = paper.ContentSize;
}
if (EntMan.TryGetComponent<PaperVisualsComponent>(Owner, out var visuals))
{
_window.InitVisuals(Owner, visuals);
Expand Down
11 changes: 7 additions & 4 deletions Content.Client/Paper/UI/PaperWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
<Control Name="TextAlignmentPadding" VerticalAlignment="Top"/>
<RichTextLabel Name="BlankPaperIndicator" StyleClasses="LabelSecondaryColor" VerticalAlignment="Top" HorizontalAlignment="Center"/>
<RichTextLabel StyleClasses="PaperWrittenText" Name="WrittenTextLabel" VerticalAlignment="Top"/>
<PanelContainer Name="InputContainer" StyleClasses="TransparentBorderedWindowPanel" MinHeight="100"
VerticalAlignment="Stretch" VerticalExpand="True" HorizontalExpand="True">
<TextEdit Name="Input" StyleClasses="PaperLineEdit" Access="Public" />
</PanelContainer>
<BoxContainer Name="InputContainer" Orientation="Vertical" VerticalExpand="True" VerticalAlignment="Stretch">
<PanelContainer StyleClasses="TransparentBorderedWindowPanel" MinHeight="100"
VerticalAlignment="Stretch" VerticalExpand="True" HorizontalExpand="True">
<TextEdit Name="Input" StyleClasses="PaperLineEdit" Access="Public" />
</PanelContainer>
<Label Name="FillStatus" StyleClasses="LabelSecondaryColor"/>
</BoxContainer>
</BoxContainer>
<paper:StampCollection Name="StampDisplay" VerticalAlignment="Bottom" Margin="6"/>

Expand Down
49 changes: 47 additions & 2 deletions Content.Client/Paper/UI/PaperWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ public sealed partial class PaperWindow : BaseWindow

public event Action<string>? OnSaved;

private int _MaxInputLength = -1;
public int MaxInputLength
{
get
{
return _MaxInputLength;
}
set
{
_MaxInputLength = value;
UpdateFillState();
}
}

public PaperWindow()
{
IoCManager.InjectDependencies(this);
Expand All @@ -63,11 +77,21 @@ public PaperWindow()
{
if (args.Function == EngineKeyFunctions.MultilineTextSubmit)
{
RunOnSaved();
args.Handle();
// SaveButton is disabled when we hit the max input limit. Just check
// that flag instead of trying to calculate the input length again
if (!SaveButton.Disabled)
{
RunOnSaved();
args.Handle();
}
}
};

Input.OnTextChanged += args =>
{
UpdateFillState();
};

SaveButton.OnPressed += _ =>
{
RunOnSaved();
Expand Down Expand Up @@ -126,6 +150,7 @@ public void InitVisuals(EntityUid entity, PaperVisualsComponent visuals)

PaperContent.ModulateSelfOverride = visuals.ContentImageModulate;
WrittenTextLabel.ModulateSelfOverride = visuals.FontAccentColor;
FillStatus.ModulateSelfOverride = visuals.FontAccentColor;

var contentImage = visuals.ContentImagePath != null ? _resCache.GetResource<TextureResource>(visuals.ContentImagePath) : null;
if (contentImage != null)
Expand Down Expand Up @@ -296,5 +321,25 @@ private void RunOnSaved()
{
OnSaved?.Invoke(Rope.Collapse(Input.TextRope));
}

private void UpdateFillState()
{
if (MaxInputLength != -1)
{
var inputLength = Input.TextLength;

FillStatus.Text = Loc.GetString("paper-ui-fill-level",
("currentLength", inputLength),
("maxLength", MaxInputLength));

// Disable the save button if we've gone over the limit
SaveButton.Disabled = inputLength > MaxInputLength;
}
else
{
FillStatus.Text = "";
SaveButton.Disabled = false;
}
}
}
}
153 changes: 84 additions & 69 deletions Content.Client/Verbs/VerbSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using Content.Client.Examine;
using Content.Client.Gameplay;
using Content.Client.Popups;
using Content.Shared.CCVar;
using Content.Shared.Examine;
using Content.Shared.Tag;
using Content.Shared.Verbs;
Expand All @@ -13,6 +13,8 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.State;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Utility;

Expand All @@ -28,11 +30,11 @@ public sealed class VerbSystem : SharedVerbSystem
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly SharedContainerSystem _containers = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;

/// <summary>
/// When a user right clicks somewhere, how large is the box we use to get entities for the context menu?
/// </summary>
public const float EntityMenuLookupSize = 0.25f;
private float _lookupSize;

/// <summary>
/// These flags determine what entities the user can see on the context menu.
Expand All @@ -41,114 +43,127 @@ public sealed class VerbSystem : SharedVerbSystem

public Action<VerbsResponseEvent>? OnVerbsResponse;

private List<EntityUid> _entities = new();

public override void Initialize()
{
base.Initialize();

SubscribeNetworkEvent<VerbsResponseEvent>(HandleVerbResponse);
Subs.CVar(_cfg, CCVars.GameEntityMenuLookup, OnLookupChanged, true);
}

private void OnLookupChanged(float val)
{
_lookupSize = val;
}

/// <summary>
/// Get all of the entities in an area for displaying on the context menu.
/// Get all of the entities in an area for displaying on the context menu.
/// </summary>
public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true)] out List<EntityUid>? result)
/// <returns>True if any entities were found.</returns>
public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true)] out List<EntityUid>? entities)
{
result = null;
entities = null;

if (_stateManager.CurrentState is not GameplayStateBase gameScreenBase)
if (_stateManager.CurrentState is not GameplayStateBase)
return false;

var player = _playerManager.LocalEntity;
if (player == null)
if (_playerManager.LocalEntity is not { } player)
return false;

// If FOV drawing is disabled, we will modify the visibility option to ignore visiblity checks.
var visibility = _eyeManager.CurrentEye.DrawFov
? Visibility
: Visibility | MenuVisibility.NoFov;
var visibility = _eyeManager.CurrentEye.DrawFov ? Visibility : Visibility | MenuVisibility.NoFov;

var ev = new MenuVisibilityEvent()
var ev = new MenuVisibilityEvent
{
TargetPos = targetPos,
Visibility = visibility,
};

RaiseLocalEvent(player.Value, ref ev);
RaiseLocalEvent(player, ref ev);
visibility = ev.Visibility;

// Get entities
_entities.Clear();
var entitiesUnderMouse = _tree.QueryAabb(targetPos.MapId, Box2.CenteredAround(targetPos.Position, new Vector2(EntityMenuLookupSize, EntityMenuLookupSize)));

// Do we have to do FoV checks?
if ((visibility & MenuVisibility.NoFov) == 0)
// Initially, we include all entities returned by a sprite area lookup
var box = Box2.CenteredAround(targetPos.Position, new Vector2(_lookupSize, _lookupSize));
var queryResult = _tree.QueryAabb(targetPos.MapId, box);
entities = new List<EntityUid>(queryResult.Count);
foreach (var ent in queryResult)
{
bool Predicate(EntityUid e) => e == player;

TryComp(player.Value, out ExaminerComponent? examiner);

foreach (var ent in entitiesUnderMouse)
{
if (_examine.CanExamine(player.Value, targetPos, Predicate, ent.Uid, examiner))
_entities.Add(ent.Uid);
}
entities.Add(ent.Uid);
}
else

// If we're in a container list all other entities in it.
// E.g., allow players in lockers to examine / interact with other entities in the same locker
if (_containers.TryGetContainingContainer((player, null), out var container))
{
foreach (var ent in entitiesUnderMouse)
// Only include the container contents when clicking near it.
if (entities.Contains(container.Owner)
|| _containers.TryGetOuterContainer(container.Owner, Transform(container.Owner), out var outer)
&& entities.Contains(outer.Owner))
{
_entities.Add(ent.Uid);
// The container itself might be in some other container, so it might not have been added by the
// sprite tree lookup.
if (!entities.Contains(container.Owner))
entities.Add(container.Owner);

// TODO Context Menu
// This might miss entities in some situations. E.g., one of the contained entities entity in it, that
// itself has another entity attached to it, then we should be able to "see" that entity.
// E.g., if a security guard is on a segway and gets thrown in a locker, this wouldn't let you see the guard.
foreach (var ent in container.ContainedEntities)
{
if (!entities.Contains(ent))
entities.Add(ent);
}
}
}

if (_entities.Count == 0)
return false;

if (visibility == MenuVisibility.All)
if ((visibility & MenuVisibility.InContainer) != 0)
{
result = new (_entities);
return true;
// This is inefficient, but I'm lazy and CBF implementing my own recursive container method. Note that
// this might actually fail to add the contained children of some entities in the menu. E.g., an entity
// with a large sprite aabb, but small broadphase might appear in the menu, but have its children added
// by this.
var flags = LookupFlags.All & ~LookupFlags.Sensors;
foreach (var e in _lookup.GetEntitiesInRange(targetPos, _lookupSize, flags: flags))
{
if (!entities.Contains(e))
entities.Add(e);
}
}

// remove any entities in containers
if ((visibility & MenuVisibility.InContainer) == 0)
// Do we have to do FoV checks?
if ((visibility & MenuVisibility.NoFov) == 0)
{
for (var i = _entities.Count - 1; i >= 0; i--)
TryComp(player, out ExaminerComponent? examiner);
for (var i = entities.Count - 1; i >= 0; i--)
{
var entity = _entities[i];

if (ContainerSystem.IsInSameOrTransparentContainer(player.Value, entity))
continue;

_entities.RemoveSwap(i);
if (!_examine.CanExamine(player, targetPos, e => e == player, entities[i], examiner))
entities.RemoveSwap(i);
}
}

// remove any invisible entities
if ((visibility & MenuVisibility.Invisible) == 0)
if ((visibility & MenuVisibility.Invisible) != 0)
return entities.Count != 0;

for (var i = entities.Count - 1; i >= 0; i--)
{
var spriteQuery = GetEntityQuery<SpriteComponent>();
if (_tagSystem.HasTag(entities[i], "HideContextMenu"))
entities.RemoveSwap(i);
}

for (var i = _entities.Count - 1; i >= 0; i--)
{
var entity = _entities[i];
// Unless we added entities in containers, every entity should already have a visible sprite due to
// the fact that we used the sprite tree query.
if (container == null && (visibility & MenuVisibility.InContainer) == 0)
return entities.Count != 0;

if (!spriteQuery.TryGetComponent(entity, out var spriteComponent) ||
!spriteComponent.Visible ||
_tagSystem.HasTag(entity, "HideContextMenu"))
{
_entities.RemoveSwap(i);
}
}
var spriteQuery = GetEntityQuery<SpriteComponent>();
for (var i = entities.Count - 1; i >= 0; i--)
{
if (!spriteQuery.TryGetComponent(entities[i], out var spriteComponent) || !spriteComponent.Visible)
entities.RemoveSwap(i);
}

if (_entities.Count == 0)
return false;

result = new(_entities);
return true;
return entities.Count != 0;
}

/// <summary>
Expand Down
Loading
Loading