Skip to content

Commit

Permalink
Merge pull request #713 from Rxup/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Aug 6, 2024
2 parents dec8c8f + d7e7824 commit 41ec878
Show file tree
Hide file tree
Showing 569 changed files with 17,423 additions and 16,777 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Actions/ActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void LoadActionAssignments(string path, bool userData)
continue;

var action = _serialization.Read<BaseActionComponent>(actionNode, notNullableOverride: true);
var actionId = Spawn(null);
var actionId = Spawn();
AddComp(actionId, action);
AddActionDirect(user, actionId);

Expand Down
50 changes: 44 additions & 6 deletions Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,51 @@ public BwoinkControl()
var ach = AHelpHelper.EnsurePanel(a.SessionId);
var bch = AHelpHelper.EnsurePanel(b.SessionId);

// First, sort by unread. Any chat with unread messages appears first. We just sort based on unread
// status, not number of unread messages, so that more recent unread messages take priority.
// Pinned players first
if (a.IsPinned != b.IsPinned)
return a.IsPinned ? -1 : 1;

// First, sort by unread. Any chat with unread messages appears first.
var aUnread = ach.Unread > 0;
var bUnread = bch.Unread > 0;
if (aUnread != bUnread)
return aUnread ? -1 : 1;

// Sort by recent messages during the current round.
var aRecent = a.ActiveThisRound && ach.LastMessage != DateTime.MinValue;
var bRecent = b.ActiveThisRound && bch.LastMessage != DateTime.MinValue;
if (aRecent != bRecent)
return aRecent ? -1 : 1;

// Next, sort by connection status. Any disconnected players are grouped towards the end.
if (a.Connected != b.Connected)
return a.Connected ? -1 : 1;

// Next, group by whether or not the players have participated in this round.
// The ahelp window shows all players that have connected since server restart, this groups them all towards the bottom.
if (a.ActiveThisRound != b.ActiveThisRound)
return a.ActiveThisRound ? -1 : 1;
// Sort connected players by New Player status, then by Antag status
if (a.Connected && b.Connected)
{
var aNewPlayer = a.OverallPlaytime <= TimeSpan.FromMinutes(_cfg.GetCVar(CCVars.NewPlayerThreshold));
var bNewPlayer = b.OverallPlaytime <= TimeSpan.FromMinutes(_cfg.GetCVar(CCVars.NewPlayerThreshold));

if (aNewPlayer != bNewPlayer)
return aNewPlayer ? -1 : 1;

if (a.Antag != b.Antag)
return a.Antag ? -1 : 1;
}

// Sort disconnected players by participation in the round
if (!a.Connected && !b.Connected)
{
if (a.ActiveThisRound != b.ActiveThisRound)
return a.ActiveThisRound ? -1 : 1;
}

// Finally, sort by the most recent message.
return bch.LastMessage.CompareTo(ach.LastMessage);
};


