Skip to content

Commit

Permalink
Merge pull request Rxup#414 from Rxup/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Jan 6, 2024
2 parents 7b4eb64 + b82760d commit 9e475af
Show file tree
Hide file tree
Showing 223 changed files with 89,435 additions and 87,821 deletions.
1 change: 1 addition & 0 deletions Content.Benchmarks/EntityManagerGetAllComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void Setup()
var componentFactory = new Mock<IComponentFactory>();
componentFactory.Setup(p => p.GetComponent<DummyComponent>()).Returns(new DummyComponent());
componentFactory.Setup(p => p.GetRegistration(It.IsAny<DummyComponent>())).Returns(dummyReg);
componentFactory.Setup(p => p.GetAllRegistrations()).Returns(new[] { dummyReg });
componentFactory.Setup(p => p.GetAllRefTypes()).Returns(new[] { CompIdx.Index<DummyComponent>() });

IoCManager.RegisterInstance<IComponentFactory>(componentFactory.Object);
Expand Down
35 changes: 19 additions & 16 deletions Content.Client/Construction/ConstructionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,30 @@ public override void Shutdown()

private void HandleConstructionGhostExamined(EntityUid uid, ConstructionGhostComponent component, ExaminedEvent args)
{
if (component.Prototype == null) return;
if (component.Prototype == null)
return;

args.PushMarkup(Loc.GetString(
"construction-ghost-examine-message",
("name", component.Prototype.Name)));
using (args.PushGroup(nameof(ConstructionGhostComponent)))
{
args.PushMarkup(Loc.GetString(
"construction-ghost-examine-message",
("name", component.Prototype.Name)));

if (!_prototypeManager.TryIndex(component.Prototype.Graph, out ConstructionGraphPrototype? graph))
return;
if (!_prototypeManager.TryIndex(component.Prototype.Graph, out ConstructionGraphPrototype? graph))
return;

var startNode = graph.Nodes[component.Prototype.StartNode];
var startNode = graph.Nodes[component.Prototype.StartNode];

if (!graph.TryPath(component.Prototype.StartNode, component.Prototype.TargetNode, out var path) ||
!startNode.TryGetEdge(path[0].Name, out var edge))
{
return;
}
if (!graph.TryPath(component.Prototype.StartNode, component.Prototype.TargetNode, out var path) ||
!startNode.TryGetEdge(path[0].Name, out var edge))
{
return;
}

foreach (ConstructionGraphStep step in edge.Steps)
{
args.Message.PushNewline();
step.DoExamine(args);
foreach (var step in edge.Steps)
{
step.DoExamine(args);
}
}
}

Expand Down
16 changes: 8 additions & 8 deletions Content.Client/Examine/ExamineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,14 @@ public void DoExamine(EntityUid entity, bool centeredOnCursor = true, EntityUid?
var canSeeClearly = !HasComp<BlurryVisionComponent>(playerEnt);

OpenTooltip(playerEnt.Value, entity, centeredOnCursor, false, knowTarget: canSeeClearly);
if (IsClientSide(entity)
|| _client.RunLevel == ClientRunLevel.SinglePlayerGame) // i.e. a replay
{
message = GetExamineText(entity, playerEnt);
UpdateTooltipInfo(playerEnt.Value, entity, message);
}
else

// Always update tooltip info from client first.
// If we get it wrong, server will correct us later anyway.
// This will usually be correct (barring server-only components, which generally only adds, not replaces text)
message = GetExamineText(entity, playerEnt);
UpdateTooltipInfo(playerEnt.Value, entity, message);

if (!IsClientSide(entity))
{
// Ask server for extra examine info.
if (entity != _lastExaminedEntity)
Expand All @@ -383,7 +384,6 @@ public void DoExamine(EntityUid entity, bool centeredOnCursor = true, EntityUid?
}

RaiseLocalEvent(entity, new ClientExaminedEvent(entity, playerEnt.Value));

_lastExaminedEntity = entity;
}

Expand Down
20 changes: 0 additions & 20 deletions Content.Client/GameTicking/Managers/ClientGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public sealed class ClientGameTicker : SharedGameTicker
[ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? LobbySong { get; private set; }
[ViewVariables] public string? RestartSound { get; private set; }
[ViewVariables] public string? LobbyBackground { get; private set; }
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
[ViewVariables] public string? ServerInfoBlob { get; private set; }
Expand Down Expand Up @@ -68,7 +67,6 @@ public override void Initialize()
});
SubscribeNetworkEvent<TickerLateJoinStatusEvent>(LateJoinStatus);
SubscribeNetworkEvent<TickerJobsAvailableEvent>(UpdateJobsAvailable);
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup);

