From a40f559fe20e451b60b9ef33e9f2675358bbb8ac Mon Sep 17 00:00:00 2001 From: Marius Hanl Date: Wed, 8 Mar 2023 23:11:23 +0100 Subject: Add conversion for common Theme Overrides --- editor/project_converter_3_to_4.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'editor/project_converter_3_to_4.cpp') diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index 97b3a11adf..6f21fe8f99 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -165,6 +165,7 @@ public: LocalVector gdscript_signals_regexes; LocalVector shaders_regexes; LocalVector builtin_types_regexes; + LocalVector theme_override_regexes; LocalVector csharp_function_regexes; LocalVector csharp_properties_regexes; LocalVector csharp_signal_regexes; @@ -208,6 +209,10 @@ public: for (unsigned int current_index = 0; RenamesMap3To4::builtin_types_renames[current_index][0]; current_index++) { builtin_types_regexes.push_back(memnew(RegEx(String("\\b") + RenamesMap3To4::builtin_types_renames[current_index][0] + "\\b"))); } + // Theme overrides. + for (unsigned int current_index = 0; RenamesMap3To4::theme_override_renames[current_index][0]; current_index++) { + theme_override_regexes.push_back(memnew(RegEx(String("\\b") + RenamesMap3To4::theme_override_renames[current_index][0] + "\\b"))); + } // CSharp function renames. for (unsigned int current_index = 0; RenamesMap3To4::csharp_function_renames[current_index][0]; current_index++) { csharp_function_regexes.push_back(memnew(RegEx(String("\\b") + RenamesMap3To4::csharp_function_renames[current_index][0] + "\\b"))); @@ -282,6 +287,9 @@ public: for (RegEx *regex : builtin_types_regexes) { memdelete(regex); } + for (RegEx *regex : theme_override_regexes) { + memdelete(regex); + } for (RegEx *regex : csharp_function_regexes) { memdelete(regex); } @@ -387,6 +395,7 @@ bool ProjectConverter3To4::convert() { rename_common(RenamesMap3To4::gdscript_signals_renames, reg_container.gdscript_signals_regexes, source_lines); rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, source_lines); rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, source_lines); + rename_common(RenamesMap3To4::theme_override_renames, reg_container.theme_override_regexes, source_lines); custom_rename(source_lines, "\\.shader", ".gdshader"); } else if (file_name.ends_with(".tscn")) { @@ -404,6 +413,7 @@ bool ProjectConverter3To4::convert() { rename_common(RenamesMap3To4::gdscript_signals_renames, reg_container.gdscript_signals_regexes, source_lines); rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, source_lines); rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, source_lines); + rename_common(RenamesMap3To4::theme_override_renames, reg_container.theme_override_regexes, source_lines); custom_rename(source_lines, "\\.shader", ".gdshader"); } else if (file_name.ends_with(".cs")) { // TODO, C# should use different methods. @@ -566,6 +576,7 @@ bool ProjectConverter3To4::validate_conversion() { changed_elements.append_array(check_for_rename_common(RenamesMap3To4::gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines)); changed_elements.append_array(check_for_rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, lines)); changed_elements.append_array(check_for_rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, lines)); + changed_elements.append_array(check_for_rename_common(RenamesMap3To4::theme_override_renames, reg_container.theme_override_regexes, lines)); changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader")); } else if (file_name.ends_with(".tscn")) { @@ -583,6 +594,7 @@ bool ProjectConverter3To4::validate_conversion() { changed_elements.append_array(check_for_rename_common(RenamesMap3To4::gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines)); changed_elements.append_array(check_for_rename_common(RenamesMap3To4::shaders_renames, reg_container.shaders_regexes, lines)); changed_elements.append_array(check_for_rename_common(RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, lines)); + changed_elements.append_array(check_for_rename_common(RenamesMap3To4::theme_override_renames, reg_container.theme_override_regexes, lines)); changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader")); } else if (file_name.ends_with(".cs")) { @@ -768,6 +780,8 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) { valid = valid && test_conversion_basic("Transform", "Transform3D", RenamesMap3To4::builtin_types_renames, reg_container.builtin_types_regexes, "builtin type"); + valid = valid && test_conversion_basic("custom_constants/margin_right", "theme_override_constants/margin_right", RenamesMap3To4::theme_override_renames, reg_container.theme_override_regexes, "theme overrides"); + // Custom Renames. valid = valid && test_conversion_with_regex("(Connect(A,B,C,D,E,F,G) != OK):", "(Connect(A, new Callable(B, C), D, E, F, G) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container); -- cgit v1.2.3