Fix selecting the script editor even if it's not the 3rd in the editor_tables array.

This commit is contained in:
Relintai 2023-03-19 10:23:58 +01:00
parent a155e44491
commit 054332ae8d
7 changed files with 11 additions and 12 deletions

View File

@ -818,7 +818,7 @@ void ConnectionsDock::_go_to_script(TreeItem &item) {
#ifdef MODULE_EDITOR_CODE_EDITOR_ENABLED #ifdef MODULE_EDITOR_CODE_EDITOR_ENABLED
if (script.is_valid() && EditorScriptEditor::get_singleton()->script_goto_method(script, c.method)) { if (script.is_valid() && EditorScriptEditor::get_singleton()->script_goto_method(script, c.method)) {
editor->call("_editor_select", EditorNode::EDITOR_SCRIPT); editor->call("select_editor_by_name", "Script");
} }
#endif #endif
} }

View File

@ -1278,7 +1278,7 @@ void EditorHelp::_update_doc() {
void EditorHelp::_request_help(const String &p_string) { void EditorHelp::_request_help(const String &p_string) {
Error err = _goto_desc(p_string); Error err = _goto_desc(p_string);
if (err == OK) { if (err == OK) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->select_editor_by_name("Script");
} }
// 100 palabras // 100 palabras
} }
@ -1702,7 +1702,7 @@ EditorHelp::~EditorHelp() {
} }
void EditorHelpBit::_go_to_help(String p_what) { void EditorHelpBit::_go_to_help(String p_what) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->select_editor_by_name("Script");
#ifdef MODULE_EDITOR_CODE_EDITOR_ENABLED #ifdef MODULE_EDITOR_CODE_EDITOR_ENABLED
EditorScriptEditor::get_singleton()->goto_help(p_what); EditorScriptEditor::get_singleton()->goto_help(p_what);
#endif #endif

View File

@ -112,7 +112,7 @@ void EditorHelpSearch::_confirmed() {
} }
// Activate the script editor and emit the signal with the documentation link to display. // Activate the script editor and emit the signal with the documentation link to display.
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->select_editor_by_name("Script");
emit_signal("go_to_help", item->get_metadata(0)); emit_signal("go_to_help", item->get_metadata(0));

View File

@ -416,7 +416,7 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) {
} else if (ED_IS_SHORTCUT("editor/editor_3d", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_3d", p_event)) {
_editor_select(EDITOR_3D); _editor_select(EDITOR_3D);
} else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) {
_editor_select(EDITOR_SCRIPT); select_editor_by_name("Script");
} else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) {
emit_signal("request_help_search", ""); emit_signal("request_help_search", "");
} else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) {
@ -3141,7 +3141,7 @@ void EditorNode::_editor_select(int p_which) {
} }
if (EditorSettings::get_singleton()->get("interface/editor/separate_distraction_mode")) { if (EditorSettings::get_singleton()->get("interface/editor/separate_distraction_mode")) {
if (p_which == EDITOR_SCRIPT) { if (editor_table[p_which]->get_name() == "Script") {
set_distraction_free_mode(script_distraction); set_distraction_free_mode(script_distraction);
} else { } else {
set_distraction_free_mode(scene_distraction); set_distraction_free_mode(scene_distraction);
@ -3209,7 +3209,7 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan
for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
if (p_editor->get_name() == singleton->main_editor_buttons[i]->get_text()) { if (p_editor->get_name() == singleton->main_editor_buttons[i]->get_text()) {
if (singleton->main_editor_buttons[i]->is_pressed()) { if (singleton->main_editor_buttons[i]->is_pressed()) {
singleton->_editor_select(EDITOR_SCRIPT); singleton->select_editor_by_name("Script");
} }
memdelete(singleton->main_editor_buttons[i]); memdelete(singleton->main_editor_buttons[i]);
@ -5176,7 +5176,7 @@ void EditorNode::_toggle_distraction_free_mode() {
} }
} }
if (screen == EDITOR_SCRIPT) { if (editor_table[screen]->get_name() == "Script") {
script_distraction = !script_distraction; script_distraction = !script_distraction;
set_distraction_free_mode(script_distraction); set_distraction_free_mode(script_distraction);
} else { } else {

View File

@ -173,8 +173,7 @@ public:
enum EditorTable { enum EditorTable {
EDITOR_2D = 0, EDITOR_2D = 0,
EDITOR_3D, EDITOR_3D
EDITOR_SCRIPT
}; };
void set_visible_editor(EditorTable p_table) { _editor_select(p_table); } void set_visible_editor(EditorTable p_table) { _editor_select(p_table); }

View File

@ -93,7 +93,7 @@ void InspectorDock::_menu_option(int p_option) {
case OBJECT_REQUEST_HELP: { case OBJECT_REQUEST_HELP: {
if (current) { if (current) {
editor->set_visible_editor(EditorNode::EDITOR_SCRIPT); editor->select_editor_by_name("Script");
emit_signal("request_help", current->get_class()); emit_signal("request_help", current->get_class());
} }
} break; } break;

View File

@ -1009,7 +1009,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
EditorScriptEditor::get_singleton()->goto_help("class_name:" + selection[i]->get_class()); EditorScriptEditor::get_singleton()->goto_help("class_name:" + selection[i]->get_class());
} }
#endif #endif
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->select_editor_by_name("Script");
} break; } break;
case TOOL_SCENE_EDITABLE_CHILDREN: { case TOOL_SCENE_EDITABLE_CHILDREN: {
List<Node *> selection = editor_selection->get_selected_node_list(); List<Node *> selection = editor_selection->get_selected_node_list();