summaryrefslogtreecommitdiffstats
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-07-06 18:13:23 +0200
committerGitHub <noreply@github.com>2020-07-06 18:13:23 +0200
commitf8c066e97eec9c936d5e809328144d7af21acd0d (patch)
tree728fb622371fa839b7c09bee7da677d7b72297db /editor/editor_node.cpp
parenta535b9160dbbcfad1884ff4a147672a0eb366a9d (diff)
parent49f6dc5004931f17a7be008b2159cd5915cd897d (diff)
downloadredot-engine-f8c066e97eec9c936d5e809328144d7af21acd0d.tar.gz
Merge pull request #37619 from pycbouh/expose-plugin-run-scene
Expose methods to play scenes from plugin code
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index a4a53d8a92..74c516caeb 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2043,7 +2043,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
play_custom_scene_button->set_pressed(false);
play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons"));
- String main_scene;
String run_filename;
String args;
bool skip_breakpoints;
@@ -2464,8 +2463,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case RUN_PLAY: {
- _menu_option_confirm(RUN_STOP, true);
- _run(false);
+ run_play();
} break;
case RUN_PLAY_CUSTOM_SCENE: {
@@ -2476,8 +2474,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
play_custom_scene_button->set_pressed(false);
} else {
String last_custom_scene = run_custom_filename;
- _menu_option_confirm(RUN_STOP, true);
- _run(false, last_custom_scene);
+ run_play_custom(last_custom_scene);
}
} break;
@@ -2517,9 +2514,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case RUN_PLAY_SCENE: {
- _save_default_environment();
- _menu_option_confirm(RUN_STOP, true);
- _run(true);
+ run_play_current();
} break;
case RUN_SCENE_SETTINGS: {
@@ -4524,10 +4519,35 @@ void EditorNode::run_play() {
_run(false);
}
+void EditorNode::run_play_current() {
+ _save_default_environment();
+ _menu_option_confirm(RUN_STOP, true);
+ _run(true);
+}
+
+void EditorNode::run_play_custom(const String &p_custom) {
+ _menu_option_confirm(RUN_STOP, true);
+ _run(false, p_custom);
+}
+
void EditorNode::run_stop() {
_menu_option_confirm(RUN_STOP, false);
}
+bool EditorNode::is_run_playing() const {
+ EditorRun::Status status = editor_run.get_status();
+ return (status == EditorRun::STATUS_PLAY || status == EditorRun::STATUS_PAUSED);
+}
+
+String EditorNode::get_run_playing_scene() const {
+ String run_filename = editor_run.get_running_scene();
+ if (run_filename == "" && is_run_playing()) {
+ run_filename = GLOBAL_DEF("application/run/main_scene", ""); // Must be the main scene then.
+ }
+
+ return run_filename;
+}
+
int EditorNode::get_current_tab() {
return scene_tabs->get_current_tab();
}