Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random Announcer System #21

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
59e06b6
AnnouncerSystem
DEATHB4DEFEAT Nov 4, 2023
4f53af8
Intern announcer sounds
DEATHB4DEFEAT Nov 4, 2023
f5cd12b
MedBot announcer sounds
DEATHB4DEFEAT Nov 4, 2023
69eb170
N.E.I.L announcer sounds
DEATHB4DEFEAT Nov 4, 2023
7d40587
VoxFem announcer sounds
DEATHB4DEFEAT Nov 4, 2023
6e6e494
add announcer prototypes
DEATHB4DEFEAT Nov 4, 2023
3f3db39
add a test to check if every announcer prototype has a fallback sound
DEATHB4DEFEAT Nov 4, 2023
e47af84
fix CVar names
DEATHB4DEFEAT Nov 4, 2023
900561d
add baseAudioParams and ignoreBasePath to announcer prototype and data
DEATHB4DEFEAT Nov 4, 2023
8f4ba76
shuttle, comms, and roundstart announcements
DEATHB4DEFEAT Nov 4, 2023
2d0f056
placeholder shuttle sounds in prototypes
DEATHB4DEFEAT Nov 4, 2023
4f27941
improvements to announcerSystem
DEATHB4DEFEAT Nov 4, 2023
da78ee6
Merge branch 'master' of https://github.com/Simple-Station/Parkstatio…
DEATHB4DEFEAT Jan 29, 2024
0b7bd04
fix the system from the merge
DEATHB4DEFEAT Jan 29, 2024
3f28fe2
add announcements to gamerules
DEATHB4DEFEAT Jan 29, 2024
68083fa
fix welcome to the station message
DEATHB4DEFEAT Jan 29, 2024
c943351
deglobalize announcer names
DEATHB4DEFEAT Jan 29, 2024
67b644d
add access to current announcer
DEATHB4DEFEAT Jan 29, 2024
f64ba2e
change welcome announcement method again
DEATHB4DEFEAT Jan 29, 2024
044c089
fix codebase change markers
DEATHB4DEFEAT Jan 29, 2024
f00b1c5
add a volume slider for announcements
DEATHB4DEFEAT Feb 1, 2024
8df66e0
fix having to apply sound settings to hear announcements
DEATHB4DEFEAT Feb 1, 2024
a8a7e64
make Intern the same volume as other announcers (he's so loud wtf)
DEATHB4DEFEAT Feb 1, 2024
f7596db
fix misspelling of shuttleauthadded
DEATHB4DEFEAT Feb 1, 2024
a93f752
adds a template file to explain *everything*
DEATHB4DEFEAT Feb 1, 2024
c34b6f6
update template
DEATHB4DEFEAT Feb 17, 2024
d6aa388
rename announcementPaths to announcements
DEATHB4DEFEAT Feb 17, 2024
9bf9b0b
more systems use AnnouncerSystem, update template
DEATHB4DEFEAT Feb 18, 2024
a0597ff
Merge branch 'master' of https://github.com/Simple-Station/Parkstatio…
DEATHB4DEFEAT Apr 6, 2024
de4446e
rename SimpleStation14 to Parkstation
DEATHB4DEFEAT Apr 6, 2024
82311a4
fix announcer localiation scheme
DEATHB4DEFEAT Apr 6, 2024
c00b5dd
update template
DEATHB4DEFEAT Apr 6, 2024
2c8ace2
fix default file paths for announcers
DEATHB4DEFEAT Apr 6, 2024
9370b46
rename SSCVars to PSCVars
DEATHB4DEFEAT Apr 6, 2024
b07c245
forgot to fix NEIL and Intern paths
DEATHB4DEFEAT Apr 6, 2024
1604abe
fix empty announcements
DEATHB4DEFEAT Apr 6, 2024
b66de8e
rename complete to Complete
DEATHB4DEFEAT Apr 6, 2024
371acb0
update template
DEATHB4DEFEAT Apr 6, 2024
d5a47d9
fix announcements playing that shouldn't
DEATHB4DEFEAT Apr 7, 2024
1133abf
reformat and improve announcement IDs
DEATHB4DEFEAT Apr 7, 2024
411f25d
move Intern sound collections from StatusEffects folder
DEATHB4DEFEAT Apr 7, 2024
7915294
fix announcer announcement formatting and announcement locales
DEATHB4DEFEAT Apr 7, 2024
b035eaf
fix SharedAnnouncerSystem not being fully merged with AnnouncerSystem
DEATHB4DEFEAT Apr 7, 2024
4f5652f
add the Delta-V announcer Michael
DEATHB4DEFEAT Apr 7, 2024
f746110
add localizationTest and improve fallbackTest
DEATHB4DEFEAT Apr 7, 2024
f8eb4ec
fix test failures
DEATHB4DEFEAT Apr 7, 2024
bef13fe
fix spawnAnnounceCaptain announcement
DEATHB4DEFEAT Apr 13, 2024
75a8c73
fix casing of PowerSinkExplosion announcement
DEATHB4DEFEAT Apr 13, 2024
e7d6170
add announcerOverride option to everything
DEATHB4DEFEAT Apr 13, 2024
8a06392
fix Automated command_report sound file name
DEATHB4DEFEAT Apr 13, 2024
e4e66b0
rewrite the announce command
DEATHB4DEFEAT Apr 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Content.Client/Audio/ContentAudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public sealed partial class ContentAudioSystem : SharedContentAudioSystem
public const float AmbientMusicMultiplier = 3f;
public const float LobbyMultiplier = 3f;
public const float InterfaceMultiplier = 2f;
public const float AnnouncerMultiplier = 3f; // Parkstation-RandomAnnouncers

public override void Initialize()
{
Expand Down
14 changes: 14 additions & 0 deletions Content.Client/Options/UI/Tabs/AudioTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@
<Label Name="AmbienceSoundsLabel" MinSize="48 0" Align="Right" />
<Control MinSize="4 0"/>
</BoxContainer>
<!-- Parkstation-RandomAnnouncers -->
<BoxContainer Orientation="Horizontal" Margin="5 0 0 0">
<Label Text="{Loc 'ui-options-announcer-volume'}" HorizontalExpand="True" />
<Control MinSize="8 0" />
<Slider Name="AnnouncerVolumeSlider"
MinValue="0"
MaxValue="100"
HorizontalExpand="True"
MinSize="80 0"
Rounded="True" />
<Control MinSize="8 0" />
<Label Name="AnnouncerVolumeLabel" MinSize="48 0" Align="Right" />
<Control MinSize="4 0"/>
</BoxContainer>
<Control MinSize="0 8" />
<CheckBox Name="LobbyMusicCheckBox" Text="{Loc 'ui-options-lobby-music'}" />
<CheckBox Name="RestartSoundsCheckBox" Text="{Loc 'ui-options-restart-sounds'}" />
Expand Down
17 changes: 16 additions & 1 deletion Content.Client/Options/UI/Tabs/AudioTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Client.Audio;
using Content.Shared.CCVar;
using Content.Shared.Parkstation.CCVar;
using Robust.Client.Audio;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
Expand Down Expand Up @@ -37,6 +38,7 @@ public AudioTab()
AmbienceSoundsSlider.OnValueChanged += OnAmbienceSoundsSliderChanged;
LobbyVolumeSlider.OnValueChanged += OnLobbyVolumeSliderChanged;
InterfaceVolumeSlider.OnValueChanged += OnInterfaceVolumeSliderChanged;
AnnouncerVolumeSlider.OnValueChanged += OnAnnouncerVolumeSliderChanged; // Parkstation-RandomAnnouncers
LobbyMusicCheckBox.OnToggled += OnLobbyMusicCheckToggled;
RestartSoundsCheckBox.OnToggled += OnRestartSoundsCheckToggled;
EventMusicCheckBox.OnToggled += OnEventMusicCheckToggled;
Expand All @@ -58,6 +60,7 @@ protected override void Dispose(bool disposing)
AmbienceVolumeSlider.OnValueChanged -= OnAmbienceVolumeSliderChanged;
LobbyVolumeSlider.OnValueChanged -= OnLobbyVolumeSliderChanged;
InterfaceVolumeSlider.OnValueChanged -= OnInterfaceVolumeSliderChanged;
AnnouncerVolumeSlider.OnValueChanged -= OnAnnouncerVolumeSliderChanged; // Parkstation-RandomAnnouncers
base.Dispose(disposing);
}

Expand Down Expand Up @@ -97,6 +100,12 @@ private void OnMidiVolumeSliderChanged(Range range)
UpdateChanges();
}

