summaryrefslogtreecommitdiff
path: root/core/os
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2022-07-29 15:30:52 +0200
committerJuan Linietsky <reduzio@gmail.com>2022-08-01 00:56:59 +0200
commit0dd65378e7594e8916474613116d8df485870710 (patch)
treeba77e856d19325ab1be79c19e18c4650e70de249 /core/os
parent6d599ed90b396c264486512d5903c209ce729c76 (diff)
Add support for command-line user arguments.
Implements the standard Unix double dash (--) commandline argument: * Arguments after a double dash (--) are ignored by Godot and stored for the user. * User can access them via `OS.get_cmdline_user_args()` Example: `godot.exe scene_to_run.tscn --fullscreen -- --start-level 2`
Diffstat (limited to 'core/os')
-rw-r--r--core/os/os.cpp3
-rw-r--r--core/os/os.h4
2 files changed, 5 insertions, 2 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 619e3eb06f..1358c926d1 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -362,9 +362,10 @@ String OS::get_model_name() const {
return "GenericDevice";
}
-void OS::set_cmdline(const char *p_execpath, const List<String> &p_args) {
+void OS::set_cmdline(const char *p_execpath, const List<String> &p_args, const List<String> &p_user_args) {
_execpath = String::utf8(p_execpath);
_cmdline = p_args;
+ _user_args = p_user_args;
}
String OS::get_unique_id() const {
diff --git a/core/os/os.h b/core/os/os.h
index b9f7328929..9152b797ef 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -46,6 +46,7 @@ class OS {
static uint64_t target_ticks;
String _execpath;
List<String> _cmdline;
+ List<String> _user_args;
bool _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0.
bool low_processor_usage_mode = false;
int low_processor_usage_mode_sleep_usec = 10000;
@@ -106,7 +107,7 @@ protected:
virtual void finalize() = 0;
virtual void finalize_core() = 0;
- virtual void set_cmdline(const char *p_execpath, const List<String> &p_args);
+ virtual void set_cmdline(const char *p_execpath, const List<String> &p_args, const List<String> &p_user_args);
virtual bool _check_internal_feature_support(const String &p_feature) = 0;
@@ -162,6 +163,7 @@ public:
virtual String get_name() const = 0;
virtual List<String> get_cmdline_args() const { return _cmdline; }
+ virtual List<String> get_cmdline_user_args() const { return _user_args; }
virtual List<String> get_cmdline_platform_args() const { return List<String>(); }
virtual String get_model_name() const;