mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Cancel all popups when loading a new game during gameplay
This commit is contained in:
1 parent
a36d3cf18d
commit
e5d929d814
3 files changed
+46
-4
No files matched your search
@@ -75,12 +75,38 @@ void ScreenManager::switchScreen(Screen *screen) {
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenManager::cancelScreensAbove(Screen *screen) {
|
||||
bool found = false;
|
||||
for (int i = 0; i < stack_.size(); i++) {
|
||||
if (stack_[i].screen == screen) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
cancelScreensAbove_ = screen;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenManager::update() {
|
||||
std::lock_guard<std::recursive_mutex> guard(inputLock_);
|
||||
if (!nextStack_.empty()) {
|
||||
switchToNext();
|
||||
}
|
||||
|
||||
if (cancelScreensAbove_) {
|
||||
bool found = false;
|
||||
for (int i = stack_.size() - 1; i >= 0; i--) {
|
||||
if (stack_[i].screen == cancelScreensAbove_) {
|
||||
break;
|
||||
}
|
||||
Layer temp = stack_.back();
|
||||
stack_.pop_back();
|
||||
delete temp.screen;
|
||||
}
|
||||
cancelScreensAbove_ = nullptr;
|
||||
}
|
||||
|
||||
if (overlayScreen_) {
|
||||
// NOTE: This is not a full UIScreen update, to avoid double global event processing.
|
||||
overlayScreen_->update();
|
||||
|
||||
@@ -177,6 +177,8 @@ public:
|
||||
return stack_.empty() ? nullptr : stack_.back().screen;
|
||||
}
|
||||
|
||||
void cancelScreensAbove(Screen *screen);
|
||||
|
||||
void getFocusPosition(float &x, float &y, float &z);
|
||||
|
||||
// Will delete any existing overlay screen.
|
||||
@@ -201,6 +203,8 @@ private:
|
||||
Screen *backgroundScreen_ = nullptr;
|
||||
Screen *overlayScreen_ = nullptr;
|
||||
|
||||
Screen *cancelScreensAbove_ = nullptr;
|
||||
|
||||
struct Layer {
|
||||
Screen *screen;
|
||||
int flags; // From LAYER_ enum above
|
||||
|
||||
+16
-4
@@ -551,6 +551,8 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
|
||||
return;
|
||||
}
|
||||
} else if (message == UIMessage::REQUEST_GAME_BOOT) {
|
||||
INFO_LOG(Log::Loader, "EmuScreen received REQUEST_GAME_BOOT: %s", value);
|
||||
|
||||
if (bootPending_) {
|
||||
ERROR_LOG(Log::Loader, "Can't boot a new game during a pending boot");
|
||||
return;
|
||||
@@ -560,17 +562,27 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
|
||||
WARN_LOG(Log::Loader, "Game already running, ignoring");
|
||||
return;
|
||||
}
|
||||
const char *ext = strrchr(value, '.');
|
||||
if (ext != nullptr && !strcmp(ext, ".ppst")) {
|
||||
SaveState::Load(Path(value), -1, [](SaveState::Status status, std::string_view message) {
|
||||
|
||||
// TODO: Create a path first and
|
||||
Path newGamePath(value);
|
||||
|
||||
if (newGamePath.GetFileExtension() == ".ppst") {
|
||||
// TODO: Should verify that it's for the correct game....
|
||||
INFO_LOG(Log::Loader, "New game is a save state - just load it.");
|
||||
SaveState::Load(newGamePath, -1, [](SaveState::Status status, std::string_view message) {
|
||||
Core_Resume();
|
||||
System_Notify(SystemNotification::DISASSEMBLY);
|
||||
});
|
||||
} else {
|
||||
PSP_Shutdown(true);
|
||||
Achievements::UnloadGame();
|
||||
|
||||
// OK, now pop any open settings screens and stuff that are running above us.
|
||||
// Otherwise, we can get strange results with game-specific settings.
|
||||
screenManager()->cancelScreensAbove(this);
|
||||
|
||||
bootPending_ = true;
|
||||
gamePath_ = Path(value);
|
||||
gamePath_ = newGamePath;
|
||||
}
|
||||
} else if (message == UIMessage::CONFIG_LOADED) {
|
||||
// In case we need to position touch controls differently.
|
||||
|
||||
Reference in new issue
Block a user