diff options
-rw-r--r-- | SConstruct | 4 | ||||
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_function.h | 1 | ||||
-rw-r--r-- | scene/main/node.cpp | 14 | ||||
-rw-r--r-- | scene/main/node.h | 3 | ||||
-rw-r--r-- | scene/resources/scene_format_text.cpp | 55 | ||||
-rw-r--r-- | scene/resources/scene_format_text.h | 2 | ||||
-rw-r--r-- | tools/editor/editor_data.cpp | 4 | ||||
-rw-r--r-- | tools/editor/editor_file_dialog.cpp | 10 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 79 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 4 | ||||
-rw-r--r-- | tools/editor/io_plugins/editor_scene_import_plugin.cpp | 6 | ||||
-rw-r--r-- | tools/editor/scene_tree_editor.cpp | 16 | ||||
-rw-r--r-- | tools/translations/tools.pot | 4 |
14 files changed, 163 insertions, 41 deletions
diff --git a/SConstruct b/SConstruct index 691536c956..01b1f2ce8e 100644 --- a/SConstruct +++ b/SConstruct @@ -144,6 +144,7 @@ opts.Add('unix_global_settings_path', 'unix-specific path to system-wide setting opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no") opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no") opts.Add('colored', 'Enable colored output for the compilation (yes/no)', 'no') +opts.Add('deprecated','Enable deprecated features (yes/no)','yes') opts.Add('extra_suffix', 'Custom extra suffix added to the base filename of all generated binary files.', '') opts.Add('vsproj', 'Generate Visual Studio Project. (yes/no)', 'no') @@ -179,6 +180,9 @@ if (env_base['target']=='debug'): env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']); env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE']) +if (env_base['deprecated']!='no'): + env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED']); + env_base.platforms = {} diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index b1da7e782c..07a5a636d4 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -212,7 +212,7 @@ String GDScriptLanguage::debug_get_stack_level_source(int p_level) const { ERR_FAIL_INDEX_V(p_level,_debug_call_stack_pos,""); int l = _debug_call_stack_pos - p_level -1; - return _call_stack[l].function->get_script()->get_path(); + return _call_stack[l].function->get_source(); } void GDScriptLanguage::debug_get_stack_level_locals(int p_level,List<String> *p_locals, List<Variant> *p_values, int p_max_subitems,int p_max_depth) { diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gd_function.h index 1f790eaadc..942db170c8 100644 --- a/modules/gdscript/gd_function.h +++ b/modules/gdscript/gd_function.h @@ -160,6 +160,7 @@ public: int get_default_argument_count() const; int get_default_argument_addr(int p_idx) const; GDScript *get_script() const { return _script; } + StringName get_source() const { return source; } void debug_get_stack_member_state(int p_line,List<Pair<StringName,int> > *r_stackvars) const; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 11b400d4a9..bea6e75aef 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2085,6 +2085,15 @@ bool Node::is_owned_by_parent() const { return data.parent_owned; } +void Node::set_display_folded(bool p_folded) { + data.display_folded=p_folded; +} + +bool Node::is_displayed_folded() const { + + return data.display_folded; +} + void Node::_bind_methods() { ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false)); @@ -2140,6 +2149,8 @@ void Node::_bind_methods() { ObjectTypeDB::bind_method(_MD("can_process"),&Node::can_process); ObjectTypeDB::bind_method(_MD("print_stray_nodes"),&Node::_print_stray_nodes); ObjectTypeDB::bind_method(_MD("get_position_in_parent"),&Node::get_position_in_parent); + ObjectTypeDB::bind_method(_MD("set_display_folded","fold"),&Node::set_display_folded); + ObjectTypeDB::bind_method(_MD("is_displayed_folded"),&Node::is_displayed_folded); ObjectTypeDB::bind_method(_MD("get_tree:SceneTree"),&Node::get_tree); @@ -2194,6 +2205,7 @@ void Node::_bind_methods() { //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/input" ), _SCS("set_process_input"),_SCS("is_processing_input" ) ); //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/unhandled_input" ), _SCS("set_process_unhandled_input"),_SCS("is_processing_unhandled_input" ) ); ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "process/pause_mode",PROPERTY_HINT_ENUM,"Inherit,Stop,Process" ), _SCS("set_pause_mode"),_SCS("get_pause_mode" ) ); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "editor/display_folded",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ), _SCS("set_display_folded"),_SCS("is_displayed_folded" ) ); BIND_VMETHOD( MethodInfo("_process",PropertyInfo(Variant::REAL,"delta")) ); BIND_VMETHOD( MethodInfo("_fixed_process",PropertyInfo(Variant::REAL,"delta")) ); @@ -2231,6 +2243,7 @@ Node::Node() { data.in_constructor=true; data.viewport=NULL; data.use_placeholder=false; + data.display_folded=false; } Node::~Node() { @@ -2240,6 +2253,7 @@ Node::~Node() { data.owned.clear(); data.children.clear(); + ERR_FAIL_COND(data.parent); ERR_FAIL_COND(data.children.size()); diff --git a/scene/main/node.h b/scene/main/node.h index 88334f32f0..dcc3829d15 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -111,6 +111,7 @@ private: bool in_constructor; bool use_placeholder; + bool display_folded; } data; @@ -325,6 +326,8 @@ public: void update_configuration_warning(); + void set_display_folded(bool p_folded); + bool is_displayed_folded() const; /* CANVAS */ Node(); diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index c7e2fc4e73..95645107d4 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -67,12 +67,17 @@ Error ResourceInteractiveLoaderText::_parse_sub_resource(VariantParser::Stream* String path = local_path+"::"+itos(index); - if (!ResourceCache::has(path)) { - r_err_str="Can't load cached sub-resource: "+path; - return ERR_PARSE_ERROR; - } + if (!ignore_resource_parsing) { - r_res=RES(ResourceCache::get(path)); + if (!ResourceCache::has(path)) { + r_err_str="Can't load cached sub-resource: "+path; + return ERR_PARSE_ERROR; + } + + r_res=RES(ResourceCache::get(path)); + } else { + r_res=RES(); + } VariantParser::get_token(p_stream,token,line,r_err_str); if (token.type!=VariantParser::TK_PARENTHESIS_CLOSE) { @@ -95,25 +100,29 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream* int id = token.value; + if (!ignore_resource_parsing) { - if (!ext_resources.has(id)) { - r_err_str="Can't load cached ext-resource #"+itos(id); - return ERR_PARSE_ERROR; - } + if (!ext_resources.has(id)) { + r_err_str="Can't load cached ext-resource #"+itos(id); + return ERR_PARSE_ERROR; + } - String path = ext_resources[id].path; - String type = ext_resources[id].type; + String path = ext_resources[id].path; + String type = ext_resources[id].type; - if (path.find("://")==-1 && path.is_rel_path()) { - // path is relative to file being loaded, so convert to a resource path - path=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path)); + if (path.find("://")==-1 && path.is_rel_path()) { + // path is relative to file being loaded, so convert to a resource path + path=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path)); - } + } - r_res=ResourceLoader::load(path,type); + r_res=ResourceLoader::load(path,type); - if (r_res.is_null()) { - WARN_PRINT(String("Couldn't load external resource: "+path).utf8().get_data()); + if (r_res.is_null()) { + WARN_PRINT(String("Couldn't load external resource: "+path).utf8().get_data()); + } + } else { + r_res=RES(); } VariantParser::get_token(p_stream,token,line,r_err_str); @@ -625,6 +634,7 @@ void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f,List<String> open(f); + ignore_resource_parsing=true; ERR_FAIL_COND(error!=OK); while(next_tag.name=="ext_resource") { @@ -662,6 +672,7 @@ void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f,List<String> Error err = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp); if (err) { + print_line(error_text+" - "+itos(lines)); error_text="Unexpected end of file"; _printerr(); error=ERR_FILE_CORRUPT; @@ -676,7 +687,7 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const open(p_f,true); ERR_FAIL_COND_V(error!=OK,error); - + ignore_resource_parsing=true; //FileAccess FileAccess *fw = NULL; @@ -794,7 +805,7 @@ void ResourceInteractiveLoaderText::open(FileAccess *p_f,bool p_skip_first_tag) stream.f=f; is_scene=false; - + ignore_resource_parsing=false; resource_current=0; @@ -879,6 +890,8 @@ String ResourceInteractiveLoaderText::recognize(FileAccess *p_f) { stream.f=f; + ignore_resource_parsing=true; + VariantParser::Tag tag; Error err = VariantParser::parse_tag(&stream,lines,error_text,tag); @@ -1296,7 +1309,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re if ((PE->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero())||(PE->get().usage&PROPERTY_USAGE_STORE_IF_NONONE && value.is_one()) ) continue; - if (PE->get().type==Variant::OBJECT && value.is_zero() && (!PE->get().usage&PROPERTY_USAGE_STORE_IF_NULL)) + if (PE->get().type==Variant::OBJECT && value.is_zero() && !(PE->get().usage&PROPERTY_USAGE_STORE_IF_NULL)) continue; String vars; diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h index 8dbfbfda48..6122a1f9d8 100644 --- a/scene/resources/scene_format_text.h +++ b/scene/resources/scene_format_text.h @@ -56,7 +56,7 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader { bool is_scene; String res_type; - + bool ignore_resource_parsing; // Map<String,String> remaps; diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index 4c4fecdd83..0f10041034 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -565,6 +565,8 @@ bool EditorData::check_and_update_scene(int p_idx) { bool must_reload = _find_updated_instances(edited_scene[p_idx].root,edited_scene[p_idx].root,checked_scenes); + print_line("MUST RELOAD? "+itos(must_reload)); + if (must_reload) { Ref<PackedScene> pscene; pscene.instance(); @@ -762,6 +764,8 @@ Ref<ResourceImportMetadata> EditorData::get_edited_scene_import_metadata() const return edited_scene[current_edited_scene].medatata; } + + void EditorData::clear_edited_scenes() { for(int i=0;i<edited_scene.size();i++) { diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index e68a53659b..b8abd1d32c 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -144,11 +144,11 @@ void EditorFileDialog::_unhandled_input(const InputEvent& p_event) { dir->grab_focus(); handled=true; } - if (ED_IS_SHORTCUT("file_dialog/mode_favorite_up", p_event)) { + if (ED_IS_SHORTCUT("file_dialog/move_favorite_up", p_event)) { _favorite_move_up(); handled=true; } - if (ED_IS_SHORTCUT("file_dialog/mode_favorite_down", p_event)) { + if (ED_IS_SHORTCUT("file_dialog/move_favorite_down", p_event)) { _favorite_move_down(); handled=true; } @@ -1290,14 +1290,14 @@ EditorFileDialog::EditorFileDialog() { ED_SHORTCUT("file_dialog/go_back", TTR("Go Back"), KEY_MASK_ALT|KEY_LEFT); ED_SHORTCUT("file_dialog/go_forward", TTR("Go Forward"), KEY_MASK_ALT|KEY_RIGHT); ED_SHORTCUT("file_dialog/go_up", TTR("Go Up"), KEY_MASK_ALT|KEY_UP); - ED_SHORTCUT("file_dialog/refresh", TTR("Refresh"), KEY_MASK_CMD|KEY_F5); // ctrl + f5 else it launches the game as well.. + ED_SHORTCUT("file_dialog/refresh", TTR("Refresh"), KEY_F5); ED_SHORTCUT("file_dialog/toggle_hidden_files", TTR("Toggle Hidden Files"), KEY_MASK_CMD|KEY_H); ED_SHORTCUT("file_dialog/toggle_favorite", TTR("Toggle Favorite"), KEY_MASK_ALT|KEY_F); ED_SHORTCUT("file_dialog/toggle_mode", TTR("Toggle Mode"), KEY_MASK_ALT|KEY_V); ED_SHORTCUT("file_dialog/create_folder", TTR("Create Folder"), KEY_MASK_CMD|KEY_N); ED_SHORTCUT("file_dialog/focus_path", TTR("Focus Path"), KEY_MASK_CMD|KEY_D); - ED_SHORTCUT("file_dialog/mode_favorite_up", TTR("Mode Favorite Up"), KEY_MASK_CMD|KEY_UP); - ED_SHORTCUT("file_dialog/mode_favorite_down", TTR("Mode Favorite Down"), KEY_MASK_CMD|KEY_DOWN); + ED_SHORTCUT("file_dialog/move_favorite_up", TTR("Move Favorite Up"), KEY_MASK_CMD|KEY_UP); + ED_SHORTCUT("file_dialog/move_favorite_down", TTR("Move Favorite Down"), KEY_MASK_CMD|KEY_DOWN); HBoxContainer *pathhb = memnew( HBoxContainer ); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 58da0e8478..9e897a41d9 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3429,7 +3429,10 @@ Dictionary EditorNode::_get_main_scene_state() { return state; } -void EditorNode::_set_main_scene_state(Dictionary p_state) { +void EditorNode::_set_main_scene_state(Dictionary p_state,Node* p_for_scene) { + + if (get_edited_scene()!=p_for_scene) + return; //not for this scene //print_line("set current 7 "); changing_scene=false; @@ -3573,7 +3576,7 @@ void EditorNode::set_current_scene(int p_idx) { }*/ //_set_main_scene_state(state); - call_deferred("_set_main_scene_state",state); //do after everything else is done setting up + call_deferred("_set_main_scene_state",state,get_edited_scene()); //do after everything else is done setting up //print_line("set current 6 "); @@ -5115,6 +5118,78 @@ void EditorNode::_file_access_close_error_notify(const String& p_str) { add_io_error("Unable to write to file '"+p_str+"', file in use, locked or lacking permissions."); } + +void EditorNode::reload_scene(const String& p_path) { + + + //first of all, reload textures as they might have changed on disk + + List<Ref<Resource> > cached; + ResourceCache::get_cached_resources(&cached); + List<Ref<Resource> > to_clear; //clear internal resources from previous scene from being used + for(List<Ref<Resource> >::Element *E=cached.front();E;E=E->next()) { + + if (E->get()->get_path().begins_with(p_path+"::")) //subresources of existing scene + to_clear.push_back(E->get()); + + if (!E->get()->cast_to<Texture>()) + continue; + if (!E->get()->get_path().is_resource_file() && !E->get()->get_path().is_abs_path()) + continue; + if (!FileAccess::exists(E->get()->get_path())) + continue; + uint64_t mt = FileAccess::get_modified_time(E->get()->get_path()); + if (mt!=E->get()->get_last_modified_time()) { + E->get()->reload_from_file(); + } + } + + //so reload reloads everything, clear subresources of previous scene + while(to_clear.front()) { + to_clear.front()->get()->set_path(""); + to_clear.pop_front(); + } + + int scene_idx=-1; + for(int i=0;i<editor_data.get_edited_scene_count();i++) { + + if (editor_data.get_scene_path(i)==p_path) { + scene_idx=i; + break; + } + } + + int current_tab = editor_data.get_edited_scene(); + + + if (scene_idx==-1) { + if (get_edited_scene()) { + //scene is not open, so at it might be instanced, just refresh, set tab to itself and it will reload + set_current_scene(current_tab); + editor_data.get_undo_redo().clear_history(); + } + return; + } + + + if (current_tab==scene_idx) { + editor_data.apply_changes_in_editors(); + _set_scene_metadata(p_path); + + } + //remove scene + _remove_scene(scene_idx); + //reload scene + load_scene(p_path); + //adjust index so tab is back a the previous position + editor_data.move_edited_scene_to_index(scene_idx); + get_undo_redo()->clear_history(); + //recover the tab + scene_tabs->set_current_tab(current_tab); + _scene_tab_changed(current_tab); +} + + void EditorNode::_bind_methods() { diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index a0a03341fc..9b0edda75e 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -555,7 +555,7 @@ private: void _scene_tab_script_edited(int p_tab); Dictionary _get_main_scene_state(); - void _set_main_scene_state(Dictionary p_state); + void _set_main_scene_state(Dictionary p_state,Node* p_for_scene); int _get_current_main_editor(); @@ -716,6 +716,8 @@ public: void update_keying(); + void reload_scene(const String& p_path); + bool is_exiting() const { return exiting; } ToolButton *get_pause_button() { return pause_button; } diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index d5d0fac2b6..b27539b933 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -2790,15 +2790,16 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c Ref<PackedScene> packer = memnew( PackedScene ); packer->pack(scene); - packer->set_path(p_dest_path); + //packer->set_path(p_dest_path); do not take over, let the changed files reload themselves packer->set_import_metadata(from); print_line("SAVING TO: "+p_dest_path); - err = ResourceSaver::save(p_dest_path,packer,ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); + err = ResourceSaver::save(p_dest_path,packer); //do not take over, let the changed files reload themselves //EditorFileSystem::get_singleton()->update_resource(packer); memdelete(scene); + /* scene->set_filename(p_dest_path); if (r_scene) { @@ -2818,6 +2819,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c */ + EditorNode::get_singleton()->reload_scene(p_dest_path); return err; diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index a155f0c0cf..f174bc2f1b 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -302,8 +302,15 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) { item->set_selectable(0,true); if (can_rename) { - - bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false; +#ifdef ENABLE_DEPRECATED + if (p_node->has_meta("_editor_collapsed")) { + //remove previous way of storing folding, which did not get along with scene inheritance and instancing + if ((bool)p_node->get_meta("_editor_collapsed")) + p_node->set_display_folded(true); + p_node->set_meta("_editor_collapsed",Variant()); + } +#endif + bool collapsed = p_node->is_displayed_folded(); if (collapsed) item->set_collapsed(true); } @@ -896,10 +903,7 @@ void SceneTreeEditor::_cell_collapsed(Object *p_obj) { Node *n=get_node(np); ERR_FAIL_COND(!n); - if (collapsed) - n->set_meta("_editor_collapsed",true); - else - n->set_meta("_editor_collapsed",Variant()); + n->set_display_folded(collapsed); } diff --git a/tools/translations/tools.pot b/tools/translations/tools.pot index cf59d9a8a2..a5385f3bad 100644 --- a/tools/translations/tools.pot +++ b/tools/translations/tools.pot @@ -1181,11 +1181,11 @@ msgid "Focus Path" msgstr "" #: tools/editor/editor_file_dialog.cpp -msgid "Mode Favorite Up" +msgid "Move Favorite Up" msgstr "" #: tools/editor/editor_file_dialog.cpp -msgid "Mode Favorite Down" +msgid "Move Favorite Down" msgstr "" #: tools/editor/editor_file_dialog.cpp tools/editor/scenes_dock.cpp |