Expand debug system pages and add noclip exploration
This commit is contained in:
1 parent
b915a2c2e4
commit
d7838980fd
20 files changed
+628
-47
No files matched your search
@@ -11,6 +11,9 @@ public sealed class SceneAudio : IDisposable
|
||||
private readonly List<SdlAudio> effects = [];
|
||||
private readonly Dictionary<string, SdlAudio> loops = new(StringComparer.OrdinalIgnoreCase);
|
||||
public bool Paused { get; private set; }
|
||||
public bool MusicMuted { get; private set; }
|
||||
public bool SpeechMuted { get; private set; }
|
||||
public bool EffectsMuted { get; private set; }
|
||||
public int EffectCount => effects.Count;
|
||||
public int LoopCount => loops.Count;
|
||||
public int QueuedEffectBytes => effects.Sum(effect => effect.QueuedBytes) + loops.Values.Sum(effect => effect.QueuedBytes);
|
||||
@@ -27,13 +30,13 @@ public sealed class SceneAudio : IDisposable
|
||||
{
|
||||
StopMusic();
|
||||
if (selectedMusic is { } selection && resources.Wave(selection.Database, selection.Id) is { } wave)
|
||||
music = new(wave.Path, true, Paused);
|
||||
music = new(wave.Path, true, Paused, MusicMuted);
|
||||
}
|
||||
public void Speech(string database, int id)
|
||||
{
|
||||
StopSpeech();
|
||||
var wave = resources.Wave(database, id) ?? throw new FileNotFoundException($"Missing prepared speech: {database}:{id}");
|
||||
speech = new(wave.Path, paused: Paused);
|
||||
speech = new(wave.Path, paused: Paused, muted: SpeechMuted);
|
||||
}
|
||||
public void StopSpeech() { speech?.Dispose(); speech = null; }
|
||||
// Default current bank set by Jimmy PostLoad423642..656; positional attenuation
|
||||
@@ -42,11 +45,11 @@ public sealed class SceneAudio : IDisposable
|
||||
{
|
||||
var wave = resources.Wave("SoundEffects.omt", id)
|
||||
?? throw new FileNotFoundException($"Missing original default sound effect {id}");
|
||||
if (loopOwner == null) effects.Add(new(wave.Path, paused: Paused));
|
||||
if (loopOwner == null) effects.Add(new(wave.Path, paused: Paused, muted: EffectsMuted));
|
||||
else
|
||||
{
|
||||
StopLoop(loopOwner);
|
||||
loops.Add(loopOwner, new(wave.Path, true, Paused));
|
||||
loops.Add(loopOwner, new(wave.Path, true, Paused, EffectsMuted));
|
||||
}
|
||||
}
|
||||
public void StopLoop(string owner)
|
||||
@@ -70,10 +73,20 @@ public sealed class SceneAudio : IDisposable
|
||||
/// <summary>Modern debug pause; new streams also inherit this state.</summary>
|
||||
public void SetPaused(bool paused)
|
||||
{
|
||||
music?.SetPaused(paused); speech?.SetPaused(paused);
|
||||
foreach (var effect in effects) effect.SetPaused(paused);
|
||||
foreach (var effect in loops.Values) effect.SetPaused(paused);
|
||||
Paused = paused;
|
||||
ApplyPause();
|
||||
}
|
||||
public void SetDebugMute(bool musicMuted, bool speechMuted, bool effectsMuted)
|
||||
{
|
||||
MusicMuted = musicMuted; SpeechMuted = speechMuted; EffectsMuted = effectsMuted;
|
||||
ApplyPause();
|
||||
}
|
||||
private void ApplyPause()
|
||||
{
|
||||
music?.SetPaused(Paused); speech?.SetPaused(Paused);
|
||||
music?.SetMuted(MusicMuted); speech?.SetMuted(SpeechMuted);
|
||||
foreach (var effect in effects) { effect.SetPaused(Paused); effect.SetMuted(EffectsMuted); }
|
||||
foreach (var effect in loops.Values) { effect.SetPaused(Paused); effect.SetMuted(EffectsMuted); }
|
||||
}
|
||||
public void Dispose() { StopEffects(); StopSpeech(); StopMusic(); }
|
||||
}
|
||||
@@ -11,6 +11,7 @@ public sealed class SdlAudio : IDisposable
|
||||
private readonly bool loop;
|
||||
private bool audioInitialized;
|
||||
public bool Paused { get; private set; }
|
||||
public bool Muted { get; private set; }
|
||||
public int QueuedBytes
|
||||
{
|
||||
get
|
||||
@@ -19,7 +20,7 @@ public sealed class SdlAudio : IDisposable
|
||||
return bytes >= 0 ? bytes : throw new InvalidOperationException(Sdl.Error);
|
||||
}
|
||||
}
|
||||
public SdlAudio(string path,bool loop=false,bool paused=false)
|
||||
public SdlAudio(string path,bool loop=false,bool paused=false,bool muted=false)
|
||||
{
|
||||
this.loop=loop;
|
||||
if(!Sdl.SDL_InitSubSystem(Sdl.InitAudio))throw new InvalidOperationException(Sdl.Error);
|
||||
@@ -34,6 +35,7 @@ public sealed class SdlAudio : IDisposable
|
||||
// SDL_OpenAudioDeviceStream starts paused. Keep it paused from its
|
||||
// first sample when created while a debug menu has stopped playback.
|
||||
Paused = true;
|
||||
SetMuted(muted);
|
||||
SetPaused(paused);
|
||||
Console.WriteLine($"SDL3 WAV stream: {spec.Frequency} Hz, {spec.Channels} channel(s), {length} source bytes.");
|
||||
}
|
||||
@@ -47,6 +49,12 @@ public sealed class SdlAudio : IDisposable
|
||||
if (!changed) throw new InvalidOperationException(Sdl.Error);
|
||||
Paused = paused;
|
||||
}
|
||||
public void SetMuted(bool muted)
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(stream == 0, this);
|
||||
if (!Sdl.SDL_SetAudioStreamGain(stream, muted ? 0 : 1)) throw new InvalidOperationException(Sdl.Error);
|
||||
Muted = muted;
|
||||
}
|
||||
private void Queue(){if(!Sdl.SDL_PutAudioStreamData(stream,data,length))throw new InvalidOperationException(Sdl.Error);}
|
||||
public void Pump(){if(!Paused && loop && QueuedBytes<length)Queue();}
|
||||
public void Dispose()
|
||||
|
||||
Reference in new issue
Block a user