Volume control on the history viewer

This commit is contained in:
NovaSquirrel 2020-10-08 01:36:42 -04:00
parent 781a70208c
commit 40d4e21cb1
6 changed files with 18 additions and 7 deletions

View file

@ -117,13 +117,15 @@ bool HistoryViewer::SaveMovie(string movieFile, uint32_t startPosition, uint32_t
return result; return result;
} }
// Copies a given state to the main window's state
void HistoryViewer::ResumeGameplay(shared_ptr<Console> console, uint32_t resumePosition) void HistoryViewer::ResumeGameplay(shared_ptr<Console> console, uint32_t resumePosition)
{ {
console->Lock(); console->Lock();
if (_console->GetRomInfo().RomFile.GetSha1Hash() != console->GetRomInfo().RomFile.GetSha1Hash()) { if (_console->GetRomInfo().RomFile.GetSha1Hash() != console->GetRomInfo().RomFile.GetSha1Hash()) {
//Load game on the main window if they aren't the same //Load game on the main window if they aren't the same
console->LoadRom(console->GetRomInfo().RomFile, console->GetRomInfo().PatchFile); console->LoadRom(console->GetRomInfo().RomFile, console->GetRomInfo().PatchFile);
// TODO? // Mesen does console->Initialize(_console->GetRomPath(), _console->GetPatchFile());
// but that's probably equivalent
} }
if (resumePosition < _history.size()) { if (resumePosition < _history.size()) {
_history[resumePosition].LoadState(console); _history[resumePosition].LoadState(console);

View file

@ -126,6 +126,13 @@ extern "C" {
} }
} }
DllExport void __stdcall SetMasterVolume(double volume, ConsoleId consoleId) {
AudioConfig config = GetConsoleById(consoleId)->GetSettings()->GetAudioConfig();
config.MasterVolume = volume;
GetConsoleById(consoleId)->GetSettings()->SetAudioConfig(config);
}
DllExport void __stdcall SetFullscreenMode(bool fullscreen, void *windowHandle, uint32_t monitorWidth, uint32_t monitorHeight) DllExport void __stdcall SetFullscreenMode(bool fullscreen, void *windowHandle, uint32_t monitorWidth, uint32_t monitorHeight)
{ {
if(_renderer) { if(_renderer) {

View file

@ -48,7 +48,7 @@ extern "C"
#ifdef _WIN32 #ifdef _WIN32
_historyRenderer.reset(new Renderer(_historyConsole, (HWND)viewerHandle, false)); _historyRenderer.reset(new Renderer(_historyConsole, (HWND)viewerHandle, false));
// _historySoundManager.reset(new SoundManager(_historyConsole, (HWND)windowHandle)); _historySoundManager.reset(new SoundManager(_historyConsole, (HWND)windowHandle));
#else #else
_historyRenderer.reset(new SdlRenderer(_historyConsole, viewerHandle, false)); _historyRenderer.reset(new SdlRenderer(_historyConsole, viewerHandle, false));
_historySoundManager.reset(new SdlSoundManager(_historyConsole)); _historySoundManager.reset(new SdlSoundManager(_historyConsole));
@ -57,8 +57,8 @@ extern "C"
DllExport void __stdcall HistoryViewerRelease() DllExport void __stdcall HistoryViewerRelease()
{ {
_historyConsole->Stop(true); // TODO: Check on this _historyConsole->Stop(true);
_historyConsole->Release(); // had True, "For ShutDown" _historyConsole->Release(); // Mesen had True, "For ShutDown"
_historyRenderer.reset(); _historyRenderer.reset();
_historySoundManager.reset(); _historySoundManager.reset();
_historyConsole.reset(); _historyConsole.reset();

View file

@ -102,7 +102,7 @@ namespace Mesen.GUI.Forms
double verticalScale = (double)dimensions.Height / size.Height; double verticalScale = (double)dimensions.Height / size.Height;
double horizontalScale = (double)dimensions.Width / size.Width; double horizontalScale = (double)dimensions.Width / size.Width;
double scale = Math.Min(verticalScale, horizontalScale); double scale = Math.Min(verticalScale, horizontalScale);
// InteropEmu.SetVideoScale(scale, InteropEmu.ConsoleId.HistoryViewer); // InteropEmu.SetVideoScale(scale, InteropEmu.ConsoleId.HistoryViewer); TODO
} }
private void tmrUpdatePosition_Tick(object sender, EventArgs e) private void tmrUpdatePosition_Tick(object sender, EventArgs e)
@ -236,7 +236,7 @@ namespace Mesen.GUI.Forms
private void trkVolume_ValueChanged(object sender, EventArgs e) private void trkVolume_ValueChanged(object sender, EventArgs e)
{ {
// InteropEmu.SetMasterVolume(trkVolume.Value / 10d, 0, EmuApi.ConsoleId.HistoryViewer); EmuApi.SetMasterVolume(trkVolume.Value, EmuApi.ConsoleId.HistoryViewer);
} }
private void mnuScale1x_Click(object sender, EventArgs e) private void mnuScale1x_Click(object sender, EventArgs e)

View file

@ -36,6 +36,8 @@ namespace Mesen.GUI
return new Version((int)major, (int)minor, (int)revision); return new Version((int)major, (int)minor, (int)revision);
} }
[DllImport(DllPath)] public static extern void SetMasterVolume(double volume, ConsoleId consoleId);
[DllImport(DllPath)] public static extern IntPtr RegisterNotificationCallback(NotificationListener.NotificationCallback callback); [DllImport(DllPath)] public static extern IntPtr RegisterNotificationCallback(NotificationListener.NotificationCallback callback);
[DllImport(DllPath)] public static extern void UnregisterNotificationCallback(IntPtr notificationListener); [DllImport(DllPath)] public static extern void UnregisterNotificationCallback(IntPtr notificationListener);

View file

@ -26,7 +26,7 @@ namespace Mesen.GUI
public static UInt32[] HistoryViewerGetSegments() public static UInt32[] HistoryViewerGetSegments()
{ {
UInt32[] segmentBuffer = new UInt32[HistoryViewerApi.HistoryViewerGetHistoryLength() / 30]; UInt32[] segmentBuffer = new UInt32[HistoryViewerApi.HistoryViewerGetHistoryLength() / 60];
UInt32 bufferSize = (UInt32)segmentBuffer.Length; UInt32 bufferSize = (UInt32)segmentBuffer.Length;
GCHandle hSegmentBuffer = GCHandle.Alloc(segmentBuffer, GCHandleType.Pinned); GCHandle hSegmentBuffer = GCHandle.Alloc(segmentBuffer, GCHandleType.Pinned);