Skip to content

Commit

Permalink
Merge pull request #476 from Rxup/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Feb 17, 2024
2 parents 03ccadf + b32d1de commit e591845
Show file tree
Hide file tree
Showing 266 changed files with 3,726 additions and 14,482 deletions.
21 changes: 0 additions & 21 deletions Content.Client/Chemistry/Components/InjectorComponent.cs

This file was deleted.

19 changes: 3 additions & 16 deletions Content.Client/Chemistry/EntitySystems/InjectorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,21 @@
using Content.Client.Chemistry.UI;
using Content.Client.Items;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Robust.Shared.GameStates;

namespace Content.Client.Chemistry.EntitySystems;

public sealed class InjectorSystem : EntitySystem
public sealed class InjectorSystem : SharedInjectorSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<InjectorComponent, ComponentHandleState>(OnHandleInjectorState);
Subs.ItemStatus<InjectorComponent>(ent => new InjectorStatusControl(ent));
Subs.ItemStatus<InjectorComponent>(ent => new InjectorStatusControl(ent, SolutionContainers));
SubscribeLocalEvent<HyposprayComponent, ComponentHandleState>(OnHandleHyposprayState);
Subs.ItemStatus<HyposprayComponent>(ent => new HyposprayStatusControl(ent));
}

private void OnHandleInjectorState(EntityUid uid, InjectorComponent component, ref ComponentHandleState args)
{
if (args.Current is not SharedInjectorComponent.InjectorComponentState state)
{
return;
}

component.CurrentVolume = state.CurrentVolume;
component.TotalVolume = state.TotalVolume;
component.CurrentMode = state.CurrentMode;
component.UiUpdateNeeded = true;
}

private void OnHandleHyposprayState(EntityUid uid, HyposprayComponent component, ref ComponentHandleState args)
{
if (args.Current is not HyposprayComponentState cState)
Expand Down
39 changes: 18 additions & 21 deletions Content.Client/Chemistry/UI/InjectorStatusControl.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Content.Client.Chemistry.Components;
using Content.Client.Message;
using Content.Client.Stylesheets;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
Expand All @@ -10,40 +10,37 @@ namespace Content.Client.Chemistry.UI;

public sealed class InjectorStatusControl : Control
{
private readonly InjectorComponent _parent;
private readonly Entity<InjectorComponent> _parent;
private readonly SharedSolutionContainerSystem _solutionContainers;
private readonly RichTextLabel _label;

public InjectorStatusControl(InjectorComponent parent)
public InjectorStatusControl(Entity<InjectorComponent> parent, SharedSolutionContainerSystem solutionContainers)
{
_parent = parent;
_solutionContainers = solutionContainers;
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);

Update();
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!_parent.UiUpdateNeeded)
return;
Update();
}

public void Update()
{
_parent.UiUpdateNeeded = false;
if (!_solutionContainers.TryGetSolution(_parent.Owner, InjectorComponent.SolutionName, out _, out var solution))
return;

//Update current volume and injector state
var modeStringLocalized = _parent.CurrentMode switch
// Update current volume and injector state
var modeStringLocalized = Loc.GetString(_parent.Comp.ToggleState switch
{
SharedInjectorComponent.InjectorToggleMode.Draw => Loc.GetString("injector-draw-text"),
SharedInjectorComponent.InjectorToggleMode.Inject => Loc.GetString("injector-inject-text"),
_ => Loc.GetString("injector-invalid-injector-toggle-mode")
};
InjectorToggleMode.Draw => "injector-draw-text",
InjectorToggleMode.Inject => "injector-inject-text",
_ => "injector-invalid-injector-toggle-mode"
});

_label.SetMarkup(Loc.GetString("injector-volume-label",
("currentVolume", _parent.CurrentVolume),
("totalVolume", _parent.TotalVolume),
("modeString", modeStringLocalized)));
("currentVolume", solution.Volume),
("totalVolume", solution.MaxVolume),
("modeString", modeStringLocalized),
("transferVolume", _parent.Comp.TransferAmount)));
}
}
36 changes: 22 additions & 14 deletions Content.Client/Corvax/TTS/TTSSystem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Content.Shared.Corvax.CCCVars;
using Content.Shared.Chat;
using Content.Shared.Corvax.CCCVars;
using Content.Shared.Corvax.TTS;
using Content.Shared.GameTicking;
using Robust.Client.Audio;
using Robust.Client.ResourceManagement;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.Player;
using Robust.Shared.Utility;

namespace Content.Client.Corvax.TTS;
Expand All @@ -18,9 +19,8 @@ namespace Content.Client.Corvax.TTS;
public sealed class TTSSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
//[Dependency] private readonly SharedGameTicker _gameTicker = default!;
[Dependency] private readonly IResourceManager _res = default!;
[Dependency] private readonly AudioSystem _audio = default!;

