Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick Resume Mode #15

Closed
wants to merge 10 commits into from
9 changes: 9 additions & 0 deletions es-app/src/FileData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ bool FileData::launchGame(Window* window, LaunchGameOptions options)
if (command.empty())
return false;

std::string quickResumeCommand = getlaunchCommand(false);

AudioManager::getInstance()->deinit();
VolumeControl::getInstance()->deinit();

Expand All @@ -705,6 +707,13 @@ bool FileData::launchGame(Window* window, LaunchGameOptions options)
const std::string rom = Utils::FileSystem::getEscapedPath(getPath());
const std::string basename = Utils::FileSystem::getStem(getPath());

if (!quickResumeCommand.empty() && SystemConf::getInstance()->getBool("global.quickresumemode") == true)
{
SystemConf::getInstance()->set("global.bootgame.path", getFullPath());
SystemConf::getInstance()->set("global.bootgame.cmd", quickResumeCommand);
SystemConf::getInstance()->saveSystemConf();
Copy link

@Mikhailzrick Mikhailzrick Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to use batocera.conf for storing what is essentially temp data in this way. I think it would be a better approach to store the data in files. Maybe "quickresume_path" and "quickresume_cmd"?

maybe something like:

std::string quickResumePathFile = "/userdata/system/quickresume_path";
std::string quickResumeCmdFile = "/userdata/system/quickresume_cmd";

std::ofstream pathFile(quickResumePathFile, std::ios::out | std::ios::trunc);
if (pathFile.is_open())
{
    pathFile << getFullPath();
    pathFile.close();
}

std::ofstream cmdFile(quickResumeCmdFile, std::ios::out | std::ios::trunc);
if (cmdFile.is_open())
{
    cmdFile << quickResumeCommand;
    cmdFile.close();
}

}

Scripting::fireEvent("game-start", rom, basename, getName());

time_t tstart = time(NULL);
Expand Down
6 changes: 6 additions & 0 deletions es-app/src/guis/GuiMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2743,6 +2743,12 @@ void GuiMenu::openGamesSettings()
s->addWithDescription(_("SHOW SAVESTATE MANAGER"), _("Display savestate manager before launching a game."), showSaveStates);
s->addSaveFunc([showSaveStates] { SystemConf::getInstance()->set("global.savestates", showSaveStates->getSelected()); });

// QUICK RESUME MODE
t0b10-r3tr0 marked this conversation as resolved.
Show resolved Hide resolved
auto quickResumeMode = std::make_shared<SwitchComponent>(mWindow);
quickResumeMode->setState(SystemConf::getInstance()->get("global.quickresumemode") == "1");
s->addWithDescription(_("QUICK RESUME MODE"), _("Boots directly from the last played game if shutdown during gameplay. Works with auto save/load. Reduces boot time by scanning games, laoding ES, after game exit."), quickResumeMode);
s->addSaveFunc([quickResumeMode] { SystemConf::getInstance()->set("global.quickresumemode", quickResumeMode->getState() ? "1" : ""); });

s->addGroup(_("DEFAULT GLOBAL SETTINGS"));

// Screen ratio choice
Expand Down