diff options
-rw-r--r-- | editor/editor_node.cpp | 16 | ||||
-rw-r--r-- | editor/editor_node.h | 1 | ||||
-rw-r--r-- | editor/editor_properties.cpp | 8 | ||||
-rw-r--r-- | editor/editor_properties.h | 9 |
4 files changed, 22 insertions, 12 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d3ae5d6601..b8d5ba5acb 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -637,6 +637,7 @@ void EditorNode::save_resource(const Ref<Resource> &p_resource) { void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path) { file->set_mode(EditorFileDialog::MODE_SAVE_FILE); + saving_resource = p_resource; current_option = RESOURCE_SAVE_AS; List<String> extensions; @@ -1263,15 +1264,13 @@ void EditorNode::_dialog_action(String p_file) { case RESOURCE_SAVE: case RESOURCE_SAVE_AS: { - uint32_t current = editor_history.get_current(); + ERR_FAIL_COND(saving_resource.is_null()) + save_resource_in_path(saving_resource, p_file); + saving_resource = Ref<Resource>(); + ObjectID current = editor_history.get_current(); Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL; - - ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)) - - RES current_res = RES(Object::cast_to<Resource>(current_obj)); - - save_resource_in_path(current_res, p_file); - + ERR_FAIL_COND(!current_obj); + current_obj->_change_notify(); } break; case SETTINGS_LAYOUT_SAVE: { @@ -5777,6 +5776,7 @@ EditorNode::EditorNode() { _edit_current(); current = NULL; + saving_resource = Ref<Resource>(); reference_resource_mem = true; save_external_resources_mem = true; diff --git a/editor/editor_node.h b/editor/editor_node.h index b828a4d7d5..be6bacd0d1 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -356,6 +356,7 @@ private: EditorExport *editor_export; Object *current; + Ref<Resource> saving_resource; bool _playing_edited; String run_custom_filename; diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 3730807243..4534eda012 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2016,6 +2016,13 @@ void EditorPropertyResource::_menu_option(int p_which) { } break; + case OBJ_MENU_SAVE: { + RES res = get_edited_object()->get(get_edited_property()); + if (res.is_null()) + return; + EditorNode::get_singleton()->save_resource(res); + } break; + case OBJ_MENU_COPY: { RES res = get_edited_object()->get(get_edited_property()); @@ -2233,6 +2240,7 @@ void EditorPropertyResource::_update_menu_items() { menu->add_icon_item(get_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT); menu->add_icon_item(get_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR); menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); + menu->add_icon_item(get_icon("Save", "EditorIcons"), TTR("Save"), OBJ_MENU_SAVE); RES r = res; if (r.is_valid() && r->get_path().is_resource_file()) { menu->add_separator(); diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 541abb1f22..b82ef977ef 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -522,10 +522,11 @@ class EditorPropertyResource : public EditorProperty { OBJ_MENU_EDIT = 1, OBJ_MENU_CLEAR = 2, OBJ_MENU_MAKE_UNIQUE = 3, - OBJ_MENU_COPY = 4, - OBJ_MENU_PASTE = 5, - OBJ_MENU_NEW_SCRIPT = 6, - OBJ_MENU_SHOW_IN_FILE_SYSTEM = 7, + OBJ_MENU_SAVE = 4, + OBJ_MENU_COPY = 5, + OBJ_MENU_PASTE = 6, + OBJ_MENU_NEW_SCRIPT = 7, + OBJ_MENU_SHOW_IN_FILE_SYSTEM = 8, TYPE_BASE_ID = 100, CONVERT_BASE_ID = 1000 |