History Viewer: Prevent history viewer from being opened before some history exists (prevents crash when trying to use resume gameplay)
This commit is contained in:
parent
3c30b23958
commit
7247b0cb4b
9 changed files with 25 additions and 6 deletions
|
@ -511,9 +511,9 @@ CheatManager* Console::GetCheatManager()
|
||||||
return _cheatManager.get();
|
return _cheatManager.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
RewindManager* Console::GetRewindManager()
|
shared_ptr<RewindManager> Console::GetRewindManager()
|
||||||
{
|
{
|
||||||
return _rewindManager.get();
|
return _rewindManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryViewer* Console::GetHistoryViewer()
|
HistoryViewer* Console::GetHistoryViewer()
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
ControlManager* GetControlManager();
|
ControlManager* GetControlManager();
|
||||||
MemoryManager* GetMemoryManager();
|
MemoryManager* GetMemoryManager();
|
||||||
CheatManager* GetCheatManager();
|
CheatManager* GetCheatManager();
|
||||||
RewindManager* GetRewindManager();
|
shared_ptr<RewindManager> GetRewindManager();
|
||||||
HistoryViewer* GetHistoryViewer();
|
HistoryViewer* GetHistoryViewer();
|
||||||
|
|
||||||
bool LoadMatchingRom(string romName, HashInfo hashInfo);
|
bool LoadMatchingRom(string romName, HashInfo hashInfo);
|
||||||
|
|
|
@ -13,6 +13,7 @@ RewindManager::RewindManager(shared_ptr<Console> console)
|
||||||
_settings = console->GetSettings();
|
_settings = console->GetSettings();
|
||||||
_rewindState = RewindState::Stopped;
|
_rewindState = RewindState::Stopped;
|
||||||
_framesToFastForward = 0;
|
_framesToFastForward = 0;
|
||||||
|
_hasHistory = false;
|
||||||
AddHistoryBlock();
|
AddHistoryBlock();
|
||||||
|
|
||||||
_console->GetControlManager()->RegisterInputProvider(this);
|
_console->GetControlManager()->RegisterInputProvider(this);
|
||||||
|
@ -27,6 +28,7 @@ RewindManager::~RewindManager()
|
||||||
|
|
||||||
void RewindManager::ClearBuffer()
|
void RewindManager::ClearBuffer()
|
||||||
{
|
{
|
||||||
|
_hasHistory = false;
|
||||||
_history.clear();
|
_history.clear();
|
||||||
_historyBackup.clear();
|
_historyBackup.clear();
|
||||||
_currentHistory = RewindData();
|
_currentHistory = RewindData();
|
||||||
|
@ -42,6 +44,7 @@ void RewindManager::ClearBuffer()
|
||||||
void RewindManager::ProcessNotification(ConsoleNotificationType type, void * parameter)
|
void RewindManager::ProcessNotification(ConsoleNotificationType type, void * parameter)
|
||||||
{
|
{
|
||||||
if(type == ConsoleNotificationType::PpuFrameDone) {
|
if(type == ConsoleNotificationType::PpuFrameDone) {
|
||||||
|
_hasHistory = _history.size() >= 2;
|
||||||
if(_settings->GetRewindBufferSize() > 0) {
|
if(_settings->GetRewindBufferSize() > 0) {
|
||||||
switch(_rewindState) {
|
switch(_rewindState) {
|
||||||
case RewindState::Starting:
|
case RewindState::Starting:
|
||||||
|
@ -338,6 +341,11 @@ void RewindManager::RewindSeconds(uint32_t seconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RewindManager::HasHistory()
|
||||||
|
{
|
||||||
|
return _hasHistory;
|
||||||
|
}
|
||||||
|
|
||||||
void RewindManager::CopyHistory(shared_ptr<HistoryViewer> destHistoryViewer)
|
void RewindManager::CopyHistory(shared_ptr<HistoryViewer> destHistoryViewer)
|
||||||
{
|
{
|
||||||
destHistoryViewer->SetHistoryData(_history);
|
destHistoryViewer->SetHistoryData(_history);
|
||||||
|
|
|
@ -25,6 +25,8 @@ private:
|
||||||
|
|
||||||
shared_ptr<Console> _console;
|
shared_ptr<Console> _console;
|
||||||
EmulationSettings* _settings;
|
EmulationSettings* _settings;
|
||||||
|
|
||||||
|
bool _hasHistory;
|
||||||
|
|
||||||
std::deque<RewindData> _history;
|
std::deque<RewindData> _history;
|
||||||
std::deque<RewindData> _historyBackup;
|
std::deque<RewindData> _historyBackup;
|
||||||
|
@ -66,6 +68,7 @@ public:
|
||||||
bool IsStepBack();
|
bool IsStepBack();
|
||||||
void RewindSeconds(uint32_t seconds);
|
void RewindSeconds(uint32_t seconds);
|
||||||
|
|
||||||
|
bool HasHistory();
|
||||||
void CopyHistory(shared_ptr<HistoryViewer> destHistoryViewer);
|
void CopyHistory(shared_ptr<HistoryViewer> destHistoryViewer);
|
||||||
|
|
||||||
void SendFrame(void *frameBuffer, uint32_t width, uint32_t height, bool forRewind);
|
void SendFrame(void *frameBuffer, uint32_t width, uint32_t height, bool forRewind);
|
||||||
|
|
|
@ -204,7 +204,7 @@ void ShortcutKeyHandler::CheckMappedKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isNetplayClient && !MovieManager::Recording() && !settings->CheckFlag(NsfPlayerEnabled)) {
|
if(!isNetplayClient && !MovieManager::Recording() && !settings->CheckFlag(NsfPlayerEnabled)) {
|
||||||
RewindManager* rewindManager = _console->GetRewindManager();
|
shared_ptr<RewindManager> rewindManager = _console->GetRewindManager();
|
||||||
if(rewindManager) {
|
if(rewindManager) {
|
||||||
if(DetectKeyPress(EmulatorShortcut::ToggleRewind)) {
|
if(DetectKeyPress(EmulatorShortcut::ToggleRewind)) {
|
||||||
if(rewindManager->IsRewinding()) {
|
if(rewindManager->IsRewinding()) {
|
||||||
|
|
|
@ -125,7 +125,7 @@ void SoundMixer::PlayAudioBuffer(uint32_t time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RewindManager* rewindManager = _console->GetRewindManager();
|
shared_ptr<RewindManager> rewindManager = _console->GetRewindManager();
|
||||||
|
|
||||||
if(!_console->GetVideoRenderer()->IsRecording() && !_waveRecorder && !_settings->CheckFlag(EmulationFlags::NsfPlayerEnabled)) {
|
if(!_console->GetVideoRenderer()->IsRecording() && !_waveRecorder && !_settings->CheckFlag(EmulationFlags::NsfPlayerEnabled)) {
|
||||||
if((_settings->CheckFlag(EmulationFlags::Turbo) || (rewindManager && rewindManager->IsRewinding())) && _settings->CheckFlag(EmulationFlags::ReduceSoundInFastForward)) {
|
if((_settings->CheckFlag(EmulationFlags::Turbo) || (rewindManager && rewindManager->IsRewinding())) && _settings->CheckFlag(EmulationFlags::ReduceSoundInFastForward)) {
|
||||||
|
|
|
@ -1090,7 +1090,7 @@ namespace Mesen.GUI.Forms
|
||||||
mnuStopMovie.Enabled = running && !netPlay && (moviePlaying || movieRecording);
|
mnuStopMovie.Enabled = running && !netPlay && (moviePlaying || movieRecording);
|
||||||
mnuRecordMovie.Enabled = running && !moviePlaying && !movieRecording && !isNetPlayClient;
|
mnuRecordMovie.Enabled = running && !moviePlaying && !movieRecording && !isNetPlayClient;
|
||||||
mnuGameConfig.Enabled = !moviePlaying && !movieRecording;
|
mnuGameConfig.Enabled = !moviePlaying && !movieRecording;
|
||||||
mnuHistoryViewer.Enabled = running && !InteropEmu.IsNsf() && ConfigManager.Config.PreferenceInfo.RewindBufferSize > 0;
|
mnuHistoryViewer.Enabled = running && !InteropEmu.IsNsf() && InteropEmu.HistoryViewerEnabled();
|
||||||
|
|
||||||
bool waveRecording = InteropEmu.WaveIsRecording();
|
bool waveRecording = InteropEmu.WaveIsRecording();
|
||||||
mnuWaveRecord.Enabled = running && !waveRecording;
|
mnuWaveRecord.Enabled = running && !waveRecording;
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace Mesen.GUI
|
||||||
[DllImport(DLLPath)] public static extern void InitializeDualSystem(IntPtr windowHandle, IntPtr viewerHandle);
|
[DllImport(DLLPath)] public static extern void InitializeDualSystem(IntPtr windowHandle, IntPtr viewerHandle);
|
||||||
[DllImport(DLLPath)] public static extern void ReleaseDualSystemAudioVideo();
|
[DllImport(DLLPath)] public static extern void ReleaseDualSystemAudioVideo();
|
||||||
|
|
||||||
|
[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 HistoryViewerInitialize(IntPtr windowHandle, IntPtr viewerHandle);
|
||||||
[DllImport(DLLPath)] public static extern void HistoryViewerRelease();
|
[DllImport(DLLPath)] public static extern void HistoryViewerRelease();
|
||||||
[DllImport(DLLPath)] public static extern void HistoryViewerRun();
|
[DllImport(DLLPath)] public static extern void HistoryViewerRun();
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "../Core/VsSystemActionManager.h"
|
#include "../Core/VsSystemActionManager.h"
|
||||||
#include "../Core/KeyManager.h"
|
#include "../Core/KeyManager.h"
|
||||||
#include "../Core/GameDatabase.h"
|
#include "../Core/GameDatabase.h"
|
||||||
|
#include "../Core/RewindManager.h"
|
||||||
#include "../Utilities/SimpleLock.h"
|
#include "../Utilities/SimpleLock.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -190,6 +191,12 @@ namespace InteropEmu {
|
||||||
_console->Resume();
|
_console->Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DllExport bool __stdcall HistoryViewerEnabled()
|
||||||
|
{
|
||||||
|
shared_ptr<RewindManager> rewindManager = _console->GetRewindManager();
|
||||||
|
return rewindManager ? rewindManager->HasHistory() : false;
|
||||||
|
}
|
||||||
|
|
||||||
DllExport void __stdcall HistoryViewerInitialize(void *windowHandle, void *viewerHandle)
|
DllExport void __stdcall HistoryViewerInitialize(void *windowHandle, void *viewerHandle)
|
||||||
{
|
{
|
||||||
_historyConsole.reset(new Console(nullptr, _settings));
|
_historyConsole.reset(new Console(nullptr, _settings));
|
||||||
|
|
Loading…
Add table
Reference in a new issue