Improve user-friendliness of project version mismatch message

This commit is contained in:
Aaron Franke 2023-07-06 17:37:24 -05:00
parent b7c2fd2e9a
commit 3b8a81d361
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
2 changed files with 21 additions and 6 deletions

View File

@ -1042,10 +1042,25 @@ void ProjectListItemControl::set_project_icon(const Ref<Texture2D> &p_icon) {
project_icon->set_texture(p_icon); project_icon->set_texture(p_icon);
} }
void ProjectListItemControl::set_unsupported_features(const PackedStringArray &p_features) { bool _project_feature_looks_like_version(const String &p_feature) {
return p_feature.contains(".") && p_feature.substr(0, 3).is_numeric();
}
void ProjectListItemControl::set_unsupported_features(PackedStringArray p_features) {
if (p_features.size() > 0) {
String tooltip_text = "";
for (int i = 0; i < p_features.size(); i++) {
if (_project_feature_looks_like_version(p_features[i])) {
tooltip_text += TTR("This project was last edited in a different Godot version: ") + p_features[i] + "\n";
p_features.remove_at(i);
i--;
}
}
if (p_features.size() > 0) { if (p_features.size() > 0) {
String unsupported_features_str = String(", ").join(p_features); String unsupported_features_str = String(", ").join(p_features);
project_unsupported_features->set_tooltip_text(TTR("The project uses features unsupported by the current build:") + "\n" + unsupported_features_str); tooltip_text += TTR("This project uses features unsupported by the current build:") + "\n" + unsupported_features_str;
}
project_unsupported_features->set_tooltip_text(tooltip_text);
project_unsupported_features->show(); project_unsupported_features->show();
} else { } else {
project_unsupported_features->hide(); project_unsupported_features->hide();
@ -1450,7 +1465,7 @@ void ProjectList::_create_project_item_control(int p_index) {
hb->set_project_path(item.path); hb->set_project_path(item.path);
hb->set_tooltip_text(item.description); hb->set_tooltip_text(item.description);
hb->set_tags(item.tags, this); hb->set_tags(item.tags, this);
hb->set_unsupported_features(item.unsupported_features); hb->set_unsupported_features(item.unsupported_features.duplicate());
hb->set_is_favorite(item.favorite); hb->set_is_favorite(item.favorite);
hb->set_is_missing(item.missing); hb->set_is_missing(item.missing);
@ -2297,7 +2312,7 @@ void ProjectManager::_open_selected_projects_ask() {
warning_message += TTR("Warning: This project uses C#, but this build of Godot does not have\nthe Mono module. If you proceed you will not be able to use any C# scripts.\n\n"); warning_message += TTR("Warning: This project uses C#, but this build of Godot does not have\nthe Mono module. If you proceed you will not be able to use any C# scripts.\n\n");
unsupported_features.remove_at(i); unsupported_features.remove_at(i);
i--; i--;
} else if (feature.substr(0, 3).is_numeric()) { } else if (_project_feature_looks_like_version(feature)) {
warning_message += vformat(TTR("Warning: This project was built in Godot %s.\nOpening will upgrade or downgrade the project to Godot %s.\n\n"), Variant(feature), Variant(VERSION_BRANCH)); warning_message += vformat(TTR("Warning: This project was built in Godot %s.\nOpening will upgrade or downgrade the project to Godot %s.\n\n"), Variant(feature), Variant(VERSION_BRANCH));
unsupported_features.remove_at(i); unsupported_features.remove_at(i);
i--; i--;

View File

@ -166,7 +166,7 @@ public:
void set_project_path(const String &p_path); void set_project_path(const String &p_path);
void set_tags(const PackedStringArray &p_tags, ProjectList *p_parent_list); void set_tags(const PackedStringArray &p_tags, ProjectList *p_parent_list);
void set_project_icon(const Ref<Texture2D> &p_icon); void set_project_icon(const Ref<Texture2D> &p_icon);
void set_unsupported_features(const PackedStringArray &p_features); void set_unsupported_features(PackedStringArray p_features);
bool should_load_project_icon() const; bool should_load_project_icon() const;
void set_selected(bool p_selected); void set_selected(bool p_selected);