Merge branch 'master' into 2020-08-19-firelocks

# Conflicts:
#	Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs
#	Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs
#	SpaceStation14.sln.DotSettings
This commit is contained in:
Víctor Aguilera Puerto
2020-08-28 14:35:45 +02:00
494 changed files with 11527 additions and 3829 deletions

View File

@@ -70,14 +70,12 @@ namespace Content.Client.Chat
// Flag Enums for holding filtered channels
private ChatChannel _filteredChannels;
#pragma warning disable 649
[Dependency] private readonly IClientNetManager _netManager;
[Dependency] private readonly IClientConsole _console;
[Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly IEyeManager _eyeManager;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IClientConsole _console = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IClientConGroupController _groupController = default!;
#pragma warning restore 649
private ChatBox _currentChatBox;
private Control _speechBubbleRoot;

View File

@@ -7,6 +7,7 @@ using Content.Client.Parallax;
using Content.Client.Sandbox;
using Content.Client.StationEvents;
using Content.Client.UserInterface;
using Content.Client.UserInterface.AdminMenu;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.Interfaces;
@@ -33,6 +34,7 @@ namespace Content.Client
IoCManager.Register<IScreenshotHook, ScreenshotHook>();
IoCManager.Register<IClickMapManager, ClickMapManager>();
IoCManager.Register<IStationEventManager, StationEventManager>();
IoCManager.Register<IAdminMenuManager, AdminMenuManager>();
}
}
}

View File

