summaryrefslogtreecommitdiffstats
path: root/editor/project_manager.cpp
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2024-09-11 16:06:12 +0200
committerkobewi <kobewi4e@gmail.com>2024-09-11 17:28:42 +0200
commitc435a8f37ba79b922c556cc4a8c4ea1da3b6d45e (patch)
tree19c29dd5f2835b8cc90b34e2434fa3447702aa1c /editor/project_manager.cpp
parent4788f54d9767425bf5435b1cc940885d357795c5 (diff)
downloadredot-engine-c435a8f37ba79b922c556cc4a8c4ea1da3b6d45e.tar.gz
Add simple minor version migration
Diffstat (limited to 'editor/project_manager.cpp')
-rw-r--r--editor/project_manager.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 55c361de4b..279590563a 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -580,7 +580,7 @@ void ProjectManager::_open_selected_projects_ask() {
if (!unsupported_features.is_empty()) {
String warning_message = "";
for (int i = 0; i < unsupported_features.size(); i++) {
- String feature = unsupported_features[i];
+ const String &feature = unsupported_features[i];
if (feature == "Double Precision") {
warning_message += TTR("Warning: This project uses double precision floats, but this version of\nGodot uses single precision floats. Opening this project may cause data loss.\n\n");
unsupported_features.remove_at(i);
@@ -590,6 +590,7 @@ void ProjectManager::_open_selected_projects_ask() {
unsupported_features.remove_at(i);
i--;
} else if (ProjectList::project_feature_looks_like_version(feature)) {
+ version_convert_feature = feature;
warning_message += vformat(TTR("Warning: This project was last edited in Godot %s. Opening will change it to Godot %s.\n\n"), Variant(feature), Variant(VERSION_BRANCH));
unsupported_features.remove_at(i);
i--;
@@ -610,6 +611,16 @@ void ProjectManager::_open_selected_projects_ask() {
_open_selected_projects();
}
+void ProjectManager::_open_selected_projects_with_migration() {
+#ifndef DISABLE_DEPRECATED
+ if (project_list->get_selected_projects().size() == 1) {
+ // Only migrate if a single project is opened.
+ _minor_project_migrate();
+ }
+#endif
+ _open_selected_projects();
+}
+
void ProjectManager::_install_project(const String &p_zip_path, const String &p_title) {
project_dialog->set_mode(ProjectDialog::MODE_INSTALL);
project_dialog->set_zip_path(p_zip_path);
@@ -877,6 +888,34 @@ void ProjectManager::add_new_tag(const String &p_tag) {
// Project converter/migration tool.
+#ifndef DISABLE_DEPRECATED
+void ProjectManager::_minor_project_migrate() {
+ const ProjectList::Item migrated_project = project_list->get_selected_projects()[0];
+
+ if (version_convert_feature.begins_with("4.3")) {
+ // Migrate layout after scale changes.
+ const float edscale = EDSCALE;
+ if (edscale != 1.0) {
+ Ref<ConfigFile> layout_file;
+ layout_file.instantiate();
+
+ const String layout_path = migrated_project.path.path_join(".godot/editor/editor_layout.cfg");
+ Error err = layout_file->load(layout_path);
+ if (err == OK) {
+ for (int i = 0; i < 4; i++) {
+ const String key = "dock_hsplit_" + itos(i + 1);
+ int old_value = layout_file->get_value("docks", key, 0);
+ if (old_value != 0) {
+ layout_file->set_value("docks", key, old_value / edscale);
+ }
+ }
+ layout_file->save(layout_path);
+ }
+ }
+ }
+}
+#endif
+
void ProjectManager::_full_convert_button_pressed() {
ask_update_settings->hide();
ask_full_convert_dialog->popup_centered(Size2i(600.0 * EDSCALE, 0));
@@ -1487,7 +1526,7 @@ ProjectManager::ProjectManager() {
ask_update_settings = memnew(ConfirmationDialog);
ask_update_settings->set_autowrap(true);
- ask_update_settings->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_selected_projects));
+ ask_update_settings->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_selected_projects_with_migration));
full_convert_button = ask_update_settings->add_button(TTR("Convert Full Project"), !GLOBAL_GET("gui/common/swap_cancel_ok"));
full_convert_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_full_convert_button_pressed));
add_child(ask_update_settings);