Bans.OnPressed += _ =>
{
if (_currentPlayer is not null)
Expand Down Expand Up @@ -266,7 +291,20 @@ private void SwitchToChannel(NetUserId? ch)

public void PopulateList()
{
// Maintain existing pin statuses
var pinnedPlayers = ChannelSelector.PlayerInfo.Where(p => p.IsPinned).ToDictionary(p => p.SessionId);

ChannelSelector.PopulateList();

// Restore pin statuses
foreach (var player in ChannelSelector.PlayerInfo)
{
if (pinnedPlayers.TryGetValue(player.SessionId, out var pinnedPlayer))
{
player.IsPinned = pinnedPlayer.IsPinned;
}
}

UpdateButtons();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public sealed partial class PlayerListControl : BoxContainer

private readonly IEntityManager _entManager;
private readonly IUserInterfaceManager _uiManager;

private PlayerInfo? _selectedPlayer;

private List<PlayerInfo> _playerList = new();
private readonly List<PlayerInfo> _sortedPlayerList = new();
private List<PlayerInfo> _sortedPlayerList = new();

public Comparison<PlayerInfo>? Comparison;
public Func<PlayerInfo, string, string>? OverrideText;
Expand Down Expand Up @@ -110,19 +110,30 @@ private void FilterList()
if (Comparison != null)
_sortedPlayerList.Sort((a, b) => Comparison(a, b));

// Ensure pinned players are always at the top
_sortedPlayerList.Sort((a, b) => a.IsPinned != b.IsPinned && a.IsPinned ? -1 : 1);

PlayerListContainer.PopulateList(_sortedPlayerList.Select(info => new PlayerListData(info)).ToList());
if (_selectedPlayer != null)
PlayerListContainer.Select(new PlayerListData(_selectedPlayer));
}


public void PopulateList(IReadOnlyList<PlayerInfo>? players = null)
{
// Maintain existing pin statuses
var pinnedPlayers = _playerList.Where(p => p.IsPinned).ToDictionary(p => p.SessionId);

players ??= _adminSystem.PlayerList;

_playerList = players.ToList();

// Restore pin statuses
foreach (var player in _playerList)
{
if (pinnedPlayers.TryGetValue(player.SessionId, out var pinnedPlayer))
{
player.IsPinned = pinnedPlayer.IsPinned;
}
}

if (_selectedPlayer != null && !_playerList.Contains(_selectedPlayer))
_selectedPlayer = null;

Expand Down
6 changes: 3 additions & 3 deletions Content.Client/Backmen/StationAI/AiEnemySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public sealed class AiEnemySystem : SharedAiEnemySystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
private EntityQuery<GhostComponent> _ghostQuery;

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

SubscribeLocalEvent<AIEnemyNTComponent, GetStatusIconsEvent>(GetIcon);
_ghostQuery = GetEntityQuery<GhostComponent>();
}

protected override void ToggleEnemy(EntityUid u, EntityUid target)
Expand All @@ -33,10 +35,8 @@ private void GetIcon(Entity<AIEnemyNTComponent> target, ref GetStatusIconsEvent
{
var ent = _player.LocalSession?.AttachedEntity ?? EntityUid.Invalid;

if (!EntityQuery.HasComponent(ent))
{
if (!EntityQuery.HasComp(ent) && !_ghostQuery.HasComp(ent))
return;
}
args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(AiEnemyStatus));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
Expand All @@ -9,18 +10,25 @@ namespace Content.Client.Chemistry.UI
[UsedImplicitly]
public sealed class TransferAmountBoundUserInterface : BoundUserInterface
{
private IEntityManager _entManager;
private EntityUid _owner;
[ViewVariables]
private TransferAmountWindow? _window;

public TransferAmountBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_owner = owner;
_entManager = IoCManager.Resolve<IEntityManager>();
}

protected override void Open()
{
base.Open();
_window = this.CreateWindow<TransferAmountWindow>();

if (_entManager.TryGetComponent<SolutionTransferComponent>(_owner, out var comp))
_window.SetBounds(comp.MinimumTransferAmount.Int(), comp.MaximumTransferAmount.Int());

_window.ApplyButton.OnPressed += _ =>
{
if (int.TryParse(_window.AmountLineEdit.Text, out var i))
Expand Down
4 changes: 4 additions & 0 deletions Content.Client/Chemistry/UI/TransferAmountWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<BoxContainer Orientation="Horizontal">
<LineEdit Name="AmountLineEdit" Access="Public" HorizontalExpand="True" PlaceHolder="{Loc 'ui-transfer-amount-line-edit-placeholder'}"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Name="MinimumAmount" Access="Public" HorizontalExpand="True" />
<Label Name="MaximumAmount" Access="Public" />
</BoxContainer>
<Button Name="ApplyButton" Access="Public" Text="{Loc 'ui-transfer-amount-apply'}"/>
</BoxContainer>
</DefaultWindow>
20 changes: 20 additions & 0 deletions Content.Client/Chemistry/UI/TransferAmountWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@ namespace Content.Client.Chemistry.UI
[GenerateTypedNameReferences]
public sealed partial class TransferAmountWindow : DefaultWindow
{
private int _max = Int32.MaxValue;
private int _min = 1;

public TransferAmountWindow()
{
RobustXamlLoader.Load(this);
AmountLineEdit.OnTextChanged += OnValueChanged;
}

public void SetBounds(int min, int max)
{
_min = min;
_max = max;
MinimumAmount.Text = Loc.GetString("comp-solution-transfer-set-amount-min", ("amount", _min));
MaximumAmount.Text = Loc.GetString("comp-solution-transfer-set-amount-max", ("amount", _max));
}

private void OnValueChanged(LineEdit.LineEditEventArgs args)
{
if (!int.TryParse(AmountLineEdit.Text, out var amount) || amount > _max || amount < _min)
ApplyButton.Disabled = true;
else
ApplyButton.Disabled = false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Clothing;
using Content.Shared.Clothing.Components;
using Content.Shared.Hands;
using Content.Shared.Item;
using Content.Shared.Rounding;
Expand All @@ -20,6 +22,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<SolutionContainerVisualsComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<SolutionContainerVisualsComponent, GetInhandVisualsEvent>(OnGetHeldVisuals);
SubscribeLocalEvent<SolutionContainerVisualsComponent, GetEquipmentVisualsEvent>(OnGetClothingVisuals);
}

private void OnMapInit(EntityUid uid, SolutionContainerVisualsComponent component, MapInitEvent args)
Expand Down Expand Up @@ -174,4 +177,41 @@ private void OnGetHeldVisuals(EntityUid uid, SolutionContainerVisualsComponent c
args.Layers.Add((key, layer));
}
}

private void OnGetClothingVisuals(Entity<SolutionContainerVisualsComponent> ent, ref GetEquipmentVisualsEvent args)
{
if (ent.Comp.EquippedFillBaseName == null)
return;

if (!TryComp<AppearanceComponent>(ent, out var appearance))
return;

if (!TryComp<ClothingComponent>(ent, out var clothing))
return;

if (!AppearanceSystem.TryGetData<float>(ent, SolutionContainerVisuals.FillFraction, out var fraction, appearance))
return;

var closestFillSprite = ContentHelpers.RoundToLevels(fraction, 1, ent.Comp.EquippedMaxFillLevels + 1);

if (closestFillSprite > 0)
{
var layer = new PrototypeLayerData();

var equippedPrefix = clothing.EquippedPrefix == null ? $"equipped-{args.Slot}" : $" {clothing.EquippedPrefix}-equipped-{args.Slot}";
var key = equippedPrefix + ent.Comp.EquippedFillBaseName + closestFillSprite;

// Make sure the sprite state is valid so we don't show a big red error message
// This saves us from having to make fill level sprites for every possible slot the item could be in (including pockets).
if (!TryComp<SpriteComponent>(ent, out var sprite) || sprite.BaseRSI == null || !sprite.BaseRSI.TryGetState(key, out _))
return;

layer.State = key;

if (ent.Comp.ChangeColor && AppearanceSystem.TryGetData<Color>(ent, SolutionContainerVisuals.Color, out var color, appearance))
layer.Color = color;

args.Layers.Add((key, layer));
}
}
}
25 changes: 1 addition & 24 deletions Content.Client/Commands/ActionsCommands.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Client.Actions;
using Content.Client.Actions;
using Content.Client.Mapping;
using Content.Shared.Administration;
Expand Down Expand Up @@ -61,27 +62,3 @@ public override void Execute(IConsoleShell shell, string argStr, string[] args)
}
}
}

