diff options
Diffstat (limited to 'editor/editor_data.cpp')
-rw-r--r-- | editor/editor_data.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index f5846c10f6..777eda2170 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -481,7 +481,7 @@ EditorPlugin *EditorData::get_editor_plugin(int p_idx) { void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon) { - ERR_FAIL_COND(p_script.is_null()); + ERR_FAIL_COND_MSG(p_script.is_null(), "It's not a reference to a valid Script object."); CustomType ct; ct.name = p_type; ct.icon = p_icon; @@ -537,6 +537,7 @@ int EditorData::add_edited_scene(int p_at_pos) { p_at_pos = edited_scene.size(); EditedScene es; es.root = NULL; + es.path = String(); es.history_current = -1; es.version = 0; es.live_edit_root = NodePath(String("/root")); @@ -653,6 +654,8 @@ bool EditorData::check_and_update_scene(int p_idx) { memdelete(edited_scene[p_idx].root); edited_scene.write[p_idx].root = new_scene; + if (new_scene->get_filename() != "") + edited_scene.write[p_idx].path = new_scene->get_filename(); edited_scene.write[p_idx].selection = new_selection; return true; @@ -684,6 +687,12 @@ void EditorData::set_edited_scene_root(Node *p_root) { ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); edited_scene.write[current_edited_scene].root = p_root; + if (p_root) { + if (p_root->get_filename() != "") + edited_scene.write[current_edited_scene].path = p_root->get_filename(); + else + p_root->set_filename(edited_scene[current_edited_scene].path); + } } int EditorData::get_edited_scene_count() const { @@ -773,6 +782,7 @@ String EditorData::get_scene_title(int p_idx) const { void EditorData::set_scene_path(int p_idx, const String &p_path) { ERR_FAIL_INDEX(p_idx, edited_scene.size()); + edited_scene.write[p_idx].path = p_path; if (!edited_scene[p_idx].root) return; @@ -783,9 +793,14 @@ String EditorData::get_scene_path(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String()); - if (!edited_scene[p_idx].root) - return ""; - return edited_scene[p_idx].root->get_filename(); + if (edited_scene[p_idx].root) { + if (edited_scene[p_idx].root->get_filename() == "") + edited_scene[p_idx].root->set_filename(edited_scene[p_idx].path); + else + return edited_scene[p_idx].root->get_filename(); + } + + return edited_scene[p_idx].path; } void EditorData::set_edited_scene_live_edit_root(const NodePath &p_root) { |