Skip to content

Commit

Permalink
Merge pull request #1430 from space-syndicate/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Morb0 authored Sep 19, 2023
2 parents bc0274d + 5bbc4a6 commit 488b413
Show file tree
Hide file tree
Showing 713 changed files with 56,097 additions and 48,463 deletions.
6 changes: 3 additions & 3 deletions Content.Client/Buckle/BuckleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void OnBuckleHandleState(EntityUid uid, BuckleComponent component, ref C
component.LastEntityBuckledTo = EnsureEntity<BuckleComponent>(state.LastEntityBuckledTo, uid);
component.DontCollide = state.DontCollide;

ActionBlockerSystem.UpdateCanMove(uid);
ActionBlocker.UpdateCanMove(uid);

if (!TryComp<SpriteComponent>(uid, out var ownerSprite))
return;
Expand Down Expand Up @@ -65,8 +65,8 @@ private void OnAppearanceChange(EntityUid uid, BuckleComponent component, ref Ap
if (!TryComp<RotationVisualsComponent>(uid, out var rotVisuals))
return;

if (!AppearanceSystem.TryGetData<int>(uid, StrapVisuals.RotationAngle, out var angle, args.Component) ||
!AppearanceSystem.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
if (!Appearance.TryGetData<int>(uid, StrapVisuals.RotationAngle, out var angle, args.Component) ||
!Appearance.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
!buckled ||
args.Sprite == null)
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/CharacterInfo/CharacterInfoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public List<Control> GetCharacterInfoControls(EntityUid uid)
public readonly record struct CharacterData(
EntityUid Entity,
string Job,
Dictionary<string, List<ConditionInfo>> Objectives,
Dictionary<string, List<ObjectiveInfo>> Objectives,
string? Briefing,
string EntityName
);
Expand Down
5 changes: 4 additions & 1 deletion Content.Client/ContextMenu/UI/EntityMenuElement.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System.Linq;
using Content.Client.Administration.Managers;
using Content.Client.Administration.Systems;
using Content.Client.UserInterface;
using Content.Shared.Administration;
using Content.Shared.IdentityManagement;
using Robust.Client.GameObjects;
using Robust.Client.Player;

namespace Content.Client.ContextMenu.UI
{
public sealed partial class EntityMenuElement : ContextMenuElement
public sealed partial class EntityMenuElement : ContextMenuElement, IEntityControl
{
[Dependency] private readonly IClientAdminManager _adminManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
Expand Down Expand Up @@ -117,5 +118,7 @@ public void UpdateEntity(EntityUid? entity = null)
Text = GetEntityDescription(entity.Value);
}
}

EntityUid? IEntityControl.UiEntity => Entity;
}
}
1 change: 1 addition & 0 deletions Content.Client/Decals/UI/DecalPlacerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ColorSelectorSliders Name="ColorPicker" IsAlphaVisible="True" />
<Button Name="PickerOpen" Text="{Loc 'decal-placer-window-palette'}" />
</BoxContainer>
<CheckBox Name="EnableAuto" Text="{Loc 'decal-placer-window-enable-auto'}" Margin="0 0 0 10"/>
<CheckBox Name="EnableColor" Text="{Loc 'decal-placer-window-use-color'}" />
<CheckBox Name="EnableSnap" Text="{Loc 'decal-placer-window-enable-snap'}" />
<CheckBox Name="EnableCleanable" Text="{Loc 'decal-placer-window-enable-cleanable'}" />
Expand Down
36 changes: 33 additions & 3 deletions Content.Client/Decals/UI/DecalPlacerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Client.Utility;
using Robust.Shared.Graphics;
using Robust.Shared.Prototypes;
using static Robust.Client.UserInterface.Controls.BaseButton;

namespace Content.Client.Decals.UI;

[GenerateTypedNameReferences]
public sealed partial class DecalPlacerWindow : DefaultWindow
{
[Dependency] private readonly IPrototypeManager _prototype = default!;

private readonly DecalPlacementSystem _decalPlacementSystem;

public FloatSpinBox RotationSpinBox;
Expand All @@ -30,9 +32,12 @@ public sealed partial class DecalPlacerWindow : DefaultWindow
private bool _cleanable;
private int _zIndex;

private bool _auto;

public DecalPlacerWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_decalPlacementSystem = EntitySystem.Get<DecalPlacementSystem>();

Expand Down Expand Up @@ -78,6 +83,12 @@ public DecalPlacerWindow()
_rotation = args.Value;
UpdateDecalPlacementInfo();
};
EnableAuto.OnToggled += args =>
{
_auto = args.Pressed;
if (_selected != null)
SelectDecal(_selected);
};
EnableColor.OnToggled += args =>
{
_useColor = args.Pressed;
Expand Down Expand Up @@ -160,9 +171,28 @@ private void RefreshList()

private void ButtonOnPressed(ButtonEventArgs obj)
{
if (obj.Button.Name == null) return;
if (obj.Button.Name == null)
return;

SelectDecal(obj.Button.Name);
}

_selected = obj.Button.Name;
private void SelectDecal(string decalId)
{
if (!_prototype.TryIndex<DecalPrototype>(decalId, out var decal))
return;

_selected = decalId;

if (_auto)
{
EnableCleanable.Pressed = decal.DefaultCleanable;
EnableColor.Pressed = decal.DefaultCustomColor;
EnableSnap.Pressed = decal.DefaultSnap;
_cleanable = decal.DefaultCleanable;
_useColor = decal.DefaultCustomColor;
_snap = decal.DefaultSnap;
}
UpdateDecalPlacementInfo();
RefreshList();
}
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public override void PostInit()
_euiManager.Initialize();
_voteManager.Initialize();
_userInterfaceManager.SetDefaultTheme("SS14DefaultTheme");
_userInterfaceManager.SetActiveTheme(_configManager.GetCVar(CVars.InterfaceTheme));
_sponsorsManager.Initialize(); // Corvax-Sponsors
_queueManager.Initialize(); // Corvax-Queue
_ttsManager.Initialize(); // Corvax-TTS
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Explosion/TriggerSystem.Proximity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public sealed partial class TriggerSystem
{
ComponentType = typeof(PointLightComponent),
InterpolationMode = AnimationInterpolationMode.Nearest,
Property = nameof(PointLightComponent.Radius),
Property = nameof(PointLightComponent.AnimatedRadius),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(0.1f, 0),
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/GameTicking/Managers/ClientGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ private void LateJoinStatus(TickerLateJoinStatusEvent message)

private void UpdateJobsAvailable(TickerJobsAvailableEvent message)
{
_jobsAvailable.Clear();

foreach (var (job, data) in message.JobsAvailableByStation)
{
_jobsAvailable.Clear();
_jobsAvailable[job] = data;
}

Expand Down
60 changes: 40 additions & 20 deletions Content.Client/Gameplay/GameplayStateBase.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Content.Client.Clickable;
using Content.Client.ContextMenu.UI;
using Content.Client.UserInterface;
using Content.Shared.Input;
using Robust.Client.ComponentTrees;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
using Robust.Client.State;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Containers;
using Robust.Shared.Console;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Timing;

namespace Content.Client.Gameplay
Expand All @@ -34,28 +36,36 @@ public class GameplayStateBase : State, IEntityEventSubscriber
[Dependency] protected readonly IUserInterfaceManager UserInterfaceManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IViewVariablesManager _vvm = default!;
[Dependency] private readonly IConsoleHost _conHost = default!;

private ClickableEntityComparer _comparer = default!;

private (ViewVariablesPath? path, string[] segments) ResolveVVHoverObject(string path)
private (ViewVariablesPath? path, string[] segments) ResolveVvHoverObject(string path)
{
// VVs the currently hovered entity. For a nifty vv keybinding you can use:
//
// /bind v command "vv /c/enthover"
// /svbind
//
// Though you probably want to include a modifier like alt, as otherwise this would open VV even when typing
// a message into chat containing the letter v.

var segments = path.Split('/');
var uid = RecursivelyFindUiEntity(UserInterfaceManager.CurrentlyHovered);
var netUid = _entityManager.GetNetEntity(uid);
return (netUid != null ? new ViewVariablesInstancePath(netUid) : null, segments);
}

EntityUid? uid = null;
if (UserInterfaceManager.CurrentlyHovered is IViewportControl vp && _inputManager.MouseScreenPosition.IsValid)
uid = GetClickedEntity(vp.PixelToMap(_inputManager.MouseScreenPosition.Position));
else if (UserInterfaceManager.CurrentlyHovered is EntityMenuElement element)
uid = element.Entity;
private EntityUid? RecursivelyFindUiEntity(Control? control)
{
if (control == null)
return null;

return (uid != null ? new ViewVariablesInstancePath(uid) : null, segments);
switch (control)
{
case IViewportControl vp:
if (_inputManager.MouseScreenPosition.IsValid)
return GetClickedEntity(vp.PixelToMap(_inputManager.MouseScreenPosition.Position));
return null;
case SpriteView sprite:
return sprite.Entity;
case IEntityControl ui:
return ui.UiEntity;
}

return RecursivelyFindUiEntity(control.Parent);
}

private IEnumerable<string>? ListVVHoverPaths(string[] segments)
Expand All @@ -65,15 +75,25 @@ public class GameplayStateBase : State, IEntityEventSubscriber

protected override void Startup()
{
_vvm.RegisterDomain("enthover", ResolveVVHoverObject, ListVVHoverPaths);
_vvm.RegisterDomain("enthover", ResolveVvHoverObject, ListVVHoverPaths);
_inputManager.KeyBindStateChanged += OnKeyBindStateChanged;
_comparer = new ClickableEntityComparer();
CommandBinds.Builder
.Bind(ContentKeyFunctions.InspectEntity, new PointerInputCmdHandler(HandleInspect, outsidePrediction: true))
.Register<GameplayStateBase>();
}

protected override void Shutdown()
{
_vvm.UnregisterDomain("enthover");
_inputManager.KeyBindStateChanged -= OnKeyBindStateChanged;
CommandBinds.Unregister<GameplayStateBase>();
}

private bool HandleInspect(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
{
_conHost.ExecuteCommand($"vv /c/enthover");
return true;
}

public EntityUid? GetClickedEntity(MapCoordinates coordinates)
Expand Down
9 changes: 6 additions & 3 deletions Content.Client/Gateway/UI/GatewayBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override void Open()
_window = new GatewayWindow();
_window.OpenPortal += destination =>
{
SendMessage(new GatewayOpenPortalMessage(EntMan.GetNetEntity(destination)));
SendMessage(new GatewayOpenPortalMessage(destination));
};
_window.OnClose += Close;
_window?.OpenCentered();
Expand All @@ -29,8 +29,11 @@ protected override void Open()
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Dispose();
_window = null;
if (disposing)
{
_window?.Dispose();
_window = null;
}
}

protected override void UpdateState(BoundUserInterfaceState state)
Expand Down
25 changes: 13 additions & 12 deletions Content.Client/Gateway/UI/GatewayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ namespace Content.Client.Gateway.UI;
public sealed partial class GatewayWindow : FancyWindow,
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
{
private readonly IEntityManager _entManager;
private readonly IGameTiming _timing;

public event Action<EntityUid>? OpenPortal;
public event Action<NetEntity>? OpenPortal;
private List<(NetEntity, string, TimeSpan, bool)> _destinations = default!;
private EntityUid? _current;
private NetEntity? _current;
private TimeSpan _nextClose;
private TimeSpan _lastOpen;
private List<Label> _readyLabels = default!;
Expand All @@ -31,14 +30,13 @@ public GatewayWindow()
{
RobustXamlLoader.Load(this);
var dependencies = IoCManager.Instance!;
_entManager = dependencies.Resolve<IEntityManager>();
_timing = dependencies.Resolve<IGameTiming>();
}

public void UpdateState(GatewayBoundUserInterfaceState state)
{
_destinations = state.Destinations;
_current = _entManager.GetEntity(state.Current);
_current = state.Current;
_nextClose = state.NextClose;
_lastOpen = state.LastOpen;

Expand Down Expand Up @@ -67,7 +65,7 @@ public void UpdateState(GatewayBoundUserInterfaceState state)
var now = _timing.CurTime;
foreach (var dest in _destinations)
{
var uid = _entManager.GetEntity(dest.Item1);
var ent = dest.Item1;
var name = dest.Item2;
var nextReady = dest.Item3;
var busy = dest.Item4;
Expand All @@ -85,7 +83,7 @@ public void UpdateState(GatewayBoundUserInterfaceState state)

var readyLabel = new Label
{
Text = ReadyText(now, nextReady),
Text = ReadyText(now, nextReady, busy),
Margin = new Thickness(10f, 0f, 0f, 0f)
};
_readyLabels.Add(readyLabel);
Expand All @@ -94,17 +92,17 @@ public void UpdateState(GatewayBoundUserInterfaceState state)
var openButton = new Button()
{
Text = Loc.GetString("gateway-window-open-portal"),
Pressed = uid == _current,
Pressed = ent == _current,
ToggleMode = true,
Disabled = _current != null || busy || now < nextReady
};

openButton.OnPressed += args =>
{
OpenPortal?.Invoke(uid);
OpenPortal?.Invoke(ent);
};

if (uid == _entManager.GetEntity(state.Current))
if (ent == _current)
{
openButton.AddStyleClass(StyleBase.ButtonCaution);
}
Expand Down Expand Up @@ -165,13 +163,16 @@ protected override void FrameUpdate(FrameEventArgs args)
var dest = _destinations[i];
var nextReady = dest.Item3;
var busy = dest.Item4;
_readyLabels[i].Text = ReadyText(now, nextReady);
_readyLabels[i].Text = ReadyText(now, nextReady, busy);
_openButtons[i].Disabled = _current != null || busy || now < nextReady;
}
}

private string ReadyText(TimeSpan now, TimeSpan nextReady)
private string ReadyText(TimeSpan now, TimeSpan nextReady, bool busy)
{
if (busy)
return Loc.GetString("gateway-window-already-active");

if (now < nextReady)
{
var time = nextReady - now;
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Input/ContentContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static void SetupContexts(IInputContextContainer contexts)
common.AddFunction(ContentKeyFunctions.ZoomOut);
common.AddFunction(ContentKeyFunctions.ZoomIn);
common.AddFunction(ContentKeyFunctions.ResetZoom);
common.AddFunction(ContentKeyFunctions.InspectEntity);

// Not in engine, because engine cannot check for sanbox/admin status before starting placement.
common.AddFunction(ContentKeyFunctions.EditorCopyObject);
Expand Down
Loading

0 comments on commit 488b413

Please sign in to comment.