[AnyCommand]
public sealed class LoadMappingActionsCommand : LocalizedCommands
{
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;

public const string CommandName = "loadmapacts";

public override string Command => CommandName;

public override string Help => LocalizationManager.GetString($"cmd-{Command}-help", ("command", Command));

public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
try
{
_entitySystemManager.GetEntitySystem<MappingSystem>().LoadMappingActions();
}
catch
{
shell.WriteError(LocalizationManager.GetString($"cmd-{Command}-error"));
}
}
}
2 changes: 1 addition & 1 deletion Content.Client/Commands/HideMechanismsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Execute(IConsoleShell shell, string argStr, string[] args)
sprite.ContainerOccluded = false;

var tempParent = uid;
while (containerSys.TryGetContainingContainer(tempParent, out var container))
while (containerSys.TryGetContainingContainer((tempParent, null, null), out var container))
{
if (!container.ShowContents)
{
Expand Down
7 changes: 5 additions & 2 deletions Content.Client/Commands/MappingClientSideSetupCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Content.Client.Mapping;
using Content.Client.Markers;
using JetBrains.Annotations;
using Robust.Client.Graphics;
using Robust.Client.State;
using Robust.Shared.Console;

namespace Content.Client.Commands;
Expand All @@ -10,6 +12,7 @@ internal sealed class MappingClientSideSetupCommand : LocalizedCommands
{
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly ILightManager _lightManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!;

public override string Command => "mappingclientsidesetup";

Expand All @@ -21,8 +24,8 @@ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
_entitySystemManager.GetEntitySystem<MarkerSystem>().MarkersVisible = true;
_lightManager.Enabled = false;
shell.ExecuteCommand(ShowSubFloorForever.CommandName);
shell.ExecuteCommand(LoadMappingActionsCommand.CommandName);
shell.ExecuteCommand("showsubfloorforever");
_stateManager.RequestStateChange<MappingState>();
}
}
}
Expand Down
Loading

0 comments on commit 41ec878

Please sign in to comment.