COMMON: Move autorun detection code to OSystem::updateStartSettings()
This commit is contained in:
parent
1b5ef79bff
commit
0f52f4694d
3 changed files with 59 additions and 81 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "common/system.h"
|
||||
#include "common/events.h"
|
||||
#include "common/fs.h"
|
||||
#include "common/file.h"
|
||||
#include "common/savefile.h"
|
||||
#include "common/str.h"
|
||||
#include "common/taskbar.h"
|
||||
|
@ -120,6 +121,56 @@ void OSystem::destroy() {
|
|||
delete this;
|
||||
}
|
||||
|
||||
void OSystem::updateStartSettings(const Common::String &executable, Common::String &command, Common::StringMap &settings, Common::StringArray& additionalArgs) {
|
||||
// If a command was explicitly passed on the command line, do not override it
|
||||
if (!command.empty())
|
||||
return;
|
||||
|
||||
bool autodetect = false;
|
||||
|
||||
// Check executable name
|
||||
if (executable.equalsIgnoreCase("scummvm-auto")) {
|
||||
warning("Will run in autodetection mode");
|
||||
autodetect = true;
|
||||
}
|
||||
|
||||
// Check for the autorun file
|
||||
if (Common::File::exists("scummvm-autorun")) {
|
||||
// Okay, the file exists. We open it and if it is empty, then run in the autorun mode
|
||||
// If the file is not empty, we read command line arguments from it, one per line
|
||||
warning("Autorun file is detected");
|
||||
|
||||
Common::File autorun;
|
||||
Common::String line;
|
||||
Common::String res;
|
||||
|
||||
if (autorun.open("scummvm-autorun")) {
|
||||
while (!autorun.eos()) {
|
||||
line = autorun.readLine();
|
||||
if (!line.empty() && line[0] != '#') {
|
||||
additionalArgs.push_back(line);
|
||||
res += Common::String::format("\"%s\" ", line.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!res.empty())
|
||||
warning("Autorun command: %s", res.c_str());
|
||||
else
|
||||
warning("Empty autorun file");
|
||||
|
||||
autorun.close();
|
||||
autodetect = true;
|
||||
}
|
||||
|
||||
if (autodetect && additionalArgs.empty()) {
|
||||
warning("Running autodetection");
|
||||
command = "auto-detect";
|
||||
if (!settings.contains("path"))
|
||||
settings["path"] = ".";
|
||||
}
|
||||
}
|
||||
|
||||
bool OSystem::setGraphicsMode(const char *name) {
|
||||
if (!name)
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue