Make History Viewer not lock up the program when closed
This commit is contained in:
parent
f6bf4d6f2a
commit
1bf62f38fc
5 changed files with 12 additions and 34 deletions
|
@ -63,7 +63,7 @@ void HistoryViewer::SeekTo(uint32_t seekPosition)
|
|||
{
|
||||
//Seek to the specified position
|
||||
if (seekPosition < _history.size()) {
|
||||
_console->Pause();
|
||||
_console->Lock();
|
||||
|
||||
bool wasPaused = _console->IsPaused();
|
||||
_console->Resume();
|
||||
|
@ -78,7 +78,7 @@ void HistoryViewer::SeekTo(uint32_t seekPosition)
|
|||
_console->Pause();
|
||||
}
|
||||
|
||||
_console->Resume();
|
||||
_console->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ bool HistoryViewer::SaveMovie(string movieFile, uint32_t startPosition, uint32_t
|
|||
//Take a savestate to be able to restore it after generating the movie file
|
||||
//(the movie generation uses the console's inputs, which could affect the emulation otherwise)
|
||||
stringstream state;
|
||||
_console->Pause();
|
||||
_console->Lock();
|
||||
_console->GetSaveStateManager()->SaveState(state);
|
||||
|
||||
//Convert the rewind data to a .mmo file
|
||||
|
@ -113,13 +113,13 @@ bool HistoryViewer::SaveMovie(string movieFile, uint32_t startPosition, uint32_t
|
|||
|
||||
//Resume the state and resume
|
||||
_console->GetSaveStateManager()->LoadState(state);
|
||||
_console->Resume();
|
||||
_console->Unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
void HistoryViewer::ResumeGameplay(shared_ptr<Console> console, uint32_t resumePosition)
|
||||
{
|
||||
console->Pause();
|
||||
console->Lock();
|
||||
if (_console->GetRomInfo().RomFile.GetSha1Hash() != console->GetRomInfo().RomFile.GetSha1Hash()) {
|
||||
//Load game on the main window if they aren't the same
|
||||
console->LoadRom(console->GetRomInfo().RomFile, console->GetRomInfo().PatchFile);
|
||||
|
@ -131,7 +131,7 @@ void HistoryViewer::ResumeGameplay(shared_ptr<Console> console, uint32_t resumeP
|
|||
else {
|
||||
_history[_history.size() - 1].LoadState(console);
|
||||
}
|
||||
console->Resume();
|
||||
console->Unlock();
|
||||
}
|
||||
|
||||
bool HistoryViewer::SetInput(BaseControlDevice* device)
|
||||
|
|
|
@ -264,9 +264,9 @@ extern "C" {
|
|||
return _logString.c_str();
|
||||
}
|
||||
|
||||
DllExport ScreenSize __stdcall GetScreenSize(bool ignoreScale)
|
||||
DllExport ScreenSize __stdcall GetScreenSize(bool ignoreScale, ConsoleId console)
|
||||
{
|
||||
return _console->GetVideoDecoder()->GetScreenSize(ignoreScale);
|
||||
return GetConsoleById(console)->GetVideoDecoder()->GetScreenSize(ignoreScale);
|
||||
}
|
||||
|
||||
DllExport void __stdcall ClearCheats() { _console->GetCheatManager()->ClearCheats(); }
|
||||
|
|
|
@ -34,8 +34,11 @@ extern "C"
|
|||
_historyConsole.reset(new Console());
|
||||
// TODO: something about initializing with settings?
|
||||
_historyConsole->Initialize();
|
||||
|
||||
_historyConsole->Lock();
|
||||
_historyConsole->LoadRom(_console->GetRomInfo().RomFile, _console->GetRomInfo().PatchFile);
|
||||
_historyConsole->CopyRewindData(_console);
|
||||
_historyConsole->Unlock();
|
||||
|
||||
//Force some settings
|
||||
// TODO
|
||||
|
@ -54,20 +57,13 @@ extern "C"
|
|||
|
||||
DllExport void __stdcall HistoryViewerRelease()
|
||||
{
|
||||
_historyConsole->Stop(false); // TODO: Check on this
|
||||
_historyConsole->Stop(true); // TODO: Check on this
|
||||
_historyConsole->Release(); // had True, "For ShutDown"
|
||||
_historyRenderer.reset();
|
||||
_historySoundManager.reset();
|
||||
_historyConsole.reset();
|
||||
}
|
||||
|
||||
DllExport void __stdcall HistoryViewerRun()
|
||||
{
|
||||
if (_historyConsole) {
|
||||
_historyConsole->Run();
|
||||
}
|
||||
}
|
||||
|
||||
DllExport uint32_t __stdcall HistoryViewerGetHistoryLength()
|
||||
{
|
||||
if (_historyConsole) {
|
||||
|
|
|
@ -51,7 +51,6 @@ namespace Mesen.GUI.Forms
|
|||
HistoryViewerApi.HistoryViewerInitialize(this.Handle, ctrlRenderer.Handle);
|
||||
trkPosition.Maximum = (int)(HistoryViewerApi.HistoryViewerGetHistoryLength() / 60);
|
||||
UpdatePositionLabel(0);
|
||||
StartEmuThread();
|
||||
EmuApi.Resume(EmuApi.ConsoleId.HistoryViewer);
|
||||
tmrUpdatePosition.Start();
|
||||
trkVolume.Value = ConfigManager.Config.HistoryViewer.Volume;
|
||||
|
@ -70,22 +69,6 @@ namespace Mesen.GUI.Forms
|
|||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
private void StartEmuThread()
|
||||
{
|
||||
if(_emuThread == null) {
|
||||
_emuThread = new Thread(() => {
|
||||
try {
|
||||
HistoryViewerApi.HistoryViewerRun();
|
||||
_emuThread = null;
|
||||
} catch(Exception ex) {
|
||||
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
|
||||
_emuThread = null;
|
||||
}
|
||||
});
|
||||
_emuThread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void TogglePause()
|
||||
{
|
||||
if(trkPosition.Value == trkPosition.Maximum) {
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace Mesen.GUI
|
|||
[DllImport(DllPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool HistoryViewerEnabled();
|
||||
[DllImport(DllPath)] public static extern void HistoryViewerInitialize(IntPtr windowHandle, IntPtr viewerHandle);
|
||||
[DllImport(DllPath)] public static extern void HistoryViewerRelease();
|
||||
[DllImport(DllPath)] public static extern void HistoryViewerRun();
|
||||
[DllImport(DllPath)] public static extern void HistoryViewerStop();
|
||||
|
||||
[DllImport(DllPath)] public static extern UInt32 HistoryViewerGetHistoryLength();
|
||||
|
|
Loading…
Add table
Reference in a new issue