// Parkstation-RandomAnnouncers
private void OnAnnouncerVolumeSliderChanged(Range range)
{
UpdateChanges();
}

private void OnLobbyMusicCheckToggled(BaseButton.ButtonEventArgs args)
{
UpdateChanges();
Expand Down Expand Up @@ -125,6 +134,7 @@ private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
_cfg.SetCVar(CCVars.AmbientMusicVolume, AmbientMusicVolumeSlider.Value / 100f * ContentAudioSystem.AmbientMusicMultiplier);
_cfg.SetCVar(CCVars.LobbyMusicVolume, LobbyVolumeSlider.Value / 100f * ContentAudioSystem.LobbyMultiplier);
_cfg.SetCVar(CCVars.InterfaceVolume, InterfaceVolumeSlider.Value / 100f * ContentAudioSystem.InterfaceMultiplier);
_cfg.SetCVar(SimpleStationCCVars.AnnouncerVolume, AnnouncerVolumeSlider.Value / 100f * ContentAudioSystem.AnnouncerMultiplier); // Parkstation-RandomAnnouncers

_cfg.SetCVar(CCVars.MaxAmbientSources, (int)AmbienceSoundsSlider.Value);

Expand All @@ -149,6 +159,7 @@ private void Reset()
AmbientMusicVolumeSlider.Value = _cfg.GetCVar(CCVars.AmbientMusicVolume) * 100f / ContentAudioSystem.AmbientMusicMultiplier;
LobbyVolumeSlider.Value = _cfg.GetCVar(CCVars.LobbyMusicVolume) * 100f / ContentAudioSystem.LobbyMultiplier;
InterfaceVolumeSlider.Value = _cfg.GetCVar(CCVars.InterfaceVolume) * 100f / ContentAudioSystem.InterfaceMultiplier;
AnnouncerVolumeSlider.Value = _cfg.GetCVar(SimpleStationCCVars.AnnouncerVolume) * 100f / ContentAudioSystem.AnnouncerMultiplier; // Parkstation-RandomAnnouncers

AmbienceSoundsSlider.Value = _cfg.GetCVar(CCVars.MaxAmbientSources);

Expand All @@ -174,14 +185,16 @@ private void UpdateChanges()
Math.Abs(LobbyVolumeSlider.Value - _cfg.GetCVar(CCVars.LobbyMusicVolume) * 100f / ContentAudioSystem.LobbyMultiplier) < 0.01f;
var isInterfaceVolumeSame =
Math.Abs(InterfaceVolumeSlider.Value - _cfg.GetCVar(CCVars.InterfaceVolume) * 100f / ContentAudioSystem.InterfaceMultiplier) < 0.01f;
var isAnnouncerVolumeSame = // Parkstation-RandomAnnouncers
Math.Abs(AnnouncerVolumeSlider.Value - _cfg.GetCVar(SimpleStationCCVars.AnnouncerVolume) * 100f / ContentAudioSystem.AnnouncerMultiplier) < 0.01f;

var isAmbientSoundsSame = (int)AmbienceSoundsSlider.Value == _cfg.GetCVar(CCVars.MaxAmbientSources);
var isLobbySame = LobbyMusicCheckBox.Pressed == _cfg.GetCVar(CCVars.LobbyMusicEnabled);
var isRestartSoundsSame = RestartSoundsCheckBox.Pressed == _cfg.GetCVar(CCVars.RestartSoundsEnabled);
var isEventSame = EventMusicCheckBox.Pressed == _cfg.GetCVar(CCVars.EventMusicEnabled);
var isAdminSoundsSame = AdminSoundsCheckBox.Pressed == _cfg.GetCVar(CCVars.AdminSoundsEnabled);
var isEverythingSame = isMasterVolumeSame && isMidiVolumeSame && isAmbientVolumeSame && isAmbientMusicVolumeSame && isAmbientSoundsSame && isLobbySame && isRestartSoundsSame && isEventSame
&& isAdminSoundsSame && isLobbyVolumeSame && isInterfaceVolumeSame;
&& isAdminSoundsSame && isLobbyVolumeSame && isInterfaceVolumeSame && isAnnouncerVolumeSame; // Parkstation-RandomAnnouncers
ApplyButton.Disabled = isEverythingSame;
ResetButton.Disabled = isEverythingSame;
MasterVolumeLabel.Text =
Expand All @@ -196,6 +209,8 @@ private void UpdateChanges()
Loc.GetString("ui-options-volume-percent", ("volume", LobbyVolumeSlider.Value / 100));
InterfaceVolumeLabel.Text =
Loc.GetString("ui-options-volume-percent", ("volume", InterfaceVolumeSlider.Value / 100));
AnnouncerVolumeLabel.Text = // Parkstation-RandomAnnouncers
Loc.GetString("ui-options-volume-percent", ("volume", AnnouncerVolumeSlider.Value / 100));
AmbienceSoundsLabel.Text = ((int)AmbienceSoundsSlider.Value).ToString();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Content.Client.Audio;
using Content.Shared.Parkstation.Announcements.Events;
using Content.Shared.Parkstation.Announcements.Systems;
using Content.Shared.Parkstation.CCVar;
using Robust.Client.Audio;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
using Robust.Shared.Audio.Sources;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;

namespace Content.Client.Parkstation.Announcements.Systems;

public sealed class AnnouncerSystem : SharedAnnouncerSystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly IResourceCache _cache = default!;
[Dependency] private readonly IAudioManager _audioManager = default!;

private IAudioSource? AnnouncerSource { get; set; }
private float AnnouncerVolume { get; set; }


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

AnnouncerVolume = _config.GetCVar(SimpleStationCCVars.AnnouncerVolume) * 100f / ContentAudioSystem.AnnouncerMultiplier;

SubscribeNetworkEvent<AnnouncementSendEvent>(OnAnnouncementReceived);
_config.OnValueChanged(SimpleStationCCVars.AnnouncerVolume, OnAnnouncerVolumeChanged);
}

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

