mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
Random Announcer Fixes (#557)
# Description In theory the test works, too tired to want to figure it out right now. --- # TODO - [x] XMLDocs instead of random comments - [x] Announcer audio test - [x] Fix the resource error - [x] Remove random extra announcement files - [x] Fix test errors - Add alert announcements to every announcer --- # Changelog 🆑 - fix: Fixed some NEIL announcements not playing audio --------- Signed-off-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Announcements.Systems;
|
||||
using Content.Server.StationEvents;
|
||||
using Content.Shared.Announcements.Prototypes;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC.Exceptions;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Serilog;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Announcers;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if every station event using the announcerSystem has a valid audio file associated with it
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
[TestOf(typeof(AnnouncerPrototype))]
|
||||
public sealed class AnnouncerAudioTest
|
||||
{
|
||||
/// <inheritdoc cref="AnnouncerAudioTest" />
|
||||
[Test]
|
||||
public async Task TestEventSounds()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true });
|
||||
var server = pair.Server;
|
||||
var client = pair.Client;
|
||||
|
||||
var entSysMan = server.ResolveDependency<IEntitySystemManager>();
|
||||
var proto = server.ResolveDependency<IPrototypeManager>();
|
||||
var cache = client.ResolveDependency<IResourceCache>();
|
||||
var announcer = entSysMan.GetEntitySystem<AnnouncerSystem>();
|
||||
var events = entSysMan.GetEntitySystem<EventManagerSystem>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var succeeded = true;
|
||||
var why = new List<string>();
|
||||
|
||||
foreach (var announcerProto in proto.EnumeratePrototypes<AnnouncerPrototype>().OrderBy(a => a.ID))
|
||||
{
|
||||
foreach (var ev in events.AllEvents())
|
||||
{
|
||||
if (ev.Value.StartAnnouncement)
|
||||
{
|
||||
var announcementId = announcer.GetAnnouncementId(ev.Key.ID);
|
||||
var path = announcer.GetAnnouncementPath(announcementId, announcerProto);
|
||||
|
||||
if (!cache.ContentFileExists(path))
|
||||
{
|
||||
succeeded = false;
|
||||
why.Add($"\"{announcerProto.ID}\", \"{announcementId}\": \"{path}\"");
|
||||
}
|
||||
}
|
||||
|
||||
if (ev.Value.EndAnnouncement)
|
||||
{
|
||||
var announcementId = announcer.GetAnnouncementId(ev.Key.ID, true);
|
||||
var path = announcer.GetAnnouncementPath(announcementId, announcerProto);
|
||||
|
||||
if (!cache.ContentFileExists(path))
|
||||
{
|
||||
succeeded = false;
|
||||
why.Add($"\"{announcerProto.ID}\", \"{announcementId}\": \"{path}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.That(succeeded, Is.True, $"The following announcements do not have a valid announcement audio:\n {string.Join("\n ", why)}");
|
||||
});
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,17 @@ using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Announcers;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if every announcer has a fallback announcement
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
[TestOf(typeof(AnnouncerPrototype))]
|
||||
public sealed class AnnouncerPrototypeTests
|
||||
public sealed class AnnouncerPrototypeTest
|
||||
{
|
||||
/// <inheritdoc cref="AnnouncerPrototypeTest"/>
|
||||
[Test]
|
||||
public async Task TestAnnouncerFallbacks()
|
||||
{
|
||||
// Checks if every announcer has a fallback announcement
|
||||
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
|
||||
@@ -24,13 +26,13 @@ public sealed class AnnouncerPrototypeTests
|
||||
var success = true;
|
||||
var why = new List<string>();
|
||||
|
||||
foreach (var announcer in prototype.EnumeratePrototypes<AnnouncerPrototype>())
|
||||
foreach (var announcer in prototype.EnumeratePrototypes<AnnouncerPrototype>().OrderBy(a => a.ID))
|
||||
{
|
||||
if (announcer.Announcements.All(a => a.ID.ToLower() != "fallback"))
|
||||
{
|
||||
success = false;
|
||||
why.Add(announcer.ID);
|
||||
}
|
||||
if (announcer.Announcements.Any(a => a.ID.ToLower() == "fallback"))
|
||||
continue;
|
||||
|
||||
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)}");
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Announcements.Systems;
|
||||
using Content.Server.StationEvents;
|
||||
using Content.Shared.Announcements.Prototypes;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Announcers;
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
[TestOf(typeof(AnnouncerPrototype))]
|
||||
public sealed class AnnouncerLocalizationTest
|
||||
{
|
||||
/// <inheritdoc cref="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 proto = server.ResolveDependency<IPrototypeManager>();
|
||||
var announcer = entSysMan.GetEntitySystem<AnnouncerSystem>();
|
||||
var events = entSysMan.GetEntitySystem<EventManagerSystem>();
|
||||
|
||||
@@ -31,29 +36,34 @@ public sealed class AnnouncerLocalizationTest
|
||||
var succeeded = true;
|
||||
var why = new List<string>();
|
||||
|
||||
foreach (var ev in events.AllEvents())
|
||||
foreach (var announcerProto in proto.EnumeratePrototypes<AnnouncerPrototype>().OrderBy(a => a.ID))
|
||||
{
|
||||
if (ev.Value.StartAnnouncement)
|
||||
foreach (var ev in events.AllEvents())
|
||||
{
|
||||
var announcementId = announcer.GetAnnouncementId(ev.Key.ID);
|
||||
var eventLocaleString = announcer.GetEventLocaleString(announcementId);
|
||||
|
||||
if (locale.GetString(eventLocaleString) == eventLocaleString)
|
||||
if (ev.Value.StartAnnouncement)
|
||||
{
|
||||
succeeded = false;
|
||||
why.Add($"\"{announcementId}\": \"{eventLocaleString}\"");
|
||||
var announcementId = announcer.GetAnnouncementId(ev.Key.ID);
|
||||
var eventLocaleString = announcer.GetAnnouncementMessage(announcementId, announcerProto.ID)
|
||||
?? announcer.GetEventLocaleString(announcementId);
|
||||
|
||||
if (locale.GetString(eventLocaleString) == eventLocaleString)
|
||||
{
|
||||
succeeded = false;
|
||||
why.Add($"\"{announcerProto.ID}\", \"{announcementId}\": \"{eventLocaleString}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ev.Value.EndAnnouncement)
|
||||
{
|
||||
var announcementId = announcer.GetAnnouncementId(ev.Key.ID, true);
|
||||
var eventLocaleString = announcer.GetEventLocaleString(announcementId);
|
||||
|
||||
if (locale.GetString(eventLocaleString) == eventLocaleString)
|
||||
if (ev.Value.EndAnnouncement)
|
||||
{
|
||||
succeeded = false;
|
||||
why.Add($"\"{announcementId}\": \"{eventLocaleString}\"");
|
||||
var announcementId = announcer.GetAnnouncementId(ev.Key.ID, true);
|
||||
var eventLocaleString = announcer.GetAnnouncementMessage(announcementId, announcerProto.ID)
|
||||
?? announcer.GetEventLocaleString(announcementId);
|
||||
|
||||
if (locale.GetString(eventLocaleString) == eventLocaleString)
|
||||
{
|
||||
succeeded = false;
|
||||
why.Add($"\"{announcerProto.ID}\", \"{announcementId}\": \"{eventLocaleString}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ public sealed partial class AnnouncerSystem
|
||||
sender ??= Loc.GetString($"announcer-{announcerOverride?.ID ?? Announcer.ID}-name");
|
||||
|
||||
// If the announcement has a message override, use that instead of the message parameter
|
||||
if (GetAnnouncementMessage(announcementId, announcerOverride?.ID ?? Announcer.ID, localeArgs) is { } announcementMessage)
|
||||
locale = announcementMessage;
|
||||
if (GetAnnouncementMessage(announcementId, announcerOverride?.ID ?? Announcer.ID) is { } announcementMessage)
|
||||
locale = Loc.GetString(announcementMessage, localeArgs);
|
||||
else
|
||||
locale = Loc.GetString(locale, localeArgs);
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public abstract class SharedAnnouncerSystem : EntitySystem
|
||||
announcer.Announcements.First(a => a.ID == "fallback");
|
||||
|
||||
// Return the announcer.BaseAudioParams if the announcementType doesn't have an override
|
||||
return announcementType.AudioParams ?? announcer.BaseAudioParams ?? null; // For some reason the formatter doesn't warn me about "?? null" being redundant, so it stays
|
||||
return announcementType.AudioParams ?? announcer.BaseAudioParams ?? null; // For some reason the formatter doesn't warn me about "?? null" being redundant, so it stays for the funnies
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -117,9 +117,7 @@ public abstract class SharedAnnouncerSystem : EntitySystem
|
||||
/// </summary>
|
||||
/// <param name="announcementId">ID of the announcement from the announcer to get information from</param>
|
||||
/// <param name="announcerId">ID of the announcer to get information from</param>
|
||||
/// <param name="localeArgs">Locale arguments to pass to the overwritten announcement</param>
|
||||
public string? GetAnnouncementMessage(string announcementId, string announcerId,
|
||||
params (string, object)[] localeArgs)
|
||||
public string? GetAnnouncementMessage(string announcementId, string announcerId)
|
||||
{
|
||||
if (!_proto.TryIndex<AnnouncerPrototype>(announcerId, out var announcer))
|
||||
return null;
|
||||
@@ -130,7 +128,7 @@ public abstract class SharedAnnouncerSystem : EntitySystem
|
||||
announcer.Announcements.First(a => a.ID == "fallback");
|
||||
|
||||
// Return the announcementType.MessageOverride if it exists, otherwise return null
|
||||
return announcementType.MessageOverride != null ? Loc.GetString(announcementType.MessageOverride, localeArgs) : null;
|
||||
return announcementType.MessageOverride != null ? announcementType.MessageOverride : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user