private ISawmill _sawmill = default!;
private readonly MemoryContentRoot _contentRoot = new();
Expand All @@ -44,7 +44,7 @@ public override void Initialize()
{
_prefix = ResPath.Root / $"TTS{_shareIdx++}";
_sawmill = Logger.GetSawmill("tts");
_resourceCache.AddRoot(_prefix, _contentRoot);
_res.AddRoot(_prefix, _contentRoot);
_cfg.OnValueChanged(CCCVars.TTSVolume, OnTtsVolumeChanged, true);
SubscribeNetworkEvent<PlayTTSEvent>(OnPlayTTS);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
Expand Down Expand Up @@ -74,24 +74,27 @@ private void OnTtsVolumeChanged(float volume)

private void OnPlayTTS(PlayTTSEvent ev)
{
//_sawmill.Debug($"Play TTS audio {ev.Data.Length} bytes from {ev.SourceUid} entity");

var volume = AdjustVolume(ev.IsWhisper);
_sawmill.Verbose($"Play TTS audio {ev.Data.Length} bytes from {ev.SourceUid} entity");

var filePath = new ResPath($"{_fileIdx++}.ogg");
_contentRoot.AddOrUpdateFile(filePath, ev.Data);

var audioParams = AudioParams.Default.WithVolume(volume);
var soundPath = new SoundPathSpecifier(_prefix / filePath, audioParams);
var audioResource = new AudioResource();
audioResource.Load(IoCManager.Instance!, _prefix / filePath);

var audioParams = AudioParams.Default
.WithVolume(AdjustVolume(ev.IsWhisper))
.WithMaxDistance(AdjustDistance(ev.IsWhisper));

if (ev.SourceUid != null)
{
var sourceUid = GetEntity(ev.SourceUid.Value);
if(sourceUid.Valid)
_audio.PlayEntity(soundPath, Filter.Local(), sourceUid, false, audioParams); // recipient arg ignored on client
if(sourceUid.IsValid())
_audio.PlayEntity(audioResource.AudioStream, sourceUid, audioParams);
}
else
{
_audio.PlayGlobal(soundPath, Filter.Local(), false);// recordReplay arg ignored on client
_audio.PlayGlobal(audioResource.AudioStream, audioParams);
}

_contentRoot.RemoveFile(filePath);
Expand All @@ -108,4 +111,9 @@ private float AdjustVolume(bool isWhisper)

return volume;
}

private float AdjustDistance(bool isWhisper)
{
return isWhisper ? SharedChatSystem.WhisperMuffledRange : SharedChatSystem.VoiceRange;
}
}
2 changes: 1 addition & 1 deletion Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ public override void Init()
_prototypeManager.RegisterIgnore("alertLevels");
_prototypeManager.RegisterIgnore("nukeopsRole");
_prototypeManager.RegisterIgnore("stationGoal"); // Corvax-StationGoal
_prototypeManager.RegisterIgnore("loadout"); // Corvax-Loadout

// Begin Backmen: our ignored prototypes.
_prototypeManager.RegisterIgnore("npcConversationTree");
_prototypeManager.RegisterIgnore("shipwreckDestination");
_prototypeManager.RegisterIgnore("shipwreckFaction");
_prototypeManager.RegisterIgnore("loadout");
// End Backmen.

_componentFactory.GenerateNetIds();
Expand Down
38 changes: 38 additions & 0 deletions Content.Client/Lock/Visualizers/LockVisualizerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Shared.Storage;
using Content.Shared.Lock;
using Robust.Client.GameObjects;

namespace Content.Client.Lock.Visualizers;

public sealed class LockVisualizerSystem : VisualizerSystem<LockVisualsComponent>
{
protected override void OnAppearanceChange(EntityUid uid, LockVisualsComponent comp, ref AppearanceChangeEvent args)
{
if (args.Sprite == null
|| !AppearanceSystem.TryGetData<bool>(uid, LockVisuals.Locked, out _, args.Component))
return;

// Lock state for the entity.
if (!AppearanceSystem.TryGetData<bool>(uid, LockVisuals.Locked, out var locked, args.Component))
locked = true;

var unlockedStateExist = args.Sprite.BaseRSI?.TryGetState(comp.StateUnlocked, out _);

if (AppearanceSystem.TryGetData<bool>(uid, StorageVisuals.Open, out var open, args.Component))
{
args.Sprite.LayerSetVisible(LockVisualLayers.Lock, !open);
}
else if (!(bool) unlockedStateExist!)
args.Sprite.LayerSetVisible(LockVisualLayers.Lock, locked);

if (!open && (bool) unlockedStateExist!)
{
args.Sprite.LayerSetState(LockVisualLayers.Lock, locked ? comp.StateLocked : comp.StateUnlocked);
}
}
}

