Uncouple savestates from NativeApp some.

Still have osm.
This commit is contained in:
Unknown W. Brackets 2016-05-27 20:41:37 -07:00
parent 2353cf6e85
commit afdd01571c
5 changed files with 24 additions and 22 deletions

View file

@ -20,7 +20,6 @@
#include "base/mutex.h"
#include "base/timeutil.h"
#include "base/NativeApp.h"
#include "i18n/i18n.h"
#include "Common/FileUtil.h"
@ -384,7 +383,6 @@ namespace SaveState
g_Config.iCurrentStateSlot = (g_Config.iCurrentStateSlot + 1) % NUM_SLOTS;
std::string msg = StringFromFormat("%s: %d", sy->T("Savestate Slot"), g_Config.iCurrentStateSlot + 1);
osm.Show(msg);
NativeMessageReceived("slotchanged", "");
}
void LoadSlot(const std::string &gameFilename, int slot, Callback callback, void *cbUserData)

View file

@ -73,6 +73,7 @@
EmuScreen::EmuScreen(const std::string &filename)
: bootPending_(true), gamePath_(filename), invalid_(true), quit_(false), pauseTrigger_(false), saveStatePreviewShownTime_(0.0), saveStatePreview_(nullptr) {
memset(axisState_, 0, sizeof(axisState_));
saveStateSlot_ = SaveState::GetCurrentSlot();
}
void EmuScreen::bootGame(const std::string &filename) {
@ -290,22 +291,6 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
} else {
gstate_c.skipDrawReason &= ~SKIPDRAW_WINDOW_MINIMIZED;
}
} else if (!strcmp(message, "slotchanged")) {
if (saveStatePreview_) {
int curSlot = SaveState::GetCurrentSlot();
std::string fn;
if (SaveState::HasSaveInSlot(gamePath_, curSlot)) {
fn = SaveState::GenerateSaveSlotFilename(gamePath_, curSlot, SaveState::SCREENSHOT_EXTENSION);
}
saveStatePreview_->SetFilename(fn);
if (!fn.empty()) {
saveStatePreview_->SetVisibility(UI::V_VISIBLE);
saveStatePreviewShownTime_ = time_now_d();
} else {
saveStatePreview_->SetVisibility(UI::V_GONE);
}
}
}
}
@ -806,8 +791,28 @@ void EmuScreen::update(InputState &input) {
screenManager()->push(new GamePauseScreen(gamePath_));
}
if (time_now_d() - saveStatePreviewShownTime_ > 2 && saveStatePreview_->GetVisibility() == UI::V_VISIBLE) {
saveStatePreview_->SetVisibility(UI::V_GONE);
if (saveStatePreview_) {
int currentSlot = SaveState::GetCurrentSlot();
if (saveStateSlot_ != currentSlot) {
saveStateSlot_ = currentSlot;
std::string fn;
if (SaveState::HasSaveInSlot(gamePath_, currentSlot)) {
fn = SaveState::GenerateSaveSlotFilename(gamePath_, currentSlot, SaveState::SCREENSHOT_EXTENSION);
}
saveStatePreview_->SetFilename(fn);
if (!fn.empty()) {
saveStatePreview_->SetVisibility(UI::V_VISIBLE);
saveStatePreviewShownTime_ = time_now_d();
} else {
saveStatePreview_->SetVisibility(UI::V_GONE);
}
}
if (time_now_d() - saveStatePreviewShownTime_ > 2 && saveStatePreview_->GetVisibility() == UI::V_VISIBLE) {
saveStatePreview_->SetVisibility(UI::V_GONE);
}
}
}

View file

@ -89,4 +89,5 @@ private:
double saveStatePreviewShownTime_;
AsyncImageFileView *saveStatePreview_;
int saveStateSlot_;
};

View file

@ -69,7 +69,6 @@ struct InputState;
void NativeUpdate(InputState &input_state) { }
void NativeRender(GraphicsContext *graphicsContext) { }
void NativeResized() { }
void NativeMessageReceived(const char *message, const char *value) {}
std::string System_GetProperty(SystemProperty prop) { return ""; }
int System_GetPropertyInt(SystemProperty prop) { return -1; }

View file

@ -50,7 +50,6 @@
std::string System_GetProperty(SystemProperty prop) { return ""; }
int System_GetPropertyInt(SystemProperty prop) { return -1; }
void NativeMessageReceived(const char *message, const char *value) {}
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923