Add rewind feature to the UI.

May not be perfect yet.
This commit is contained in:
Unknown W. Brackets 2013-11-02 18:33:23 -07:00
parent 79254c7a52
commit 2f010773e1
6 changed files with 21 additions and 4 deletions

View File

@ -75,6 +75,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
general->Get("EnableCheats", &bEnableCheats, false);
general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false);
general->Get("StateSlot", &iCurrentStateSlot, 0);
general->Get("RewindFlipFrequency", &iRewindFlipFrequency, 0);
general->Get("GridView1", &bGridView1, true);
general->Get("GridView2", &bGridView2, true);
general->Get("GridView3", &bGridView3, true);
@ -341,6 +342,7 @@ void Config::Save() {
general->Set("EnableCheats", bEnableCheats);
general->Set("ScreenshotsAsPNG", bScreenshotsAsPNG);
general->Set("StateSlot", iCurrentStateSlot);
general->Set("RewindFlipFrequency", iRewindFlipFrequency);
general->Set("GridView1", bGridView1);
general->Set("GridView2", bGridView2);
general->Set("GridView3", bGridView3);

View File

@ -92,6 +92,7 @@ public:
int iForceMaxEmulatedFPS;
int iMaxRecent;
int iCurrentStateSlot;
int iRewindFlipFrequency;
bool bEnableCheats;
bool bReloadCheats;
bool bDisableStencilTest;

View File

@ -125,8 +125,6 @@ namespace SaveState
// TODO: Should this be configurable?
static const int REWIND_NUM_STATES = 5;
static StateRingbuffer rewindStates(REWIND_NUM_STATES);
// TODO: g_Config setting or something instead.
static int rewindStateFreq = 0;
// TODO: Any reason for this to be configurable?
const static float rewindMaxWallFrequency = 1.0f;
static float rewindLastTime = 0.0f;
@ -318,7 +316,7 @@ namespace SaveState
static inline void CheckRewindState()
{
if (gpuStats.numFlips % rewindStateFreq != 0)
if (gpuStats.numFlips % g_Config.iRewindFlipFrequency != 0)
return;
// For fast-forwarding, otherwise they may be useless and too close.
@ -333,7 +331,7 @@ namespace SaveState
void Process()
{
if (rewindStateFreq != 0 && gpuStats.numFlips != 0)
if (g_Config.iRewindFlipFrequency != 0 && gpuStats.numFlips != 0)
CheckRewindState();
if (!needsProcess)

View File

@ -254,6 +254,7 @@ void GameSettingsScreen::CreateViews() {
systemSettings->Add(new CheckBox(&g_Config.bSeparateIOThread, s->T("I/O on thread (experimental)")))->SetEnabled(!PSP_IsInited());
#endif
systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, s->T("Change CPU Clock", "Change CPU Clock (0 = default)"), screenManager()));
systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindFlipFrequency, 0, 1800, s->T("Rewind Snapshot Frequency (0 = off)"), screenManager()));
systemSettings->Add(new CheckBox(&g_Config.bAtomicAudioLocks, s->T("Atomic Audio locks (experimental)")))->SetEnabled(!PSP_IsInited());

View File

@ -779,6 +779,12 @@ void GamePauseScreen::CreateViews() {
loadStateButton_ = leftColumnItems->Add(new Choice(i->T("Load State")));
loadStateButton_->OnClick.Handle(this, &GamePauseScreen::OnLoadState);
if (g_Config.iRewindFlipFrequency > 0) {
UI::Choice *rewindButton = leftColumnItems->Add(new Choice(i->T("Rewind")));
rewindButton->SetEnabled(SaveState::CanRewind());
rewindButton->OnClick.Handle(this, &GamePauseScreen::OnRewind);
}
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins));
root_->Add(rightColumn);
@ -833,6 +839,14 @@ UI::EventReturn GamePauseScreen::OnSaveState(UI::EventParams &e) {
screenManager()->finishDialog(this, DR_CANCEL);
return UI::EVENT_DONE;
}
UI::EventReturn GamePauseScreen::OnRewind(UI::EventParams &e) {
SaveState::Rewind(0, 0);
screenManager()->finishDialog(this, DR_CANCEL);
return UI::EVENT_DONE;
}
UI::EventReturn GamePauseScreen::OnCwCheat(UI::EventParams &e) {
screenManager()->push(new CwCheatScreen());
return UI::EVENT_DONE;

View File

@ -72,6 +72,7 @@ private:
UI::EventReturn OnSaveState(UI::EventParams &e);
UI::EventReturn OnLoadState(UI::EventParams &e);
UI::EventReturn OnRewind(UI::EventParams &e);
UI::EventReturn OnStateSelected(UI::EventParams &e);
UI::EventReturn OnCwCheat(UI::EventParams &e);