_initialized = true;
}
Expand Down Expand Up @@ -147,7 +145,6 @@ private void RoundEnd(RoundEndMessageEvent message)
{
// Force an update in the event of this song being the same as the last.
SetLobbySong(message.LobbySong, true);
RestartSound = message.RestartSound;

// Don't open duplicate windows (mainly for replays).
if (_window?.RoundId == message.RoundId)
Expand All @@ -156,22 +153,5 @@ private void RoundEnd(RoundEndMessageEvent message)
//This is not ideal at all, but I don't see an immediately better fit anywhere else.
_window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, _entityManager);
}

private void RoundRestartCleanup(RoundRestartCleanupEvent ev)
{
if (string.IsNullOrEmpty(RestartSound))
return;

if (!_configManager.GetCVar(CCVars.RestartSoundsEnabled))
{
RestartSound = null;
return;
}

_audio.PlayGlobal(RestartSound, Filter.Local(), false);

// Cleanup the sound, we only want it to play when the round restarts after it ends normally.
RestartSound = null;
}
}
}
8 changes: 7 additions & 1 deletion Content.Client/Launcher/LauncherConnecting.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using Robust.Client;
using Robust.Client.UserInterface;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

namespace Content.Client.Launcher
{
Expand All @@ -13,6 +16,9 @@ public sealed class LauncherConnecting : Robust.Client.State.State
[Dependency] private readonly IClientNetManager _clientNetManager = default!;
[Dependency] private readonly IGameController _gameController = default!;
[Dependency] private readonly IBaseClient _baseClient = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

private LauncherConnectingGui? _control;

Expand Down Expand Up @@ -51,7 +57,7 @@ private set

protected override void Startup()
{
_control = new LauncherConnectingGui(this);
_control = new LauncherConnectingGui(this, _random, _prototypeManager, _cfg);

_userInterfaceManager.StateRoot.AddChild(_control);

Expand Down
13 changes: 13 additions & 0 deletions Content.Client/Launcher/LauncherConnectingGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,17 @@
</BoxContainer>
</BoxContainer>
</Control>
<!-- Bottom window for tips -->
<PanelContainer Name="LoginTips" StyleClasses="AngleRect" Margin="0 10" MaxWidth="600" VerticalExpand="True" VerticalAlignment="Bottom">
<BoxContainer Orientation="Vertical" VerticalExpand="True">
<controls:StripeBack>
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Center">
<Label Name="LoginTipTitle" Text="Tip" StyleClasses="LabelHeading" Align="Center"/>
</BoxContainer>
</controls:StripeBack>
<BoxContainer Orientation="Vertical" Margin="5 5 5 5" >
<RichTextLabel Name="LoginTip" VerticalExpand="True" />
</BoxContainer>
</BoxContainer>
</PanelContainer>
</Control>
40 changes: 39 additions & 1 deletion Content.Client/Launcher/LauncherConnectingGui.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using System.Linq;
using Content.Client.Stylesheets;
using Content.Shared.CCVar;
using Content.Shared.Dataset;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
using Robust.Shared.Localization;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

namespace Content.Client.Launcher
{
Expand All @@ -15,18 +21,27 @@ public sealed partial class LauncherConnectingGui : Control
{
private const float RedialWaitTimeSeconds = 15f;
private readonly LauncherConnecting _state;
private readonly IRobustRandom _random;
private readonly IPrototypeManager _prototype;
private readonly IConfigurationManager _cfg;

private float _redialWaitTime = RedialWaitTimeSeconds;

public LauncherConnectingGui(LauncherConnecting state)
public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,
IPrototypeManager prototype, IConfigurationManager config)
{
_state = state;
_random = random;
_prototype = prototype;
_cfg = config;

RobustXamlLoader.Load(this);

LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);

Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;

ChangeLoginTip();
ReconnectButton.OnPressed += _ => _state.RetryConnect();
// Redial shouldn't fail, but if it does, try a reconnect (maybe we're being run from debug)
RedialButton.OnPressed += _ =>
Expand Down Expand Up @@ -67,6 +82,29 @@ private void LastNetDisconnectedArgsChanged(NetDisconnectedArgs? args)
ReconnectButton.Visible = !redialFlag;
}

private void ChangeLoginTip()
{
var tipsDataset = _cfg.GetCVar(CCVars.LoginTipsDataset);
var loginTipsEnabled = _prototype.TryIndex<DatasetPrototype>(tipsDataset, out var tips);

LoginTips.Visible = loginTipsEnabled;
if (!loginTipsEnabled)
{
return;
}

var tipList = tips!.Values;

if (tipList.Count == 0)
return;

var randomIndex = _random.Next(tipList.Count);
var tip = tipList[randomIndex];
LoginTip.SetMessage(tip);

LoginTipTitle.Text = Loc.GetString("connecting-window-tip", ("numberTip", randomIndex));
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
Expand Down
8 changes: 5 additions & 3 deletions Content.Client/MagicMirror/MagicMirrorBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected override void Open()
_window.OnFacialHairSlotAdded += delegate () { AddSlot(MagicMirrorCategory.FacialHair); };
_window.OnFacialHairSlotRemoved += args => RemoveSlot(MagicMirrorCategory.FacialHair, args);

_window.OnClose += Close;
_window.OpenCentered();
}

Expand All @@ -53,17 +54,18 @@ private void AddSlot(MagicMirrorCategory category)
SendMessage(new MagicMirrorAddSlotMessage(category));
}

protected override void ReceiveMessage(BoundUserInterfaceMessage message)
protected override void UpdateState(BoundUserInterfaceState state)
{
base.ReceiveMessage(message);
base.UpdateState(state);

if (message is not MagicMirrorUiData data || _window == null)
if (state is not MagicMirrorUiState data || _window == null)
{
return;
}

_window.UpdateState(data);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
Expand Down
7 changes: 2 additions & 5 deletions Content.Client/MagicMirror/MagicMirrorWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public sealed partial class MagicMirrorWindow : DefaultWindow
public Action<int>? OnFacialHairSlotRemoved;
public Action? OnFacialHairSlotAdded;

private bool _noHair;

public MagicMirrorWindow()
{
RobustXamlLoader.Load(this);
Expand All @@ -38,15 +36,14 @@ public MagicMirrorWindow()
FacialHairPicker.OnSlotAdd += delegate { OnFacialHairSlotAdded!(); };
}

public void UpdateState(MagicMirrorUiData state)
public void UpdateState(MagicMirrorUiState state)
{
HairPicker.UpdateData(state.Hair, state.Species, state.HairSlotTotal);
FacialHairPicker.UpdateData(state.FacialHair, state.Species, state.FacialHairSlotTotal);

if (!HairPicker.Visible && !FacialHairPicker.Visible && !_noHair)
if (!HairPicker.Visible && !FacialHairPicker.Visible)
{
AddChild(new Label { Text = Loc.GetString("magic-mirror-component-activate-user-has-no-hair") });
_noHair = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public NavMapBeaconBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner,
protected override void Open()
{
base.Open();

_window = new NavMapBeaconWindow(Owner);
_window.OpenCentered();
_window.OnClose += Close;
Expand Down
35 changes: 35 additions & 0 deletions Content.Client/Pinpointer/UI/UntrackedMapBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Robust.Client.GameObjects;

namespace Content.Client.Pinpointer.UI;

public sealed class UntrackedStationMapBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private StationMapWindow? _window;

public UntrackedStationMapBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();
_window?.Close();
EntityUid? gridUid = null;

if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
{
gridUid = xform.GridUid;
}

_window = new StationMapWindow(gridUid, null);
_window.OpenCentered();
_window.OnClose += Close;
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ await Interact(
Screw,
Pry,
Wrench,
Weld);
Screw);

// construction finished, entity no longer exists.
AssertDeleted();
Expand Down
2 changes: 0 additions & 2 deletions Content.Server/Afk/AfkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.Input;
using Robust.Shared.Player;
using Robust.Shared.Timing;

Expand Down Expand Up @@ -35,7 +34,6 @@ public interface IAfkManager
[UsedImplicitly]
public sealed class AfkManager : IAfkManager
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Atmos/EntitySystems/GasTankSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private void OnGetActions(EntityUid uid, GasTankComponent component, GetItemActi

private void OnExamined(EntityUid uid, GasTankComponent component, ExaminedEvent args)
{
using(args.PushGroup(nameof(GasTankComponent)));
if (args.IsInDetailsRange)
args.PushMarkup(Loc.GetString("comp-gas-tank-examine", ("pressure", Math.Round(component.Air?.Pressure ?? 0))));
if (component.IsConnected)
Expand Down
Loading

0 comments on commit 9e475af

Please sign in to comment.