Skip to content

Commit

Permalink
Merge pull request #1666 from space-syndicate/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Morb0 authored Dec 23, 2023
2 parents c44c469 + 203db7d commit 8c482a0
Show file tree
Hide file tree
Showing 467 changed files with 8,003 additions and 5,550 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Linq;
using Content.Client.Administration.Systems;
using Content.Client.UserInterface.Controls;
using Content.Client.Verbs;
using Content.Client.Verbs.UI;
using Content.Shared.Administration;
using Content.Shared.Input;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
Expand Down Expand Up @@ -39,6 +37,7 @@ public PlayerListControl()
RobustXamlLoader.Load(this);
// Fill the Option data
PlayerListContainer.ItemPressed += PlayerListItemPressed;
PlayerListContainer.ItemKeyBindDown += PlayerListItemKeyBindDown;
PlayerListContainer.GenerateItem += GenerateButton;
PopulateList(_adminSystem.PlayerList);
FilterLineEdit.OnTextChanged += _ => FilterList();
Expand All @@ -50,18 +49,27 @@ private void PlayerListItemPressed(BaseButton.ButtonEventArgs? args, ListData? d
{
if (args == null || data is not PlayerListData {Info: var selectedPlayer})
return;
if (args.Event.Function == EngineKeyFunctions.UIClick)
{
OnSelectionChanged?.Invoke(selectedPlayer);

// update label text. Only required if there is some override (e.g. unread bwoink count).
if (OverrideText != null && args.Button.Children.FirstOrDefault()?.Children?.FirstOrDefault() is Label label)
label.Text = GetText(selectedPlayer);
}
else if (args.Event.Function == EngineKeyFunctions.UseSecondary && selectedPlayer.NetEntity != null)
{
_uiManager.GetUIController<VerbMenuUIController>().OpenVerbMenu(selectedPlayer.NetEntity.Value, true);
}
if (args.Event.Function != EngineKeyFunctions.UIClick)
return;

OnSelectionChanged?.Invoke(selectedPlayer);

// update label text. Only required if there is some override (e.g. unread bwoink count).
if (OverrideText != null && args.Button.Children.FirstOrDefault()?.Children?.FirstOrDefault() is Label label)
label.Text = GetText(selectedPlayer);
}

private void PlayerListItemKeyBindDown(GUIBoundKeyEventArgs? args, ListData? data)
{
if (args == null || data is not PlayerListData { Info: var selectedPlayer })
return;

if (args.Function != EngineKeyFunctions.UIRightClick || selectedPlayer.NetEntity == null)
return;

_uiManager.GetUIController<VerbMenuUIController>().OpenVerbMenu(selectedPlayer.NetEntity.Value, true);
args.Handle();
}

public void StopFiltering()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Content.Client.Station;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Map.Components;

Expand All @@ -15,7 +14,7 @@ public sealed partial class ObjectsTab : Control
private readonly List<ObjectsTabEntry> _objects = new();
private List<ObjectsTabSelection> _selections = new();

public event Action<BaseButton.ButtonEventArgs>? OnEntryPressed;
public event Action<ObjectsTabEntry, GUIBoundKeyEventArgs>? OnEntryKeyBindDown;

public ObjectsTab()
{
Expand Down Expand Up @@ -82,7 +81,7 @@ private void RefreshObjectList(ObjectsTabSelection selection)
var ctrl = new ObjectsTabEntry(name, entity);
_objects.Add(ctrl);
ObjectList.AddChild(ctrl);
ctrl.OnPressed += args => OnEntryPressed?.Invoke(args);
ctrl.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(ctrl, args);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed partial class PlayerTab : Control
private bool _ascending = true;
private bool _showDisconnected;

public event Action<ButtonEventArgs>? OnEntryPressed;
public event Action<PlayerTabEntry, GUIBoundKeyEventArgs>? OnEntryKeyBindDown;

public PlayerTab()
{
Expand Down Expand Up @@ -123,7 +123,7 @@ private void RefreshPlayerList(IReadOnlyList<PlayerInfo> players)
player.Connected,
player.PlaytimeString);
entry.PlayerEntity = player.NetEntity;
entry.OnPressed += args => OnEntryPressed?.Invoke(args);
entry.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(entry, args);
entry.ToolTip = Loc.GetString("player-tab-entry-tooltip");
PlayerList.AddChild(entry);

Expand Down
14 changes: 4 additions & 10 deletions Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void InitializeAmbientMusic()
_nextAudio = TimeSpan.MaxValue;

SetupAmbientSounds();
_proto.PrototypesReloaded += OnProtoReload;
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnProtoReload);
_state.OnStateChanged += OnStateChange;
// On round end summary OR lobby cut audio.
SubscribeNetworkEvent<RoundEndMessageEvent>(OnRoundEndMessage);
Expand All @@ -86,21 +86,14 @@ private void AmbienceCVarChanged(float obj)
private void ShutdownAmbientMusic()
{
_configManager.UnsubValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged);
_proto.PrototypesReloaded -= OnProtoReload;
_state.OnStateChanged -= OnStateChange;
_ambientMusicStream = _audio.Stop(_ambientMusicStream);
}

