diff options
Diffstat (limited to 'editor/editor_data.cpp')
-rw-r--r-- | editor/editor_data.cpp | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 4c4dacbeb5..213c3f5631 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -273,16 +273,6 @@ EditorPlugin *EditorData::get_editor(Object *p_object) { return nullptr; } -EditorPlugin *EditorData::get_subeditor(Object *p_object) { - for (int i = editor_plugins.size() - 1; i > -1; i--) { - if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) { - return editor_plugins[i]; - } - } - - return nullptr; -} - Vector<EditorPlugin *> EditorData::get_subeditors(Object *p_object) { Vector<EditorPlugin *> sub_plugins; for (int i = editor_plugins.size() - 1; i > -1; i--) { @@ -468,24 +458,25 @@ void EditorData::add_custom_type(const String &p_type, const String &p_inherits, custom_types[p_inherits].push_back(ct); } -Object *EditorData::instance_custom_type(const String &p_type, const String &p_inherits) { +Variant EditorData::instance_custom_type(const String &p_type, const String &p_inherits) { if (get_custom_types().has(p_inherits)) { for (int i = 0; i < get_custom_types()[p_inherits].size(); i++) { if (get_custom_types()[p_inherits][i].name == p_type) { Ref<Script> script = get_custom_types()[p_inherits][i].script; - Object *ob = ClassDB::instance(p_inherits); - ERR_FAIL_COND_V(!ob, nullptr); - if (ob->is_class("Node")) { - ob->call("set_name", p_type); + Variant ob = ClassDB::instance(p_inherits); + ERR_FAIL_COND_V(!ob, Variant()); + Node *n = Object::cast_to<Node>(ob); + if (n) { + n->set_name(p_type); } - ob->set_script(script); + ((Object *)ob)->set_script(script); return ob; } } } - return nullptr; + return Variant(); } void EditorData::remove_custom_type(const String &p_type) { @@ -509,6 +500,7 @@ int EditorData::add_edited_scene(int p_at_pos) { EditedScene es; es.root = nullptr; es.path = String(); + es.file_modified_time = 0; es.history_current = -1; es.version = 0; es.live_edit_root = NodePath(String("/root")); @@ -665,6 +657,10 @@ void EditorData::set_edited_scene_root(Node *p_root) { p_root->set_filename(edited_scene[current_edited_scene].path); } } + + if (edited_scene[current_edited_scene].path != "") { + edited_scene.write[current_edited_scene].file_modified_time = FileAccess::get_modified_time(edited_scene[current_edited_scene].path); + } } int EditorData::get_edited_scene_count() const { @@ -696,6 +692,21 @@ uint64_t EditorData::get_scene_version(int p_idx) const { return edited_scene[p_idx].version; } +void EditorData::set_scene_modified_time(int p_idx, uint64_t p_time) { + if (p_idx == -1) { + p_idx = current_edited_scene; + } + + ERR_FAIL_INDEX(p_idx, edited_scene.size()); + + edited_scene.write[p_idx].file_modified_time = p_time; +} + +uint64_t EditorData::get_scene_modified_time(int p_idx) const { + ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), 0); + return edited_scene[p_idx].file_modified_time; +} + String EditorData::get_scene_type(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String()); if (!edited_scene[p_idx].root) { @@ -867,18 +878,18 @@ StringName EditorData::script_class_get_base(const String &p_class) const { return script->get_language()->get_global_class_name(base_script->get_path()); } -Object *EditorData::script_class_instance(const String &p_class) { +Variant EditorData::script_class_instance(const String &p_class) { if (ScriptServer::is_global_class(p_class)) { - Object *obj = ClassDB::instance(ScriptServer::get_global_class_native_base(p_class)); + Variant obj = ClassDB::instance(ScriptServer::get_global_class_native_base(p_class)); if (obj) { Ref<Script> script = script_class_load_script(p_class); if (script.is_valid()) { - obj->set_script(script); + ((Object *)obj)->set_script(script); } return obj; } } - return nullptr; + return Variant(); } Ref<Script> EditorData::script_class_load_script(const String &p_class) const { @@ -931,6 +942,14 @@ void EditorData::script_class_save_icon_paths() { } } + Dictionary old; + if (ProjectSettings::get_singleton()->has_setting("_global_script_class_icons")) { + old = ProjectSettings::get_singleton()->get("_global_script_class_icons"); + } + if ((!old.is_empty() || d.is_empty()) && d.hash() == old.hash()) { + return; + } + if (d.is_empty()) { if (ProjectSettings::get_singleton()->has_setting("_global_script_class_icons")) { ProjectSettings::get_singleton()->clear("_global_script_class_icons"); |