Skip to content

Commit

Permalink
Merge branch 'space-wizards:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
RonRonstation authored Dec 30, 2023
2 parents b29a544 + ad67a23 commit 1302541
Show file tree
Hide file tree
Showing 383 changed files with 496,298 additions and 390,002 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;

namespace Content.Client.Administration.UI.ManageSolutions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed partial class EditSolutionsWindow : DefaultWindow
private NetEntity _target = NetEntity.Invalid;
private string? _selectedSolution;
private AddReagentWindow? _addReagentWindow;
private Dictionary<string, Solution>? _solutions;
private Dictionary<string, EntityUid>? _solutions;

public EditSolutionsWindow()
{
Expand Down Expand Up @@ -60,9 +60,11 @@ public void UpdateReagents()
if (_selectedSolution == null || _solutions == null)
return;

if (!_solutions.TryGetValue(_selectedSolution, out var solution))
if (!_solutions.TryGetValue(_selectedSolution, out var solutionId) ||
!_entityManager.TryGetComponent(solutionId, out SolutionComponent? solutionComp))
return;

var solution = solutionComp.Solution;
UpdateVolumeBox(solution);
UpdateThermalBox(solution);

Expand Down Expand Up @@ -198,10 +200,13 @@ private void AddReagentEntry(ReagentQuantity reagentQuantity)
/// </summary>
private void SetReagent(FloatSpinBox.FloatSpinBoxEventArgs args, string prototype)
{
if (_solutions == null || _selectedSolution == null)
if (_solutions == null || _selectedSolution == null ||
!_solutions.TryGetValue(_selectedSolution, out var solutionId) ||
!_entityManager.TryGetComponent(solutionId, out SolutionComponent? solutionComp))
return;

var current = _solutions[_selectedSolution].GetTotalPrototypeQuantity(prototype);
var solution = solutionComp.Solution;
var current = solution.GetTotalPrototypeQuantity(prototype);
var delta = args.Value - current.Float();

if (MathF.Abs(delta) < 0.01)
Expand Down Expand Up @@ -275,22 +280,38 @@ private void SolutionSelected(OptionButton.ItemSelectedEventArgs args)
/// <summary>
/// Update the solution options.
/// </summary>
public void UpdateSolutions(Dictionary<string, Solution>? solutions)
public void UpdateSolutions(List<(string, NetEntity)>? solutions)
{
SolutionOption.Clear();
_solutions = solutions;

if (solutions is { Count: > 0 })
{
if (_solutions is { Count: > 0 })
_solutions.Clear();
else
_solutions = new(solutions.Count);

foreach (var (name, netSolution) in solutions)
{
if (_entityManager.TryGetEntity(netSolution, out var solution))
_solutions.Add(name, solution.Value);
}
}
else
_solutions = null;

if (_solutions == null)
return;

int i = 0;
foreach (var solution in _solutions.Keys)
int selectedIndex = 0; // Default to the first solution if none are found.
foreach (var (name, _) in _solutions)
{
SolutionOption.AddItem(solution, i);
SolutionOption.SetItemMetadata(i, solution);
SolutionOption.AddItem(name, i);
SolutionOption.SetItemMetadata(i, name);

if (solution == _selectedSolution)
SolutionOption.Select(i);
if (name == _selectedSolution)
selectedIndex = i;

i++;
}
Expand All @@ -300,14 +321,11 @@ public void UpdateSolutions(Dictionary<string, Solution>? solutions)
// No applicable solutions
Close();
Dispose();
return;
}

if (_selectedSolution == null || !_solutions.ContainsKey(_selectedSolution))
{
// the previously selected solution is no longer valid.
SolutionOption.Select(0);
_selectedSolution = (string?) SolutionOption.SelectedMetadata;
}
SolutionOption.Select(selectedIndex);
_selectedSolution = (string?) SolutionOption.SelectedMetadata;
}
}
}
98 changes: 98 additions & 0 deletions Content.Client/Audio/AudioUIController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using Content.Shared.CCVar;
using Robust.Client.Audio;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Audio.Sources;
using Robust.Shared.Configuration;