private void OnProtoReload(PrototypesReloadedEventArgs obj)
{
if (!obj.ByType.ContainsKey(typeof(AmbientMusicPrototype)) &&
!obj.ByType.ContainsKey(typeof(RulesPrototype)))
{
return;
}

_ambientSounds.Clear();
SetupAmbientSounds();
if (obj.WasModified<AmbientMusicPrototype>() || obj.WasModified<RulesPrototype>())
SetupAmbientSounds();
}

private void OnStateChange(StateChangedEventArgs obj)
Expand All @@ -114,6 +107,7 @@ private void OnStateChange(StateChangedEventArgs obj)

private void SetupAmbientSounds()
{
_ambientSounds.Clear();
foreach (var ambience in _proto.EnumeratePrototypes<AmbientMusicPrototype>())
{
var tracks = _ambientSounds.GetOrNew(ambience.ID);
Expand Down
13 changes: 4 additions & 9 deletions Content.Client/Clothing/Systems/ChameleonClothingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,13 @@ public override void Initialize()
SubscribeLocalEvent<ChameleonClothingComponent, AfterAutoHandleStateEvent>(HandleState);

PrepareAllVariants();
_proto.PrototypesReloaded += OnProtoReloaded;
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnProtoReloaded);
}

public override void Shutdown()
private void OnProtoReloaded(PrototypesReloadedEventArgs args)
{
base.Shutdown();
_proto.PrototypesReloaded -= OnProtoReloaded;
}

private void OnProtoReloaded(PrototypesReloadedEventArgs _)
{
PrepareAllVariants();
if (args.WasModified<EntityPrototype>())
PrepareAllVariants();
}

private void HandleState(EntityUid uid, ChameleonClothingComponent component, ref AfterAutoHandleStateEvent args)
Expand Down
18 changes: 6 additions & 12 deletions Content.Client/CrewManifest/CrewManifestSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Content.Client.GameTicking.Managers;
using Content.Shared.CrewManifest;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;
Expand All @@ -19,12 +18,7 @@ public override void Initialize()
base.Initialize();

BuildDepartmentLookup();
_prototypeManager.PrototypesReloaded += OnPrototypesReload;
}

public override void Shutdown()
{
_prototypeManager.PrototypesReloaded -= OnPrototypesReload;
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypesReload);
}

/// <summary>
Expand All @@ -36,16 +30,16 @@ public void RequestCrewManifest(NetEntity netEntity)
RaiseNetworkEvent(new RequestCrewManifestMessage(netEntity));
}

private void OnPrototypesReload(PrototypesReloadedEventArgs _)
private void OnPrototypesReload(PrototypesReloadedEventArgs args)
{
_jobDepartmentLookup.Clear();
_departments.Clear();

BuildDepartmentLookup();
if (args.WasModified<DepartmentPrototype>())
BuildDepartmentLookup();
}

