Improve scene playing and reloading
This commit is contained in:
parent
060d0ce882
commit
8328fb56f4
2 changed files with 34 additions and 16 deletions
|
@ -2432,7 +2432,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
|
|||
|
||||
String run_filename;
|
||||
|
||||
if (p_current || (editor_data.get_edited_scene_root() && !p_custom.is_empty() && p_custom == editor_data.get_edited_scene_root()->get_scene_file_path())) {
|
||||
if ((p_current && p_custom.is_empty()) || (editor_data.get_edited_scene_root() && !p_custom.is_empty() && p_custom == editor_data.get_edited_scene_root()->get_scene_file_path())) {
|
||||
Node *scene = editor_data.get_edited_scene_root();
|
||||
|
||||
if (!scene) {
|
||||
|
@ -2494,15 +2494,19 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
|
|||
|
||||
emit_signal(SNAME("play_pressed"));
|
||||
if (p_current) {
|
||||
run_current_filename = run_filename;
|
||||
play_scene_button->set_pressed(true);
|
||||
play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
|
||||
play_scene_button->set_tooltip(TTR("Reload the played scene."));
|
||||
} else if (!p_custom.is_empty()) {
|
||||
run_custom_filename = p_custom;
|
||||
play_custom_scene_button->set_pressed(true);
|
||||
play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
|
||||
play_custom_scene_button->set_tooltip(TTR("Reload the played scene."));
|
||||
} else {
|
||||
play_button->set_pressed(true);
|
||||
play_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
|
||||
play_button->set_tooltip(TTR("Reload the played scene."));
|
||||
}
|
||||
stop_button->set_disabled(false);
|
||||
|
||||
|
@ -2527,9 +2531,22 @@ void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) {
|
|||
}
|
||||
}
|
||||
|
||||
void EditorNode::_reset_play_buttons() {
|
||||
play_button->set_pressed(false);
|
||||
play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
|
||||
play_button->set_tooltip(TTR("Play the project."));
|
||||
play_scene_button->set_pressed(false);
|
||||
play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")));
|
||||
play_scene_button->set_tooltip(TTR("Play the edited scene."));
|
||||
play_custom_scene_button->set_pressed(false);
|
||||
play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons")));
|
||||
play_custom_scene_button->set_tooltip(TTR("Play a custom scene."));
|
||||
}
|
||||
|
||||
void EditorNode::_android_build_source_selected(const String &p_file) {
|
||||
export_template_manager->install_android_template_from_file(p_file);
|
||||
}
|
||||
|
||||
void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
||||
if (!p_confirmed) { // FIXME: this may be a hack.
|
||||
current_menu_option = (MenuOptions)p_option;
|
||||
|
@ -2821,7 +2838,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||
quick_run->set_title(TTR("Quick Run Scene..."));
|
||||
play_custom_scene_button->set_pressed(false);
|
||||
} else {
|
||||
String last_custom_scene = run_custom_filename;
|
||||
String last_custom_scene = run_custom_filename; // This is necessary to have a copy of the string.
|
||||
run_play_custom(last_custom_scene);
|
||||
}
|
||||
|
||||
|
@ -2833,13 +2850,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||
|
||||
editor_run.stop();
|
||||
run_custom_filename.clear();
|
||||
play_button->set_pressed(false);
|
||||
play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
|
||||
play_scene_button->set_pressed(false);
|
||||
play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")));
|
||||
play_custom_scene_button->set_pressed(false);
|
||||
play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons")));
|
||||
run_current_filename.clear();
|
||||
stop_button->set_disabled(true);
|
||||
_reset_play_buttons();
|
||||
|
||||
if (bool(EDITOR_GET("run/output/always_close_output_on_stop"))) {
|
||||
for (int i = 0; i < bottom_panel_items.size(); i++) {
|
||||
|
@ -2862,7 +2875,12 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||
} break;
|
||||
|
||||
case RUN_PLAY_SCENE: {
|
||||
run_play_current();
|
||||
if (run_current_filename.is_empty() || editor_run.get_status() == EditorRun::STATUS_STOP) {
|
||||
run_play_current();
|
||||
} else {
|
||||
String last_current_scene = run_current_filename; // This is necessary to have a copy of the string.
|
||||
run_play_custom(last_current_scene);
|
||||
}
|
||||
|
||||
} break;
|
||||
case RUN_SETTINGS: {
|
||||
|
@ -5066,8 +5084,9 @@ void EditorNode::run_play_current() {
|
|||
}
|
||||
|
||||
void EditorNode::run_play_custom(const String &p_custom) {
|
||||
bool is_current = !run_current_filename.is_empty();
|
||||
_menu_option_confirm(RUN_STOP, true);
|
||||
_run(false, p_custom);
|
||||
_run(is_current, p_custom);
|
||||
}
|
||||
|
||||
void EditorNode::run_stop() {
|
||||
|
@ -6782,10 +6801,8 @@ EditorNode::EditorNode() {
|
|||
play_button->set_flat(true);
|
||||
play_hb->add_child(play_button);
|
||||
play_button->set_toggle_mode(true);
|
||||
play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
|
||||
play_button->set_focus_mode(Control::FOCUS_NONE);
|
||||
play_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_PLAY));
|
||||
play_button->set_tooltip(TTR("Play the project."));
|
||||
|
||||
ED_SHORTCUT_AND_COMMAND("editor/play", TTR("Play"), Key::F5);
|
||||
ED_SHORTCUT_OVERRIDE("editor/play", "macos", KeyModifierMask::CMD | Key::B);
|
||||
|
@ -6826,9 +6843,7 @@ EditorNode::EditorNode() {
|
|||
play_hb->add_child(play_scene_button);
|
||||
play_scene_button->set_toggle_mode(true);
|
||||
play_scene_button->set_focus_mode(Control::FOCUS_NONE);
|
||||
play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")));
|
||||
play_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_PLAY_SCENE));
|
||||
play_scene_button->set_tooltip(TTR("Play the edited scene."));
|
||||
|
||||
ED_SHORTCUT_AND_COMMAND("editor/play_scene", TTR("Play Scene"), Key::F6);
|
||||
ED_SHORTCUT_OVERRIDE("editor/play_scene", "macos", KeyModifierMask::CMD | Key::R);
|
||||
|
@ -6839,9 +6854,9 @@ EditorNode::EditorNode() {
|
|||
play_hb->add_child(play_custom_scene_button);
|
||||
play_custom_scene_button->set_toggle_mode(true);
|
||||
play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE);
|
||||
play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons")));
|
||||
play_custom_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_PLAY_CUSTOM_SCENE));
|
||||
play_custom_scene_button->set_tooltip(TTR("Play custom scene"));
|
||||
|
||||
_reset_play_buttons();
|
||||
|
||||
ED_SHORTCUT_AND_COMMAND("editor/play_custom_scene", TTR("Play Custom Scene"), KeyModifierMask::CMD | KeyModifierMask::SHIFT | Key::F5);
|
||||
ED_SHORTCUT_OVERRIDE("editor/play_custom_scene", "macos", KeyModifierMask::CMD | KeyModifierMask::SHIFT | Key::R);
|
||||
|
|
|
@ -470,7 +470,9 @@ private:
|
|||
String _tmp_import_path;
|
||||
String external_file;
|
||||
String open_navigate;
|
||||
|
||||
String run_custom_filename;
|
||||
String run_current_filename;
|
||||
|
||||
DynamicFontImportSettings *fontdata_import_settings = nullptr;
|
||||
SceneImportSettings *scene_import_settings = nullptr;
|
||||
|
@ -580,6 +582,7 @@ private:
|
|||
|
||||
void _run(bool p_current = false, const String &p_custom = "");
|
||||
void _run_native(const Ref<EditorExportPreset> &p_preset);
|
||||
void _reset_play_buttons();
|
||||
|
||||
void _add_to_recent_scenes(const String &p_scene);
|
||||
void _update_recent_scenes();
|
||||
|
|
Loading…
Reference in a new issue