namespace Content.Client.Audio;

public sealed class AudioUIController : UIController
{
[Dependency] private readonly IAudioManager _audioManager = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly IResourceCache _cache = default!;

private float _interfaceGain;
private IAudioSource? _clickSource;
private IAudioSource? _hoverSource;

private const float ClickGain = 0.25f;
private const float HoverGain = 0.05f;

public override void Initialize()
{
base.Initialize();

/*
* This exists to load UI sounds outside of the game sim.
*/

// No unsub coz never shuts down until program exit.
_configManager.OnValueChanged(CCVars.UIClickSound, SetClickSound, true);
_configManager.OnValueChanged(CCVars.UIHoverSound, SetHoverSound, true);

_configManager.OnValueChanged(CCVars.InterfaceVolume, SetInterfaceVolume, true);
}

private void SetInterfaceVolume(float obj)
{
_interfaceGain = obj;

if (_clickSource != null)
{
_clickSource.Gain = ClickGain * _interfaceGain;
}

if (_hoverSource != null)
{
_hoverSource.Gain = HoverGain * _interfaceGain;
}
}

private void SetClickSound(string value)
{
if (!string.IsNullOrEmpty(value))
{
var resource = _cache.GetResource<AudioResource>(value);
var source =
_audioManager.CreateAudioSource(resource);

if (source != null)
{
source.Gain = ClickGain * _interfaceGain;
source.Global = true;
}

_clickSource = source;
UIManager.SetClickSound(source);
}
else
{
UIManager.SetClickSound(null);
}
}

private void SetHoverSound(string value)
{
if (!string.IsNullOrEmpty(value))
{
var hoverResource = _cache.GetResource<AudioResource>(value);
var hoverSource =
_audioManager.CreateAudioSource(hoverResource);

if (hoverSource != null)
{
hoverSource.Gain = HoverGain * _interfaceGain;
hoverSource.Global = true;
}

_hoverSource = hoverSource;
UIManager.SetHoverSound(hoverSource);
}
else
{
UIManager.SetHoverSound(null);
}
}
}
12 changes: 8 additions & 4 deletions Content.Client/Audio/ContentAudioSystem.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using Content.Shared.Audio;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Robust.Client.GameObjects;
using Robust.Shared;
using Robust.Shared.Audio;
using Robust.Client.Audio;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using AudioComponent = Robust.Shared.Audio.Components.AudioComponent;

namespace Content.Client.Audio;

public sealed partial class ContentAudioSystem : SharedContentAudioSystem
{
[Dependency] private readonly IAudioManager _audioManager = default!;
[Dependency] private readonly IResourceCache _cache = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;

// Need how much volume to change per tick and just remove it when it drops below "0"
private readonly Dictionary<EntityUid, float> _fadingOut = new();

Expand All @@ -32,6 +35,7 @@ public sealed partial class ContentAudioSystem : SharedContentAudioSystem
public const float AmbienceMultiplier = 3f;
public const float AmbientMusicMultiplier = 3f;
public const float LobbyMultiplier = 3f;
public const float InterfaceMultiplier = 2f;

public override void Initialize()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Content.Shared.Chemistry.EntitySystems;

namespace Content.Client.Chemistry.Containers.EntitySystems;

public sealed partial class SolutionContainerSystem : SharedSolutionContainerSystem
{
}
4 changes: 2 additions & 2 deletions Content.Client/Construction/UI/ConstructionMenuPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,15 @@ private void SystemOnToggleMenu(object? sender, EventArgs eventArgs)
if (IsAtFront)
{
WindowOpen = false;
_uiManager.GetActiveUIWidget<GameTopMenuBar>().CraftingButton.Pressed = false; // This does not call CraftingButtonToggled
_uiManager.GetActiveUIWidget<GameTopMenuBar>().CraftingButton.SetClickPressed(false); // This does not call CraftingButtonToggled
}
else
_constructionView.MoveToFront();
}
else
{
WindowOpen = true;
_uiManager.GetActiveUIWidget<GameTopMenuBar>().CraftingButton.Pressed = true; // This does not call CraftingButtonToggled
_uiManager.GetActiveUIWidget<GameTopMenuBar>().CraftingButton.SetClickPressed(true); // This does not call CraftingButtonToggled
}
}

