diff options
Diffstat (limited to 'editor/rename_dialog.cpp')
-rw-r--r-- | editor/rename_dialog.cpp | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index ce37b9e7f6..7586f6eac1 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -109,15 +109,13 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und const int feature_min_height = 160 * EDSCALE; - Ref<Theme> collapse_theme = create_editor_theme(); - collapse_theme->set_icon("checked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowDown", "EditorIcons")); - collapse_theme->set_icon("unchecked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowRight", "EditorIcons")); + cbut_regex = memnew(CheckButton); + cbut_regex->set_text(TTR("Use Regular Expressions")); + vbc->add_child(cbut_regex); - CheckBox *chk_collapse_features = memnew(CheckBox); - chk_collapse_features->set_text(TTR("Advanced Options")); - chk_collapse_features->set_theme(collapse_theme); - chk_collapse_features->set_focus_mode(FOCUS_NONE); - vbc->add_child(chk_collapse_features); + CheckButton *cbut_collapse_features = memnew(CheckButton); + cbut_collapse_features->set_text(TTR("Advanced Options")); + vbc->add_child(cbut_collapse_features); tabc_features = memnew(TabContainer); tabc_features->set_tab_align(TabContainer::ALIGN_LEFT); @@ -201,7 +199,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und grd_substitute->add_child(but_insert_count); chk_per_level_counter = memnew(CheckBox); - chk_per_level_counter->set_text(TTR("Per Level counter")); + chk_per_level_counter->set_text(TTR("Per-level Counter")); chk_per_level_counter->set_tooltip(TTR("If set the counter restarts for each group of child nodes")); vbc_substitute->add_child(chk_per_level_counter); @@ -239,18 +237,6 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und spn_count_padding->set_step(1); hbc_count_options->add_child(spn_count_padding); - // ---- Tab RegEx - - VBoxContainer *vbc_regex = memnew(VBoxContainer); - vbc_regex->set_h_size_flags(SIZE_EXPAND_FILL); - vbc_regex->set_name(TTR("Regular Expressions")); - vbc_regex->set_custom_minimum_size(Size2(0, feature_min_height)); - tabc_features->add_child(vbc_regex); - - cbut_regex = memnew(CheckBox); - cbut_regex->set_text(TTR("Regular Expressions")); - vbc_regex->add_child(cbut_regex); - // ---- Tab Process VBoxContainer *vbc_process = memnew(VBoxContainer); @@ -274,8 +260,8 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und opt_style = memnew(OptionButton); opt_style->add_item(TTR("Keep")); - opt_style->add_item(TTR("CamelCase to under_scored")); - opt_style->add_item(TTR("under_scored to CamelCase")); + opt_style->add_item(TTR("PascalCase to snake_case")); + opt_style->add_item(TTR("snake_case to PascalCase")); hbc_style->add_child(opt_style); // ------ Case @@ -305,7 +291,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und lbl_preview = memnew(Label); lbl_preview->set_text(""); - lbl_preview->add_color_override("font_color", Color(1, 0.5f, 0, 1)); + lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); vbc->add_child(lbl_preview); // ---- Dialog related @@ -320,7 +306,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und // ---- Connections - chk_collapse_features->connect("toggled", this, "_features_toggled"); + cbut_collapse_features->connect("toggled", this, "_features_toggled"); // Substitite Buttons @@ -420,9 +406,12 @@ void RenameDialog::_update_preview(String new_text) { lbl_preview->set_text(new_name); if (new_name == preview_node->get_name()) { - lbl_preview->add_color_override("font_color", Color(0, 0.5f, 0.25f, 1)); + // New name is identical to the old one. Don't color it as much to avoid distracting the user. + const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_color("accent_color", "Editor"); + const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_color("default_color", "RichTextLabel"); + lbl_preview->add_color_override("font_color", accent_color.linear_interpolate(text_color, 0.5)); } else { - lbl_preview->add_color_override("font_color", Color(0, 1, 0.5f, 1)); + lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("success_color", "Editor")); } } @@ -507,9 +496,9 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * } self->has_errors = true; - self->lbl_preview_title->set_text(TTR("Error")); - self->lbl_preview->add_color_override("font_color", Color(1, 0.25f, 0, 1)); - self->lbl_preview->set_text(err_str); + self->lbl_preview_title->set_text(TTR("Regular Expression Error")); + self->lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); + self->lbl_preview->set_text(vformat(TTR("At character %s"), err_str)); } String RenameDialog::_regex(const String &pattern, const String &subject, const String &replacement) { @@ -526,18 +515,18 @@ String RenameDialog::_postprocess(const String &subject) { String result = subject; if (style_id == 1) { + // PascalCase to snake_case - // CamelCase to Under_Line result = result.camelcase_to_underscore(true); result = _regex("_+", result, "_"); } else if (style_id == 2) { + // snake_case to PascalCase - // Under_Line to CamelCase RegEx pattern("_+(.?)"); Array matches = pattern.search_all(result); - // _ name would become empty. Ignore + // The name `_` would become empty; ignore it. if (matches.size() && result != "_") { String buffer; int start = 0; |