_config.UnsubValueChanged(SimpleStationCCVars.AnnouncerVolume, OnAnnouncerVolumeChanged);
}


private void OnAnnouncerVolumeChanged(float value)
{
AnnouncerVolume = value;

if (AnnouncerSource != null)
AnnouncerSource.Gain = AnnouncerVolume;
}

private void OnAnnouncementReceived(AnnouncementSendEvent ev)
{
if (!ev.Recipients.Contains(_player.LocalSession!.UserId)
|| !_cache.TryGetResource<AudioResource>(GetAnnouncementPath(ev.AnnouncementId, ev.AnnouncerId),
out var resource))
return;

var source = _audioManager.CreateAudioSource(resource);
if (source != null)
{
source.Gain = AnnouncerVolume * SharedAudioSystem.VolumeToGain(ev.AudioParams.Volume);
source.Global = true;
}

AnnouncerSource?.Dispose();
AnnouncerSource = source;
AnnouncerSource?.StartPlaying();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Parkstation.Announcements.Prototypes;
using Robust.Shared.Prototypes;

namespace Content.IntegrationTests.Tests.Parkstation.Announcers;

[TestFixture]
[TestOf(typeof(AnnouncerPrototype))]
public sealed class AnnouncerPrototypeTests
{
[Test]
public async Task TestAnnouncerFallbacks()
{
// Checks if every announcer has a fallback announcement

await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var prototype = server.ResolveDependency<IPrototypeManager>();

await server.WaitAssertion(() =>
{
var success = true;
var why = new List<string>();

foreach (var announcer in prototype.EnumeratePrototypes<AnnouncerPrototype>())
{
if (announcer.Announcements.All(a => a.ID.ToLower() != "fallback"))
{
success = false;
why.Add(announcer.ID);
}
}

Assert.That(success, Is.True, $"The following announcers do not have a fallback announcement:\n {string.Join("\n ", why)}");
});

await pair.CleanReturnAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System.Collections.Generic;
using Content.Server.Parkstation.Announcements.Systems;
using Content.Server.StationEvents;
using Content.Shared.Parkstation.Announcements.Prototypes;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;

namespace Content.IntegrationTests.Tests.Parkstation.Announcers;

[TestFixture]
[TestOf(typeof(AnnouncerPrototype))]
public sealed class AnnouncerLocalizationTest
{
[Test]
public async Task TestEventLocalization()
{
// Checks if every station event wanting the announcerSystem to send messages has a localization string
// If an event doesn't have startAnnouncement or endAnnouncement set to true
// it will be expected for that system to handle the announcements if it wants them

await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var locale = server.ResolveDependency<ILocalizationManager>();
var entSysMan = server.ResolveDependency<IEntitySystemManager>();
var announcer = entSysMan.GetEntitySystem<AnnouncerSystem>();
var events = entSysMan.GetEntitySystem<EventManagerSystem>();

await server.WaitAssertion(() =>
{
var succeeded = true;
var why = new List<string>();

foreach (var ev in events.AllEvents())
{
if (ev.Value.StartAnnouncement)
{
var announcementId = announcer.GetAnnouncementId(ev.Key.ID);
var eventLocaleString = announcer.GetEventLocaleString(announcementId);

if (locale.GetString(eventLocaleString) == eventLocaleString)
{
succeeded = false;
why.Add($"\"{announcementId}\": \"{eventLocaleString}\"");
}
}

if (ev.Value.EndAnnouncement)
{
var announcementId = announcer.GetAnnouncementId(ev.Key.ID, true);
var eventLocaleString = announcer.GetEventLocaleString(announcementId);

if (locale.GetString(eventLocaleString) == eventLocaleString)
{
succeeded = false;
why.Add($"\"{announcementId}\": \"{eventLocaleString}\"");
}
}
}

Assert.That(succeeded, Is.True, $"The following announcements do not have a localization string:\n {string.Join("\n ", why)}");
});

await pair.CleanReturnAsync();
}
}
8 changes: 7 additions & 1 deletion Content.Server/Administration/UI/AdminAnnounceEui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
using Content.Server.Chat.Managers;
using Content.Server.Chat.Systems;
using Content.Server.EUI;
using Content.Server.Parkstation.Announcements.Systems;
using Content.Shared.Administration;
using Content.Shared.Eui;
using Robust.Shared.Player;

namespace Content.Server.Administration.UI
{
public sealed class AdminAnnounceEui : BaseEui
{
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;
private readonly ChatSystem _chatSystem;

public AdminAnnounceEui()
Expand Down Expand Up @@ -50,7 +53,10 @@ public override void HandleMessage(EuiMessageBase msg)
break;
// TODO: Per-station announcement support
case AdminAnnounceType.Station:
_chatSystem.DispatchGlobalAnnouncement(doAnnounce.Announcement, doAnnounce.Announcer, colorOverride: Color.Gold);
// Parkstation-RandomAnnouncers-Start
_announcer.SendAnnouncement(_announcer.GetAnnouncementId("Announce"), Filter.Broadcast(),
doAnnounce.Announcement, doAnnounce.Announcer, Color.Gold);
// Parkstation-RandomAnnouncers-End
break;
}

Expand Down
25 changes: 8 additions & 17 deletions Content.Server/AlertLevel/AlertLevelSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Linq;
using Content.Server.Chat.Systems;
using Content.Server.Parkstation.Announcements.Systems;
using Content.Server.Station.Systems;
using Content.Shared.CCVar;
using Content.Shared.Parkstation.Announcements.Systems;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
Expand All @@ -16,6 +18,7 @@ public sealed class AlertLevelSystem : EntitySystem
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

// Until stations are a prototype, this is how it's going to have to be.
public const string DefaultAlertLevelSet = "stationAlerts";
Expand Down Expand Up @@ -162,25 +165,13 @@ public void SetLevel(EntityUid station, string level, bool playSound, bool annou
// The full announcement to be spat out into chat.
var announcementFull = Loc.GetString("alert-level-announcement", ("name", name), ("announcement", announcement));

var playDefault = false;
// Parkstation-RandomAnnouncers-Start
var alert = _announcer.GetAnnouncementId($"Alert{level}");
if (playSound)
{
if (detail.Sound != null)
{
var filter = _stationSystem.GetInOwningStation(station);
_audio.PlayGlobal(detail.Sound.GetSound(), filter, true, detail.Sound.Params);
}
else
{
playDefault = true;
}
}

_announcer.SendAnnouncementAudio(alert, _stationSystem.GetInOwningStation(station));
if (announce)
{
_chatSystem.DispatchStationAnnouncement(station, announcementFull, playDefaultSound: playDefault,
colorOverride: detail.Color, sender: stationName);
}
_announcer.SendAnnouncementMessage(alert, announcementFull, colorOverride: detail.Color);
// Parkstation-RandomAnnouncers-End

RaiseLocalEvent(new AlertLevelChangedEvent(station, level));
}
Expand Down
Loading
Loading