private void BuildDepartmentLookup()
{
_jobDepartmentLookup.Clear();
_departments.Clear();
foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{
_departments.Add(department.ID);
Expand Down
11 changes: 11 additions & 0 deletions Content.Client/MagicMirror/MagicMirrorBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,16 @@ protected override void ReceiveMessage(BoundUserInterfaceMessage message)

_window.UpdateState(data);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;

if (_window != null)
_window.OnClose -= Close;

_window?.Dispose();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,6 @@ public void ClearAllOverlays()
_overlay.RemoveOverlay(overlay);
}

// hacky solution related to mapping
public void SetActiveDeviceList(EntityUid tool, EntityUid list, NetworkConfiguratorComponent? component = null)
{
if (!Resolve(tool, ref component))
{
return;
}

component.ActiveDeviceList = list;
}

private sealed class StatusControl : Control
{
private readonly RichTextLabel _label;
Expand Down
6 changes: 2 additions & 4 deletions Content.Client/Parallax/ParallaxSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ public override void Initialize()
{
base.Initialize();
_overlay.AddOverlay(new ParallaxOverlay());
_protoManager.PrototypesReloaded += OnReload;

SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnReload);
SubscribeLocalEvent<ParallaxComponent, AfterAutoHandleStateEvent>(OnAfterAutoHandleState);
}

private void OnReload(PrototypesReloadedEventArgs obj)
{
if (!obj.ByType.ContainsKey(typeof(ParallaxPrototype)))
if (!obj.WasModified<ParallaxPrototype>())
return;

_parallax.UnloadParallax(Fallback);
Expand All @@ -48,7 +47,6 @@ public override void Shutdown()
{
base.Shutdown();
_overlay.RemoveOverlay<ParallaxOverlay>();
_protoManager.PrototypesReloaded -= OnReload;
}

private void OnAfterAutoHandleState(EntityUid uid, ParallaxComponent component, ref AfterAutoHandleStateEvent args)
Expand Down
14 changes: 12 additions & 2 deletions Content.Client/Pinpointer/UI/NavMapControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ public partial class NavMapControl : MapGridControl
protected float UpdateTime = 1.0f;
protected float MaxSelectableDistance = 10f;
protected float RecenterMinimum = 0.05f;
protected float MinDragDistance = 5f;

// Local variables
private Vector2 _offset;
private bool _draggin;
private Vector2 _startDragPosition = default!;
private bool _recentering = false;
private readonly Font _font;
private float _updateTimer = 0.25f;
Expand Down Expand Up @@ -168,23 +170,31 @@ protected override void KeyBindDown(GUIBoundKeyEventArgs args)
base.KeyBindDown(args);

if (args.Function == EngineKeyFunctions.Use)
{
_startDragPosition = args.PointerLocation.Position;
_draggin = true;
}
}

protected override void KeyBindUp(GUIBoundKeyEventArgs args)
{
base.KeyBindUp(args);

if (args.Function == EngineKeyFunctions.Use)
_draggin = false;

if (TrackedEntitySelectedAction == null)
return;

if (args.Function == EngineKeyFunctions.Use)
{
_draggin = false;

if (_xform == null || _physics == null || TrackedEntities.Count == 0)
return;

// If the cursor has moved a significant distance, exit
if ((_startDragPosition - args.PointerLocation.Position).Length() > MinDragDistance)
return;

// Get the clicked position
var offset = _offset + _physics.LocalCenter;
var localPosition = args.PointerLocation.Position - GlobalPixelPosition;
Expand Down
5 changes: 5 additions & 0 deletions Content.Client/UserInterface/BoundKeyHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public static string ShortKeyName(BoundKeyFunction keyFunction)
return TryGetShortKeyName(keyFunction, out var name) ? Loc.GetString(name) : " ";
}

public static bool IsBound(BoundKeyFunction keyFunction)
{
return TryGetShortKeyName(keyFunction, out _);
}

private static string? DefaultShortKeyName(BoundKeyFunction keyFunction)
{
var name = FormattedMessage.EscapeText(IoCManager.Resolve<IInputManager>().GetKeyFunctionButtonString(keyFunction));
Expand Down
7 changes: 7 additions & 0 deletions Content.Client/UserInterface/Controls/ListContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public bool Group
public bool Toggle { get; set; }
public Action<ListData, ListContainerButton>? GenerateItem;
public Action<BaseButton.ButtonEventArgs?, ListData?>? ItemPressed;
public Action<GUIBoundKeyEventArgs, ListData?>? ItemKeyBindDown;
public IReadOnlyList<ListData> Data => _data;

private const int DefaultSeparation = 3;
Expand Down Expand Up @@ -135,6 +136,11 @@ private void OnItemPressed(BaseButton.ButtonEventArgs args)
ItemPressed?.Invoke(args, button.Data);
}

private void OnItemKeyBindDown(ListContainerButton button, GUIBoundKeyEventArgs args)
{
ItemKeyBindDown?.Invoke(args, button.Data);
}

[Pure]
private Vector2 GetScrollValue()
{
Expand Down Expand Up @@ -256,6 +262,7 @@ protected override Vector2 ArrangeOverride(Vector2 finalSize)
{
button = new ListContainerButton(data);
button.OnPressed += OnItemPressed;
button.OnKeyBindDown += args => OnItemKeyBindDown(button, args);
button.ToggleMode = Toggle;
button.Group = _buttonGroup;

Expand Down
Loading

0 comments on commit 8c482a0

Please sign in to comment.