summaryrefslogtreecommitdiff
path: root/editor/editor_run.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_run.cpp')
-rw-r--r--editor/editor_run.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index 8a7ec9aa82..92dae89b33 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -31,6 +31,7 @@
#include "editor_run.h"
#include "core/config/project_settings.h"
+#include "editor/editor_node.h"
#include "editor_settings.h"
#include "servers/display_server.h"
@@ -42,20 +43,17 @@ String EditorRun::get_running_scene() const {
return running_scene;
}
-Error EditorRun::run(const String &p_scene, const String &p_custom_args, const List<String> &p_breakpoints, const bool &p_skip_breakpoints) {
+Error EditorRun::run(const String &p_scene) {
List<String> args;
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
- String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host");
- int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
-
- if (resource_path != "") {
+ if (!resource_path.is_empty()) {
args.push_back("--path");
args.push_back(resource_path.replace(" ", "%20"));
}
args.push_back("--remote-debug");
- args.push_back("tcp://" + remote_host + ":" + String::num(remote_port));
+ args.push_back(EditorDebuggerNode::get_singleton()->get_server_uri());
args.push_back("--allow_focus_steal_pid");
args.push_back(itos(OS::get_singleton()->get_process_id()));
@@ -162,10 +160,13 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
} break;
}
- if (p_breakpoints.size()) {
+ List<String> breakpoints;
+ EditorNode::get_editor_data().get_editor_breakpoints(&breakpoints);
+
+ if (!breakpoints.is_empty()) {
args.push_back("--breakpoints");
String bpoints;
- for (const List<String>::Element *E = p_breakpoints.front(); E; E = E->next()) {
+ for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
bpoints += E->get().replace(" ", "%20");
if (E->next()) {
bpoints += ",";
@@ -175,33 +176,34 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
args.push_back(bpoints);
}
- if (p_skip_breakpoints) {
+ if (EditorDebuggerNode::get_singleton()->is_skip_breakpoints()) {
args.push_back("--skip-breakpoints");
}
- if (p_scene != "") {
+ if (!p_scene.is_empty()) {
args.push_back(p_scene);
}
String exec = OS::get_singleton()->get_executable_path();
- if (p_custom_args != "") {
+ const String raw_custom_args = ProjectSettings::get_singleton()->get("editor/run/main_run_args");
+ if (!raw_custom_args.is_empty()) {
// Allow the user to specify a command to run, similar to Steam's launch options.
// In this case, Godot will no longer be run directly; it's up to the underlying command
// to run it. For instance, this can be used on Linux to force a running project
// to use Optimus using `prime-run` or similar.
// Example: `prime-run %command% --time-scale 0.5`
- const int placeholder_pos = p_custom_args.find("%command%");
+ const int placeholder_pos = raw_custom_args.find("%command%");
Vector<String> custom_args;
if (placeholder_pos != -1) {
// Prepend executable-specific custom arguments.
// If nothing is placed before `%command%`, behave as if no placeholder was specified.
- Vector<String> exec_args = p_custom_args.substr(0, placeholder_pos).split(" ", false);
+ Vector<String> exec_args = raw_custom_args.substr(0, placeholder_pos).split(" ", false);
if (exec_args.size() >= 1) {
exec = exec_args[0];
- exec_args.remove(0);
+ exec_args.remove_at(0);
// Append the Godot executable name before we append executable arguments
// (since the order is reversed when using `push_front()`).
@@ -214,13 +216,13 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
}
// Append Godot-specific custom arguments.
- custom_args = p_custom_args.substr(placeholder_pos + String("%command%").size()).split(" ", false);
+ custom_args = raw_custom_args.substr(placeholder_pos + String("%command%").size()).split(" ", false);
for (int i = 0; i < custom_args.size(); i++) {
args.push_back(custom_args[i].replace(" ", "%20"));
}
} else {
// Append Godot-specific custom arguments.
- custom_args = p_custom_args.split(" ", false);
+ custom_args = raw_custom_args.split(" ", false);
for (int i = 0; i < custom_args.size(); i++) {
args.push_back(custom_args[i].replace(" ", "%20"));
}
@@ -236,13 +238,13 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
int instances = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_instances", 1);
for (int i = 0; i < instances; i++) {
OS::ProcessID pid = 0;
- Error err = OS::get_singleton()->create_process(exec, args, &pid);
+ Error err = OS::get_singleton()->create_instance(args, &pid);
ERR_FAIL_COND_V(err, err);
pids.push_back(pid);
}
status = STATUS_PLAY;
- if (p_scene != "") {
+ if (!p_scene.is_empty()) {
running_scene = p_scene;
}