public enum LockVisualLayers : byte
{
Lock
}
20 changes: 20 additions & 0 deletions Content.Client/Lock/Visualizers/LockVisualsComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Content.Client.Lock.Visualizers;

[RegisterComponent]
[Access(typeof(LockVisualizerSystem))]
public sealed partial class LockVisualsComponent : Component
{
/// <summary>
/// The RSI state used for the lock indicator while the entity is locked.
/// </summary>
[DataField("stateLocked")]
[ViewVariables(VVAccess.ReadWrite)]
public string? StateLocked = "locked";

/// <summary>
/// The RSI state used for the lock indicator entity is unlocked.
/// </summary>
[DataField("stateUnlocked")]
[ViewVariables(VVAccess.ReadWrite)]
public string? StateUnlocked = "unlocked";
}
72 changes: 37 additions & 35 deletions Content.Client/MainMenu/UI/MainMenuControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,46 @@
xmlns:pllax="clr-namespace:Content.Client.Parallax"
xmlns:clog="clr-namespace:Content.Client.Changelog">
<pllax:ParallaxControl />
<LayoutContainer>
<BoxContainer Name="VBox"
Orientation="Vertical"
StyleIdentifier="mainMenuVBox">
<TextureRect Name="Logo"
Stretch="KeepCentered" />
<BoxContainer Orientation="Horizontal"
SeparationOverride="4">
<Label Text="{Loc 'main-menu-username-label'}" />
<LineEdit Name="UsernameBox"
Access="Public"
PlaceHolder="{Loc 'main-menu-username-text'}"
HorizontalExpand="True" />
</BoxContainer>
<BoxContainer Name="VBox"
Orientation="Vertical"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalExpand="True"
VerticalExpand="True"
StyleIdentifier="mainMenuVBox"
SeparationOverride="3">
<TextureRect Name="Logo"
Stretch="KeepCentered"/>
<GridContainer Columns="2">
<Label Text="{Loc 'main-menu-username-label'}" />
<LineEdit Name="UsernameBox"
Access="Public"
PlaceHolder="{Loc 'main-menu-username-text'}"
HorizontalExpand="True" />
<Label Text="{Loc 'main-menu-address-label'}"/>
<LineEdit Name="AddressBox"
Access="Public"
Text="localhost"
PlaceHolder="server address:port"
HorizontalExpand="True" />
<Button Name="DirectConnectButton"
Access="Public"
Text="{Loc 'main-menu-direct-connect-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu" />
<Control MinSize="0 2" />
<Button Name="OptionsButton"
Access="Public"
Text="{Loc 'main-menu-options-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu" />
<Button Name="QuitButton"
Access="Public"
Text="{Loc 'main-menu-quit-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu" />
<clog:ChangelogButton
Name="ChangelogButton"
Access="Public"/>
</BoxContainer>
</LayoutContainer>
</GridContainer>
<Button Name="DirectConnectButton"
Access="Public"
Text="{Loc 'main-menu-direct-connect-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu"/>
<Button Name="OptionsButton"
Access="Public"
Text="{Loc 'main-menu-options-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu"/>
<Button Name="QuitButton"
Access="Public"
Text="{Loc 'main-menu-quit-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu"/>
<clog:ChangelogButton
Name="ChangelogButton"
Access="Public"/>
</BoxContainer>
</Control>
12 changes: 1 addition & 11 deletions Content.Client/Singularity/Systems/EmitterSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Content.Client.Storage.Visualizers;
using Content.Shared.Singularity.Components;
using Content.Shared.Singularity.Components;
using Content.Shared.Singularity.EntitySystems;
using Content.Shared.Storage;
using Robust.Client.GameObjects;

namespace Content.Client.Singularity.Systems;
Expand All @@ -21,14 +19,6 @@ private void OnAppearanceChange(EntityUid uid, EmitterComponent component, ref A
if (args.Sprite == null)
return;

if (args.Sprite.LayerMapTryGet(StorageVisualLayers.Lock, out var lockLayer))
{
if (!_appearance.TryGetData<bool>(uid, StorageVisuals.Locked, out var locked, args.Component))
locked = false;

args.Sprite.LayerSetVisible(lockLayer, locked);
}

if (!_appearance.TryGetData<EmitterVisualState>(uid, EmitterVisuals.VisualState, out var state, args.Component))
state = EmitterVisualState.Off;

Expand Down
Loading

0 comments on commit e591845

Please sign in to comment.