diff --git a/CHANGELOG.md b/CHANGELOG.md index a4a0def1..a96e2726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,14 @@ and a release's notes are its section. The procedure is in [`docs/RELEASING.md`] the line. The client sizes it, not the world: F7 ▸ Links & pictures ▸ **pictures in a line, tallest (rows)** sets how tall (2 by default), and 0 puts such pictures under their line as before. A picture on a line of its own, or in a box the world laid out, is drawn as it was. +- A trigger can play a sound when it matches: F2 ▸ **sound** takes the full path to a .wav, .mp3, .ogg or .flac file + on your computer, and in the window **Choose…** picks one and **Play** tries it. It plays at F7's master and sound + levels even when the line is gagged, stays on when F7's **game sound** (the world's own sounds) is off, and is + silenced by Ctrl+P ▸ Mute sound. A rule that matches again while its sound is playing starts it over. Rules with a + sound show ♪ in F2's list, and a MUSHclient import keeps a trigger's sound when the file is on this computer. +- The client comes with 100 short sounds a trigger can play by name, such as `confirmation_001` or `glass_002`: Kenney's + Interface Sounds (kenney.nl), which Kenney released into the public domain. F2 ▸ **sound** lists them as you type, the + window's sound field lists them all, and a full path to your own file still works. ## [0.3.10] - 2026-11-30 diff --git a/CLAUDE.md b/CLAUDE.md index 7cc9baed..807bda13 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -250,6 +250,17 @@ fallbacks) for inline images/maps. registered only when `PlaysMedia` is true (`TelnetSessionOptions.PlaysMsp`), because registering it is the statement that this client plays sound; otherwise the server's `WILL MSP` is refused. Its two callbacks raise `MspChanged`. + - **A trigger can play a local sound** (`TriggerActions.Sound`; Core `TriggerSound`, `WorldSession.SoundRequested`; Tui + `PlayTriggerSound` in `SharpMUTermApp.Sound.cs`; F2 `sound`, field 11, `TextRule.Sound`; the window's list editor adds + Choose… and Play, `SettingsForm.PlaySound`). A full path or `~/…` with one of `MediaCache.Extensions`, nothing fetched, + or a **built-in sound by name** (`BuiltInSounds`, Core: Kenney's Interface Sounds 1.0, 100 OGGs, CC0, embedded as + `sound/` resources, `Media/Sounds/README.md`). A name is looked up whole, ignoring case, never made a path; it is + played from memory through `IAudioOutput.Play(Stream, name, start)`, so nothing is written to disk and every package + has it. The field's `Suggest` is the names: F2's dropdown (`DeclaredFields.Item`), the window's editable combo. + It goes straight to the device, not through a `MediaQueue` (no server rules apply), at master × sound level; F7's + `game sound` does not silence it (that is the world's), ⌃P ▸ Mute does. One voice per file: a repeat restarts it. A + missing or unplayable file is said once a run in the message log. F2's editor folds `set` onto its heading row only + when a short pane still overflows after compacting, so taller frames are unchanged. - **Packages** (`Core/Packages`: `PackageManifest`, `PackageArchive`, `PackageStore`; Tui `PackageScreen`, `ListOverlay`, `SharpMUTermApp.Packages.cs`). A `.zip` with `package.json` (id, name, SemVer version, `games` as `host[:port]`, `*.host` or `*`), `sets/*.json`, `scripts/**.lua`, `media/**`; anything else is diff --git a/README.md b/README.md index 9dbeb254..921c2a73 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ cell, so a feature cannot land in one and not the other. **Sound and alerts** - MCMP and MSP sound through [SoundFlow](https://github.com/LSXPrime/SoundFlow), with captions when there is no audio device. +- Triggers can play a sound of your own or one of 100 built-in ones (Kenney's Interface Sounds). - Desktop alerts when you are paged or named while away, and a list of recent alerts. **Accessibility** @@ -209,6 +210,9 @@ The terminal client renders frames headlessly for checking layout without a term The window bundles [Inter](https://rsms.me/inter/), [JetBrains Mono](https://www.jetbrains.com/lp/mono/) and Symbols Nerd Font Mono, all under the SIL Open Font License. +The built-in trigger sounds are [Interface Sounds](https://kenney.nl/assets/interface-sounds) by +[Kenney](https://kenney.nl), CC0. + ## More - [`docs/PACKAGING.md`](docs/PACKAGING.md) and [`docs/RELEASING.md`](docs/RELEASING.md): how the packages and diff --git a/src/SharpMUTerm.Audio/DesktopAudio.cs b/src/SharpMUTerm.Audio/DesktopAudio.cs index 44a5a5d2..f25986f0 100644 --- a/src/SharpMUTerm.Audio/DesktopAudio.cs +++ b/src/SharpMUTerm.Audio/DesktopAudio.cs @@ -80,9 +80,40 @@ private static MiniAudioBackend[] Backends() => Stream? stream = null; try { - stream = Path.GetExtension(path).Equals(".ogg", StringComparison.OrdinalIgnoreCase) - ? OggToWav(path) - : File.OpenRead(path); + stream = IsOgg(path) ? OggToWav(new NVorbis.VorbisReader(path)) : File.OpenRead(path); + } + catch (Exception ex) when (Unplayable(ex)) + { + _logger?.LogInformation("Sound: could not play {File} ({Reason})", Path.GetFileName(path), ex.Message); + return null; + } + + return Start(stream, Path.GetFileName(path), start); + } + + public IAudioVoice? Play(Stream sound, string name, AudioStart start) + { + ArgumentNullException.ThrowIfNull(sound); + Stream stream; + try + { + stream = IsOgg(name) ? OggToWav(new NVorbis.VorbisReader(sound, closeOnDispose: true)) : sound; + } + catch (Exception ex) when (Unplayable(ex)) + { + sound.Dispose(); + _logger?.LogInformation("Sound: could not play {File} ({Reason})", name, ex.Message); + return null; + } + + return Start(stream, name, start); + } + + /// Plays a decodable , which the voice then owns; disposed here when it cannot start. + private Voice? Start(Stream stream, string name, AudioStart start) + { + try + { var provider = new StreamDataProvider(_engine, DeviceFormat, stream); var player = new SoundPlayer(_engine, DeviceFormat, provider); var voice = new Voice(this, player, provider, stream, start); @@ -95,16 +126,20 @@ private static MiniAudioBackend[] Backends() => voice.Begin(); return voice; } - catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidOperationException - or InvalidDataException or ArgumentException or NotSupportedException - or SoundFlow.Exceptions.BackendException) + catch (Exception ex) when (Unplayable(ex)) { - stream?.Dispose(); - _logger?.LogInformation("Sound: could not play {File} ({Reason})", Path.GetFileName(path), ex.Message); + stream.Dispose(); + _logger?.LogInformation("Sound: could not play {File} ({Reason})", name, ex.Message); return null; } } + private static bool IsOgg(string name) => Path.GetExtension(name).Equals(".ogg", StringComparison.OrdinalIgnoreCase); + + private static bool Unplayable(Exception ex) => + ex is IOException or UnauthorizedAccessException or InvalidOperationException or InvalidDataException + or ArgumentException or NotSupportedException or SoundFlow.Exceptions.BackendException; + public void Dispose() { Voice[] voices; @@ -137,9 +172,13 @@ private void Remove(Voice voice) /// An OGG Vorbis file as a 16-bit PCM WAV in memory, at the file's own rate and channels, for miniaudio to /// convert. Bounded by the cache's per-file cap on the compressed file, and by . /// - internal static MemoryStream OggToWav(string path, int maxSeconds = 20 * 60) + internal static MemoryStream OggToWav(string path, int maxSeconds = 20 * 60) => + OggToWav(new NVorbis.VorbisReader(path), maxSeconds); + + /// Decodes to a WAV in memory, then disposes it. + internal static MemoryStream OggToWav(NVorbis.VorbisReader source, int maxSeconds = 20 * 60) { - using var reader = new NVorbis.VorbisReader(path); + using var reader = source; var channels = reader.Channels; var rate = reader.SampleRate; if (channels is < 1 or > 8 || rate is < 4000 or > 192000) diff --git a/src/SharpMUTerm.Avalonia/ListEditorView.cs b/src/SharpMUTerm.Avalonia/ListEditorView.cs index 1146a833..9b7d2a66 100644 --- a/src/SharpMUTerm.Avalonia/ListEditorView.cs +++ b/src/SharpMUTerm.Avalonia/ListEditorView.cs @@ -7,6 +7,7 @@ using Avalonia.Input; using Avalonia.Layout; using Avalonia.Media; +using Avalonia.Platform.Storage; using SharpMUTerm.Client.Contributions; using SharpMUTerm.Client.Settings; using SharpMUTerm.Core.Configuration; @@ -1154,6 +1155,9 @@ void Put(string value) } } + // Whether the last edit was refused and the stored value put back, until the box is edited again: Play reads it, + // so a refused replacement does not play the sound it failed to replace (leaving the box commits before the click). + var lastRefused = false; void Commit() { if (_syncing || Current() == _form.Text(text)) @@ -1164,17 +1168,20 @@ void Commit() if (_form.SetText(text, Current()) is { } refused) { // Refused by the rule the cell screen's field applies: put the value back and say why. + lastRefused = true; Put(_form.Text(text)); ToolTip.SetTip(control, refused); ToolTip.SetIsOpen(control, true); } else { + lastRefused = false; ToolTip.SetTip(control, NativeKeys.Words(text.Help)); } } control.LostFocus += (_, _) => Commit(); + control.GotFocus += (_, _) => lastRefused = false; if (auto is not null) { // A pick from the list commits as ⏎ would; typing commits on ⏎ or leaving the box. @@ -1219,7 +1226,103 @@ void Commit() ShowPreview(control.IsKeyboardFocusWithin ? Current() : null); } }); - return control; + return text.Rule == TextRule.Sound + ? SoundRow(text, control, Put, Commit, () => + { + Commit(); + var refused = lastRefused; + lastRefused = false; + return refused; + }) + : control; + } + + /// + /// A trigger's sound: the path box, then Choose… (the window's own open dialog, which fills the box and commits it + /// exactly as typing would, so the field's rule decides) and Play (the file once, at the level a match plays it). + /// + private Grid SoundRow(TextField text, Control box, Action put, Action commit, Func commitRefused) + { + AutomationProperties.SetName(box, text.Label); + var choose = new Button { Content = "Choose…", VerticalAlignment = VerticalAlignment.Center }; + AutomationProperties.SetName(choose, $"Choose a sound file for {text.Label}"); + ToolTip.SetTip(choose, "Pick a .wav, .mp3, .ogg or .flac file"); + choose.Click += async (_, _) => + { + var (path, problem) = await PickSoundAsync(); + if (path is not null) + { + put(path); + commit(); + } + else if (problem is not null) + { + ToolTip.SetTip(box, problem); + ToolTip.SetIsOpen(box, true); + } + }; + + var play = new Button { Content = "Play", VerticalAlignment = VerticalAlignment.Center, IsVisible = _form.PlaySound is not null }; + AutomationProperties.SetName(play, $"Play the {text.Label}"); + ToolTip.SetTip(play, "Play the sound once, at your sound level"); + play.Click += (_, _) => + { + // What is typed is committed first, so Play plays the file the rule will; a path the rule refused plays nothing, + // not the sound it failed to replace. + if (!commitRefused() && _form.Text(text) is { Length: > 0 } stored) + { + _form.PlaySound?.Invoke(stored); + } + }; + + var row = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto,Auto"), ColumnSpacing = NativeTokens.Space8 }; + Grid.SetColumn(box, 0); + Grid.SetColumn(choose, 1); + Grid.SetColumn(play, 2); + row.Children.Add(box); + row.Children.Add(choose); + row.Children.Add(play); + return row; + } + + /// + /// A sound file picked with the window's own open dialog: no path and no problem when it was cancelled, and a problem + /// when there is no dialog or the file has no path on this machine. + /// + private async Task<(string? Path, string? Problem)> PickSoundAsync() + { + if (TopLevel.GetTopLevel(this)?.StorageProvider is not { CanOpen: true } storage) + { + return (null, "this window has no file picker here: type the sound's full path instead"); + } + + try + { + var files = await storage.OpenFilePickerAsync(new FilePickerOpenOptions + { + Title = "Choose a sound", + AllowMultiple = false, + FileTypeFilter = + [ + new FilePickerFileType("Sounds") + { + Patterns = [.. SharpMUTerm.Core.Media.TriggerSound.Extensions.Select(e => "*" + e)], + }, + ], + }); + if (files.Count == 0) + { + return (null, null); + } + + return files[0].TryGetLocalPath() is { } local + ? (local, null) + : (null, "that file has no path on this computer: save a copy locally and choose that"); + } + catch (InvalidOperationException) + { + return (null, "the file picker could not open: type the sound's full path instead"); + } } /// diff --git a/src/SharpMUTerm.Client/Settings/BuiltInLists.cs b/src/SharpMUTerm.Client/Settings/BuiltInLists.cs index 71bdfa3c..51020b77 100644 --- a/src/SharpMUTerm.Client/Settings/BuiltInLists.cs +++ b/src/SharpMUTerm.Client/Settings/BuiltInLists.cs @@ -1,6 +1,7 @@ using SharpMUTerm.Client.Contributions; using SharpMUTerm.Core.Automation; using SharpMUTerm.Core.Configuration; +using SharpMUTerm.Core.Media; using SharpMUTerm.Core.Text; namespace SharpMUTerm.Client.Settings; @@ -173,6 +174,14 @@ public static partial class BuiltInSettings ItemText("respond", "respond", TextRule.Template, ActionsGroup, (_, t) => t.Actions.SendResponse, (_, t, v) => t.Actions.SendResponse = v, "send this to the game; $1..$9 insert captures", NewTrigger, "send command reply"), + ItemText("sound", "sound", TextRule.Sound, ActionsGroup, + (_, t) => t.Actions.Sound, (_, t, v) => t.Actions.Sound = v, + "a sound to play: a built-in one by name (" + BuiltInSounds.Credit + "), or a full path to a .wav, .mp3, .ogg or .flac", + NewTrigger, + "audio play noise beep chime wav mp3 ogg flac file kenney") with + { + Suggest = (_, _) => BuiltInSounds.Names, + }, new TextField("script", "script", Help: "a Lua function to call") { Group = ActionsGroup, diff --git a/src/SharpMUTerm.Client/Settings/SettingsForm.cs b/src/SharpMUTerm.Client/Settings/SettingsForm.cs index 8d76fc52..8f11fab9 100644 --- a/src/SharpMUTerm.Client/Settings/SettingsForm.cs +++ b/src/SharpMUTerm.Client/Settings/SettingsForm.cs @@ -666,6 +666,11 @@ private void Commit(Action change, string? what) /// public Action? PictureCropped { get; init; } + /// + /// Plays a trigger's sound file once, as a match would (the Play beside F2's sound). Null where nothing can play. + /// + public Action? PlaySound { get; init; } + /// Undoes the last edit made on ; false when the client keeps no history. public bool Undo(string sectionId) => Step(sectionId, redo: false); diff --git a/src/SharpMUTerm.Client/Settings/TextRules.cs b/src/SharpMUTerm.Client/Settings/TextRules.cs index 6489db84..f1c4ce8c 100644 --- a/src/SharpMUTerm.Client/Settings/TextRules.cs +++ b/src/SharpMUTerm.Client/Settings/TextRules.cs @@ -55,6 +55,12 @@ public enum TextRule /// Image, + /// + /// A trigger's sound (): blank for none, else a full path to a sound file that + /// exists; trimmed, and stored as null when blank. + /// + Sound, + /// /// A world's WebSocket path (): blank for telnet, stored as null; /// else starting with /; trimmed. @@ -97,6 +103,7 @@ TextRule.Name or TextRule.Secret or TextRule.Defaulted when text.Any(char.IsCont $"{field.Label} cannot contain control characters", TextRule.Pattern when !string.IsNullOrWhiteSpace(text) => PatternError(text), TextRule.Image => Core.Avatars.AvatarSource.Problem(text), + TextRule.Sound => Core.Media.TriggerSound.Problem(text), TextRule.ScrollTail => Core.Configuration.ScrollTail.Problem(text), TextRule.WebSocketPath when !string.IsNullOrWhiteSpace(text) && !Core.Transport.WebSocketAddress.IsPath(text.Trim()) => $"{field.Label} starts with / and holds no spaces or characters past ASCII", diff --git a/src/SharpMUTerm.Core/Automation/Trigger.cs b/src/SharpMUTerm.Core/Automation/Trigger.cs index d7ea3288..16d3692d 100644 --- a/src/SharpMUTerm.Core/Automation/Trigger.cs +++ b/src/SharpMUTerm.Core/Automation/Trigger.cs @@ -91,6 +91,13 @@ public sealed class TriggerActions /// public bool Alert { get; set; } + /// + /// A sound file to play when this rule matches (: a full path on this machine), or + /// null for none. Played whether or not the line is gagged, at F7's sound level, and silenced by ⌃P ▸ Mute. Settable so + /// the F2 screen can change it live; the engine reads it per match. + /// + public string? Sound { get; set; } + /// /// A copy of these actions. Every field is a value or an immutable string, so a member-wise copy /// really is a deep one — but it has to be written out rather than shared, because @@ -108,6 +115,7 @@ public sealed class TriggerActions SpawnTarget = SpawnTarget, ScriptCallback = ScriptCallback, Alert = Alert, + Sound = Sound, }; } diff --git a/src/SharpMUTerm.Core/Import/MushclientImport.cs b/src/SharpMUTerm.Core/Import/MushclientImport.cs index 060165ec..720dc483 100644 --- a/src/SharpMUTerm.Core/Import/MushclientImport.cs +++ b/src/SharpMUTerm.Core/Import/MushclientImport.cs @@ -192,14 +192,35 @@ private static void ReadTrigger(XElement element, ImportResult result) } var gag = ImportText.Flag(element, "omit_from_output"); - if (send.Length == 0 && !gag) + + // A sound is kept only when it is a file this client can play on this computer: a MUSHclient set is usually a + // Windows path, and a sound that is not there would be a rule that silently does nothing. + var soundFile = ImportText.Attr(element, "sound")?.Trim() is { Length: > 0 } named && !named.StartsWith('(') + ? named + : null; + string? sound = null; + string? soundProblem = null; + if (soundFile is not null) + { + soundProblem = Media.TriggerSound.Problem(soundFile); + sound = soundProblem is null ? soundFile : null; + } + + if (send.Length == 0 && !gag && sound is null) { result.Skip("trigger", name, ImportText.Attr(element, "script") is { Length: > 0 } ? "it only calls a script function, which is never imported" - : "it does nothing this client can import (colours or sounds only)"); + : soundProblem is not null + ? "it only plays a sound, and that file is not one this computer can play" + : "it does nothing this client can import (colours only)"); return; } + if (soundProblem is not null) + { + result.Skip("part", name, $"its sound {Media.TriggerSound.Caption(soundFile!)} was left out: that file is not one this computer can play"); + } + if (ImportText.Attr(element, "script") is { Length: > 0 } function) { result.Skip("part", name, $"its script function {ImportText.Name(function)} was left out"); @@ -213,7 +234,7 @@ private static void ReadTrigger(XElement element, ImportResult result) Enabled = ImportText.Flag(element, "enabled", fallback: true), CaseSensitive = !ImportText.Flag(element, "ignore_case"), StopProcessing = !ImportText.Flag(element, "keep_evaluating"), - Actions = { Gag = gag, SendResponse = send.Length > 0 ? send : null }, + Actions = { Gag = gag, SendResponse = send.Length > 0 ? send : null, Sound = sound }, }); } diff --git a/src/SharpMUTerm.Core/Media/BuiltInSounds.cs b/src/SharpMUTerm.Core/Media/BuiltInSounds.cs new file mode 100644 index 00000000..fd0de9f7 --- /dev/null +++ b/src/SharpMUTerm.Core/Media/BuiltInSounds.cs @@ -0,0 +1,44 @@ +namespace SharpMUTerm.Core.Media; + +/// +/// The sounds that come with the client, which a trigger names instead of a path (confirmation_001): Kenney's +/// Interface Sounds, CC0, embedded in this assembly (Media/Sounds/README.md). They are read from memory, so every +/// host and package has them and nothing is written to disk to play one. +/// +/// A name is looked up, never turned into a path. Only a name this assembly carries is a built-in sound, matched +/// whole and ignoring case, so a trigger set from somewhere else cannot reach anything else through one. +/// +/// +public static class BuiltInSounds +{ + private const string Prefix = "sound/"; + + /// The extension every built-in sound has: what the device is told it is decoding. + public const string Extension = ".ogg"; + + /// Who made them, for a credit line. + public const string Credit = "Interface Sounds by Kenney (kenney.nl), CC0"; + + private static readonly Lazy> All = new(() => typeof(BuiltInSounds).Assembly + .GetManifestResourceNames() + .Where(n => n.StartsWith(Prefix, StringComparison.Ordinal)) + .Select(n => n[Prefix.Length..]) + .Order(StringComparer.Ordinal) + .ToArray()); + + /// Every built-in sound's name, in order. + public static IReadOnlyList Names => All.Value; + + /// The built-in sound names, as the list spells it, or null when it names none. + public static string? Find(string? source) + { + var text = source?.Trim(); + return string.IsNullOrEmpty(text) + ? null + : Names.FirstOrDefault(n => string.Equals(n, text, StringComparison.OrdinalIgnoreCase)); + } + + /// The bytes of the built-in sound names (see ), or null. + public static Stream? Open(string name) => + Find(name) is { } found ? typeof(BuiltInSounds).Assembly.GetManifestResourceStream(Prefix + found) : null; +} diff --git a/src/SharpMUTerm.Core/Media/IAudioOutput.cs b/src/SharpMUTerm.Core/Media/IAudioOutput.cs index 3f361b2d..aa94b09e 100644 --- a/src/SharpMUTerm.Core/Media/IAudioOutput.cs +++ b/src/SharpMUTerm.Core/Media/IAudioOutput.cs @@ -9,6 +9,13 @@ public interface IAudioOutput : IDisposable { /// Starts , or returns null when it cannot be played (unreadable, unsupported). IAudioVoice? Play(string path, AudioStart start); + + /// + /// Starts a sound read from (a built-in one, ), decoded by + /// 's extension, or returns null when it cannot be played. The device owns the stream from then + /// and disposes it, played or not. + /// + IAudioVoice? Play(Stream sound, string name, AudioStart start); } /// How a file starts. Volume is final, 0 to 1: the queue has already applied the player's own levels. diff --git a/src/SharpMUTerm.Core/Media/Sounds/License.txt b/src/SharpMUTerm.Core/Media/Sounds/License.txt new file mode 100644 index 00000000..19ce2a10 --- /dev/null +++ b/src/SharpMUTerm.Core/Media/Sounds/License.txt @@ -0,0 +1,22 @@ + + + Interface Sounds (1.0) + + Created/distributed by Kenney (www.kenney.nl) + Creation date: 11-02-2020 + + ------------------------------ + + License: (Creative Commons Zero, CC0) + http://creativecommons.org/publicdomain/zero/1.0/ + + This content is free to use in personal, educational and commercial projects. + Support us by crediting Kenney or www.kenney.nl (this is not mandatory) + + ------------------------------ + + Donate: http://support.kenney.nl + Patreon: http://patreon.com/kenney/ + + Follow on Twitter for updates: + http://twitter.com/KenneyNL \ No newline at end of file diff --git a/src/SharpMUTerm.Core/Media/Sounds/README.md b/src/SharpMUTerm.Core/Media/Sounds/README.md new file mode 100644 index 00000000..465ec07e --- /dev/null +++ b/src/SharpMUTerm.Core/Media/Sounds/README.md @@ -0,0 +1,16 @@ +# Built-in sounds + +The sounds a trigger can play by name (`BuiltInSounds`): Kenney's **Interface Sounds 1.0**, all 100 files, unchanged. + +| | | +|---|---| +| Author | [Kenney](https://kenney.nl) | +| Pack | [Interface Sounds](https://kenney.nl/assets/interface-sounds), created 2020-02-11 | +| Copied from | Kenney's own release on OpenGameArt, `kenney_interfaceSounds.zip` (SHA-256 `f2193d072726d6758a5f7871b2dcc54dcce0d5c35c6f0a62f92549b327c81232`) | +| Licence | CC0 1.0 (`License.txt`, Kenney's own file) | + +CC0 asks for no credit. Kenney asks for one if we want to give it, and we do: the README, the trigger editor's help and +this folder name him. Kenney's support page also asks that the Kenney logo is not used on its own; we use none. + +The files are embedded in `SharpMUTerm.Core` (1.2 MB), so every package and every host has them with nothing installed +beside the program, and they are played from memory: nothing is written to disk. diff --git a/src/SharpMUTerm.Core/Media/Sounds/back_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/back_001.ogg new file mode 100644 index 00000000..06c5e72c Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/back_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/back_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/back_002.ogg new file mode 100644 index 00000000..79ecd8ca Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/back_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/back_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/back_003.ogg new file mode 100644 index 00000000..8b17f01d Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/back_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/back_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/back_004.ogg new file mode 100644 index 00000000..a71bd6fb Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/back_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/bong_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/bong_001.ogg new file mode 100644 index 00000000..562ddb32 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/bong_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/click_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/click_001.ogg new file mode 100644 index 00000000..7ca77c71 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/click_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/click_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/click_002.ogg new file mode 100644 index 00000000..4564b888 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/click_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/click_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/click_003.ogg new file mode 100644 index 00000000..62de5e45 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/click_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/click_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/click_004.ogg new file mode 100644 index 00000000..d569cdaf Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/click_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/click_005.ogg b/src/SharpMUTerm.Core/Media/Sounds/click_005.ogg new file mode 100644 index 00000000..2f0b9aa3 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/click_005.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/close_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/close_001.ogg new file mode 100644 index 00000000..b2545e71 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/close_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/close_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/close_002.ogg new file mode 100644 index 00000000..029bb085 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/close_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/close_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/close_003.ogg new file mode 100644 index 00000000..def35d4a Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/close_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/close_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/close_004.ogg new file mode 100644 index 00000000..41683bcf Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/close_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/confirmation_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/confirmation_001.ogg new file mode 100644 index 00000000..78f119c6 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/confirmation_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/confirmation_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/confirmation_002.ogg new file mode 100644 index 00000000..4e01396f Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/confirmation_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/confirmation_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/confirmation_003.ogg new file mode 100644 index 00000000..673b0a04 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/confirmation_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/confirmation_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/confirmation_004.ogg new file mode 100644 index 00000000..1586187a Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/confirmation_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/drop_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/drop_001.ogg new file mode 100644 index 00000000..091750a7 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/drop_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/drop_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/drop_002.ogg new file mode 100644 index 00000000..c1465386 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/drop_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/drop_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/drop_003.ogg new file mode 100644 index 00000000..3213b025 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/drop_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/drop_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/drop_004.ogg new file mode 100644 index 00000000..d9cd3684 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/drop_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/error_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/error_001.ogg new file mode 100644 index 00000000..c146db9a Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/error_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/error_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/error_002.ogg new file mode 100644 index 00000000..356a7c81 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/error_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/error_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/error_003.ogg new file mode 100644 index 00000000..f7e41372 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/error_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/error_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/error_004.ogg new file mode 100644 index 00000000..cbeb4fb1 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/error_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/error_005.ogg b/src/SharpMUTerm.Core/Media/Sounds/error_005.ogg new file mode 100644 index 00000000..95562066 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/error_005.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/error_006.ogg b/src/SharpMUTerm.Core/Media/Sounds/error_006.ogg new file mode 100644 index 00000000..2d0ad6d7 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/error_006.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/error_007.ogg b/src/SharpMUTerm.Core/Media/Sounds/error_007.ogg new file mode 100644 index 00000000..ee7ea35a Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/error_007.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/error_008.ogg b/src/SharpMUTerm.Core/Media/Sounds/error_008.ogg new file mode 100644 index 00000000..8ed96e4d Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/error_008.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glass_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/glass_001.ogg new file mode 100644 index 00000000..fe0a11eb Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glass_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glass_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/glass_002.ogg new file mode 100644 index 00000000..2b0df026 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glass_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glass_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/glass_003.ogg new file mode 100644 index 00000000..ba812ed0 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glass_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glass_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/glass_004.ogg new file mode 100644 index 00000000..be13b135 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glass_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glass_005.ogg b/src/SharpMUTerm.Core/Media/Sounds/glass_005.ogg new file mode 100644 index 00000000..c5f7b9de Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glass_005.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glass_006.ogg b/src/SharpMUTerm.Core/Media/Sounds/glass_006.ogg new file mode 100644 index 00000000..3a4cfa9b Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glass_006.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glitch_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/glitch_001.ogg new file mode 100644 index 00000000..7f489a77 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glitch_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glitch_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/glitch_002.ogg new file mode 100644 index 00000000..79d824b9 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glitch_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glitch_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/glitch_003.ogg new file mode 100644 index 00000000..e54b8d0b Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glitch_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/glitch_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/glitch_004.ogg new file mode 100644 index 00000000..8e4b42d6 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/glitch_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/maximize_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/maximize_001.ogg new file mode 100644 index 00000000..c0a359bd Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/maximize_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/maximize_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/maximize_002.ogg new file mode 100644 index 00000000..9284ec2e Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/maximize_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/maximize_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/maximize_003.ogg new file mode 100644 index 00000000..3b651872 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/maximize_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/maximize_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/maximize_004.ogg new file mode 100644 index 00000000..0250b1bb Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/maximize_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/maximize_005.ogg b/src/SharpMUTerm.Core/Media/Sounds/maximize_005.ogg new file mode 100644 index 00000000..0d32c255 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/maximize_005.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/maximize_006.ogg b/src/SharpMUTerm.Core/Media/Sounds/maximize_006.ogg new file mode 100644 index 00000000..7bac35d7 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/maximize_006.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/maximize_007.ogg b/src/SharpMUTerm.Core/Media/Sounds/maximize_007.ogg new file mode 100644 index 00000000..123a76c3 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/maximize_007.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/maximize_008.ogg b/src/SharpMUTerm.Core/Media/Sounds/maximize_008.ogg new file mode 100644 index 00000000..2ad6ab82 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/maximize_008.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/maximize_009.ogg b/src/SharpMUTerm.Core/Media/Sounds/maximize_009.ogg new file mode 100644 index 00000000..ea3425b2 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/maximize_009.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/minimize_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/minimize_001.ogg new file mode 100644 index 00000000..2fe8c891 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/minimize_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/minimize_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/minimize_002.ogg new file mode 100644 index 00000000..fafffc4a Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/minimize_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/minimize_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/minimize_003.ogg new file mode 100644 index 00000000..af11951c Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/minimize_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/minimize_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/minimize_004.ogg new file mode 100644 index 00000000..76f64575 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/minimize_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/minimize_005.ogg b/src/SharpMUTerm.Core/Media/Sounds/minimize_005.ogg new file mode 100644 index 00000000..8452c3be Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/minimize_005.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/minimize_006.ogg b/src/SharpMUTerm.Core/Media/Sounds/minimize_006.ogg new file mode 100644 index 00000000..9f3cd0e9 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/minimize_006.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/minimize_007.ogg b/src/SharpMUTerm.Core/Media/Sounds/minimize_007.ogg new file mode 100644 index 00000000..d45a554f Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/minimize_007.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/minimize_008.ogg b/src/SharpMUTerm.Core/Media/Sounds/minimize_008.ogg new file mode 100644 index 00000000..fe4df6d1 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/minimize_008.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/minimize_009.ogg b/src/SharpMUTerm.Core/Media/Sounds/minimize_009.ogg new file mode 100644 index 00000000..f122bc52 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/minimize_009.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/open_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/open_001.ogg new file mode 100644 index 00000000..699b4984 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/open_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/open_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/open_002.ogg new file mode 100644 index 00000000..ecb8887e Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/open_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/open_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/open_003.ogg new file mode 100644 index 00000000..60535466 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/open_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/open_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/open_004.ogg new file mode 100644 index 00000000..06291acc Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/open_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/pluck_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/pluck_001.ogg new file mode 100644 index 00000000..106118c3 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/pluck_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/pluck_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/pluck_002.ogg new file mode 100644 index 00000000..40e135d5 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/pluck_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/question_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/question_001.ogg new file mode 100644 index 00000000..10697e40 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/question_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/question_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/question_002.ogg new file mode 100644 index 00000000..a39f6f2f Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/question_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/question_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/question_003.ogg new file mode 100644 index 00000000..bbb8b2ed Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/question_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/question_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/question_004.ogg new file mode 100644 index 00000000..12697e52 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/question_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scratch_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/scratch_001.ogg new file mode 100644 index 00000000..dd760512 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scratch_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scratch_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/scratch_002.ogg new file mode 100644 index 00000000..88a46086 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scratch_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scratch_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/scratch_003.ogg new file mode 100644 index 00000000..5815d116 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scratch_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scratch_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/scratch_004.ogg new file mode 100644 index 00000000..5324aeba Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scratch_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scratch_005.ogg b/src/SharpMUTerm.Core/Media/Sounds/scratch_005.ogg new file mode 100644 index 00000000..8e291d6f Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scratch_005.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scroll_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/scroll_001.ogg new file mode 100644 index 00000000..71c2d3eb Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scroll_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scroll_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/scroll_002.ogg new file mode 100644 index 00000000..4adac77b Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scroll_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scroll_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/scroll_003.ogg new file mode 100644 index 00000000..52ad0a8c Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scroll_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scroll_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/scroll_004.ogg new file mode 100644 index 00000000..9a31a2dd Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scroll_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/scroll_005.ogg b/src/SharpMUTerm.Core/Media/Sounds/scroll_005.ogg new file mode 100644 index 00000000..8811c75a Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/scroll_005.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/select_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/select_001.ogg new file mode 100644 index 00000000..0f81a639 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/select_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/select_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/select_002.ogg new file mode 100644 index 00000000..97334e62 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/select_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/select_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/select_003.ogg new file mode 100644 index 00000000..d4780ac7 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/select_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/select_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/select_004.ogg new file mode 100644 index 00000000..de0107df Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/select_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/select_005.ogg b/src/SharpMUTerm.Core/Media/Sounds/select_005.ogg new file mode 100644 index 00000000..ce730211 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/select_005.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/select_006.ogg b/src/SharpMUTerm.Core/Media/Sounds/select_006.ogg new file mode 100644 index 00000000..9d1f5873 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/select_006.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/select_007.ogg b/src/SharpMUTerm.Core/Media/Sounds/select_007.ogg new file mode 100644 index 00000000..7a56f33f Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/select_007.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/select_008.ogg b/src/SharpMUTerm.Core/Media/Sounds/select_008.ogg new file mode 100644 index 00000000..8e99411d Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/select_008.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/switch_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/switch_001.ogg new file mode 100644 index 00000000..8a098517 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/switch_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/switch_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/switch_002.ogg new file mode 100644 index 00000000..849bf7ab Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/switch_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/switch_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/switch_003.ogg new file mode 100644 index 00000000..f5a24e77 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/switch_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/switch_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/switch_004.ogg new file mode 100644 index 00000000..a999dcc9 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/switch_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/switch_005.ogg b/src/SharpMUTerm.Core/Media/Sounds/switch_005.ogg new file mode 100644 index 00000000..799e3277 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/switch_005.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/switch_006.ogg b/src/SharpMUTerm.Core/Media/Sounds/switch_006.ogg new file mode 100644 index 00000000..075a0f85 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/switch_006.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/switch_007.ogg b/src/SharpMUTerm.Core/Media/Sounds/switch_007.ogg new file mode 100644 index 00000000..856a60d3 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/switch_007.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/tick_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/tick_001.ogg new file mode 100644 index 00000000..e5827a01 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/tick_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/tick_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/tick_002.ogg new file mode 100644 index 00000000..de74ba96 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/tick_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/tick_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/tick_004.ogg new file mode 100644 index 00000000..4c3a492c Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/tick_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/toggle_001.ogg b/src/SharpMUTerm.Core/Media/Sounds/toggle_001.ogg new file mode 100644 index 00000000..3848ea87 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/toggle_001.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/toggle_002.ogg b/src/SharpMUTerm.Core/Media/Sounds/toggle_002.ogg new file mode 100644 index 00000000..87ba2a45 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/toggle_002.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/toggle_003.ogg b/src/SharpMUTerm.Core/Media/Sounds/toggle_003.ogg new file mode 100644 index 00000000..ace9f8e0 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/toggle_003.ogg differ diff --git a/src/SharpMUTerm.Core/Media/Sounds/toggle_004.ogg b/src/SharpMUTerm.Core/Media/Sounds/toggle_004.ogg new file mode 100644 index 00000000..c744f1b5 Binary files /dev/null and b/src/SharpMUTerm.Core/Media/Sounds/toggle_004.ogg differ diff --git a/src/SharpMUTerm.Core/Media/TriggerSound.cs b/src/SharpMUTerm.Core/Media/TriggerSound.cs new file mode 100644 index 00000000..75d18e2d --- /dev/null +++ b/src/SharpMUTerm.Core/Media/TriggerSound.cs @@ -0,0 +1,94 @@ +namespace SharpMUTerm.Core.Media; + +/// +/// The sound a trigger plays when it matches (): one of the client's own +/// sounds by name (), or a file on this machine, written as an absolute path or ~/…, +/// with one of the extensions the audio device decodes (). Nothing on the web is fetched for it: a game's own sounds are MCMP's and MSP's. +/// +/// A trigger set is shared configuration (an import, a package, a copy from a friend), so the rule is narrow: no +/// relative path, no URL, no control characters, a sound's own extension and a bounded length. A file that is missing when +/// the rule fires is said once in the message log and otherwise ignored. +/// +/// +public static class TriggerSound +{ + /// The longest path accepted, in characters. + public const int MaxLength = 1024; + + /// The extensions a sound file may have, with their dots. + public static IReadOnlyList Extensions { get; } = MediaCache.Extensions.Select(e => "." + e).ToArray(); + + /// + /// Why is refused, or null when it is accepted. Blank is accepted: it means no sound. The file + /// is checked to exist when , so a mistyped path is said while it is typed. + /// + public static string? Problem(string? source, bool mustExist = true) + { + var text = source?.Trim() ?? string.Empty; + if (text.Length == 0) + { + return null; + } + + if (text.Length > MaxLength) + { + return $"a sound's path is at most {MaxLength} characters"; + } + + if (text.Any(char.IsControl)) + { + return "a sound's path cannot contain control characters"; + } + + if (BuiltInSounds.Find(text) is not null) + { + return null; + } + + if (IsNetworkPath(text) || Resolve(text) is not { } path) + { + return "name a built-in sound, or use a full path to a sound file on this computer"; + } + + if (!Extensions.Contains(Path.GetExtension(path).ToLowerInvariant())) + { + return "the file needs to be a sound: " + string.Join(", ", Extensions); + } + + return mustExist && !File.Exists(path) ? "there is no file there" : null; + } + + /// + /// The absolute path names (~/ expanded), or null when it is not a full path. A built-in + /// sound has no path (). + /// + public static string? Resolve(string source) => + IsNetworkPath(source) ? null : Avatars.AvatarSource.ExpandPath(source); + + /// + /// A URL, or a path that names another machine (\\server\share, //server/share, \\?\UNC\…). Refused + /// before anything touches the file system: on Windows even asking whether such a file exists connects to that machine + /// and offers it the player's credentials. A device path to a local drive (\\?\C:\…) is not one. + /// + public static bool IsNetworkPath(string source) + { + var text = source.Trim().Replace('/', '\\'); + if (source.Contains("://", StringComparison.Ordinal)) + { + return true; + } + + if (!text.StartsWith(@"\\", StringComparison.Ordinal)) + { + return false; + } + + // \\?\C:\… and \\.\C:\… are local; anything else after two separators (a server, \\?\UNC\, a volume GUID) is not + // a plain file on this machine's drives. + return !(text.Length >= 6 && (text[2] is '?' or '.') && text[3] == '\\' && char.IsAsciiLetter(text[4]) && text[5] == ':'); + } + + /// The file's name without its folder or extension: what a caption or a message says. + public static string Caption(string source) => + Path.GetFileNameWithoutExtension(source.Trim().Replace('\\', '/').Split('/')[^1]); +} diff --git a/src/SharpMUTerm.Core/Session/WorldSession.cs b/src/SharpMUTerm.Core/Session/WorldSession.cs index ff0ec3ab..9aeec34a 100644 --- a/src/SharpMUTerm.Core/Session/WorldSession.cs +++ b/src/SharpMUTerm.Core/Session/WorldSession.cs @@ -1105,8 +1105,27 @@ private void ProcessOutputLineNow(StyledLine line, bool isPrompt = false) { AttentionRequested?.Invoke(this, new AttentionEventArgs(why, shown.Text)); } + + // Each matched rule's sound, once per file: two rules naming the same file are one sound. Gagged or not, like the + // alert above: the rule asked. + if (SoundRequested is { } playSound) + { + foreach (var file in result.Matched + .Select(t => t.Actions.Sound) + .Where(f => !string.IsNullOrWhiteSpace(f)) + .Distinct(StringComparer.Ordinal)) + { + playSound(this, file!); + } + } } + /// + /// Raised on the read loop with a matched trigger's . Whether and how it plays — a + /// device, the mute, the level — is the host's to decide. + /// + public event EventHandler? SoundRequested; + /// /// Raised on the read loop when a line asks for the player's attention: a trigger marked alert matched, /// or (with ) the line names the character or pages them. Whether that diff --git a/src/SharpMUTerm.Core/SharpMUTerm.Core.csproj b/src/SharpMUTerm.Core/SharpMUTerm.Core.csproj index f30ac351..572fc713 100644 --- a/src/SharpMUTerm.Core/SharpMUTerm.Core.csproj +++ b/src/SharpMUTerm.Core/SharpMUTerm.Core.csproj @@ -15,4 +15,9 @@ + + + + + diff --git a/src/SharpMUTerm.Tui/DeclaredFields.cs b/src/SharpMUTerm.Tui/DeclaredFields.cs index 9c790764..fc662fb8 100644 --- a/src/SharpMUTerm.Tui/DeclaredFields.cs +++ b/src/SharpMUTerm.Tui/DeclaredFields.cs @@ -49,7 +49,7 @@ internal static ScreenField Screen(SettingsField field, SettingTarget target) TextRule.Pattern => ScreenField.OptionalPattern(field.Label, Get, Set), TextRule.Secret => ScreenField.Password(field.Label, Get, Set), TextRule.Defaulted => ScreenField.Defaulted(field.Label, Get, Set, text.Fallback ?? string.Empty), - TextRule.Image or TextRule.WebSocketPath => + TextRule.Image or TextRule.WebSocketPath or TextRule.Sound => ScreenField.Optional(field.Label, Get, Set) with { Validate = v => TextRules.Check(text, v) }, _ => ScreenField.Optional(field.Label, Get, Set), }; @@ -114,6 +114,7 @@ internal static ScreenField Item( TextRule.Lines => ScreenField.Lines(field.Label, () => Get() ?? string.Empty, v => Set(v)), TextRule.Window => ScreenField.WindowName( field.Label, () => Get() ?? string.Empty, v => Set(v), known ?? Array.Empty()), + TextRule.Sound => Screen(field, target) with { Choices = known is { Count: > 0 } ? known : null }, _ => Screen(field, target), }; } diff --git a/src/SharpMUTerm.Tui/SharpMUTermApp.Settings.cs b/src/SharpMUTerm.Tui/SharpMUTermApp.Settings.cs index 4761b554..bb894f29 100644 --- a/src/SharpMUTerm.Tui/SharpMUTermApp.Settings.cs +++ b/src/SharpMUTerm.Tui/SharpMUTermApp.Settings.cs @@ -228,6 +228,7 @@ void Commit(Action change, string? what) Packages = PackageManager, Selections = _listSelections, PictureCropped = (source, crop) => OnUiThread(() => ChooseAvatarCrop(source, crop)), + PlaySound = CanPlaySound ? source => OnUiThread(() => PreviewTriggerSound(source)) : null, Theme = () => _theme.Clone(), BesideOutput = item is Trigger, WorldNotes = WorldNotesNow(), diff --git a/src/SharpMUTerm.Tui/SharpMUTermApp.Sound.cs b/src/SharpMUTerm.Tui/SharpMUTermApp.Sound.cs index 00ce192f..83bc9120 100644 --- a/src/SharpMUTerm.Tui/SharpMUTermApp.Sound.cs +++ b/src/SharpMUTerm.Tui/SharpMUTermApp.Sound.cs @@ -40,6 +40,7 @@ private void StartSound(WorldSession session) { session.PlaysMedia = CanPlaySound && _config.Sound.Enabled; session.MediaReceived += (_, command) => OnUiThread(() => OnMedia(session, command)); + session.SoundRequested += (_, file) => OnUiThread(() => PlayTriggerSound(session, file)); session.StateChanged += (_, e) => { if (e.State is ConnectionState.Disconnected or ConnectionState.Faulted) @@ -64,6 +65,122 @@ private void OnMedia(WorldSession session, MediaCommand command) } } + /// + /// Plays a matched trigger's sound (). It is the player's + /// own sound, not the game's, so F7's game sound switch does not silence it; the master and sound levels and ⌃P ▸ + /// Mute do. The same file asked for again while it plays starts over rather than piling up, so a burst of matching + /// lines is one sound. A file that cannot be found or played is said once a run in the message log. + /// + private void PlayTriggerSound(WorldSession session, string source) + { + if (_muted) + { + return; + } + + switch (StartTriggerSound(source)) + { + case (null, { } problem): + SoundProblem(session, source, problem); + break; + case ({ } path, null) when _config.Sound.Captions: + Caption(session, new MediaRequest(path)); + break; + } + } + + /// + /// The settings window's Play beside a trigger's sound: the same file at the same level a match would play it, said on + /// the status row when it cannot be. + /// + private void PreviewTriggerSound(string source) + { + if (_muted) + { + Notice("muted: ⌃P ▸ Unmute sound to hear it.", MessageSeverity.Info, source: SharpMUTerm.Client.Chrome.NoticeModel.Sources.Sound); + return; + } + + if (StartTriggerSound(source) is (null, { } problem)) + { + Notice($"{TriggerSound.Caption(source)} not played — {problem}.", MessageSeverity.Info, source: SharpMUTerm.Client.Chrome.NoticeModel.Sources.Sound); + } + } + + /// + /// Starts a trigger sound: what it played (a path, or a built-in sound's name), or why it did not (null and null when + /// there is no device). + /// + private (string? Path, string? Problem) StartTriggerSound(string source) + { + var builtIn = BuiltInSounds.Find(source); + string key; + if (builtIn is not null) + { + key = builtIn; + } + else if (TriggerSound.Problem(source, mustExist: false) is not null || TriggerSound.Resolve(source) is not { } path) + { + return (null, "it is not a built-in sound or a full path to a sound file"); + } + else if (!File.Exists(path)) + { + return (null, "there is no file there"); + } + else + { + key = path; + } + + if (OpenAudio() is not { } output) + { + return (key, null); + } + + if (_triggerVoices.Remove(key, out var playing)) + { + playing.Dispose(); + } + + var start = new AudioStart(TriggerSoundVolume(), 1, TimeSpan.Zero, null, TimeSpan.Zero, TimeSpan.Zero); + var voice = builtIn is null + ? output.Play(key, start) + : BuiltInSounds.Open(builtIn) is { } sound ? output.Play(sound, builtIn + BuiltInSounds.Extension, start) : null; + if (voice is null) + { + return (null, "it could not be played"); + } + + _triggerVoices[key] = voice; + voice.Ended += (_, _) => OnUiThread(() => + { + if (_triggerVoices.TryGetValue(key, out var current) && ReferenceEquals(current, voice)) + { + _triggerVoices.Remove(key); + } + }); + return (key, null); + } + + /// Says once a run that a trigger's sound could not be played, in the message log. + private void SoundProblem(WorldSession session, string source, string problem) + { + if (_soundProblems.Add(source)) + { + _messages.Record(_time.GetUtcNow(), MessageSeverity.Info, + $"trigger sound {TriggerSound.Caption(source)} not played — {problem}", SessionTitle(session)); + } + } + + /// The trigger sounds playing, by file: one voice a file, so a repeat restarts it. + private readonly Dictionary _triggerVoices = new(StringComparer.Ordinal); + + /// The trigger sounds already said not to play this run. + private readonly HashSet _soundProblems = new(StringComparer.Ordinal); + + /// Test seam: how many trigger sounds are playing. + internal int TriggerSoundsPlaying => _triggerVoices.Count; + private MediaQueue? QueueFor(WorldSession session) { if (_queues.TryGetValue(session, out var queue)) @@ -131,12 +248,31 @@ private void ApplySoundMix() queue.Stop(MediaFilter.All); } } + + foreach (var voice in _triggerVoices.Values) + { + voice.SetVolume(TriggerSoundVolume()); + } } + /// A trigger sound's level: master × sound, never the world's game-sound switch. + private float TriggerSoundVolume() => + Math.Clamp(_config.Sound.MasterVolume, 0, 100) / 100f * Math.Clamp(_config.Sound.SoundVolume, 0, 100) / 100f; + private void SetMuted(bool muted) { _muted = muted; ApplySoundMix(); + if (muted) + { + foreach (var voice in _triggerVoices.Values) + { + voice.Dispose(); + } + + _triggerVoices.Clear(); + } + Notice(muted ? "muted." : "on.", MessageSeverity.Info, source: SharpMUTerm.Client.Chrome.NoticeModel.Sources.Sound); RefreshStatusBar(); } @@ -157,6 +293,12 @@ private void DisposeSound() } _queues.Clear(); + foreach (var voice in _triggerVoices.Values) + { + voice.Dispose(); + } + + _triggerVoices.Clear(); (_audio as IDisposable)?.Dispose(); _audio = null; } diff --git a/src/SharpMUTerm.Tui/TriggersScreenRenderer.cs b/src/SharpMUTerm.Tui/TriggersScreenRenderer.cs index 760acb62..1b0e10ee 100644 --- a/src/SharpMUTerm.Tui/TriggersScreenRenderer.cs +++ b/src/SharpMUTerm.Tui/TriggersScreenRenderer.cs @@ -102,6 +102,12 @@ internal static class TriggersScreenRenderer /// internal const int MatchTypeField = 10; + /// + /// The sound file the rule plays (), appended for the reason + /// was; the editor draws it with the actions, under the script. + /// + internal const int SoundField = 11; + /// The words the match field offers, in the order gives. internal static IReadOnlyList MatchTypeNames => BuiltInSettings.MatchTypeNames; @@ -114,7 +120,7 @@ internal static class TriggersScreenRenderer /// own order is the window's grouping; this is the cell screen's. /// internal static IReadOnlyList RowFieldOrder { get; } = - ["name", "pattern", "route", "fg", "bg", "attributes", "rewrite", "respond", "script", "set", "match"]; + ["name", "pattern", "route", "fg", "bg", "attributes", "rewrite", "respond", "script", "set", "match", "sound"]; /// The editor pane's check boxes by declared id, in the order the pane draws them. internal static IReadOnlyList EditorFieldOrder { get; } = ["gag", "stop", "case", "alert"]; @@ -512,6 +518,7 @@ private static readonly (string Glyph, string Meaning)[] RuleMarks = ("R", "respond"), (Glyphs.Capture, "routed"), ("ƒ", "script"), + ("♪", "sound"), }; /// @@ -661,6 +668,11 @@ private static string Flags(TriggerActions actions) flags.Add("ƒ"); } + if (!string.IsNullOrEmpty(actions.Sound)) + { + flags.Add("♪"); + } + return flags.Count == 0 ? "—" : string.Join(" ", flags); } @@ -686,6 +698,7 @@ private static List BuildEditor( var response = cursor.EditOn(0, index, ResponseField); var script = cursor.EditOn(0, index, ScriptField); var match = cursor.EditOn(0, index, MatchTypeField); + var sound = cursor.EditOn(0, index, SoundField); // What the live test and the regex line read: the buffers while they are open, so both follow the // keystroke rather than the last commit. @@ -779,6 +792,7 @@ private static List BuildEditor( lines.Add(ActionRow("rewrite", trigger.Actions.Rewrite, rewrite)); lines.Add(ActionRow("respond", trigger.Actions.SendResponse, response)); lines.Add(ActionRow("script", trigger.Actions.ScriptCallback, script)); + lines.Add(ActionRow("sound", trigger.Actions.Sound, sound)); lines.Add(string.Empty); // The four rows below are real booleans on the trigger, and are the editor pane's navigable @@ -791,6 +805,14 @@ private static List BuildEditor( lines.Add(ScreenChrome.Cursor( Checkbox("alert me when away", trigger.Actions.Alert), cursor.IsOn(1, 3), width)); + // A pane too short for every row even without its blanks (24 rows, with the sound row) draws the set on its + // heading's row, as the match kind is: one row given back, and only where it is needed, so a taller pane is as it was. + if (height > 0 && lines.Count(l => l.Length > 0) > height && lines.IndexOf("[dim]set[/]") is var heading and >= 0) + { + lines[heading] = $"[dim]set[/] {lines[heading + 1].TrimStart()}"; + lines.RemoveAt(heading + 1); + } + // Compacted before the dropdown is laid over it, not after: the overlay replaces rows by index, // so dropping a blank underneath it afterwards would slide the list off the field it belongs to. ScreenChrome.Compact(lines, height); diff --git a/tests/SharpMUTerm.Avalonia.Tests/ListEditorTests.cs b/tests/SharpMUTerm.Avalonia.Tests/ListEditorTests.cs index 54ff4a23..e4bb1f35 100644 --- a/tests/SharpMUTerm.Avalonia.Tests/ListEditorTests.cs +++ b/tests/SharpMUTerm.Avalonia.Tests/ListEditorTests.cs @@ -8,6 +8,7 @@ using SharpMUTerm.Client.Settings; using SharpMUTerm.Core.Automation; using SharpMUTerm.Core.Configuration; +using SharpMUTerm.Core.Media; using SharpMUTerm.Core.Packages; namespace SharpMUTerm.Avalonia.Tests; @@ -45,6 +46,8 @@ public Harness() public int Commits { get; set; } + public List Played { get; } = new(); + public SettingsForm Form(string initial, object? item = null) { SettingsForm? form = null; @@ -66,7 +69,10 @@ public SettingsForm Form(string initial, object? item = null) initial, isDark: true, context: context, - item: item); + item: item) + { + PlaySound = Played.Add, + }; return form; } } @@ -192,6 +198,63 @@ public async Task TheLiveTestListsTheMatchingLinesWithTheMatchMarked() await Assert.That(marked).All().Satisfy(m => m!.StartsWith("You gain", StringComparison.Ordinal), m => m.IsTrue()); } + [Test] + public async Task PlayAfterARefusedSoundPlaysNothing_ThenPlaysTheSoundTheRuleKept() + { + var harness = new Harness(); + var file = Path.Combine(Path.GetTempPath(), $"sharpmuterm-play-{Guid.NewGuid():N}.wav"); + File.WriteAllBytes(file, [0x52, 0x49, 0x46, 0x46]); + harness.Own.Triggers[0].Actions.Sound = file; + try + { + var (afterRefusal, afterRetry, kept) = await Run(harness, "triggers", window => + { + window.ListEditor!.Choose(harness.Own.Triggers[0]); + Dispatcher.UIThread.RunJobs(); + var controls = window.GetVisualDescendants().OfType().ToArray(); + var box = controls.OfType().Single(b => global::Avalonia.Automation.AutomationProperties.GetName(b) == "sound"); + var play = controls.OfType