mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 01:46:42 +00:00
COMMON: Add updateStartSettings() method to OSystem
This lets backend customize the start settings. For example they can auto-start a game under some circumstances.
This commit is contained in:
parent
6d97288dce
commit
c8ce35075a
@ -424,15 +424,15 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
|
||||
bool autodetect = false;
|
||||
|
||||
// Check for the autorun name
|
||||
Common::String executable;
|
||||
if (argc && argv && argv[0]) {
|
||||
const char *s = strrchr(argv[0], '/');
|
||||
|
||||
if (!s)
|
||||
s = strrchr(argv[0], '\\');
|
||||
|
||||
const char *appName =s ? (s + 1) : argv[0];
|
||||
executable = s ? (s + 1) : argv[0];
|
||||
|
||||
if (!scumm_strnicmp(appName, "scummvm-auto", strlen("scummvm-auto"))) {
|
||||
if (executable.equalsIgnoreCase("scummvm-auto")) {
|
||||
warning("Will run in autodetection mode");
|
||||
autodetect = true;
|
||||
}
|
||||
@ -502,6 +502,35 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
|
||||
|
||||
command = Base::parseCommandLine(settings, argc, argv);
|
||||
|
||||
Common::StringArray additionalArgs;
|
||||
system.updateStartSettings(executable, command, settings, additionalArgs);
|
||||
|
||||
if (!additionalArgs.empty()) {
|
||||
// Parse those additional command line arguments.
|
||||
additionalArgs.insert_at(0, executable);
|
||||
uint argumentsSize = additionalArgs.size();
|
||||
char **arguments = (char **)malloc(argumentsSize * sizeof(char *));
|
||||
for (uint i = 0; i < argumentsSize; i++) {
|
||||
arguments[i] = (char *)malloc(additionalArgs[i].size() + 1);
|
||||
Common::strlcpy(arguments[i], additionalArgs[i].c_str(), additionalArgs[i].size() + 1);
|
||||
}
|
||||
|
||||
Common::StringMap additionalSettings;
|
||||
Common::String additionalCommand = Base::parseCommandLine(additionalSettings, argumentsSize, arguments);
|
||||
|
||||
for (uint i = 0; i < argumentsSize; i++)
|
||||
free(arguments[i]);
|
||||
free(arguments);
|
||||
|
||||
// Merge additional settings and command with command line. Command line has priority.
|
||||
if (command.empty())
|
||||
command = additionalCommand;
|
||||
for (Common::StringMap::const_iterator x = additionalSettings.begin(); x != additionalSettings.end(); ++x) {
|
||||
if (!settings.contains(x->_key))
|
||||
settings[x->_key] = x->_value;
|
||||
}
|
||||
}
|
||||
|
||||
// We allow overriding the automatic command
|
||||
if (command.empty())
|
||||
command = autoCommand;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "common/array.h" // For OSystem::getGlobalKeymaps()
|
||||
#include "common/list.h" // For OSystem::getSupportedFormats()
|
||||
#include "common/ustr.h"
|
||||
#include "common/hash-str.h" // For Common::StringMap used in OSystem::updateStartSettings()
|
||||
#include "graphics/pixelformat.h"
|
||||
#include "graphics/mode.h"
|
||||
#include "graphics/opengl/context.h"
|
||||
@ -324,6 +325,15 @@ public:
|
||||
*/
|
||||
virtual void engineDone() { }
|
||||
|
||||
/**
|
||||
* Allow the backend to customize the start settings, such as for example starting
|
||||
* automatically a game under certain circumstances.
|
||||
*
|
||||
* This function is called after the command line parameters have been parsed,
|
||||
* and thus the initial value of command and settings will reflect those.
|
||||
*/
|
||||
virtual void updateStartSettings(const Common::String &executable, Common::String &command, Common::StringMap &startSettings, Common::StringArray& additionalArgs) { }
|
||||
|
||||
/**
|
||||
* @defgroup common_system_flags Feature flags
|
||||
* @ingroup common_system
|
||||
|
Loading…
x
Reference in New Issue
Block a user