Qt: Fix double-clicking psexes/psfs in game list

This commit is contained in:
Connor McLaughlin 2021-03-16 01:00:47 +10:00
parent 299ba60b8d
commit a0086851ce
4 changed files with 28 additions and 25 deletions

View File

@ -412,17 +412,12 @@ void AndroidHostInterface::EmulationThreadEntryPoint(JNIEnv* env, jobject emulat
// Boot system. // Boot system.
bool boot_result = false; bool boot_result = false;
if (resume_state) if (resume_state && boot_params.filename.empty())
{
if (boot_params.filename.empty())
boot_result = ResumeSystemFromMostRecentState(); boot_result = ResumeSystemFromMostRecentState();
else else if (resume_state && CanResumeSystemFromFile(boot_params.filename.c_str()))
boot_result = ResumeSystemFromState(boot_params.filename.c_str(), true); boot_result = ResumeSystemFromState(boot_params.filename.c_str(), true);
}
else else
{
boot_result = BootSystem(boot_params); boot_result = BootSystem(boot_params);
}
if (boot_result) if (boot_result)
{ {
@ -1193,7 +1188,8 @@ DEFINE_JNI_ARGS_METHOD(jobjectArray, AndroidHostInterface_getControllerAxisNames
return name_array; return name_array;
} }
DEFINE_JNI_ARGS_METHOD(jint, AndroidHostInterface_getControllerVibrationMotorCount, jobject unused, jstring controller_type) DEFINE_JNI_ARGS_METHOD(jint, AndroidHostInterface_getControllerVibrationMotorCount, jobject unused,
jstring controller_type)
{ {
std::optional<ControllerType> type = std::optional<ControllerType> type =
Settings::ParseControllerTypeName(AndroidHelpers::JStringToString(env, controller_type).c_str()); Settings::ParseControllerTypeName(AndroidHelpers::JStringToString(env, controller_type).c_str());

View File

@ -939,21 +939,11 @@ void MainWindow::startGameOrChangeDiscs(const std::string& path)
// if we're not running, boot the system, otherwise swap discs // if we're not running, boot the system, otherwise swap discs
if (!m_emulation_running) if (!m_emulation_running)
{ {
if (m_host_interface->GetBoolSettingValue("Main", "SaveStateOnExit", true) && if (m_host_interface->CanResumeSystemFromFile(path.c_str()))
!m_host_interface->IsCheevosChallengeModeActive())
{
const GameListEntry* entry = m_host_interface->getGameList()->GetEntryForPath(path.c_str());
if ((entry && !entry->code.empty()) || !System::GetGameCodeForPath(path.c_str(), true).empty())
{
m_host_interface->resumeSystemFromState(QString::fromStdString(path), true); m_host_interface->resumeSystemFromState(QString::fromStdString(path), true);
return;
}
}
else else
{
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(path)); m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(path));
} }
}
else else
{ {
m_host_interface->changeDisc(QString::fromStdString(path)); m_host_interface->changeDisc(QString::fromStdString(path));

View File

@ -706,6 +706,20 @@ bool CommonHostInterface::SaveState(bool global, s32 slot)
return true; return true;
} }
bool CommonHostInterface::CanResumeSystemFromFile(const char* filename)
{
if (GetBoolSettingValue("Main", "SaveStateOnExit", true) && !IsCheevosChallengeModeActive())
{
const GameListEntry* entry = m_game_list->GetEntryForPath(filename);
if (entry)
return !entry->code.empty();
else
return !System::GetGameCodeForPath(filename, true).empty();
}
return false;
}
bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_on_failure) bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_on_failure)
{ {
SystemBootParameters boot_params; SystemBootParameters boot_params;

View File

@ -180,6 +180,9 @@ public:
/// Saves the current emulation state to a file. Specifying a slot of -1 saves the "resume" save state. /// Saves the current emulation state to a file. Specifying a slot of -1 saves the "resume" save state.
bool SaveState(bool global, s32 slot); bool SaveState(bool global, s32 slot);
/// Returns true if the specified file/disc image is resumable.
bool CanResumeSystemFromFile(const char* filename);
/// Loads the resume save state for the given game. Optionally boots the game anyway if loading fails. /// Loads the resume save state for the given game. Optionally boots the game anyway if loading fails.
bool ResumeSystemFromState(const char* filename, bool boot_on_failure); bool ResumeSystemFromState(const char* filename, bool boot_on_failure);