@@ -21,14 +21,12 @@ namespace Content.Client
{
public class ClientNotifyManager : SharedNotifyManager, IClientNotifyManager
{
#pragma warning disable 649
[Dependency] private IPlayerManager _playerManager;
[Dependency] private IUserInterfaceManager _userInterfaceManager;
[Dependency] private IInputManager _inputManager;
[Dependency] private IEyeManager _eyeManager;
[Dependency] private IClientNetManager _netManager;
[Dependency] private IEntityManager _entityManager;
#pragma warning restore 649
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly List<PopupLabel> _aliveLabels = new List<PopupLabel>();
private bool _initialized;

View File

@@ -14,9 +14,7 @@ namespace Content.Client
/// </summary>
public class ClientPreferencesManager : SharedPreferencesManager, IClientPreferencesManager
{
#pragma warning disable 649
[Dependency] private readonly IClientNetManager _netManager;
#pragma warning restore 649
[Dependency] private readonly IClientNetManager _netManager = default!;
public event Action OnServerDataLoaded;
public GameSettings Settings { get; private set; }

View File

@@ -12,9 +12,7 @@ namespace Content.Client.Command
{
public class CommunicationsConsoleMenu : SS14Window
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
protected override Vector2? CustomSize => new Vector2(600, 400);

View File

@@ -22,11 +22,9 @@ namespace Content.Client.Construction
{
public class ConstructionMenu : SS14Window
{
#pragma warning disable CS0649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly IEntitySystemManager _systemManager;
#pragma warning restore
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IEntitySystemManager _systemManager = default!;
private readonly Button BuildButton;
private readonly Button EraseButton;

View File

@@ -9,6 +9,7 @@ using Content.Client.Sandbox;
using Content.Client.State;
using Content.Client.StationEvents;
using Content.Client.UserInterface;
using Content.Client.UserInterface.AdminMenu;
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.GameObjects.Components;
using Content.Shared.GameObjects.Components.Cargo;
@@ -39,14 +40,12 @@ namespace Content.Client
{
public class EntryPoint : GameClient
{
#pragma warning disable 649
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IBaseClient _baseClient;
[Dependency] private readonly IEscapeMenuOwner _escapeMenuOwner;
[Dependency] private readonly IGameController _gameController;
[Dependency] private readonly IStateManager _stateManager;
[Dependency] private readonly IConfigurationManager _configurationManager;
#pragma warning restore 649
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IBaseClient _baseClient = default!;
[Dependency] private readonly IEscapeMenuOwner _escapeMenuOwner = default!;
[Dependency] private readonly IGameController _gameController = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
public override void Init()
{
@@ -152,6 +151,7 @@ namespace Content.Client
IoCManager.Resolve<ISandboxManager>().Initialize();
IoCManager.Resolve<IClientPreferencesManager>().Initialize();
IoCManager.Resolve<IStationEventManager>().Initialize();
IoCManager.Resolve<IAdminMenuManager>().Initialize();
_baseClient.RunLevelChanged += (sender, args) =>
{

View File

@@ -17,18 +17,16 @@ namespace Content.Client
{
internal sealed class EscapeMenuOwner : IEscapeMenuOwner
{
#pragma warning disable 649
[Dependency] private readonly IClientConsole _clientConsole;
[Dependency] private readonly IConfigurationManager _configurationManager;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IPlacementManager _placementManager;
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly IStateManager _stateManager;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
[Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
[Dependency] private readonly IClientConsole _clientConsole = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
private EscapeMenu _escapeMenu;

View File

@@ -10,10 +10,9 @@ namespace Content.Client.GameObjects.Components.Access
{
public class IdCardConsoleBoundUserInterface : BoundUserInterface
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
[Dependency] private readonly IPrototypeManager _prototypeManager;
#pragma warning restore 649
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public IdCardConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
}

View File

@@ -0,0 +1,58 @@
using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Shared.IoC;
using Robust.Shared.GameObjects;
using Content.Shared.GameObjects.Components.ActionBlocking;
using Content.Shared.Preferences.Appearance;
using Robust.Client.GameObjects;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects.Components.ActionBlocking
{
[RegisterComponent]
public class CuffableComponent : SharedCuffableComponent
{
[ViewVariables]
private string _currentRSI = default;
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
if (!(curState is CuffableComponentState cuffState))
{
return;
}
CanStillInteract = cuffState.CanStillInteract;
if (Owner.TryGetComponent<SpriteComponent>(out var sprite))
{
sprite.LayerSetVisible(HumanoidVisualLayers.Handcuffs, cuffState.NumHandsCuffed > 0);
sprite.LayerSetColor(HumanoidVisualLayers.Handcuffs, cuffState.Color);
if (cuffState.NumHandsCuffed > 0)
{
if (_currentRSI != cuffState.RSI) // we don't want to keep loading the same RSI
{
_currentRSI = cuffState.RSI;
sprite.LayerSetState(HumanoidVisualLayers.Handcuffs, new RSI.StateId(cuffState.IconState), new ResourcePath(cuffState.RSI));
}
else
{
sprite.LayerSetState(HumanoidVisualLayers.Handcuffs, new RSI.StateId(cuffState.IconState)); // TODO: safety check to see if RSI contains the state?
}
}
}
}
public override void OnRemove()
{
base.OnRemove();
if (Owner.TryGetComponent<SpriteComponent>(out var sprite))
{
sprite.LayerSetVisible(HumanoidVisualLayers.Handcuffs, false);
}
}
}
}

View File

@@ -0,0 +1,27 @@
using Robust.Shared.GameObjects;
using Content.Shared.GameObjects.Components.ActionBlocking;
using Robust.Client.Graphics;
using Robust.Client.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Client.GameObjects.Components.ActionBlocking
{
[RegisterComponent]
public class HandcuffComponent : SharedHandcuffComponent
{
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
var cuffState = curState as HandcuffedComponentState;
if (cuffState == null || cuffState.IconState == string.Empty)
{
return;
}
if (Owner.TryGetComponent<SpriteComponent>(out var sprite))
{
sprite.LayerSetState(0, new RSI.StateId(cuffState.IconState)); // TODO: safety check to see if RSI contains the state?
}
}
}
}

View File

@@ -14,12 +14,10 @@ namespace Content.Client.GameObjects.Components.Actor
[RegisterComponent]
public sealed class CharacterInfoComponent : Component, ICharacterUI
{
private CharacterInfoControl _control;
[Dependency] private readonly ILocalizationManager _loc = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _loc;
[Dependency] private readonly IResourceCache _resourceCache;
#pragma warning restore 649
private CharacterInfoControl _control;
public override string Name => "CharacterInfo";

View File

@@ -20,12 +20,9 @@ namespace Content.Client.GameObjects.Components.Actor
[RegisterComponent]
public class CharacterInterface : Component
{
public override string Name => "Character Interface Component";
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency]
#pragma warning disable 649
private readonly IGameHud _gameHud;
#pragma warning restore 649
public override string Name => "Character Interface Component";
/// <summary>
/// Window to hold each of the character interfaces

View File

@@ -17,9 +17,7 @@ namespace Content.Client.GameObjects.Components.Body
[ComponentReference(typeof(IBodyManagerComponent))]
public class BodyManagerComponent : SharedBodyManagerComponent, IClientDraggable
{
#pragma warning disable 649
[Dependency] private readonly IEntityManager _entityManager = default!;
#pragma warning restore 649
public bool ClientCanDropOn(CanDropEventArgs eventArgs)
{

View File

@@ -10,9 +10,7 @@ namespace Content.Client.GameObjects.Components.Cargo
[RegisterComponent]
public class GalacticMarketComponent : SharedGalacticMarketComponent
{
#pragma warning disable CS0649
[Dependency] private IPrototypeManager _prototypeManager;
#pragma warning restore
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
/// <summary>
/// Event called when the database is updated.

View File

@@ -21,6 +21,8 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
/// </summary>
public class ChemMasterWindow : SS14Window
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
/// <summary>Contains info about the reagent container such as it's contents, if one is loaded into the dispenser.</summary>
private readonly VBoxContainer ContainerInfo;
@@ -45,11 +47,6 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
public Button CreatePills { get; }
public Button CreateBottles { get; }
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
protected override Vector2? CustomSize => (400, 200);
/// <summary>
@@ -69,9 +66,9 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
Children =
{
new Label {Text = _localizationManager.GetString("Container")},
new Label {Text = Loc.GetString("Container")},
new Control {SizeFlagsHorizontal = SizeFlags.FillExpand},
(EjectButton = new Button {Text = _localizationManager.GetString("Eject")})
(EjectButton = new Button {Text = Loc.GetString("Eject")})
}
},
//Wrap the container info in a PanelContainer so we can color it's background differently.
@@ -94,7 +91,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
new Label
{
Text = _localizationManager.GetString("No container loaded.")
Text = Loc.GetString("No container loaded.")
}
}
}),
@@ -109,10 +106,10 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
Children =
{
new Label {Text = _localizationManager.GetString("Buffer")},
new Label {Text = Loc.GetString("Buffer")},
new Control {SizeFlagsHorizontal = SizeFlags.FillExpand},
(BufferTransferButton = new Button {Text = _localizationManager.GetString("Transfer"), Pressed = BufferModeTransfer, StyleClasses = { StyleBase.ButtonOpenRight }}),
(BufferDiscardButton = new Button {Text = _localizationManager.GetString("Discard"), Pressed = !BufferModeTransfer, StyleClasses = { StyleBase.ButtonOpenLeft }})
(BufferTransferButton = new Button {Text = Loc.GetString("Transfer"), Pressed = BufferModeTransfer, StyleClasses = { StyleBase.ButtonOpenRight }}),
(BufferDiscardButton = new Button {Text = Loc.GetString("Discard"), Pressed = !BufferModeTransfer, StyleClasses = { StyleBase.ButtonOpenLeft }})
}
},
@@ -136,7 +133,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
new Label
{
Text = _localizationManager.GetString("Buffer empty.")
Text = Loc.GetString("Buffer empty.")
}
}
}),
@@ -151,7 +148,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
Children =
{
new Label {Text = _localizationManager.GetString("Packaging ")},
new Label {Text = Loc.GetString("Packaging ")},
}
},
@@ -185,7 +182,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
new Label
{
Text = _localizationManager.GetString("Pills:")
Text = Loc.GetString("Pills:")
},
},
@@ -212,7 +209,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
};
PillInfo.AddChild((pillVolume));
CreatePills = new Button {Text = _localizationManager.GetString("Create")};
CreatePills = new Button {Text = Loc.GetString("Create")};
PillInfo.AddChild(CreatePills);
//Bottles
@@ -222,7 +219,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
new Label
{
Text = _localizationManager.GetString("Bottles:")
Text = Loc.GetString("Bottles:")
},
},
@@ -249,7 +246,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
};
BottleInfo.AddChild((bottleVolume));
CreateBottles = new Button {Text = _localizationManager.GetString("Create")};
CreateBottles = new Button {Text = Loc.GetString("Create")};
BottleInfo.AddChild(CreateBottles);
}
@@ -314,7 +311,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
if (!state.HasBeaker)
{
ContainerInfo.Children.Add(new Label {Text = _localizationManager.GetString("No container loaded.")});
ContainerInfo.Children.Add(new Label {Text = Loc.GetString("No container loaded.")});
return;
}
@@ -333,7 +330,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
foreach (var reagent in state.ContainerReagents)
{
var name = _localizationManager.GetString("Unknown reagent");
var name = Loc.GetString("Unknown reagent");
//Try to the prototype for the given reagent. This gives us it's name.
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
{
@@ -370,7 +367,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
if (!state.BufferReagents.Any())
{
BufferInfo.Children.Add(new Label {Text = _localizationManager.GetString("Buffer empty.")});
BufferInfo.Children.Add(new Label {Text = Loc.GetString("Buffer empty.")});
return;
}
@@ -388,7 +385,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
foreach (var reagent in state.BufferReagents)
{
var name = _localizationManager.GetString("Unknown reagent");
var name = Loc.GetString("Unknown reagent");
//Try to the prototype for the given reagent. This gives us it's name.
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
{

View File

@@ -17,10 +17,6 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
[UsedImplicitly]
public class ReagentDispenserBoundUserInterface : BoundUserInterface
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
private ReagentDispenserWindow _window;
private ReagentDispenserBoundUserInterfaceState _lastState;
@@ -41,7 +37,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
//Setup window layout/elements
_window = new ReagentDispenserWindow
{
Title = _localizationManager.GetString("Reagent dispenser"),
Title = Loc.GetString("Reagent dispenser"),
};
_window.OpenCentered();

View File

@@ -20,6 +20,8 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
/// </summary>
public class ReagentDispenserWindow : SS14Window
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
/// <summary>Contains info about the reagent container such as it's contents, if one is loaded into the dispenser.</summary>
private readonly VBoxContainer ContainerInfo;
@@ -50,11 +52,6 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
/// <summary>A grid of buttons for each reagent which can be dispensed.</summary>
public GridContainer ChemicalList { get; }
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
protected override Vector2? CustomSize => (500, 600);
/// <summary>
@@ -76,7 +73,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
{
Children =
{
new Label {Text = _localizationManager.GetString("Amount")},
new Label {Text = Loc.GetString("Amount")},
//Padding
new Control {CustomMinimumSize = (20, 0)},
(DispenseButton1 = new Button {Text = "1", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenRight }}),
@@ -100,9 +97,9 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
{
Children =
{
new Label {Text = _localizationManager.GetString("Container: ")},
(ClearButton = new Button {Text = _localizationManager.GetString("Clear"), StyleClasses = {StyleBase.ButtonOpenRight}}),
(EjectButton = new Button {Text = _localizationManager.GetString("Eject"), StyleClasses = {StyleBase.ButtonOpenLeft}})
new Label {Text = Loc.GetString("Container: ")},
(ClearButton = new Button {Text = Loc.GetString("Clear"), StyleClasses = {StyleBase.ButtonOpenRight}}),
(EjectButton = new Button {Text = Loc.GetString("Eject"), StyleClasses = {StyleBase.ButtonOpenLeft}})
}
},
//Wrap the container info in a PanelContainer so we can color it's background differently.
@@ -125,7 +122,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
{
new Label
{
Text = _localizationManager.GetString("No container loaded.")
Text = Loc.GetString("No container loaded.")
}
}
}),
@@ -155,7 +152,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
}
else
{
ChemicalList.AddChild(new Button {Text = _localizationManager.GetString("Reagent name not found")});
ChemicalList.AddChild(new Button {Text = Loc.GetString("Reagent name not found")});
}
}
}
@@ -243,7 +240,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
if (!state.HasBeaker)
{
ContainerInfo.Children.Add(new Label {Text = _localizationManager.GetString("No container loaded.")});
ContainerInfo.Children.Add(new Label {Text = Loc.GetString("No container loaded.")});
return;
}
@@ -267,7 +264,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
foreach (var reagent in state.ContainerReagents)
{
var name = _localizationManager.GetString("Unknown reagent");
var name = Loc.GetString("Unknown reagent");
//Try to the prototype for the given reagent. This gives us it's name.
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
{

View File

@@ -11,12 +11,9 @@ namespace Content.Client.GameObjects.Components.Command
{
public class CommunicationsConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private CommunicationsConsoleMenu _menu;
[Dependency] private readonly IGameTiming _gameTiming = default!;
#pragma warning disable 649
[Dependency] private IGameTiming _gameTiming;
#pragma warning restore 649
[ViewVariables] private CommunicationsConsoleMenu _menu;
public bool CountdownStarted { get; private set; }

View File

@@ -2,7 +2,6 @@
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -12,9 +11,6 @@ namespace Content.Client.GameObjects.Components.Construction
[RegisterComponent]
public class ConstructionGhostComponent : Component, IExamine
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _loc;
#pragma warning restore 649
public override string Name => "ConstructionGhost";
[ViewVariables] public ConstructionPrototype Prototype { get; set; }
@@ -22,7 +18,7 @@ namespace Content.Client.GameObjects.Components.Construction
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{
message.AddText(_loc.GetString("Building: {0}\n", Prototype.Name));
message.AddText(Loc.GetString("Building: {0}\n", Prototype.Name));
EntitySystem.Get<SharedConstructionSystem>().DoExamine(message, Prototype, 0, inDetailsRange);
}
}

View File

@@ -4,6 +4,7 @@ using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components.Disposal
{
[RegisterComponent]
[ComponentReference(typeof(SharedDisposalUnitComponent))]
public class DisposalUnitComponent : SharedDisposalUnitComponent
{
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Client.GameObjects.Components.Animations;
@@ -13,6 +13,7 @@ namespace Content.Client.GameObjects.Components
{
public override string Name => "EmergencyLight";
/// <inheritdoc/>
protected override void Startup()
{
base.Startup();

View File

@@ -0,0 +1,119 @@
using System;
using Content.Shared.GameObjects.Components;
using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Client.GameObjects.Components.Animations;
using Robust.Shared.Animations;
using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components
{
[UsedImplicitly]
public class FlashLightVisualizer : AppearanceVisualizer
{
private readonly Animation _radiatingLightAnimation = new Animation
{
Length = TimeSpan.FromSeconds(1),
AnimationTracks =
{
new AnimationTrackComponentProperty
{
ComponentType = typeof(PointLightComponent),
InterpolationMode = AnimationInterpolationMode.Linear,
Property = nameof(PointLightComponent.Radius),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(3.0f, 0),
new AnimationTrackProperty.KeyFrame(2.0f, 0.5f),
new AnimationTrackProperty.KeyFrame(3.0f, 1)
}
}
}
};
private readonly Animation _blinkingLightAnimation = new Animation
{
Length = TimeSpan.FromSeconds(1),
AnimationTracks =
{
new AnimationTrackComponentProperty()
{
ComponentType = typeof(PointLightComponent),
//To create the blinking effect we go from nearly zero radius, to the light radius, and back
//We do this instead of messing with the `PointLightComponent.enabled` because we don't want the animation to affect component behavior
InterpolationMode = AnimationInterpolationMode.Nearest,
Property = nameof(PointLightComponent.Radius),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(0.1f, 0),
new AnimationTrackProperty.KeyFrame(2f, 0.5f),
new AnimationTrackProperty.KeyFrame(0.1f, 1)
}
}
}
};
private Action<string> _radiatingCallback;
private Action<string> _blinkingCallback;
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (component.Deleted)
{
return;
}
if (component.TryGetData(HandheldLightVisuals.Power,
out HandheldLightPowerStates state))
{
PlayAnimation(component, state);
}
}
private void PlayAnimation(AppearanceComponent component, HandheldLightPowerStates state)
{
component.Owner.EnsureComponent(out AnimationPlayerComponent animationPlayer);
switch (state)
{
case HandheldLightPowerStates.LowPower:
if (!animationPlayer.HasRunningAnimation("radiatingLight"))
{
animationPlayer.Play(_radiatingLightAnimation, "radiatingLight");
_radiatingCallback = (s) => animationPlayer.Play(_radiatingLightAnimation, s);
animationPlayer.AnimationCompleted += _radiatingCallback;
}
break;
case HandheldLightPowerStates.Dying:
animationPlayer.Stop("radiatingLight");
animationPlayer.AnimationCompleted -= _radiatingCallback;
if (!animationPlayer.HasRunningAnimation("blinkingLight"))
{
animationPlayer.Play(_blinkingLightAnimation, "blinkingLight");
_blinkingCallback = (s) => animationPlayer.Play(_blinkingLightAnimation, s);
animationPlayer.AnimationCompleted += _blinkingCallback;
}
break;
case HandheldLightPowerStates.FullPower:
if (animationPlayer.HasRunningAnimation("blinkingLight"))
{
animationPlayer.Stop("blinkingLight");
animationPlayer.AnimationCompleted -= _blinkingCallback;
}
if (animationPlayer.HasRunningAnimation("radiatingLight"))
{
animationPlayer.Stop("radiatingLight");
animationPlayer.AnimationCompleted -= _radiatingCallback;
}
break;
}
}
}
}

View File

@@ -18,11 +18,9 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
[UsedImplicitly]
public class HumanInventoryInterfaceController : InventoryInterfaceController
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _loc;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly IItemSlotManager _itemSlotManager;
#pragma warning restore 649
[Dependency] private readonly ILocalizationManager _loc = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
private readonly Dictionary<Slots, List<ItemSlotButton>> _inventoryButtons
= new Dictionary<Slots, List<ItemSlotButton>>();
@@ -43,7 +41,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
base.Initialize();
_window = new HumanInventoryWindow(_loc, _resourceCache);
_window.OnClose += () => _gameHud.InventoryButtonDown = false;
_window.OnClose += () => GameHud.InventoryButtonDown = false;
foreach (var (slot, button) in _window.Buttons)
{
button.OnPressed = (e) => AddToInventory(e, slot);
@@ -153,7 +151,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{
base.PlayerAttached();
_gameHud.InventoryQuickButtonContainer.AddChild(_quickButtonsContainer);
GameHud.InventoryQuickButtonContainer.AddChild(_quickButtonsContainer);
// Update all the buttons to make sure they check out.
@@ -175,7 +173,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{
base.PlayerDetached();
_gameHud.InventoryQuickButtonContainer.RemoveChild(_quickButtonsContainer);
GameHud.InventoryQuickButtonContainer.RemoveChild(_quickButtonsContainer);
foreach (var (slot, list) in _inventoryButtons)
{

View File

@@ -12,9 +12,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{
public abstract class InventoryInterfaceController : IDisposable
{
#pragma warning disable 649
[Dependency] protected readonly IGameHud _gameHud;
#pragma warning restore 649
[Dependency] protected readonly IGameHud GameHud = default!;
protected InventoryInterfaceController(ClientInventoryComponent owner)
{
@@ -31,8 +29,8 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
public virtual void PlayerAttached()
{
_gameHud.InventoryButtonVisible = true;
_gameHud.InventoryButtonToggled = b =>
GameHud.InventoryButtonVisible = true;
GameHud.InventoryButtonToggled = b =>
{
if (b)
{
@@ -47,7 +45,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
public virtual void PlayerDetached()
{
_gameHud.InventoryButtonVisible = false;
GameHud.InventoryButtonVisible = false;
Window.Close();
}

View File

@@ -4,8 +4,10 @@ using Content.Shared.GameObjects.Components.GUI;
using Content.Shared.GameObjects.Components.Inventory;
using JetBrains.Annotations;
using Robust.Client.GameObjects.Components.UserInterface;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.UserInterface;
using Robust.Shared.ViewVariables;
using Robust.Shared.Localization;
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
namespace Content.Client.GameObjects.Components.HUD.Inventory
@@ -15,6 +17,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{
public Dictionary<Slots, string> Inventory { get; private set; }
public Dictionary<string, string> Hands { get; private set; }
public Dictionary<EntityUid, string> Handcuffs { get; private set; }
[ViewVariables]
private StrippingMenu _strippingMenu;
@@ -28,6 +31,8 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
base.Open();
_strippingMenu = new StrippingMenu($"{Owner.Owner.Name}'s inventory");
_strippingMenu.OnClose += Close;
_strippingMenu.OpenCentered();
UpdateMenu();
}
@@ -48,6 +53,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
_strippingMenu.ClearButtons();
if (Inventory != null)
{
foreach (var (slot, name) in Inventory)
{
_strippingMenu.AddButton(EquipmentSlotDefines.SlotNames[slot], name, (ev) =>
@@ -55,8 +61,10 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
SendMessage(new StrippingInventoryButtonPressed(slot));
});
}
}
if (Hands != null)
{
foreach (var (hand, name) in Hands)
{
_strippingMenu.AddButton(hand, name, (ev) =>
@@ -66,6 +74,18 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
}
}
if (Handcuffs != null)
{
foreach (var (id, name) in Handcuffs)
{
_strippingMenu.AddButton(Loc.GetString("Restraints"), name, (ev) =>
{
SendMessage(new StrippingHandcuffButtonPressed(id));
});
}
}
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
@@ -74,6 +94,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
Inventory = stripState.Inventory;
Hands = stripState.Hands;
Handcuffs = stripState.Handcuffs;
UpdateMenu();
}

View File

@@ -13,7 +13,10 @@ namespace Content.Client.GameObjects.Components
[RegisterComponent]
public sealed class HandheldLightComponent : SharedHandheldLightComponent, IItemStatus
{
private bool _hasCell;
[ViewVariables] public float? Charge { get; private set; }
[ViewVariables] protected override bool HasCell => _hasCell;
public Control MakeControl()
{
@@ -26,6 +29,7 @@ namespace Content.Client.GameObjects.Components
return;
Charge = cast.Charge;
_hasCell = cast.HasCell;
}
private sealed class StatusControl : Control

View File

@@ -27,13 +27,9 @@ namespace Content.Client.GameObjects.Components.Instruments
/// </summary>
public event Action? OnMidiPlaybackEnded;
#pragma warning disable 649
[Dependency] private readonly IMidiManager _midiManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;
#pragma warning restore 649
private IMidiRenderer? _renderer;

View File

@@ -9,15 +9,13 @@ namespace Content.Client.GameObjects.Components
[RegisterComponent]
public class InteractionOutlineComponent : Component
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private const string ShaderInRange = "SelectionOutlineInrange";
private const string ShaderOutOfRange = "SelectionOutline";
public override string Name => "InteractionOutline";
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
#pragma warning restore 649
private ShaderInstance _selectionShaderInstance;
private ShaderInstance _selectionShaderInRangeInstance;

View File

@@ -17,11 +17,9 @@ namespace Content.Client.GameObjects.Components.Items
[ComponentReference(typeof(ISharedHandsComponent))]
public class HandsComponent : SharedHandsComponent
{
private HandsGui? _gui;
#pragma warning disable 649
[Dependency] private readonly IGameHud _gameHud = default!;
#pragma warning restore 649
private HandsGui? _gui;
/// <inheritdoc />
private readonly List<Hand> _hands = new List<Hand>();
@@ -158,7 +156,8 @@ namespace Content.Client.GameObjects.Components.Items
}
else
{
var (rsi, state) = maybeInHands.Value;
var (rsi, state, color) = maybeInHands.Value;
_sprite.LayerSetColor($"hand-{name}", color);
_sprite.LayerSetVisible($"hand-{name}", true);
_sprite.LayerSetState($"hand-{name}", state, rsi);
}

View File

@@ -12,6 +12,7 @@ using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.Maths;
using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects.Components.Items
@@ -25,6 +26,8 @@ namespace Content.Client.GameObjects.Components.Items
[ViewVariables] protected ResourcePath RsiPath;
[ViewVariables(VVAccess.ReadWrite)] protected Color Color;
private string _equippedPrefix;
[ViewVariables(VVAccess.ReadWrite)]
@@ -40,7 +43,7 @@ namespace Content.Client.GameObjects.Components.Items
}
}
public (RSI rsi, RSI.StateId stateId)? GetInHandStateInfo(HandLocation hand)
public (RSI rsi, RSI.StateId stateId, Color color)? GetInHandStateInfo(HandLocation hand)
{
if (RsiPath == null)
{
@@ -52,7 +55,7 @@ namespace Content.Client.GameObjects.Components.Items
var stateId = EquippedPrefix != null ? $"{EquippedPrefix}-inhand-{handName}" : $"inhand-{handName}";
if (rsi.TryGetState(stateId, out _))
{
return (rsi, stateId);
return (rsi, stateId, Color);
}
return null;
@@ -62,6 +65,7 @@ namespace Content.Client.GameObjects.Components.Items
{
base.ExposeData(serializer);
serializer.DataFieldCached(ref Color, "color", Color.White);
serializer.DataFieldCached(ref RsiPath, "sprite", null);
serializer.DataFieldCached(ref _equippedPrefix, "HeldPrefix", null);
}

View File

@@ -20,10 +20,9 @@ namespace Content.Client.GameObjects.Components.Kitchen
{
public class MicrowaveBoundUserInterface : BoundUserInterface
{
#pragma warning disable 649
[Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly IPrototypeManager _prototypeManager;
#pragma warning restore 649
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private MicrowaveMenu _menu;
private Dictionary<int, EntityUid> _solids = new Dictionary<int, EntityUid>();

View File

@@ -0,0 +1,56 @@
using System;
using Content.Shared.GameObjects.Components;
using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Client.GameObjects.Components.Animations;
using Robust.Shared.Animations;
using Robust.Shared.GameObjects;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components
{
[UsedImplicitly]
public class LanternVisualizer : AppearanceVisualizer
{
private readonly Animation _radiatingLightAnimation = new Animation
{
Length = TimeSpan.FromSeconds(5),
AnimationTracks =
{
new AnimationTrackComponentProperty
{
ComponentType = typeof(PointLightComponent),
InterpolationMode = AnimationInterpolationMode.Linear,
Property = nameof(PointLightComponent.Radius),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(3.0f, 0),
new AnimationTrackProperty.KeyFrame(2.0f, 1.5f),
new AnimationTrackProperty.KeyFrame(3.0f, 3f)
}
}
}
};
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (component.Deleted)
{
return;
}
PlayAnimation(component);
}
private void PlayAnimation(AppearanceComponent component)
{
component.Owner.EnsureComponent(out AnimationPlayerComponent animationPlayer);
if (animationPlayer.HasRunningAnimation("radiatingLight")) return;
animationPlayer.Play(_radiatingLightAnimation, "radiatingLight");
animationPlayer.AnimationCompleted += s => animationPlayer.Play(_radiatingLightAnimation, s);
}
}
}

View File

@@ -24,6 +24,10 @@ namespace Content.Client.GameObjects.Components.Mobs
[ComponentReference(typeof(SharedOverlayEffectsComponent))]
public sealed class ClientOverlayEffectsComponent : SharedOverlayEffectsComponent//, ICharacterUI
{
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;
/// <summary>
/// A list of overlay containers representing the current overlays applied
/// </summary>
@@ -36,13 +40,6 @@ namespace Content.Client.GameObjects.Components.Mobs
set => SetEffects(value);
}
#pragma warning disable 649
// Required dependencies
[Dependency] private readonly IOverlayManager _overlayManager;
[Dependency] private readonly IReflectionManager _reflectionManager;
[Dependency] private readonly IClientNetManager _netManager;
#pragma warning restore 649
public override void Initialize()
{
base.Initialize();

View File

@@ -23,12 +23,10 @@ namespace Content.Client.GameObjects.Components.Mobs
[ComponentReference(typeof(SharedStatusEffectsComponent))]
public sealed class ClientStatusEffectsComponent : SharedStatusEffectsComponent
{
#pragma warning disable 649
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IGameTiming _gameTiming;
#pragma warning restore 649
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
private StatusEffectsUI _ui;
private Dictionary<StatusEffect, StatusEffectStatus> _status = new Dictionary<StatusEffect, StatusEffectStatus>();

View File

@@ -12,10 +12,8 @@ namespace Content.Client.GameObjects.Components.Mobs
[ComponentReference(typeof(SharedCombatModeComponent))]
public sealed class CombatModeComponent : SharedCombatModeComponent
{
#pragma warning disable 649
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IGameHud _gameHud;
#pragma warning restore 649
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameHud _gameHud = default!;
public override bool IsInCombatMode
{

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Mobs;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
@@ -12,26 +13,26 @@ namespace Content.Client.GameObjects.Components.Mobs
[UsedImplicitly]
public sealed class DamageStateVisualizer : AppearanceVisualizer
{
private DamageStateVisualData _data = DamageStateVisualData.Normal;
private Dictionary<DamageStateVisualData, string> _stateMap = new Dictionary<DamageStateVisualData,string>();
private int? _originalDrawDepth = null;
private DamageState _data = DamageState.Alive;
private readonly Dictionary<DamageState, string> _stateMap = new Dictionary<DamageState, string>();
private int? _originalDrawDepth;
public override void LoadData(YamlMappingNode node)
{
base.LoadData(node);
if (node.TryGetNode("normal", out var normal))
{
_stateMap.Add(DamageStateVisualData.Normal, normal.AsString());
_stateMap.Add(DamageState.Alive, normal.AsString());
}
if (node.TryGetNode("crit", out var crit))
{
_stateMap.Add(DamageStateVisualData.Crit, crit.AsString());
_stateMap.Add(DamageState.Critical, crit.AsString());
}
if (node.TryGetNode("dead", out var dead))
{
_stateMap.Add(DamageStateVisualData.Dead, dead.AsString());
_stateMap.Add(DamageState.Dead, dead.AsString());
}
}
@@ -39,7 +40,7 @@ namespace Content.Client.GameObjects.Components.Mobs
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (!component.TryGetData(DamageStateVisuals.State, out DamageStateVisualData data))
if (!component.TryGetData(DamageStateVisuals.State, out DamageState data))
{
return;
}
@@ -57,7 +58,7 @@ namespace Content.Client.GameObjects.Components.Mobs
}
// So they don't draw over mobs anymore
if (_data == DamageStateVisualData.Dead)
if (_data == DamageState.Dead)
{
_originalDrawDepth = sprite.DrawDepth;
sprite.DrawDepth = (int) DrawDepth.FloorObjects;

View File

@@ -1,8 +1,9 @@
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.Preferences;
using Content.Shared.Preferences.Appearance;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Content.Client.GameObjects.Components.ActionBlocking;
namespace Content.Client.GameObjects.Components.Mobs
{
@@ -49,6 +50,15 @@ namespace Content.Client.GameObjects.Components.Mobs
sprite.LayerSetVisible(HumanoidVisualLayers.StencilMask, Sex == Sex.Female);
if (Owner.TryGetComponent<CuffableComponent>(out var cuffed))
{
sprite.LayerSetVisible(HumanoidVisualLayers.Handcuffs, !cuffed.CanStillInteract);
}
else
{
sprite.LayerSetVisible(HumanoidVisualLayers.Handcuffs, false);
}
var hairStyle = Appearance.HairStyleName;
if (string.IsNullOrWhiteSpace(hairStyle) || !HairStyles.HairStylesMap.ContainsKey(hairStyle))
hairStyle = HairStyles.DefaultHairStyle;

View File

@@ -12,6 +12,10 @@ namespace Content.Client.GameObjects.Components.Observer
[RegisterComponent]
public class GhostComponent : SharedGhostComponent
{
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IComponentManager _componentManager = default!;
private GhostGui _gui;
[ViewVariables(VVAccess.ReadOnly)]
@@ -19,12 +23,6 @@ namespace Content.Client.GameObjects.Components.Observer
private bool _isAttached;
#pragma warning disable 649
[Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private IComponentManager _componentManager;
#pragma warning restore 649
public override void OnRemove()
{
base.OnRemove();

View File

@@ -19,10 +19,9 @@ namespace Content.Client.GameObjects.Components.PDA
{
public class PDABoundUserInterface : BoundUserInterface
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
#pragma warning restore 649
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
private PDAMenu _menu;
private PDAMenuPopup failPopup;
@@ -70,7 +69,7 @@ namespace Content.Client.GameObjects.Components.PDA
};
}
SendMessage(new PDAUplinkBuyListingMessage(listing));
SendMessage(new PDAUplinkBuyListingMessage(listing.ItemId));
};
_menu.OnCategoryButtonPressed += (args, category) =>

View File

@@ -1,45 +0,0 @@
using System;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Client.GameObjects.Components.Animations;
using Robust.Shared.Animations;
using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components
{
[RegisterComponent]
public class RadiatingLightComponent : Component
{
public override string Name => "RadiatingLight";
protected override void Startup()
{
base.Startup();
var animation = new Animation
{
Length = TimeSpan.FromSeconds(4),
AnimationTracks =
{
new AnimationTrackComponentProperty
{
ComponentType = typeof(PointLightComponent),
InterpolationMode = AnimationInterpolationMode.Linear,
Property = nameof(PointLightComponent.Radius),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(3.0f, 0),
new AnimationTrackProperty.KeyFrame(2.0f, 1),
new AnimationTrackProperty.KeyFrame(3.0f, 2)
}
}
}
};
var playerComponent = Owner.EnsureComponent<AnimationPlayerComponent>();
playerComponent.Play(animation, "emergency");
playerComponent.AnimationCompleted += s => playerComponent.Play(animation, s);
}
}
}

View File

@@ -12,10 +12,8 @@ namespace Content.Client.GameObjects.Components.Research
{
public class LatheBoundUserInterface : BoundUserInterface
{
#pragma warning disable CS0649
[Dependency]
private IPrototypeManager _prototypeManager;
#pragma warning restore
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[ViewVariables]
private LatheMenu _menu;
[ViewVariables]

View File

@@ -10,10 +10,7 @@ namespace Content.Client.GameObjects.Components.Research
[ComponentReference(typeof(SharedLatheDatabaseComponent))]
public class LatheDatabaseComponent : SharedLatheDatabaseComponent
{
#pragma warning disable CS0649
[Dependency]
private IPrototypeManager _prototypeManager;
#pragma warning restore
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{

View File

@@ -11,10 +11,7 @@ namespace Content.Client.GameObjects.Components.Research
[ComponentReference(typeof(SharedLatheDatabaseComponent))]
public class ProtolatheDatabaseComponent : SharedProtolatheDatabaseComponent
{
#pragma warning disable CS0649
[Dependency]
private IPrototypeManager _prototypeManager;
#pragma warning restore
[Dependency] private IPrototypeManager _prototypeManager = default!;
/// <summary>
/// Invoked when the database gets updated.

View File

@@ -14,10 +14,6 @@ namespace Content.Client.GameObjects.Components.Research
private int[] _serverIds = new int[]{};
private int _selectedServerId = -1;
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
protected override Vector2? CustomSize => (300, 300);
public ResearchClientBoundUserInterface Owner { get; set; }
@@ -25,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Research
{
IoCManager.InjectDependencies(this);
Title = _localizationManager.GetString("Research Server Selection");
Title = Loc.GetString("Research Server Selection");
_servers = new ItemList() {SelectMode = ItemList.ItemListSelectMode.Single};

View File

@@ -16,11 +16,10 @@ namespace Content.Client.GameObjects.Components.Sound
[RegisterComponent]
public class LoopingSoundComponent : SharedLoopingSoundComponent
{
[Dependency] private readonly IRobustRandom _random = default!;
private readonly Dictionary<ScheduledSound, IPlayingAudioStream> _audioStreams = new Dictionary<ScheduledSound, IPlayingAudioStream>();
private AudioSystem _audioSystem;
#pragma warning disable 649
[Dependency] private readonly IRobustRandom _random;
#pragma warning restore 649
public override void StopAllSounds()
{

View File

@@ -0,0 +1,109 @@
#nullable enable
using System.Collections.Generic;
using System.Linq;
using Content.Client.UserInterface;
using Content.Client.UserInterface.Suspicion;
using Content.Shared.GameObjects.Components.Suspicion;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Players;
namespace Content.Client.GameObjects.Components.Suspicion
{
[RegisterComponent]
public class SuspicionRoleComponent : SharedSuspicionRoleComponent
{
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private SuspicionGui? _gui;
private string? _role;
private bool? _antagonist;
public string? Role
{
get => _role;
set
{
_role = value;
_gui?.UpdateLabel();
Dirty();
}
}
public bool? Antagonist
{
get => _antagonist;
set
{
_antagonist = value;
_gui?.UpdateLabel();
Dirty();
}
}
public HashSet<IEntity> Allies { get; } = new HashSet<IEntity>();
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
if (!(curState is SuspicionRoleComponentState state))
{
return;
}
_role = state.Role;
_antagonist = state.Antagonist;
}
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case PlayerAttachedMsg _:
if (_gui == null)
{
_gui = new SuspicionGui();
}
else
{
_gui.Parent?.RemoveChild(_gui);
}
_gameHud.SuspicionContainer.AddChild(_gui);
_gui.UpdateLabel();
break;
case PlayerDetachedMsg _:
_gui?.Parent?.RemoveChild(_gui);
break;
}
}
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null)
{
base.HandleNetworkMessage(message, netChannel, session);
switch (message)
{
case SuspicionAlliesMessage msg:
Allies.Clear();
Allies.UnionWith(msg.Allies.Select(_entityManager.GetEntity));
break;
}
}
public override void OnRemove()
{
base.OnRemove();
_gui?.Dispose();
}
}
}

View File

@@ -0,0 +1,160 @@
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged.Barrels;
using Robust.Client.Graphics.Drawing;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.ViewVariables;
using System;
namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
{
[RegisterComponent]
public class ClientBatteryBarrelComponent : Component, IItemStatus
{
public override string Name => "BatteryBarrel";
public override uint? NetID => ContentNetIDs.BATTERY_BARREL;
private StatusControl _statusControl;
/// <summary>
/// Count of bullets in the magazine.
/// </summary>
/// <remarks>
/// Null if no magazine is inserted.
/// </remarks>
[ViewVariables]
public (int count, int max)? MagazineCount { get; private set; }
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
if (!(curState is BatteryBarrelComponentState cast))
return;
MagazineCount = cast.Magazine;
_statusControl?.Update();
}
public Control MakeControl()
{
_statusControl = new StatusControl(this);
_statusControl.Update();
return _statusControl;
}
public void DestroyControl(Control control)
{
if (_statusControl == control)
{
_statusControl = null;
}
}
private sealed class StatusControl : Control
{
private readonly ClientBatteryBarrelComponent _parent;
private readonly HBoxContainer _bulletsList;
private readonly Label _noBatteryLabel;
private readonly Label _ammoCount;
public StatusControl(ClientBatteryBarrelComponent parent)
{
_parent = parent;
SizeFlagsHorizontal = SizeFlags.FillExpand;
SizeFlagsVertical = SizeFlags.ShrinkCenter;
AddChild(new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
new Control
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
(_bulletsList = new HBoxContainer
{
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SeparationOverride = 4
}),
(_noBatteryLabel = new Label
{
Text = "No Battery!",
StyleClasses = {StyleNano.StyleClassItemStatus}
})
}
},
new Control() { CustomMinimumSize = (5,0) },
(_ammoCount = new Label
{
StyleClasses = {StyleNano.StyleClassItemStatus},
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
}),
}
});
}
public void Update()
{
_bulletsList.RemoveAllChildren();
if (_parent.MagazineCount == null)
{
_noBatteryLabel.Visible = true;
_ammoCount.Visible = false;
return;
}
var (count, capacity) = _parent.MagazineCount.Value;
_noBatteryLabel.Visible = false;
_ammoCount.Visible = true;
_ammoCount.Text = $"x{count:00}";
capacity = Math.Min(capacity, 8);
FillBulletRow(_bulletsList, count, capacity);
}
private static void FillBulletRow(Control container, int count, int capacity)
{
var colorGone = Color.FromHex("#000000");
var color = Color.FromHex("#E00000");
// Draw the empty ones
for (var i = count; i < capacity; i++)
{
container.AddChild(new PanelContainer
{
PanelOverride = new StyleBoxFlat()
{
BackgroundColor = colorGone,
},
CustomMinimumSize = (10, 15),
});
}
// Draw the full ones, but limit the count to the capacity
count = Math.Min(count, capacity);
for (var i = 0; i < count; i++)
{
container.AddChild(new PanelContainer
{
PanelOverride = new StyleBoxFlat()
{
BackgroundColor = color,
},
CustomMinimumSize = (10, 15),
});
}
}
protected override Vector2 CalculateMinimumSize()
{
return Vector2.ComponentMax((0, 15), base.CalculateMinimumSize());
}
}
}
}

View File

@@ -0,0 +1,206 @@
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged.Barrels;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.ViewVariables;
using System;
namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
{
[RegisterComponent]
public class ClientBoltActionBarrelComponent : Component, IItemStatus
{
public override string Name => "BoltActionBarrel";
public override uint? NetID => ContentNetIDs.BOLTACTION_BARREL;
private StatusControl _statusControl;
/// <summary>
/// chambered is true when a bullet is chambered
/// spent is true when the chambered bullet is spent
/// </summary>
[ViewVariables]
public (bool chambered, bool spent) Chamber { get; private set; }
/// <summary>
/// Count of bullets in the magazine.
/// </summary>
/// <remarks>
/// Null if no magazine is inserted.
/// </remarks>
[ViewVariables]
public (int count, int max)? MagazineCount { get; private set; }
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
if (!(curState is BoltActionBarrelComponentState cast))
return;
Chamber = cast.Chamber;
MagazineCount = cast.Magazine;
_statusControl?.Update();
}
public Control MakeControl()
{
_statusControl = new StatusControl(this);
_statusControl.Update();
return _statusControl;
}
public void DestroyControl(Control control)
{
if (_statusControl == control)
{
_statusControl = null;
}
}
private sealed class StatusControl : Control
{
private readonly ClientBoltActionBarrelComponent _parent;
private readonly HBoxContainer _bulletsListTop;
private readonly HBoxContainer _bulletsListBottom;
private readonly TextureRect _chamberedBullet;
private readonly Label _noMagazineLabel;
public StatusControl(ClientBoltActionBarrelComponent parent)
{
_parent = parent;
SizeFlagsHorizontal = SizeFlags.FillExpand;
SizeFlagsVertical = SizeFlags.ShrinkCenter;
AddChild(new VBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SeparationOverride = 0,
Children =
{
(_bulletsListTop = new HBoxContainer {SeparationOverride = 0}),
new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
new Control
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
(_bulletsListBottom = new HBoxContainer
{
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SeparationOverride = 0
}),
(_noMagazineLabel = new Label
{
Text = "No Magazine!",
StyleClasses = {StyleNano.StyleClassItemStatus}
})
}
},
(_chamberedBullet = new TextureRect
{
Texture = StaticIoC.ResC.GetTexture("/Textures/Interface/ItemStatus/Bullets/chambered.png"),
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SizeFlagsHorizontal = SizeFlags.ShrinkEnd | SizeFlags.Fill,
})
}
}
}
});
}
public void Update()
{
_chamberedBullet.ModulateSelfOverride =
_parent.Chamber.chambered ?
_parent.Chamber.spent ? Color.Red : Color.FromHex("#d7df60")
: Color.Black;
_bulletsListTop.RemoveAllChildren();
_bulletsListBottom.RemoveAllChildren();
if (_parent.MagazineCount == null)
{
_noMagazineLabel.Visible = true;
return;
}
var (count, capacity) = _parent.MagazineCount.Value;
_noMagazineLabel.Visible = false;
string texturePath;
if (capacity <= 20)
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/normal.png";
}
else if (capacity <= 30)
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/small.png";
}
else
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/tiny.png";
}
var texture = StaticIoC.ResC.GetTexture(texturePath);
const int tinyMaxRow = 60;
if (capacity > tinyMaxRow)
{
FillBulletRow(_bulletsListBottom, Math.Min(tinyMaxRow, count), tinyMaxRow, texture);
FillBulletRow(_bulletsListTop, Math.Max(0, count - tinyMaxRow), capacity - tinyMaxRow, texture);
}
else
{
FillBulletRow(_bulletsListBottom, count, capacity, texture);
}
}
private static void FillBulletRow(Control container, int count, int capacity, Texture texture)
{
var colorA = Color.FromHex("#b68f0e");
var colorB = Color.FromHex("#d7df60");
var colorGoneA = Color.FromHex("#000000");
var colorGoneB = Color.FromHex("#222222");
var altColor = false;
for (var i = count; i < capacity; i++)
{
container.AddChild(new TextureRect
{
Texture = texture,
ModulateSelfOverride = altColor ? colorGoneA : colorGoneB
});
altColor ^= true;
}
for (var i = 0; i < count; i++)
{
container.AddChild(new TextureRect
{
Texture = texture,
ModulateSelfOverride = altColor ? colorA : colorB
});
altColor ^= true;
}
}
protected override Vector2 CalculateMinimumSize()
{
return Vector2.ComponentMax((0, 15), base.CalculateMinimumSize());
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Content.Client.Animations;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
@@ -138,35 +138,35 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
private sealed class StatusControl : Control
{
private readonly ClientMagazineBarrelComponent _parent;
private readonly HBoxContainer _bulletsListTop;
private readonly HBoxContainer _bulletsListBottom;
private readonly HBoxContainer _bulletsList;
private readonly TextureRect _chamberedBullet;
private readonly Label _noMagazineLabel;
private readonly Label _ammoCount;
public StatusControl(ClientMagazineBarrelComponent parent)
{
_parent = parent;
SizeFlagsHorizontal = SizeFlags.FillExpand;
SizeFlagsVertical = SizeFlags.ShrinkCenter;
AddChild(new VBoxContainer
AddChild(new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
(_chamberedBullet = new TextureRect
{
Texture = StaticIoC.ResC.GetTexture("/Textures/Interface/ItemStatus/Bullets/chambered_rotated.png"),
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SeparationOverride = 0,
Children =
{
(_bulletsListTop = new HBoxContainer {SeparationOverride = 0}),
new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
SizeFlagsHorizontal = SizeFlags.ShrinkEnd | SizeFlags.Fill,
}),
new Control() { CustomMinimumSize = (5,0) },
new Control
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
(_bulletsListBottom = new HBoxContainer
(_bulletsList = new HBoxContainer
{
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SeparationOverride = 0
@@ -178,14 +178,12 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
})
}
},
(_chamberedBullet = new TextureRect
new Control() { CustomMinimumSize = (5,0) },
(_ammoCount = new Label
{
Texture = StaticIoC.ResC.GetTexture("/Textures/Interface/ItemStatus/Bullets/chambered.png"),
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SizeFlagsHorizontal = SizeFlags.ShrinkEnd | SizeFlags.Fill,
})
}
}
StyleClasses = {StyleNano.StyleClassItemStatus},
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
}),
}
});
}
@@ -195,46 +193,26 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
_chamberedBullet.ModulateSelfOverride =
_parent.Chambered ? Color.FromHex("#d7df60") : Color.Black;
_bulletsListTop.RemoveAllChildren();
_bulletsListBottom.RemoveAllChildren();
_bulletsList.RemoveAllChildren();
if (_parent.MagazineCount == null)
{
_noMagazineLabel.Visible = true;
_ammoCount.Visible = false;
return;
}
var (count, capacity) = _parent.MagazineCount.Value;
_noMagazineLabel.Visible = false;
_ammoCount.Visible = true;
string texturePath;
if (capacity <= 20)
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/normal.png";
}
else if (capacity <= 30)
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/small.png";
}
else
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/tiny.png";
}
var texturePath = "/Textures/Interface/ItemStatus/Bullets/normal.png";
var texture = StaticIoC.ResC.GetTexture(texturePath);
const int tinyMaxRow = 60;
if (capacity > tinyMaxRow)
{
FillBulletRow(_bulletsListBottom, Math.Min(tinyMaxRow, count), tinyMaxRow, texture);
FillBulletRow(_bulletsListTop, Math.Max(0, count - tinyMaxRow), capacity - tinyMaxRow, texture);
}
else
{
FillBulletRow(_bulletsListBottom, count, capacity, texture);
}
_ammoCount.Text = $"x{count:00}";
capacity = Math.Min(capacity, 20);
FillBulletRow(_bulletsList, count, capacity, texture);
}
private static void FillBulletRow(Control container, int count, int capacity, Texture texture)
@@ -246,23 +224,32 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
var altColor = false;
// Draw the empty ones
for (var i = count; i < capacity; i++)
{
container.AddChild(new TextureRect
{
Texture = texture,
ModulateSelfOverride = altColor ? colorGoneA : colorGoneB
ModulateSelfOverride = altColor ? colorGoneA : colorGoneB,
SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsVertical = SizeFlags.Fill,
Stretch = TextureRect.StretchMode.KeepCentered
});
altColor ^= true;
}
// Draw the full ones, but limit the count to the capacity
count = Math.Min(count, capacity);
for (var i = 0; i < count; i++)
{
container.AddChild(new TextureRect
{
Texture = texture,
ModulateSelfOverride = altColor ? colorA : colorB
ModulateSelfOverride = altColor ? colorA : colorB,
SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsVertical = SizeFlags.Fill,
Stretch = TextureRect.StretchMode.KeepCentered
});
altColor ^= true;

View File

@@ -0,0 +1,208 @@
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged.Barrels;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.ViewVariables;
using System;
using System.Collections.Generic;
using System.Text;
namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
{
[RegisterComponent]
public class ClientPumpBarrelComponent : Component, IItemStatus
{
public override string Name => "PumpBarrel";
public override uint? NetID => ContentNetIDs.PUMP_BARREL;
private StatusControl _statusControl;
/// <summary>
/// chambered is true when a bullet is chambered
/// spent is true when the chambered bullet is spent
/// </summary>
[ViewVariables]
public (bool chambered, bool spent) Chamber { get; private set; }
/// <summary>
/// Count of bullets in the magazine.
/// </summary>
/// <remarks>
/// Null if no magazine is inserted.
/// </remarks>
[ViewVariables]
public (int count, int max)? MagazineCount { get; private set; }
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
if (!(curState is PumpBarrelComponentState cast))
return;
Chamber = cast.Chamber;
MagazineCount = cast.Magazine;
_statusControl?.Update();
}
public Control MakeControl()
{
_statusControl = new StatusControl(this);
_statusControl.Update();
return _statusControl;
}
public void DestroyControl(Control control)
{
if (_statusControl == control)
{
_statusControl = null;
}
}
private sealed class StatusControl : Control
{
private readonly ClientPumpBarrelComponent _parent;
private readonly HBoxContainer _bulletsListTop;
private readonly HBoxContainer _bulletsListBottom;
private readonly TextureRect _chamberedBullet;
private readonly Label _noMagazineLabel;
public StatusControl(ClientPumpBarrelComponent parent)
{
_parent = parent;
SizeFlagsHorizontal = SizeFlags.FillExpand;
SizeFlagsVertical = SizeFlags.ShrinkCenter;
AddChild(new VBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SeparationOverride = 0,
Children =
{
(_bulletsListTop = new HBoxContainer {SeparationOverride = 0}),
new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
new Control
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
(_bulletsListBottom = new HBoxContainer
{
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SeparationOverride = 0
}),
(_noMagazineLabel = new Label
{
Text = "No Magazine!",
StyleClasses = {StyleNano.StyleClassItemStatus}
})
}
},
(_chamberedBullet = new TextureRect
{
Texture = StaticIoC.ResC.GetTexture("/Textures/Interface/ItemStatus/Bullets/chambered.png"),
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SizeFlagsHorizontal = SizeFlags.ShrinkEnd | SizeFlags.Fill,
})
}
}
}
});
}
public void Update()
{
_chamberedBullet.ModulateSelfOverride =
_parent.Chamber.chambered ?
_parent.Chamber.spent ? Color.Red : Color.FromHex("#d7df60")
: Color.Black;
_bulletsListTop.RemoveAllChildren();
_bulletsListBottom.RemoveAllChildren();
if (_parent.MagazineCount == null)
{
_noMagazineLabel.Visible = true;
return;
}
var (count, capacity) = _parent.MagazineCount.Value;
_noMagazineLabel.Visible = false;
string texturePath;
if (capacity <= 20)
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/normal.png";
}
else if (capacity <= 30)
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/small.png";
}
else
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/tiny.png";
}
var texture = StaticIoC.ResC.GetTexture(texturePath);
const int tinyMaxRow = 60;
if (capacity > tinyMaxRow)
{
FillBulletRow(_bulletsListBottom, Math.Min(tinyMaxRow, count), tinyMaxRow, texture);
FillBulletRow(_bulletsListTop, Math.Max(0, count - tinyMaxRow), capacity - tinyMaxRow, texture);
}
else
{
FillBulletRow(_bulletsListBottom, count, capacity, texture);
}
}
private static void FillBulletRow(Control container, int count, int capacity, Texture texture)
{
var colorA = Color.FromHex("#b68f0e");
var colorB = Color.FromHex("#d7df60");
var colorGoneA = Color.FromHex("#000000");
var colorGoneB = Color.FromHex("#222222");
var altColor = false;
for (var i = count; i < capacity; i++)
{
container.AddChild(new TextureRect
{
Texture = texture,
ModulateSelfOverride = altColor ? colorGoneA : colorGoneB
});
altColor ^= true;
}
for (var i = 0; i < count; i++)
{
container.AddChild(new TextureRect
{
Texture = texture,
ModulateSelfOverride = altColor ? colorA : colorB
});
altColor ^= true;
}
}
protected override Vector2 CalculateMinimumSize()
{
return Vector2.ComponentMax((0, 15), base.CalculateMinimumSize());
}
}
}
}

