Merge pull request #96861 from KoBeWi/it's_3_to_4_again
Add simple minor version migration
This commit is contained in:
commit
14a7e0abb3
|
@ -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);
|
||||
|
|
|
@ -176,6 +176,7 @@ class ProjectManager : public Control {
|
|||
void _run_project_confirm();
|
||||
void _open_selected_projects();
|
||||
void _open_selected_projects_ask();
|
||||
void _open_selected_projects_with_migration();
|
||||
|
||||
void _install_project(const String &p_zip_path, const String &p_title);
|
||||
void _import_project();
|
||||
|
@ -223,6 +224,11 @@ class ProjectManager : public Control {
|
|||
ConfirmationDialog *ask_update_settings = nullptr;
|
||||
Button *full_convert_button = nullptr;
|
||||
|
||||
String version_convert_feature;
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
void _minor_project_migrate();
|
||||
#endif
|
||||
void _full_convert_button_pressed();
|
||||
void _perform_full_project_conversion();
|
||||
|
||||
|
|
Loading…
Reference in New Issue