diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 70e8133eaa9..9b28ef7b810 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -597,6 +597,7 @@ Error ProjectSettings::_load_settings_text(const String &p_path) { // If we're loading a project.godot from source code, we can operate some // ProjectSettings conversions if need be. _convert_to_last_version(config_version); + last_save_time = FileAccess::get_modified_time(get_resource_path().plus_file("project.godot")); return OK; } else if (err != OK) { ERR_PRINT("Error parsing " + p_path + " at line " + itos(lines) + ": " + error_text + " File might be corrupted."); @@ -676,7 +677,11 @@ void ProjectSettings::clear(const String &p_name) { } Error ProjectSettings::save() { - return save_custom(get_resource_path().plus_file("project.godot")); + Error error = save_custom(get_resource_path().plus_file("project.godot")); + if (error == OK) { + last_save_time = FileAccess::get_modified_time(get_resource_path().plus_file("project.godot")); + } + return error; } Error ProjectSettings::_save_settings_binary(const String &p_file, const Map> &props, const CustomMap &p_custom, const String &p_custom_features) { diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 59c56c23c25..645506f302a 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -78,6 +78,8 @@ protected: int last_order = NO_BUILTIN_ORDER_BASE; int last_builtin_order = 0; + uint64_t last_save_time = 0; + Map props; String resource_path; Map custom_prop_info; @@ -113,7 +115,6 @@ protected: Error _setup(const String &p_path, const String &p_main_pack, bool p_upwards = false); -protected: static void _bind_methods(); public: @@ -150,6 +151,7 @@ public: Error save(); void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info); const Map &get_custom_property_info() const; + uint64_t get_last_saved_time() { return last_save_time; } Vector get_optimizer_presets() const; diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 336bf266078..18364dc32f8 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -500,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")); @@ -656,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 { @@ -687,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) { diff --git a/editor/editor_data.h b/editor/editor_data.h index f14a3fb4e02..18b41371628 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -111,6 +111,7 @@ public: struct EditedScene { Node *root = nullptr; String path; + uint64_t file_modified_time = 0; Dictionary editor_states; List selection; Vector history_stored; @@ -190,6 +191,8 @@ public: Ref