summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp29
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/inspector_dock.cpp31
-rw-r--r--editor/inspector_dock.h1
-rw-r--r--editor/plugins/text_shader_editor.cpp4
5 files changed, 32 insertions, 35 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 13dd03068f..fe31eff095 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1123,6 +1123,12 @@ void EditorNode::_version_button_pressed() {
DisplayServer::get_singleton()->clipboard_set(version_btn->get_meta(META_TEXT_TO_COPY));
}
+void EditorNode::_update_undo_redo_allowed() {
+ Ref<EditorUndoRedoManager> undo_redo = get_undo_redo();
+ file_menu->set_item_disabled(file_menu->get_item_index(EDIT_UNDO), !undo_redo->has_undo());
+ file_menu->set_item_disabled(file_menu->get_item_index(EDIT_REDO), !undo_redo->has_redo());
+}
+
void EditorNode::_node_renamed() {
if (InspectorDock::get_inspector_singleton()) {
InspectorDock::get_inspector_singleton()->update_tree();
@@ -3245,16 +3251,8 @@ void EditorNode::_discard_changes(const String &p_str) {
}
void EditorNode::_update_file_menu_opened() {
- Ref<Shortcut> close_scene_sc = ED_GET_SHORTCUT("editor/close_scene");
- close_scene_sc->set_name(TTR("Close Scene"));
- Ref<Shortcut> reopen_closed_scene_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene");
- reopen_closed_scene_sc->set_name(TTR("Reopen Closed Scene"));
-
file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), previous_scenes.is_empty());
-
- Ref<EditorUndoRedoManager> undo_redo = editor_data.get_undo_redo();
- file_menu->set_item_disabled(file_menu->get_item_index(EDIT_UNDO), !undo_redo->has_undo());
- file_menu->set_item_disabled(file_menu->get_item_index(EDIT_REDO), !undo_redo->has_redo());
+ _update_undo_redo_allowed();
}
void EditorNode::_update_file_menu_closed() {
@@ -5281,12 +5279,10 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
scene_tabs_context_menu->add_item(TTR("Play This Scene"), RUN_PLAY_SCENE);
scene_tabs_context_menu->add_separator();
- Ref<Shortcut> close_tab_sc = ED_GET_SHORTCUT("editor/close_scene");
- close_tab_sc->set_name(TTR("Close Tab"));
- scene_tabs_context_menu->add_shortcut(close_tab_sc, FILE_CLOSE);
- Ref<Shortcut> undo_close_tab_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene");
- undo_close_tab_sc->set_name(TTR("Undo Close Tab"));
- scene_tabs_context_menu->add_shortcut(undo_close_tab_sc, FILE_OPEN_PREV);
+ scene_tabs_context_menu->add_shortcut(ED_GET_SHORTCUT("editor/close_scene"), FILE_CLOSE);
+ scene_tabs_context_menu->set_item_text(scene_tabs_context_menu->get_item_index(FILE_CLOSE), TTR("Close Tab"));
+ scene_tabs_context_menu->add_shortcut(ED_GET_SHORTCUT("editor/reopen_closed_scene"), FILE_OPEN_PREV);
+ scene_tabs_context_menu->set_item_text(scene_tabs_context_menu->get_item_index(FILE_OPEN_PREV), TTR("Undo Close Tab"));
if (previous_scenes.is_empty()) {
scene_tabs_context_menu->set_item_disabled(scene_tabs_context_menu->get_item_index(FILE_OPEN_PREV), true);
}
@@ -6053,6 +6049,9 @@ EditorNode::EditorNode() {
singleton = this;
+ get_undo_redo()->connect("version_changed", callable_mp(this, &EditorNode::_update_undo_redo_allowed));
+ get_undo_redo()->connect("history_changed", callable_mp(this, &EditorNode::_update_undo_redo_allowed));
+
TranslationServer::get_singleton()->set_enabled(false);
// Load settings.
if (!EditorSettings::get_singleton()) {
diff --git a/editor/editor_node.h b/editor/editor_node.h
index f3dad8e223..ae951808d5 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -577,6 +577,8 @@ private:
void _titlebar_resized();
void _version_button_pressed();
+ void _update_undo_redo_allowed();
+
int _save_external_resources();
bool _validate_scene_recursive(const String &p_filename, Node *p_node);
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index fbe01c26b0..99d4e59bfe 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -257,12 +257,8 @@ void InspectorDock::_resource_file_selected(String p_file) {
}
void InspectorDock::_save_resource(bool save_as) {
- ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
- Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
-
- ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
-
- Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj));
+ Ref<Resource> current_res = _get_current_resource();
+ ERR_FAIL_COND(current_res.is_null());
if (save_as) {
EditorNode::get_singleton()->save_resource_as(current_res);
@@ -272,24 +268,15 @@ void InspectorDock::_save_resource(bool save_as) {
}
void InspectorDock::_unref_resource() {
- ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
- Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
-
- ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
-
- Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj));
+ Ref<Resource> current_res = _get_current_resource();
+ ERR_FAIL_COND(current_res.is_null());
current_res->set_path("");
EditorNode::get_singleton()->edit_current();
}
void InspectorDock::_copy_resource() {
- ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
- Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
-
- ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
-
- Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj));
-
+ Ref<Resource> current_res = _get_current_resource();
+ ERR_FAIL_COND(current_res.is_null());
EditorSettings::get_singleton()->set_resource_clipboard(current_res);
}
@@ -306,6 +293,12 @@ void InspectorDock::_prepare_resource_extra_popup() {
popup->set_item_disabled(popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), r.is_null());
}
+Ref<Resource> InspectorDock::_get_current_resource() const {
+ ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
+ Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
+ return Ref<Resource>(Object::cast_to<Resource>(current_obj));
+}
+
void InspectorDock::_prepare_history() {
EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history();
diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h
index fb2e1d53b1..2ac82eb451 100644
--- a/editor/inspector_dock.h
+++ b/editor/inspector_dock.h
@@ -119,6 +119,7 @@ class InspectorDock : public VBoxContainer {
void _copy_resource();
void _paste_resource();
void _prepare_resource_extra_popup();
+ Ref<Resource> _get_current_resource() const;
void _info_pressed();
void _resource_created();
diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp
index cd160f8b14..1b29999796 100644
--- a/editor/plugins/text_shader_editor.cpp
+++ b/editor/plugins/text_shader_editor.cpp
@@ -301,7 +301,9 @@ void ShaderTextEditor::_load_theme_settings() {
syntax_highlighter->clear_color_regions();
syntax_highlighter->add_color_region("/*", "*/", comment_color, false);
syntax_highlighter->add_color_region("//", "", comment_color, true);
- syntax_highlighter->set_disabled_branch_color(comment_color);
+
+ // Disabled preprocessor branches use translucent text color to be easier to distinguish from comments.
+ syntax_highlighter->set_disabled_branch_color(Color(EDITOR_GET("text_editor/theme/highlighting/text_color")) * Color(1, 1, 1, 0.5));
te->clear_comment_delimiters();
te->add_comment_delimiter("/*", "*/", false);