View File

@@ -0,0 +1,175 @@
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged.Barrels;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.ViewVariables;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
{
[RegisterComponent]
public class ClientRevolverBarrelComponent : Component, IItemStatus
{
public override string Name => "RevolverBarrel";
public override uint? NetID => ContentNetIDs.REVOLVER_BARREL;
private StatusControl _statusControl;
/// <summary>
/// A array that lists the bullet states
/// true means a spent bullet
/// false means a "shootable" bullet
/// null means no bullet
/// </summary>
[ViewVariables]
public bool?[] Bullets { get; private set; }
[ViewVariables]
public int CurrentSlot { get; private set; }
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
if (!(curState is RevolverBarrelComponentState cast))
return;
CurrentSlot = cast.CurrentSlot;
Bullets = cast.Bullets;
_statusControl?.Update();
}
public Control MakeControl()
{
_statusControl = new StatusControl(this);
_statusControl.Update();
return _statusControl;
}
public void DestroyControl(Control control)
{
if (_statusControl == control)
{
_statusControl = null;
}
}
private sealed class StatusControl : Control
{
private readonly ClientRevolverBarrelComponent _parent;
private readonly HBoxContainer _bulletsList;
public StatusControl(ClientRevolverBarrelComponent parent)
{
_parent = parent;
SizeFlagsHorizontal = SizeFlags.FillExpand;
SizeFlagsVertical = SizeFlags.ShrinkCenter;
AddChild((_bulletsList = new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SeparationOverride = 0
}));
}
public void Update()
{
_bulletsList.RemoveAllChildren();
var capacity = _parent.Bullets.Length;
string texturePath;
if (capacity <= 20)
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/normal.png";
}
else if (capacity <= 30)
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/small.png";
}
else
{
texturePath = "/Textures/Interface/ItemStatus/Bullets/tiny.png";
}
var texture = StaticIoC.ResC.GetTexture(texturePath);
var spentTexture = StaticIoC.ResC.GetTexture("/Textures/Interface/ItemStatus/Bullets/empty.png");
FillBulletRow(_bulletsList, texture, spentTexture);
}
private void FillBulletRow(Control container, Texture texture, Texture emptyTexture)
{
var colorA = Color.FromHex("#b68f0e");
var colorB = Color.FromHex("#d7df60");
var colorSpentA = Color.FromHex("#b50e25");
var colorSpentB = Color.FromHex("#d3745f");
var colorGoneA = Color.FromHex("#000000");
var colorGoneB = Color.FromHex("#222222");
var altColor = false;
var scale = 1.3f;
for (var i = 0; i < _parent.Bullets.Length; i++)
{
var bulletSpent = _parent.Bullets[i];
// Add a outline
var box = new Control()
{
CustomMinimumSize = texture.Size * scale,
};
if (i == _parent.CurrentSlot)
{
box.AddChild(new TextureRect
{
Texture = texture,
TextureScale = (scale, scale),
ModulateSelfOverride = Color.Green,
});
}
Color color;
Texture bulletTexture = texture;
if (bulletSpent.HasValue)
{
if (bulletSpent.Value)
{
color = altColor ? colorSpentA : colorSpentB;
bulletTexture = emptyTexture;
}
else
{
color = altColor ? colorA : colorB;
}
}
else
{
color = altColor ? colorGoneA : colorGoneB;
}
box.AddChild(new TextureRect
{
SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsVertical = SizeFlags.Fill,
Stretch = TextureRect.StretchMode.KeepCentered,
Texture = bulletTexture,
ModulateSelfOverride = color,
});
altColor ^= true;
container.AddChild(box);
}
}
protected override Vector2 CalculateMinimumSize()
{
return Vector2.ComponentMax((0, 15), base.CalculateMinimumSize());
}
}
}
}

