1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Add UID upgrade tool

Apply suggestions from code review

Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>

memdelete the UID upgrade tool

Remove redeclaration of singleton

Add note about committing .uid files to version control

Add "Learn more" button that links to Godot blog post about UIDs

Detect project from 4.3 or less and automatically display UID upgrade window

Display popup after first run of `_sources_changed`

Apply suggestions from code review

Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>

Replace magic strings with constants

Update editor/editor_node.cpp

Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
This commit is contained in:
Malcolm Anderson
2025-01-26 19:28:57 -08:00
parent b15b24b087
commit d034d124b2
4 changed files with 260 additions and 0 deletions

View File

@@ -163,6 +163,7 @@
#include "editor/surface_upgrade_tool.h"
#include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
#include "editor/uid_upgrade_tool.h"
#include "editor/window_wrapper.h"
#include "modules/modules_enabled.gen.h" // For gdscript, mono.
@@ -651,6 +652,10 @@ void EditorNode::_notification(int p_what) {
run_surface_upgrade_tool = false;
SurfaceUpgradeTool::get_singleton()->connect("upgrade_finished", callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::scan), CONNECT_ONE_SHOT);
SurfaceUpgradeTool::get_singleton()->finish_upgrade();
} else if (run_uid_upgrade_tool) {
run_uid_upgrade_tool = false;
UIDUpgradeTool::get_singleton()->connect("upgrade_finished", callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::scan), CONNECT_ONE_SHOT);
UIDUpgradeTool::get_singleton()->finish_upgrade();
} else {
EditorFileSystem::get_singleton()->scan();
}
@@ -735,6 +740,23 @@ void EditorNode::_notification(int p_what) {
// Save the project after opening to mark it as last modified, except in headless mode.
if (DisplayServer::get_singleton()->window_can_draw()) {
// Try to determine if this project's Godot version was less than 4.4 - if
// so, we'll ask the user if they want to upgrade the project.
PackedStringArray features = ProjectSettings::get_singleton()->get_setting("application/config/features");
if (!features.is_empty()) {
String version_str = features[0];
PackedStringArray version_parts = version_str.split(".", true, 1);
if (version_parts.size() >= 2) {
if (version_parts[0].is_valid_int() && version_parts[1].is_valid_int()) {
int major_ver = version_parts[0].to_int();
int minor_ver = version_parts[1].to_int();
if (major_ver < 4 || (major_ver == 4 && minor_ver < 4)) {
should_prompt_uid_upgrade_tool = true;
}
}
}
}
ProjectSettings::get_singleton()->save();
}
@@ -1180,6 +1202,11 @@ void EditorNode::_sources_changed(bool p_exist) {
EditorResourcePreview::get_singleton()->start();
}
if (should_prompt_uid_upgrade_tool) {
should_prompt_uid_upgrade_tool = false;
uid_upgrade_dialog->popup_on_demand();
}
get_tree()->create_timer(1.0f)->connect("timeout", callable_mp(this, &EditorNode::_remove_lock_file));
}
}
@@ -3317,6 +3344,9 @@ void EditorNode::_tool_menu_option(int p_idx) {
case TOOLS_SURFACE_UPGRADE: {
surface_upgrade_dialog->popup_on_demand();
} break;
case TOOLS_UID_UPGRADE: {
uid_upgrade_dialog->popup_on_demand();
} break;
case TOOLS_CUSTOM: {
if (tool_menu->get_item_submenu(p_idx) == "") {
Callable callback = tool_menu->get_item_metadata(p_idx);
@@ -6864,6 +6894,13 @@ EditorNode::EditorNode() {
SurfaceUpgradeTool::get_singleton()->begin_upgrade();
}
// Same for UID upgrade tool.
uid_upgrade_tool = memnew(UIDUpgradeTool);
run_uid_upgrade_tool = EditorSettings::get_singleton()->get_project_metadata(UIDUpgradeTool::META_UID_UPGRADE_TOOL, UIDUpgradeTool::META_RUN_ON_RESTART, false);
if (run_uid_upgrade_tool) {
UIDUpgradeTool::get_singleton()->begin_upgrade();
}
{
bool agile_input_event_flushing = EDITOR_GET("input/buffering/agile_event_flushing");
bool use_accumulated_input = EDITOR_GET("input/buffering/use_accumulated_input");
@@ -7406,6 +7443,7 @@ EditorNode::EditorNode() {
tool_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/orphan_resource_explorer", TTRC("Orphan Resource Explorer...")), TOOLS_ORPHAN_RESOURCES);
tool_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/engine_compilation_configuration_editor", TTRC("Engine Compilation Configuration Editor...")), TOOLS_BUILD_PROFILE_MANAGER);
tool_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/upgrade_mesh_surfaces", TTRC("Upgrade Mesh Surfaces...")), TOOLS_SURFACE_UPGRADE);
tool_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/upgrade_uids", TTRC("Upgrade UIDs...")), TOOLS_UID_UPGRADE);
project_menu->add_separator();
project_menu->add_shortcut(ED_SHORTCUT("editor/reload_current_project", TTRC("Reload Current Project")), PROJECT_RELOAD_CURRENT_PROJECT);
@@ -7686,6 +7724,9 @@ EditorNode::EditorNode() {
surface_upgrade_dialog = memnew(SurfaceUpgradeDialog);
gui_base->add_child(surface_upgrade_dialog);
uid_upgrade_dialog = memnew(UIDUpgradeDialog);
gui_base->add_child(uid_upgrade_dialog);
confirmation = memnew(ConfirmationDialog);
gui_base->add_child(confirmation);
confirmation->connect(SceneStringName(confirmed), callable_mp(this, &EditorNode::_menu_confirm_current));
@@ -8079,6 +8120,7 @@ EditorNode::~EditorNode() {
memdelete(editor_plugins_force_input_forwarding);
memdelete(progress_hb);
memdelete(surface_upgrade_tool);
memdelete(uid_upgrade_tool);
memdelete(editor_dock_manager);
EditorSettings::destroy();