You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Warn the user that changes to resources will be lost when editing imported or instanced resources from scenes.
This commit is contained in:
@@ -254,6 +254,7 @@ void EditorNode::_notification(int p_what) {
|
||||
get_tree()->get_root()->set_as_audio_listener_2d(false);
|
||||
get_tree()->set_auto_accept_quit(false);
|
||||
get_tree()->connect("files_dropped", this, "_dropped_files");
|
||||
property_editable_warning->set_icon(gui_base->get_icon("NodeWarning","EditorIcons"));
|
||||
}
|
||||
|
||||
if (p_what == NOTIFICATION_EXIT_TREE) {
|
||||
@@ -1387,6 +1388,11 @@ static bool overrides_external_editor(Object *p_object) {
|
||||
return script->get_language()->overrides_external_editor();
|
||||
}
|
||||
|
||||
void EditorNode::_property_editable_warning_pressed() {
|
||||
|
||||
property_editable_warning_dialog->popup_centered_minsize();
|
||||
}
|
||||
|
||||
void EditorNode::_edit_current() {
|
||||
|
||||
uint32_t current = editor_history.get_current();
|
||||
@@ -1398,6 +1404,9 @@ void EditorNode::_edit_current() {
|
||||
this->current = current_obj;
|
||||
editor_path->update_path();
|
||||
|
||||
String editable_warning; //none by default
|
||||
property_editable_warning->hide(); //hide by default
|
||||
|
||||
if (!current_obj) {
|
||||
|
||||
scene_tree_dock->set_selected(NULL);
|
||||
@@ -1425,6 +1434,22 @@ void EditorNode::_edit_current() {
|
||||
node_dock->set_node(NULL);
|
||||
object_menu->set_disabled(false);
|
||||
EditorNode::get_singleton()->get_import_dock()->set_edit_path(current_res->get_path());
|
||||
|
||||
int subr_idx = current_res->get_path().find("::");
|
||||
if (subr_idx!=-1) {
|
||||
String base_path=current_res->get_path().substr(0,subr_idx);
|
||||
if (FileAccess::exists(base_path+".import")) {
|
||||
editable_warning=TTR("This resource belongs to a scene that was imported, so it's not editable.\nPlease read the documentation relevant to importing scenes to better understand this workflow.");
|
||||
} else {
|
||||
if (!get_edited_scene() || get_edited_scene()->get_filename()!=base_path) {
|
||||
editable_warning=TTR("This resource belongs to a scene that was instanced or inherited.\nChanges to it will not be kept when saving the current scene.");
|
||||
}
|
||||
}
|
||||
} else if (current_res->get_path().is_resource_file()){
|
||||
if (FileAccess::exists(current_res->get_path()+".import")) {
|
||||
editable_warning=TTR("This resource was imported, so it's not editable. Change it's settings in the import panel and re-import.");
|
||||
}
|
||||
}
|
||||
} else if (is_node) {
|
||||
|
||||
Node *current_node = Object::cast_to<Node>(current_obj);
|
||||
@@ -1440,12 +1465,25 @@ void EditorNode::_edit_current() {
|
||||
}
|
||||
object_menu->get_popup()->clear();
|
||||
|
||||
if (get_edited_scene() && get_edited_scene()->get_filename()!=String()) {
|
||||
String source_scene = get_edited_scene()->get_filename();
|
||||
if (FileAccess::exists(source_scene+".import")) {
|
||||
editable_warning=TTR("This scene was imported, so changes to it will not be kept.\nInstancing it or inheriting will allow making changes to it.\nPlease read the documentation relevant to importing scenes to better understand this workflow.");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
property_editor->edit(current_obj);
|
||||
node_dock->set_node(NULL);
|
||||
}
|
||||
|
||||
if (editable_warning!=String()) {
|
||||
property_editable_warning->show(); //hide by default
|
||||
property_editable_warning_dialog->set_text(editable_warning);
|
||||
|
||||
}
|
||||
|
||||
/* Take care of PLUGIN EDITOR */
|
||||
|
||||
EditorPlugin *main_plugin = editor_data.get_editor(current_obj);
|
||||
@@ -4471,6 +4509,9 @@ void EditorNode::_bind_methods() {
|
||||
ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history);
|
||||
ClassDB::bind_method("_dropped_files", &EditorNode::_dropped_files);
|
||||
ClassDB::bind_method("_toggle_distraction_free_mode", &EditorNode::_toggle_distraction_free_mode);
|
||||
ClassDB::bind_method("_property_editable_warning_pressed", &EditorNode::_property_editable_warning_pressed);
|
||||
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
|
||||
ClassDB::bind_method(D_METHOD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch);
|
||||
@@ -5232,6 +5273,15 @@ EditorNode::EditorNode() {
|
||||
search_bar->add_child(clear_button);
|
||||
clear_button->connect("pressed", this, "_clear_search_box");
|
||||
|
||||
property_editable_warning = memnew (Button);
|
||||
property_editable_warning->set_text(TTR("Changes my be lost!"));
|
||||
prop_editor_base->add_child(property_editable_warning);
|
||||
property_editable_warning_dialog = memnew( AcceptDialog );
|
||||
gui_base->add_child(property_editable_warning_dialog);
|
||||
property_editable_warning->hide();
|
||||
property_editable_warning->connect("pressed",this,"_property_editable_warning_pressed");
|
||||
|
||||
|
||||
property_editor = memnew(PropertyEditor);
|
||||
property_editor->set_autoclear(true);
|
||||
property_editor->set_show_categories(true);
|
||||
@@ -5244,6 +5294,7 @@ EditorNode::EditorNode() {
|
||||
property_editor->hide_top_label();
|
||||
property_editor->register_text_enter(search_box);
|
||||
|
||||
Button *property_editable_warning;
|
||||
prop_editor_base->add_child(property_editor);
|
||||
property_editor->set_undo_redo(&editor_data.get_undo_redo());
|
||||
|
||||
@@ -5251,6 +5302,7 @@ EditorNode::EditorNode() {
|
||||
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(import_dock);
|
||||
import_dock->set_name(TTR("Import"));
|
||||
|
||||
|
||||
bool use_single_dock_column = (OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x < 1200);
|
||||
|
||||
node_dock = memnew(NodeDock);
|
||||
|
||||
Reference in New Issue
Block a user