Expand Down
21 changes: 14 additions & 7 deletions Content.Client/Explosion/ExplosionOverlaySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Robust.Client.ResourceManagement;
using Robust.Shared.GameStates;
using Robust.Shared.Graphics.RSI;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

Expand All @@ -18,6 +19,7 @@ public sealed class ExplosionOverlaySystem : EntitySystem
[Dependency] private readonly IResourceCache _resCache = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly SharedPointLightSystem _lights = default!;
[Dependency] private readonly IMapManager _mapMan = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -65,15 +67,20 @@ private void OnExplosionInit(EntityUid uid, ExplosionVisualsComponent component,
return;
}

// spawn in a client-side light source at the epicenter
var lightEntity = Spawn("ExplosionLight", component.Epicenter);
var light = _lights.EnsureLight(lightEntity);
// Map may have been deleted.
if (_mapMan.MapExists(component.Epicenter.MapId))
{
// spawn in a client-side light source at the epicenter
var lightEntity = Spawn("ExplosionLight", component.Epicenter);
var light = _lights.EnsureLight(lightEntity);

_lights.SetRadius(lightEntity, component.Intensity.Count, light);
_lights.SetEnergy(lightEntity, component.Intensity.Count, light);
_lights.SetColor(lightEntity, type.LightColor, light);
textures.LightEntity = lightEntity;
}

_lights.SetRadius(lightEntity, component.Intensity.Count, light);
_lights.SetEnergy(lightEntity, component.Intensity.Count, light);
_lights.SetColor(lightEntity, type.LightColor, light);

textures.LightEntity = lightEntity;
textures.FireColor = type.FireColor;
textures.IntensityPerState = type.IntensityPerState;

Expand Down
21 changes: 16 additions & 5 deletions Content.Client/Eye/Blinding/BlindOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
using Content.Client.Movement.Systems;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared.Eye.Blinding;
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;

namespace Content.Client.Eye.Blinding
{
public sealed class BlindOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] IEntityManager _entityManager = default!;
[Dependency] ILightManager _lightManager = default!;

[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly ILightManager _lightManager = default!;

public override bool RequestScreenTexture => true;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
Expand All @@ -30,13 +32,13 @@ public BlindOverlay()
}
protected override bool BeforeDraw(in OverlayDrawArgs args)
{
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp))
if (!_entityManager.TryGetComponent(_playerManager.LocalSession?.AttachedEntity, out EyeComponent? eyeComp))
return false;

if (args.Viewport.Eye != eyeComp.Eye)
return false;

var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
var playerEntity = _playerManager.LocalSession?.AttachedEntity;

if (playerEntity == null)
return false;
Expand Down Expand Up @@ -64,6 +66,11 @@ protected override void Draw(in OverlayDrawArgs args)
if (ScreenTexture == null)
return;

var playerEntity = _playerManager.LocalSession?.AttachedEntity;

if (playerEntity == null)
return;

if (!_blindableComponent.GraceFrame)
{
_blindableComponent.LightSetup = true; // Ok we touched the lights
Expand All @@ -73,6 +80,10 @@ protected override void Draw(in OverlayDrawArgs args)
_blindableComponent.GraceFrame = false;
}

if (_entityManager.TryGetComponent<EyeComponent>(playerEntity, out var content))
{
_circleMaskShader?.SetParameter("ZOOM", content.Zoom.X);
}
_greyscaleShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);

var worldHandle = args.WorldHandle;
Expand Down
Loading

0 comments on commit 1302541

Please sign in to comment.