View File

@@ -10,6 +10,9 @@ namespace Content.Client.GameObjects.Components.Wires
{
base.OnChangeData(component);
if (component.Owner.Deleted)
return;
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (component.TryGetData<bool>(WiresVisuals.MaintenancePanelState, out var state))
{

View File

@@ -15,9 +15,7 @@ namespace Content.Client.GameObjects.EntitySystems.AI
#if DEBUG
public class ClientAiDebugSystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private IEyeManager _eyeManager;
#pragma warning restore 649
[Dependency] private readonly IEyeManager _eyeManager = default!;
private AiDebugMode _tooltips = AiDebugMode.None;
private readonly Dictionary<IEntity, PanelContainer> _aiBoxes = new Dictionary<IEntity,PanelContainer>();

View File

@@ -0,0 +1,10 @@
using Content.Shared.GameObjects.EntitySystems.Atmos;
using JetBrains.Annotations;
namespace Content.Client.GameObjects.EntitySystems
{
[UsedImplicitly]
public class AtmosphereSystem : SharedAtmosphereSystem
{
}
}

View File

@@ -11,10 +11,8 @@ namespace Content.Client.GameObjects.EntitySystems
{
public sealed class CharacterInterfaceSystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IPlayerManager _playerManager;
#pragma warning restore 649
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override void Initialize()
{

View File

@@ -11,10 +11,8 @@ namespace Content.Client.GameObjects.EntitySystems
{
public sealed class ClientInventorySystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IPlayerManager _playerManager;
#pragma warning restore 649
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override void Initialize()
{

View File

@@ -17,11 +17,9 @@ namespace Content.Client.GameObjects.EntitySystems
[UsedImplicitly]
public sealed class CombatModeSystem : SharedCombatModeSystem
{
#pragma warning disable 649
[Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IGameTiming _gameTiming;
#pragma warning restore 649
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override void Initialize()
{

View File

@@ -24,11 +24,9 @@ namespace Content.Client.GameObjects.EntitySystems
[UsedImplicitly]
public class ConstructionSystem : SharedConstructionSystem
{
#pragma warning disable 649
[Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IEntityManager _entityManager;
#pragma warning restore 649
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private int _nextId;
private readonly Dictionary<int, ConstructionGhostComponent> _ghosts = new Dictionary<int, ConstructionGhostComponent>();

View File

@@ -30,6 +30,13 @@ namespace Content.Client.GameObjects.EntitySystems
[UsedImplicitly]
public class DragDropSystem : EntitySystem
{
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
// drag will be triggered when mouse leaves this deadzone around the click position.
private const float DragDeadzone = 2f;
// how often to recheck possible targets (prevents calling expensive
@@ -44,15 +51,6 @@ namespace Content.Client.GameObjects.EntitySystems
private const string ShaderDropTargetInRange = "SelectionOutlineInrange";
private const string ShaderDropTargetOutOfRange = "SelectionOutline";
#pragma warning disable 649
[Dependency] private readonly IStateManager _stateManager;
[Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IEyeManager _eyeManager;
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IMapManager _mapManager;
#pragma warning restore 649
// entity performing the drag action
private IEntity _dragger;
private IEntity _draggedEntity;

View File

@@ -25,14 +25,12 @@ namespace Content.Client.GameObjects.EntitySystems
[UsedImplicitly]
internal sealed class ExamineSystem : ExamineSystemShared
{
public const string StyleClassEntityTooltip = "entity-tooltip";
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
#pragma warning disable 649
[Dependency] private IInputManager _inputManager;
[Dependency] private IUserInterfaceManager _userInterfaceManager;
[Dependency] private IEntityManager _entityManager;
[Dependency] private IPlayerManager _playerManager;
#pragma warning restore 649
public const string StyleClassEntityTooltip = "entity-tooltip";
private Popup _examineTooltipOpen;
private CancellationTokenSource _requestCancelTokenSource;

View File

@@ -2,12 +2,9 @@
using System;
using System.Collections.Generic;
using Content.Client.Atmos;
using Content.Client.GameObjects.Components.Atmos;
using Content.Shared.Atmos;
using Content.Shared.GameObjects.EntitySystems.Atmos;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.GameObjects.EntitySystems;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.Graphics.Overlays;
using Robust.Client.Interfaces.ResourceManagement;
@@ -47,15 +44,19 @@ namespace Content.Client.GameObjects.EntitySystems
private Dictionary<GridId, Dictionary<MapIndices, GasOverlayChunk>> _tileData =
new Dictionary<GridId, Dictionary<MapIndices, GasOverlayChunk>>();
private AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<GasOverlayMessage>(HandleGasOverlayMessage);
_mapManager.OnGridRemoved += OnGridRemoved;
_atmosphereSystem = Get<AtmosphereSystem>();
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
{
var overlay = Atmospherics.GetOverlay(i);
var overlay = _atmosphereSystem.GetOverlay(i);
switch (overlay)
{
case SpriteSpecifier.Rsi animated:

View File

@@ -19,9 +19,7 @@ namespace Content.Client.GameObjects.EntitySystems
[UsedImplicitly]
internal sealed class IconSmoothSystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private readonly IMapManager _mapManager;
#pragma warning restore 649
[Dependency] private readonly IMapManager _mapManager = default!;
private readonly Queue<IEntity> _dirtyEntities = new Queue<IEntity>();

View File

@@ -17,9 +17,7 @@ namespace Content.Client.GameObjects.EntitySystems
[UsedImplicitly]
public sealed class MeleeWeaponSystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
#pragma warning restore 649
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{

View File

@@ -17,14 +17,11 @@ namespace Content.Client.GameObjects.EntitySystems
{
public class RangedWeaponSystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IEyeManager _eyeManager;
[Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IGameTiming _gameTiming;
#pragma warning restore 649
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
private InputSystem _inputSystem;
private CombatModeSystem _combatModeSystem;

View File

@@ -7,9 +7,7 @@ namespace Content.Client.GameObjects.EntitySystems
{
public class StatusEffectsSystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private IGameTiming _gameTiming;
#pragma warning restore 649
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override void FrameUpdate(float frameTime)
{

View File

@@ -15,12 +15,10 @@ namespace Content.Client.GameObjects.EntitySystems
/// </summary>
internal sealed class SubFloorHideSystem : EntitySystem
{
private bool _enableAll;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
#pragma warning disable 649
[Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
#pragma warning restore 649
private bool _enableAll;
[ViewVariables(VVAccess.ReadWrite)]
public bool EnableAll

View File

@@ -42,16 +42,14 @@ namespace Content.Client.GameObjects.EntitySystems
[UsedImplicitly]
public sealed class VerbSystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private readonly IStateManager _stateManager;
[Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IItemSlotManager _itemSlotManager;
[Dependency] private readonly IGameTiming _gameTiming;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IMapManager _mapManager;
#pragma warning restore 649
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
private EntityList _currentEntityList;
private VerbPopup _currentVerbListRoot;

View File

@@ -17,10 +17,8 @@ namespace Content.Client.GameTicking
{
public class ClientGameTicker : SharedGameTicker, IClientGameTicker
{
#pragma warning disable 649
[Dependency] private IClientNetManager _netManager;
[Dependency] private IStateManager _stateManager;
#pragma warning restore 649
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[ViewVariables] private bool _initialized;

View File

@@ -11,10 +11,8 @@ namespace Content.Client.Graphics.Overlays
{
public class CircleMaskOverlay : Overlay
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IEyeManager _eyeManager;
#pragma warning restore 649
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _shader;

View File

@@ -16,11 +16,9 @@ namespace Content.Client.Graphics.Overlays
{
public class FlashOverlay : Overlay, IConfigurable<TimedOverlayParameter>
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IClyde _displayManager;
[Dependency] private readonly IGameTiming _gameTiming;
#pragma warning restore 649
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IClyde _displayManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
private readonly ShaderInstance _shader;

View File

@@ -11,10 +11,9 @@ namespace Content.Client.Graphics.Overlays
{
public class GradientCircleMaskOverlay : Overlay
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IEyeManager _eyeManager;
#pragma warning restore 649
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _shader;

View File

@@ -86,9 +86,6 @@
"CanSpill",
"SpeedLoader",
"Hitscan",
"BoltActionBarrel",
"PumpBarrel",
"RevolverBarrel",
"ExplosiveProjectile",
"StunnableProjectile",
"RandomPottedPlant",
@@ -108,7 +105,6 @@
"SecureEntityStorage",
"PresetIdCard",
"SolarControlConsole",
"BatteryBarrel",
"FlashExplosive",
"FlashProjectile",
"Utensil",
@@ -162,6 +158,11 @@
"GasVapor",
"MobStateManager",
"Metabolism",
"AiFactionTag",
"PressureProtection",
"DebugPump",
"DebugVent",
"DebugSiphon",
};
}
}

View File

@@ -50,6 +50,7 @@ namespace Content.Client.Input
common.AddFunction(ContentKeyFunctions.OpenEntitySpawnWindow);
common.AddFunction(ContentKeyFunctions.OpenSandboxWindow);
common.AddFunction(ContentKeyFunctions.OpenTileSpawnWindow);
common.AddFunction(ContentKeyFunctions.OpenAdminMenu);
}
}
}

View File

@@ -20,10 +20,8 @@ namespace Content.Client.Instruments
{
public class InstrumentMenu : SS14Window
{
#pragma warning disable 649
[Dependency] private IMidiManager _midiManager;
[Dependency] private IFileDialogManager _fileDialogManager;
#pragma warning restore 649
[Dependency] private readonly IMidiManager _midiManager = default!;
[Dependency] private readonly IFileDialogManager _fileDialogManager = default!;
private InstrumentBoundUserInterface _owner;
private Button midiLoopButton;

View File

@@ -19,11 +19,9 @@ namespace Content.Client.Parallax
{
internal sealed class ParallaxManager : IParallaxManager, IPostInjectInit
{
#pragma warning disable 649
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly ILogManager _logManager;
[Dependency] private readonly IConfigurationManager _configurationManager;
#pragma warning restore 649
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
private static readonly ResourcePath ParallaxConfigPath = new ResourcePath("/parallax_config.toml");

View File

@@ -13,12 +13,10 @@ namespace Content.Client.Parallax
{
public class ParallaxOverlay : Overlay
{
#pragma warning disable 649
[Dependency] private readonly IParallaxManager _parallaxManager;
[Dependency] private readonly IEyeManager _eyeManager;
[Dependency] private readonly IClyde _displayManager;
[Dependency] private readonly IPrototypeManager _prototypeManager;
#pragma warning restore 649
[Dependency] private readonly IParallaxManager _parallaxManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IClyde _displayManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override bool AlwaysDirty => true;
private const float Slowness = 0.5f;

View File

@@ -14,9 +14,7 @@ namespace Content.Client.Research
{
public class LatheMenu : SS14Window
{
#pragma warning disable CS0649
[Dependency] private IPrototypeManager PrototypeManager;
#pragma warning restore
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private ItemList Items;
private ItemList Materials;
@@ -174,7 +172,7 @@ namespace Content.Client.Research
foreach (var (id, amount) in Owner.Storage)
{
if (!PrototypeManager.TryIndex(id, out MaterialPrototype materialPrototype)) continue;
if (!_prototypeManager.TryIndex(id, out MaterialPrototype materialPrototype)) continue;
var material = materialPrototype.Material;
Materials.AddItem($"{material.Name} {amount} cm³", material.Icon.Frame0(), false);
}

View File

@@ -32,9 +32,7 @@ namespace Content.Client.Research
private ItemList _unlockableTechnologies;
private ItemList _futureTechnologies;
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
public Button UnlockButton { get; private set; }
public Button ServerSelectionButton { get; private set; }

View File

@@ -74,19 +74,18 @@ namespace Content.Client.Sandbox
vBox.AddChild(ShowBbButton);
}
}
internal class SandboxManager : SharedSandboxManager, ISandboxManager
{
#pragma warning disable 649
[Dependency] private readonly IClientConsole _console;
[Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IClientNetManager _netManager;
[Dependency] private readonly ILocalizationManager _localization;
[Dependency] private readonly IPlacementManager _placementManager;
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
[Dependency] private readonly IInputManager _inputManager;
#pragma warning restore 649
[Dependency] private readonly IClientConsole _console = default!;
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly ILocalizationManager _localization = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
public bool SandboxAllowed { get; private set; }

View File

@@ -14,12 +14,10 @@ namespace Content.Client.State
{
public class GameScreen : GameScreenBase
{
#pragma warning disable 649
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IChatManager _chatManager;
#pragma warning restore 649
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[ViewVariables] private ChatBox _gameChat;

View File

@@ -28,17 +28,15 @@ namespace Content.Client.State
// Instantiated dynamically through the StateManager, Dependencies will be resolved.
public partial class GameScreenBase : Robust.Client.State.State
{
#pragma warning disable 649
[Dependency] protected readonly IClientEntityManager EntityManager;
[Dependency] protected readonly IInputManager InputManager;
[Dependency] protected readonly IPlayerManager PlayerManager;
[Dependency] protected readonly IEyeManager EyeManager;
[Dependency] protected readonly IEntitySystemManager EntitySystemManager;
[Dependency] protected readonly IGameTiming Timing;
[Dependency] protected readonly IMapManager MapManager;
[Dependency] protected readonly IUserInterfaceManager UserInterfaceManager;
[Dependency] protected readonly IConfigurationManager ConfigurationManager;
#pragma warning restore 649
[Dependency] protected readonly IClientEntityManager EntityManager = default!;
[Dependency] protected readonly IInputManager InputManager = default!;
[Dependency] protected readonly IPlayerManager PlayerManager = default!;
[Dependency] protected readonly IEyeManager EyeManager = default!;
[Dependency] protected readonly IEntitySystemManager EntitySystemManager = default!;
[Dependency] protected readonly IGameTiming Timing = default!;
[Dependency] protected readonly IMapManager MapManager = default!;
[Dependency] protected readonly IUserInterfaceManager UserInterfaceManager = default!;
[Dependency] protected readonly IConfigurationManager ConfigurationManager = default!;
private IEntity _lastHoveredEntity;

View File

@@ -16,13 +16,11 @@ namespace Content.Client.State
{
public class LauncherConnecting : Robust.Client.State.State
{
#pragma warning disable 649
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IStylesheetManager _stylesheetManager;
[Dependency] private readonly IClientNetManager _clientNetManager;
[Dependency] private readonly IGameController _gameController;
[Dependency] private readonly IBaseClient _baseClient;
#pragma warning restore 649
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IStylesheetManager _stylesheetManager = default!;
[Dependency] private readonly IClientNetManager _clientNetManager = default!;
[Dependency] private readonly IGameController _gameController = default!;
[Dependency] private readonly IBaseClient _baseClient = default!;
private Control _control;
private Label _connectStatus;

View File

@@ -1,6 +1,4 @@
using System;
using System.Linq;
using Content.Client.Interfaces;
using Content.Client.Interfaces;
using Content.Client.Interfaces.Chat;
using Content.Client.UserInterface;
using Content.Shared.Input;
@@ -18,25 +16,25 @@ using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
using System;
using System.Linq;
using static Content.Shared.SharedGameTicker;
namespace Content.Client.State
{
public class LobbyState : Robust.Client.State.State
{
#pragma warning disable 649
[Dependency] private readonly IBaseClient _baseClient;
[Dependency] private readonly IClientConsole _console;
[Dependency] private readonly IChatManager _chatManager;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly IClientGameTicker _clientGameTicker;
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IClientPreferencesManager _preferencesManager;
#pragma warning restore 649
[Dependency] private readonly IBaseClient _baseClient = default!;
[Dependency] private readonly IClientConsole _console = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IClientGameTicker _clientGameTicker = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IClientPreferencesManager _preferencesManager = default!;
[ViewVariables] private CharacterSetupGui _characterSetup;
[ViewVariables] private LobbyGui _lobby;
@@ -211,12 +209,11 @@ namespace Content.Client.State
private void UpdatePlayerList()
{
_lobby.OnlinePlayerItemList.Clear();
_lobby.PlayerReadyList.Clear();
_lobby.OnlinePlayerList.Clear();
foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name))
{
_lobby.OnlinePlayerItemList.AddItem(session.Name);
var readyState = "";
// Don't show ready state if we're ingame
@@ -236,7 +233,7 @@ namespace Content.Client.State
_ => "",
};
}
_lobby.PlayerReadyList.AddItem(readyState, null, false);
_lobby.OnlinePlayerList.AddItem(session.Name, readyState);
}
}

View File

@@ -27,15 +27,13 @@ namespace Content.Client.State
{
private const string PublicServerAddress = "server.spacestation14.io";
#pragma warning disable 649
[Dependency] private readonly IBaseClient _client;
[Dependency] private readonly IClientNetManager _netManager;
[Dependency] private readonly IConfigurationManager _configurationManager;
[Dependency] private readonly IGameController _controllerProxy;
[Dependency] private readonly ILocalizationManager _loc;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly IUserInterfaceManager userInterfaceManager;
#pragma warning restore 649
[Dependency] private readonly IBaseClient _client = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IGameController _controllerProxy = default!;
[Dependency] private readonly ILocalizationManager _loc = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
private MainMenuControl _mainMenuControl;
private OptionsMenu OptionsMenu;
@@ -48,7 +46,7 @@ namespace Content.Client.State
public override void Startup()
{
_mainMenuControl = new MainMenuControl(_resourceCache, _configurationManager);
userInterfaceManager.StateRoot.AddChild(_mainMenuControl);
_userInterfaceManager.StateRoot.AddChild(_mainMenuControl);
_mainMenuControl.QuitButton.OnPressed += QuitButtonPressed;
_mainMenuControl.OptionsButton.OnPressed += OptionsButtonPressed;
@@ -108,7 +106,7 @@ namespace Content.Client.State
if (!UsernameHelpers.IsNameValid(inputName, out var reason))
{
var invalidReason = _loc.GetString(reason.ToText());
userInterfaceManager.Popup(
_userInterfaceManager.Popup(
_loc.GetString("Invalid username:\n{0}", invalidReason),
_loc.GetString("Invalid Username"));
return;
@@ -130,7 +128,7 @@ namespace Content.Client.State
}
catch (ArgumentException e)
{
userInterfaceManager.Popup($"Unable to connect: {e.Message}", "Connection error.");
_userInterfaceManager.Popup($"Unable to connect: {e.Message}", "Connection error.");
Logger.Warning(e.ToString());
_netManager.ConnectFailed -= _onConnectFailed;
}
@@ -185,7 +183,7 @@ namespace Content.Client.State
private void _onConnectFailed(object _, NetConnectFailArgs args)
{
userInterfaceManager.Popup($"Failed to connect:\n{args.Reason}");
_userInterfaceManager.Popup($"Failed to connect:\n{args.Reason}");
_netManager.ConnectFailed -= _onConnectFailed;
_setConnectingState(false);
}

View File

@@ -9,5 +9,6 @@ namespace Content.Client.StationEvents
public List<string>? StationEvents { get; }
public void Initialize();
public event Action OnStationEventsReceived;
public void RequestEvents();
}
}

View File

@@ -0,0 +1,103 @@
using Content.Shared.Input;
using Robust.Client.Console;
using Robust.Client.Interfaces.Input;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Input.Binding;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using System.Collections.Generic;
namespace Content.Client.UserInterface.AdminMenu
{
internal class AdminMenuManager : IAdminMenuManager
{
[Dependency] private INetManager _netManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IClientConGroupController _clientConGroupController = default!;
private SS14Window _window;
private List<SS14Window> _commandWindows;
public void Initialize()
{
_commandWindows = new List<SS14Window>();
// Reset the AdminMenu Window on disconnect
_netManager.Disconnect += (sender, channel) => ResetWindow();
_inputManager.SetInputCommand(ContentKeyFunctions.OpenAdminMenu,
InputCmdHandler.FromDelegate(session => Toggle()));
}
public void ResetWindow()
{
_window?.Close();
_window = null;
foreach (var window in _commandWindows)
window?.Dispose();
_commandWindows.Clear();
}
public void OpenCommand(SS14Window window)
{
_commandWindows.Add(window);
window.OpenCentered();
}
public void Open()
{
if (_window == null)
_window = new AdminMenuWindow();
_window.OpenCentered();
}
public void Close()
{
_window?.Close();
foreach (var window in _commandWindows)
window?.Dispose();
_commandWindows.Clear();
}
/// <summary>
/// Checks if the player can open the window
/// </summary>
/// <returns>True if the player is allowed</returns>
public bool CanOpen()
{
return _clientConGroupController.CanAdminMenu();
}
/// <summary>
/// Checks if the player can open the window and tries to open it
/// </summary>
public void TryOpen()
{
if (CanOpen())
Open();
}
public void Toggle()
{
if (_window != null && _window.IsOpen)
{
Close();
}
else
{
TryOpen();
}
}
}
internal interface IAdminMenuManager
{
void Initialize();
void Open();
void OpenCommand(SS14Window window);
bool CanOpen();
void TryOpen();
void Toggle();
}
}

View File

@@ -0,0 +1,670 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Client.GameObjects.EntitySystems;
using Content.Client.StationEvents;
using Content.Shared.Atmos;
using Robust.Client.Console;
using Robust.Client.Interfaces.Placement;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.UserInterface.AdminMenu
{
public class AdminMenuWindow : SS14Window
{
public TabContainer MasterTabContainer;
public VBoxContainer PlayerList;
private List<CommandButton> _adminButtons = new List<CommandButton>
{
new KickCommandButton(),
new DirectCommandButton("Admin Ghost", "aghost"),
//TODO: teleport
};
private List<CommandButton> _adminbusButtons = new List<CommandButton>
{
new SpawnEntitiesCommandButton(),
new SpawnTilesCommandButton(),
new StationEventsCommandButton(),
};
private List<CommandButton> _debugButtons = new List<CommandButton>
{
new AddAtmosCommandButton(),
new FillGasCommandButton(),
};
private List<CommandButton> _roundButtons = new List<CommandButton>
{
new DirectCommandButton("Start Round", "startround"),
new DirectCommandButton("End Round", "endround"),
new DirectCommandButton("Restart Round", "restartround"),
};
private List<CommandButton> _serverButtons = new List<CommandButton>
{
new DirectCommandButton("Reboot", "restart"),
new DirectCommandButton("Shutdown", "shutdown"),
};
private void RefreshPlayerList(ButtonEventArgs args)
{
PlayerList.RemoveAllChildren();
var sessions = IoCManager.Resolve<IPlayerManager>().Sessions;
var header = new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
new Label { Text = "Name",
SizeFlagsStretchRatio = 2f,
SizeFlagsHorizontal = SizeFlags.FillExpand },
new Label { Text = "Player",
SizeFlagsStretchRatio = 2f,
SizeFlagsHorizontal = SizeFlags.FillExpand },
new Label { Text = "Status",
SizeFlagsStretchRatio = 1f,
SizeFlagsHorizontal = SizeFlags.FillExpand },
new Label { Text = "Ping",
SizeFlagsStretchRatio = 1f,
SizeFlagsHorizontal = SizeFlags.FillExpand,
Align = Label.AlignMode.Right },
}
};
PlayerList.AddChild(header);
PlayerList.AddChild(new Controls.HighDivider());
foreach (var player in sessions)
{
var hbox = new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
new Label {
Text = player.Name,
SizeFlagsStretchRatio = 2f,
SizeFlagsHorizontal = SizeFlags.FillExpand },
new Label {
Text = player.AttachedEntity?.Name,
SizeFlagsStretchRatio = 2f,
SizeFlagsHorizontal = SizeFlags.FillExpand },
new Label {
Text = player.Status.ToString(),
SizeFlagsStretchRatio = 1f,
SizeFlagsHorizontal = SizeFlags.FillExpand },
new Label {
Text = player.Ping.ToString(),
SizeFlagsStretchRatio = 1f,
SizeFlagsHorizontal = SizeFlags.FillExpand,
Align = Label.AlignMode.Right },
}
};
PlayerList.AddChild(hbox);
}
}
private void AddCommandButton(List<CommandButton> buttons, Control parent)
{
foreach (var cmd in buttons)
{
// Check if the player can do the command
if (!cmd.CanPress())
continue;
//TODO: make toggle?
var button = new Button
{
Text = cmd.Name
};
button.OnPressed += cmd.ButtonPressed;
parent.AddChild(button);
}
}
public AdminMenuWindow() //TODO: search for buttons?
{
CustomMinimumSize = (415,0);
Title = Loc.GetString("Admin Menu");
#region PlayerList
// Players // List of all the players, their entities and status
var playerTabContainer = new MarginContainer
{
MarginLeftOverride = 4,
MarginTopOverride = 4,
MarginRightOverride = 4,
MarginBottomOverride = 4,
CustomMinimumSize = (50, 50),
};
PlayerList = new VBoxContainer();
var refreshButton = new Button
{
Text = "Refresh"
};
refreshButton.OnPressed += RefreshPlayerList;
RefreshPlayerList(null!);
var playerVBox = new VBoxContainer
{
Children =
{
refreshButton,
PlayerList
}
};
playerTabContainer.AddChild(playerVBox);
#endregion PlayerList
#region Admin Tab
// Admin Tab // Actual admin stuff
var adminTabContainer = new MarginContainer
{
MarginLeftOverride = 4,
MarginTopOverride = 4,
MarginRightOverride = 4,
MarginBottomOverride = 4,
CustomMinimumSize = (50, 50),
};
var adminButtonGrid = new GridContainer
{
Columns = 4,
};
AddCommandButton(_adminButtons, adminButtonGrid);
adminTabContainer.AddChild(adminButtonGrid);
#endregion
#region Adminbus
// Adminbus // Fun Commands
var adminbusTabContainer = new MarginContainer
{
MarginLeftOverride = 4,
MarginTopOverride = 4,
MarginRightOverride = 4,
MarginBottomOverride = 4,
CustomMinimumSize = (50, 50),
};
var adminbusButtonGrid = new GridContainer
{
Columns = 4,
};
AddCommandButton(_adminbusButtons, adminbusButtonGrid);
adminbusTabContainer.AddChild(adminbusButtonGrid);
#endregion
#region Debug
// Debug // Mostly dev tools, like addatmos
var debugTabContainer = new MarginContainer
{
MarginLeftOverride = 4,
MarginTopOverride = 4,
MarginRightOverride = 4,
MarginBottomOverride = 4,
CustomMinimumSize = (50, 50),
};
var debugButtonGrid = new GridContainer
{
Columns = 4,
};
AddCommandButton(_debugButtons, debugButtonGrid);
debugTabContainer.AddChild(debugButtonGrid);
#endregion
#region Round
// Round // Commands like Check Antags, End Round, RestartRound
var roundTabContainer = new MarginContainer
{
MarginLeftOverride = 4,
MarginTopOverride = 4,
MarginRightOverride = 4,
MarginBottomOverride = 4,
CustomMinimumSize = (50, 50),
};
var roundButtonGrid = new GridContainer
{
Columns = 4,
};
AddCommandButton(_roundButtons, roundButtonGrid);
roundTabContainer.AddChild(roundButtonGrid);
#endregion
#region Server
// Server // Commands like Restart, Shutdown
var serverTabContainer = new MarginContainer
{
MarginLeftOverride = 4,
MarginTopOverride = 4,
MarginRightOverride = 4,
MarginBottomOverride = 4,
CustomMinimumSize = (50, 50),
};
var serverButtonGrid = new GridContainer
{
Columns = 4,
};
AddCommandButton(_serverButtons, serverButtonGrid);
serverTabContainer.AddChild(serverButtonGrid);
#endregion
//The master menu that contains all of the tabs.
MasterTabContainer = new TabContainer();
//Add all the tabs to the Master container.
MasterTabContainer.AddChild(adminTabContainer);
MasterTabContainer.SetTabTitle(0, Loc.GetString("Admin"));
MasterTabContainer.AddChild(adminbusTabContainer);
MasterTabContainer.SetTabTitle(1, Loc.GetString("Adminbus"));
MasterTabContainer.AddChild(debugTabContainer);
MasterTabContainer.SetTabTitle(2, Loc.GetString("Debug"));
MasterTabContainer.AddChild(roundTabContainer);
MasterTabContainer.SetTabTitle(3, Loc.GetString("Round"));
MasterTabContainer.AddChild(serverTabContainer);
MasterTabContainer.SetTabTitle(4, Loc.GetString("Server"));
MasterTabContainer.AddChild(playerTabContainer);
MasterTabContainer.SetTabTitle(5, Loc.GetString("Players"));
Contents.AddChild(MasterTabContainer);
//Request station events, so we can use them later
IoCManager.Resolve<IStationEventManager>().RequestEvents();
}
#region CommandButtonBaseClass
private abstract class CommandButton
{
public virtual string Name { get; }
public virtual string RequiredCommand { get; }
public abstract void ButtonPressed(ButtonEventArgs args);
public virtual bool CanPress()
{
return RequiredCommand == string.Empty ||
IoCManager.Resolve<IClientConGroupController>().CanCommand(RequiredCommand);
}
public CommandButton() : this(string.Empty, string.Empty) {}
public CommandButton(string name, string command)
{
Name = name;
RequiredCommand = command;
}
}
// Button that opens a UI
private abstract class UICommandButton : CommandButton
{
// The text on the submit button
public virtual string? SubmitText { get; }
/// <summary>
/// Called when the Submit button is pressed
/// </summary>
/// <param name="val">Dictionary of the parameter names and values</param>
public abstract void Submit();
public override void ButtonPressed(ButtonEventArgs args)
{
var manager = IoCManager.Resolve<IAdminMenuManager>();
var window = new CommandWindow(this);
window.Submit += Submit;
manager.OpenCommand(window);
}
// List of all the UI Elements
public abstract List<CommandUIControl> UI { get; }
}
// Button that directly calls a Command
private class DirectCommandButton : CommandButton
{
public DirectCommandButton(string name, string command) : base(name, command) { }
public override void ButtonPressed(ButtonEventArgs args)
{
IoCManager.Resolve<IClientConsole>().ProcessCommand(RequiredCommand);
}
}
#endregion
#region CommandButtons
private class SpawnEntitiesCommandButton : CommandButton
{
public override string Name => "Spawn Entities";
//TODO: override CanPress
public override void ButtonPressed(ButtonEventArgs args)
{
var manager = IoCManager.Resolve<IAdminMenuManager>();
var window = new EntitySpawnWindow(IoCManager.Resolve<IPlacementManager>(),
IoCManager.Resolve<IPrototypeManager>(),
IoCManager.Resolve<IResourceCache>(),
IoCManager.Resolve<ILocalizationManager>());
manager.OpenCommand(window);
}
}
private class SpawnTilesCommandButton : CommandButton
{
public override string Name => "Spawn Tiles";
//TODO: override CanPress
public override void ButtonPressed(ButtonEventArgs args)
{
var manager = IoCManager.Resolve<IAdminMenuManager>();
var window = new TileSpawnWindow(IoCManager.Resolve<ITileDefinitionManager>(),
IoCManager.Resolve<IPlacementManager>(),
IoCManager.Resolve<IResourceCache>());
manager.OpenCommand(window);
}
}
private class StationEventsCommandButton : UICommandButton
{
public override string Name => "Station Events";
public override string RequiredCommand => "events";
public override string? SubmitText => "Run";
private CommandUIDropDown _eventsDropDown = new CommandUIDropDown
{
Name = "Event",
GetData = () =>
{
var events = IoCManager.Resolve<IStationEventManager>().StationEvents;
if (events == null)
return new List<object> { "Not loaded" };
events.Add("Random");
return events.ToList<object>();
},
GetDisplayName = (obj) => (string) obj,
GetValueFromData = (obj) => ((string) obj).ToLower(),
};
public override List<CommandUIControl> UI => new List<CommandUIControl>
{
_eventsDropDown,
new CommandUIButton
{
Name = "Pause",
Handler = () =>
{
IoCManager.Resolve<IClientConsole>().ProcessCommand($"events pause");
},
},
new CommandUIButton
{
Name = "Resume",
Handler = () =>
{
IoCManager.Resolve<IClientConsole>().ProcessCommand($"events resume");
},
},
};
public override void Submit()
{
IoCManager.Resolve<IClientConsole>().ProcessCommand($"events run \"{_eventsDropDown.GetValue()}\"");
}
}
private class KickCommandButton : UICommandButton
{
public override string Name => "Kick";
public override string RequiredCommand => "kick";
private CommandUIDropDown _playerDropDown = new CommandUIDropDown
{
Name = "Player",
GetData = () => IoCManager.Resolve<IPlayerManager>().Sessions.ToList<object>(),
GetDisplayName = (obj) => $"{((IPlayerSession) obj).Name} ({((IPlayerSession) obj).AttachedEntity?.Name})",
GetValueFromData = (obj) => ((IPlayerSession) obj).Name,
};
private CommandUILineEdit _reason = new CommandUILineEdit
{
Name = "Reason"
};
public override List<CommandUIControl> UI => new List<CommandUIControl>
{
_playerDropDown,
_reason
};
public override void Submit()
{
IoCManager.Resolve<IClientConsole>().ProcessCommand($"kick \"{_playerDropDown.GetValue()}\" \"{CommandParsing.Escape(_reason.GetValue())}\"");
}
}
private class AddAtmosCommandButton : UICommandButton
{
public override string Name => "Add Atmos";
public override string RequiredCommand => "addatmos";
private CommandUIDropDown _grid = new CommandUIDropDown
{
Name = "Grid",
GetData = () => IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0).ToList<object>(),
GetDisplayName = (obj) => $"{((IMapGrid) obj).Index}{(IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID == ((IMapGrid) obj).Index ? " (Current)" : "")}",
GetValueFromData = (obj) => ((IMapGrid) obj).Index.ToString(),
};
public override List<CommandUIControl> UI => new List<CommandUIControl>
{
_grid,
};
public override void Submit()
{
IoCManager.Resolve<IClientConsole>().ProcessCommand($"addatmos {_grid.GetValue()}");
}
}
private class FillGasCommandButton : UICommandButton
{
public override string Name => "Fill Gas";
public override string RequiredCommand => "fillgas";
private CommandUIDropDown _grid = new CommandUIDropDown
{
Name = "Grid",
GetData = () => IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0).ToList<object>(),
GetDisplayName = (obj) => $"{((IMapGrid) obj).Index}{(IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID == ((IMapGrid) obj).Index ? " (Current)" : "")}",
GetValueFromData = (obj) => ((IMapGrid) obj).Index.ToString(),
};
private CommandUIDropDown _gas = new CommandUIDropDown
{
Name = "Gas",
GetData = () =>
{
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
return atmosSystem.Gases.ToList<object>();
},
GetDisplayName = (obj) => $"{((GasPrototype) obj).Name} ({((GasPrototype) obj).ID})",
GetValueFromData = (obj) => ((GasPrototype) obj).ID.ToString(),
};
private CommandUISpinBox _amount = new CommandUISpinBox
{
Name = "Amount"
};
public override List<CommandUIControl> UI => new List<CommandUIControl>
{
_grid,
_gas,
_amount,
};
public override void Submit()
{
IoCManager.Resolve<IClientConsole>().ProcessCommand($"fillgas {_grid.GetValue()} {_gas.GetValue()} {_amount.GetValue()}");
}
}
#endregion
#region CommandUIControls
private abstract class CommandUIControl
{
public string? Name;
public Control? Control;
public abstract Control GetControl();
public abstract string GetValue();
}
private class CommandUIDropDown : CommandUIControl
{
public Func<List<object>>? GetData;
// The string that the player sees in the list
public Func<object, string>? GetDisplayName;
// The value that is given to Submit
public Func<object, string>? GetValueFromData;
// Cache
protected List<object>? Data; //TODO: make this like IEnumerable or smth, so you don't have to do this ToList<object> shittery
public override Control GetControl() //TODO: fix optionbutton being shitty after moving the window
{
var opt = new OptionButton { CustomMinimumSize = (100, 0), SizeFlagsHorizontal = SizeFlags.FillExpand };
Data = GetData!();
foreach (var item in Data)
opt.AddItem(GetDisplayName!(item));
opt.OnItemSelected += eventArgs => opt.SelectId(eventArgs.Id);
Control = opt;
return Control;
}
public override string GetValue()
{
return GetValueFromData!(Data![((OptionButton)Control!).SelectedId]);
}
}
private class CommandUICheckBox : CommandUIControl
{
public override Control GetControl()
{
Control = new CheckBox { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.ShrinkCenter };
return Control;
}
public override string GetValue()
{
return ((CheckBox)Control!).Pressed ? "1" : "0";
}
}
private class CommandUILineEdit : CommandUIControl
{
public override Control GetControl()
{
Control = new LineEdit { CustomMinimumSize = (100, 0), SizeFlagsHorizontal = SizeFlags.FillExpand };
return Control;
}
public override string GetValue()
{
return ((LineEdit)Control!).Text;
}
}
private class CommandUISpinBox : CommandUIControl
{
public override Control GetControl()
{
Control = new SpinBox { CustomMinimumSize = (100, 0), SizeFlagsHorizontal = SizeFlags.FillExpand };
return Control;
}
public override string GetValue()
{
return ((SpinBox)Control!).Value.ToString();
}
}
private class CommandUIButton : CommandUIControl
{
public Action? Handler { get; set; }
public override Control GetControl()
{
Control = new Button {
CustomMinimumSize = (100, 0),
SizeFlagsHorizontal = SizeFlags.FillExpand,
Text = Name };
return Control;
}
public override string GetValue()
{
return "";
}
}
#endregion
#region CommandWindow
private class CommandWindow : SS14Window
{
List<CommandUIControl> _controls;
public Action? Submit { get; set; }
public CommandWindow(UICommandButton button)
{
Title = button.Name;
_controls = button.UI;
var container = new VBoxContainer //TODO: add margin between different controls
{
};
// Init Controls in a hbox + a label
foreach (var control in _controls)
{
var c = control.GetControl();
if (c is Button)
{
((Button) c).OnPressed += (args) =>
{
((CommandUIButton) control).Handler?.Invoke();
};
container.AddChild(c);
}
else
{
var label = new Label
{
Text = control.Name,
CustomMinimumSize = (100, 0)
};
var divider = new Control
{
CustomMinimumSize = (50, 0)
};
var hbox = new HBoxContainer
{
Children =
{
label,
divider,
c
},
};
container.AddChild(hbox);
}
}
// Init Submit Button
var submitButton = new Button
{
Text = button.SubmitText ?? button.Name
};
submitButton.OnPressed += SubmitPressed;
container.AddChild(submitButton);
Contents.AddChild(container);
}
public void SubmitPressed(ButtonEventArgs args)
{
Submit?.Invoke();
}
}
#endregion
}
}

View File

@@ -15,9 +15,7 @@ namespace Content.Client.UserInterface.Cargo
{
public class CargoConsoleMenu : SS14Window
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _loc;
#pragma warning restore 649
[Dependency] private readonly ILocalizationManager _loc = default!;
protected override Vector2? CustomSize => (400, 600);

View File

@@ -8,9 +8,7 @@ namespace Content.Client.UserInterface.Cargo
{
class CargoConsoleOrderMenu : SS14Window
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _loc;
#pragma warning restore 649
[Dependency] private readonly ILocalizationManager _loc = default!;
public LineEdit Requester { get; set; }
public LineEdit Reason { get; set; }

View File

@@ -10,16 +10,14 @@ namespace Content.Client.UserInterface.Cargo
{
public class GalacticBankSelectionMenu : SS14Window
{
[Dependency] private readonly ILocalizationManager _loc = default!;
private ItemList _accounts;
private int _accountCount = 0;
private string[] _accountNames = new string[] { };
private int[] _accountIds = new int[] { };
private int _selectedAccountId = -1;
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _loc;
#pragma warning restore 649
protected override Vector2? CustomSize => (300, 300);
public CargoConsoleBoundUserInterface Owner;

View File

@@ -47,6 +47,7 @@ namespace Content.Client.UserInterface
Action<bool> SandboxButtonToggled { get; set; }
Control HandsContainer { get; }
Control SuspicionContainer { get; }
Control InventoryQuickButtonContainer { get; }
bool CombatPanelVisible { get; set; }
@@ -74,13 +75,12 @@ namespace Content.Client.UserInterface
private Button _combatModeButton;
private VBoxContainer _combatPanelContainer;
#pragma warning disable 649
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly ILocalizationManager _loc;
[Dependency] private readonly IInputManager _inputManager;
#pragma warning restore 649
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly ILocalizationManager _loc = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
public Control HandsContainer { get; private set; }
public Control SuspicionContainer { get; private set; }
public Control InventoryQuickButtonContainer { get; private set; }
public bool CombatPanelVisible
@@ -244,6 +244,17 @@ namespace Content.Client.UserInterface
LayoutContainer.SetAnchorAndMarginPreset(HandsContainer, LayoutContainer.LayoutPreset.CenterBottom);
LayoutContainer.SetGrowHorizontal(HandsContainer, LayoutContainer.GrowDirection.Both);
LayoutContainer.SetGrowVertical(HandsContainer, LayoutContainer.GrowDirection.Begin);
SuspicionContainer = new MarginContainer
{
SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter
};
RootControl.AddChild(SuspicionContainer);
LayoutContainer.SetAnchorAndMarginPreset(SuspicionContainer, LayoutContainer.LayoutPreset.BottomLeft, margin: 10);
LayoutContainer.SetGrowHorizontal(SuspicionContainer, LayoutContainer.GrowDirection.End);
LayoutContainer.SetGrowVertical(SuspicionContainer, LayoutContainer.GrowDirection.Begin);
}
private void ButtonTutorialOnOnToggled()

View File

@@ -17,11 +17,9 @@ namespace Content.Client.UserInterface
{
public class HandsGui : Control
{
#pragma warning disable 0649
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly IItemSlotManager _itemSlotManager;
#pragma warning restore 0649
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
private readonly TextureRect _activeHandRect;

View File

@@ -21,15 +21,13 @@ namespace Content.Client.UserInterface
{
public class ItemSlotManager : IItemSlotManager
{
#pragma warning disable 0649
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IGameTiming _gameTiming;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
[Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly IEyeManager _eyeManager;
[Dependency] private readonly IMapManager _mapManager;
#pragma warning restore 0649
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
public bool SetItemSlot(ItemSlotButton button, IEntity entity)
{

View File

@@ -16,10 +16,8 @@ namespace Content.Client.UserInterface
{
public sealed class LateJoinGui : SS14Window
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IClientConsole _console;
#pragma warning restore 649
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IClientConsole _console = default!;
protected override Vector2? CustomSize => (360, 560);

View File

@@ -9,6 +9,8 @@ using Robust.Client.UserInterface.Controls;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using System;
using System.Collections.Generic;
namespace Content.Client.UserInterface
{
@@ -21,8 +23,7 @@ namespace Content.Client.UserInterface
public Button CreditsButton { get; }
public Button LeaveButton { get; }
public ChatBox Chat { get; }
public ItemList OnlinePlayerItemList { get; }
public ItemList PlayerReadyList { get; }
public LobbyPlayerList OnlinePlayerList { get; }
public ServerInfo ServerInfo { get; }
public LobbyCharacterPreviewPanel CharacterPreview { get; }
@@ -226,17 +227,11 @@ namespace Content.Client.UserInterface
CustomMinimumSize = (50,50),
Children =
{
(OnlinePlayerItemList = new ItemList
(OnlinePlayerList = new LobbyPlayerList
{
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsHorizontal = SizeFlags.FillExpand,
}),
(PlayerReadyList = new ItemList
{
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 0.2f
}),
})
}
}
}
@@ -262,4 +257,82 @@ namespace Content.Client.UserInterface
}
}
}
public class LobbyPlayerList : Control
{
private ScrollContainer _scroll;
private VBoxContainer _vBox;
public LobbyPlayerList()
{
var panel = new PanelContainer()
{
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#202028") },
};
_vBox = new VBoxContainer();
_scroll = new ScrollContainer();
_scroll.AddChild(_vBox);
panel.AddChild(_scroll);
AddChild(panel);
}
// Adds a row
public void AddItem(string name, string status)
{
var hbox = new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
};
// Player Name
hbox.AddChild(new PanelContainer()
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#373744"),
ContentMarginBottomOverride = 2,
ContentMarginLeftOverride = 4,
ContentMarginRightOverride = 4,
ContentMarginTopOverride = 2
},
Children =
{
new Label
{
Text = name
}
},
SizeFlagsHorizontal = SizeFlags.FillExpand
});
// Status
hbox.AddChild(new PanelContainer()
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#373744"),
ContentMarginBottomOverride = 2,
ContentMarginLeftOverride = 4,
ContentMarginRightOverride = 4,
ContentMarginTopOverride = 2
},
Children =
{
new Label
{
Text = status
}
},
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 0.2f,
});
_vBox.AddChild(hbox);
}
// Deletes all rows
public void Clear()
{
_vBox.RemoveAllChildren();
}
}
}

View File

@@ -69,8 +69,8 @@ namespace Content.Client.UserInterface
scrollContainer.SizeFlagsVertical = SizeFlags.FillExpand;
var innerScrollContainer = new VBoxContainer();
//Put antags on top of the list.
var manifestSortedList = info.OrderBy(p => !p.Antag);
//Put observers at the bottom of the list. Put antags on top.
var manifestSortedList = info.OrderBy(p => p.Observer).ThenBy(p => !p.Antag);
//Create labels for each player info.
foreach (var plyinfo in manifestSortedList)
{
@@ -79,12 +79,21 @@ namespace Content.Client.UserInterface
SizeFlagsVertical = SizeFlags.Fill,
};
if (plyinfo.Observer)
{
playerInfoText.SetMarkup(
Loc.GetString("[color=gray]{0}[/color] was [color=lightblue]{1}[/color], an observer.",
plyinfo.PlayerOOCName, plyinfo.PlayerICName));
}
else
{
//TODO: On Hover display a popup detailing more play info.
//For example: their antag goals and if they completed them sucessfully.
var icNameColor = plyinfo.Antag ? "red" : "white";
playerInfoText.SetMarkup(
Loc.GetString("[color=gray]{0}[/color] was [color={1}]{2}[/color] playing role of [color=orange]{3}[/color].",
plyinfo.PlayerOOCName, icNameColor, plyinfo.PlayerICName, Loc.GetString(plyinfo.Role)));
}
innerScrollContainer.AddChild(playerInfoText);
}

View File

@@ -7,10 +7,8 @@ namespace Content.Client.UserInterface.Stylesheets
{
public sealed class StylesheetManager : IStylesheetManager
{
#pragma warning disable 649
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IResourceCache _resourceCache;
#pragma warning restore 649
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
public Stylesheet SheetNano { get; private set; }
public Stylesheet SheetSpace { get; private set; }

View File

@@ -0,0 +1,116 @@
using System;
using System.Globalization;
using Content.Client.GameObjects.Components.Suspicion;
using Content.Shared.Interfaces;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.UserInterface.Suspicion
{
public class SuspicionGui : Control
{
#pragma warning disable 0649
[Dependency] private readonly IPlayerManager _playerManager;
#pragma warning restore 0649
private readonly VBoxContainer _container;
private readonly Button _roleButton;
private string _previousRoleName;
private bool _previousAntagonist;
public SuspicionGui()
{
IoCManager.InjectDependencies(this);
AddChild(_container = new VBoxContainer
{
SeparationOverride = 0,
Children =
{
(_roleButton = new Button
{
Name = "Suspicion Role Button"
})
}
});
_roleButton.CustomMinimumSize = (200, 60);
_roleButton.OnPressed += RoleButtonPressed;
}
private void RoleButtonPressed(ButtonEventArgs obj)
{
if (!TryGetComponent(out var role))
{
return;
}
if (!role.Antagonist ?? false)
{
return;
}
var allies = string.Join(", ", role.Allies);
var message = role.Allies.Count switch
{
0 => Loc.GetString("You have no allies"),
1 => Loc.GetString("Your ally is {0}", allies),
var n when n > 2 => Loc.GetString("Your allies are {0}", allies),
_ => throw new ArgumentException($"Invalid number of allies: {role.Allies.Count}")
};
role.Owner.PopupMessage(role.Owner, message);
}
private bool TryGetComponent(out SuspicionRoleComponent suspicion)
{
suspicion = default;
return _playerManager?.LocalPlayer?.ControlledEntity?.TryGetComponent(out suspicion) == true;
}
public void UpdateLabel()
{
if (!TryGetComponent(out var suspicion))
{
Visible = false;
return;
}
if (suspicion.Role == null || suspicion.Antagonist == null)
{
Visible = false;
return;
}
if (_previousRoleName == suspicion.Role && _previousAntagonist == suspicion.Antagonist)
{
return;
}
_previousRoleName = suspicion.Role;
_previousAntagonist = suspicion.Antagonist.Value;
var buttonText = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_previousRoleName);
buttonText = Loc.GetString(buttonText);
_roleButton.Text = buttonText;
_roleButton.ModulateSelfOverride = _previousAntagonist ? Color.Red : Color.Green;
Visible = true;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
UpdateLabel();
}
}
}

View File

@@ -92,7 +92,8 @@ Toggle UI: [color=#a4885c]{17}[/color]
Toggle debug overlay: [color=#a4885c]{18}[/color]
Toggle entity spawner: [color=#a4885c]{19}[/color]
Toggle tile spawner: [color=#a4885c]{20}[/color]
Toggle sandbox window: [color=#a4885c]{21}[/color]",
Toggle sandbox window: [color=#a4885c]{21}[/color]
Toggle admin menu [color=#a4885c]{31}[/color]",
Key(MoveUp), Key(MoveLeft), Key(MoveDown), Key(MoveRight),
Key(SwapHands),
Key(ActivateItemInHand),
@@ -120,7 +121,8 @@ Toggle sandbox window: [color=#a4885c]{21}[/color]",
Key(FocusAdminChat),
Key(Point),
Key(TryPullObject),
Key(MovePulledObject)));
Key(MovePulledObject),
Key(OpenAdminMenu)));
//Gameplay
VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nGameplay" });

Some files were not shown because too many files have changed in this diff Show More