Skip to content

Commit

Permalink
Fix node names of submenu items across the editor
Browse files Browse the repository at this point in the history
Also removes some programmer remarks and fixes some docs.
  • Loading branch information
YuriSizov committed Nov 8, 2023
1 parent 3e7f638 commit b04b546
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 44 deletions.
2 changes: 1 addition & 1 deletion doc/classes/EditorPlugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@
<param index="0" name="name" type="String" />
<param index="1" name="submenu" type="PopupMenu" />
<description>
Adds a custom [PopupMenu] submenu under [b]Project &gt; Tools &gt;[/b] [param name]. Use [code]remove_tool_menu_item(name)[/code] on plugin clean up to remove the menu.
Adds a custom [PopupMenu] submenu under [b]Project &gt; Tools &gt;[/b] [param name]. Use [method remove_tool_menu_item] on plugin clean up to remove the menu.
</description>
</method>
<method name="add_translation_parser_plugin">
Expand Down
5 changes: 2 additions & 3 deletions editor/plugins/animation_blend_space_1d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
classes.sort_custom<StringName::AlphCompare>();

menu->add_submenu_item(TTR("Add Animation"), "animations");
menu->add_submenu_item(TTR("Add Animation"), "AddAnimations");

List<StringName> names;
tree->get_animation_list(&names);
Expand Down Expand Up @@ -796,15 +796,14 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {

error_label = memnew(Label);
error_panel->add_child(error_label);
error_label->set_text("hmmm");

menu = memnew(PopupMenu);
add_child(menu);
menu->connect("id_pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_add_menu_type));

animations_menu = memnew(PopupMenu);
menu->add_child(animations_menu);
animations_menu->set_name("animations");
animations_menu->set_name("AddAnimations");
animations_menu->connect("index_pressed", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_add_animation_type));

open_file = memnew(EditorFileDialog);
Expand Down
5 changes: 2 additions & 3 deletions editor/plugins/animation_blend_space_2d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
classes.sort_custom<StringName::AlphCompare>();

ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
menu->add_submenu_item(TTR("Add Animation"), "animations");
menu->add_submenu_item(TTR("Add Animation"), "AddAnimations");

List<StringName> names;
tree->get_animation_list(&names);
Expand Down Expand Up @@ -1073,7 +1073,6 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
add_child(error_panel);
error_label = memnew(Label);
error_panel->add_child(error_label);
error_label->set_text("eh");

set_custom_minimum_size(Size2(0, 300 * EDSCALE));

Expand All @@ -1083,7 +1082,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {

animations_menu = memnew(PopupMenu);
menu->add_child(animations_menu);
animations_menu->set_name("animations");
animations_menu->set_name("AddAnimations");
animations_menu->connect("index_pressed", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_add_animation_type));

open_file = memnew(EditorFileDialog);
Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/animation_state_machine_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void AnimationNodeStateMachineEditor::_open_menu(const Vector2 &p_position) {

List<StringName> animation_names;
tree->get_animation_list(&animation_names);
menu->add_submenu_item(TTR("Add Animation"), "animations");
menu->add_submenu_item(TTR("Add Animation"), "AddAnimations");
if (animation_names.is_empty()) {
menu->set_item_disabled(menu->get_item_idx_from_text(TTR("Add Animation")), true);
} else {
Expand Down Expand Up @@ -1774,7 +1774,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {

animations_menu = memnew(PopupMenu);
menu->add_child(animations_menu);
animations_menu->set_name("animations");
animations_menu->set_name("AddAnimations");
animations_menu->connect("index_pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_add_animation_type));

connect_menu = memnew(PopupMenu);
Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/debugger_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(PopupMenu *p_debug_menu) {

// Multi-instance, start/stop
instances_menu = memnew(PopupMenu);
instances_menu->set_name("run_instances");
instances_menu->set_name("RunInstances");
instances_menu->set_hide_on_checkable_item_selection(false);

debug_menu->add_child(instances_menu);
debug_menu->add_separator();
debug_menu->add_submenu_item(TTR("Run Multiple Instances"), "run_instances");
debug_menu->add_submenu_item(TTR("Run Multiple Instances"), "RunInstances");

for (int i = 1; i <= 4; i++) {
instances_menu->add_radio_check_item(vformat(TTRN("Run %d Instance", "Run %d Instances", i), i));
Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5120,8 +5120,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
display_submenu->add_radio_check_item(TTR("Motion Vectors"), VIEW_DISPLAY_MOTION_VECTORS);
display_submenu->add_radio_check_item(TTR("Internal Buffer"), VIEW_DISPLAY_INTERNAL_BUFFER);

display_submenu->set_name("display_advanced");
view_menu->get_popup()->add_submenu_item(TTR("Display Advanced..."), "display_advanced", VIEW_DISPLAY_ADVANCED);
display_submenu->set_name("DisplayAdvanced");
view_menu->get_popup()->add_submenu_item(TTR("Display Advanced..."), "DisplayAdvanced", VIEW_DISPLAY_ADVANCED);
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("View Environment")), VIEW_ENVIRONMENT);
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("View Gizmos")), VIEW_GIZMOS);
Expand Down
28 changes: 14 additions & 14 deletions editor/plugins/script_text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,7 @@ void ScriptTextEditor::_enable_code_editor() {
edit_menu->get_popup()->add_separator();
{
PopupMenu *sub_menu = memnew(PopupMenu);
sub_menu->set_name("line_menu");
sub_menu->set_name("LineMenu");
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_up"), EDIT_MOVE_LINE_UP);
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_down"), EDIT_MOVE_LINE_DOWN);
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent"), EDIT_INDENT);
Expand All @@ -2247,46 +2247,46 @@ void ScriptTextEditor::_enable_code_editor() {
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT);
sub_menu->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
edit_menu->get_popup()->add_child(sub_menu);
edit_menu->get_popup()->add_submenu_item(TTR("Line"), "line_menu");
edit_menu->get_popup()->add_submenu_item(TTR("Line"), "LineMenu");
}
{
PopupMenu *sub_menu = memnew(PopupMenu);
sub_menu->set_name("folding_menu");
sub_menu->set_name("FoldingMenu");
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE);
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_all_lines"), EDIT_FOLD_ALL_LINES);
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_all_lines"), EDIT_UNFOLD_ALL_LINES);
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/create_code_region"), EDIT_CREATE_CODE_REGION);
sub_menu->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
edit_menu->get_popup()->add_child(sub_menu);
edit_menu->get_popup()->add_submenu_item(TTR("Folding"), "folding_menu");
edit_menu->get_popup()->add_submenu_item(TTR("Folding"), "FoldingMenu");
}
edit_menu->get_popup()->add_separator();
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_text_completion_query"), EDIT_COMPLETE);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE);
{
PopupMenu *sub_menu = memnew(PopupMenu);
sub_menu->set_name("indent_menu");
sub_menu->set_name("IndentMenu");
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES);
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS);
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/auto_indent"), EDIT_AUTO_INDENT);
sub_menu->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
edit_menu->get_popup()->add_child(sub_menu);
edit_menu->get_popup()->add_submenu_item(TTR("Indentation"), "indent_menu");
edit_menu->get_popup()->add_submenu_item(TTR("Indentation"), "IndentMenu");
}
edit_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
edit_menu->get_popup()->add_separator();
{
PopupMenu *sub_menu = memnew(PopupMenu);
sub_menu->set_name("convert_case");
sub_menu->set_name("ConvertCase");
sub_menu->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase"), KeyModifierMask::SHIFT | Key::F4), EDIT_TO_UPPERCASE);
sub_menu->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase"), KeyModifierMask::SHIFT | Key::F5), EDIT_TO_LOWERCASE);
sub_menu->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize"), KeyModifierMask::SHIFT | Key::F6), EDIT_CAPITALIZE);
sub_menu->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
edit_menu->get_popup()->add_child(sub_menu);
edit_menu->get_popup()->add_submenu_item(TTR("Convert Case"), "convert_case");
edit_menu->get_popup()->add_submenu_item(TTR("Convert Case"), "ConvertCase");
}
edit_menu->get_popup()->add_child(highlighter_menu);
edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "highlighter_menu");
edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "HighlighterMenu");
highlighter_menu->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_change_syntax_highlighter));

edit_hb->add_child(search_menu);
Expand All @@ -2309,13 +2309,13 @@ void ScriptTextEditor::_enable_code_editor() {
goto_menu->get_popup()->add_separator();

goto_menu->get_popup()->add_child(bookmarks_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "BookmarksMenu");
_update_bookmark_list();
bookmarks_menu->connect("about_to_popup", callable_mp(this, &ScriptTextEditor::_update_bookmark_list));
bookmarks_menu->connect("index_pressed", callable_mp(this, &ScriptTextEditor::_bookmark_item_pressed));

goto_menu->get_popup()->add_child(breakpoints_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Breakpoints"), "Breakpoints");
goto_menu->get_popup()->add_submenu_item(TTR("Breakpoints"), "BreakpointsMenu");
_update_breakpoint_list();
breakpoints_menu->connect("about_to_popup", callable_mp(this, &ScriptTextEditor::_update_breakpoint_list));
breakpoints_menu->connect("index_pressed", callable_mp(this, &ScriptTextEditor::_breakpoint_item_pressed));
Expand Down Expand Up @@ -2378,7 +2378,7 @@ ScriptTextEditor::ScriptTextEditor() {
edit_menu->set_shortcut_context(this);

highlighter_menu = memnew(PopupMenu);
highlighter_menu->set_name("highlighter_menu");
highlighter_menu->set_name("HighlighterMenu");

Ref<EditorPlainTextSyntaxHighlighter> plain_highlighter;
plain_highlighter.instantiate();
Expand All @@ -2400,10 +2400,10 @@ ScriptTextEditor::ScriptTextEditor() {
goto_menu->set_shortcut_context(this);

bookmarks_menu = memnew(PopupMenu);
bookmarks_menu->set_name("Bookmarks");
bookmarks_menu->set_name("BookmarksMenu");

breakpoints_menu = memnew(PopupMenu);
breakpoints_menu->set_name("Breakpoints");
breakpoints_menu->set_name("BreakpointsMenu");

connection_info_dialog = memnew(ConnectionInfoDialog);

Expand Down
12 changes: 6 additions & 6 deletions editor/plugins/text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,18 +662,18 @@ TextEditor::TextEditor() {

edit_menu->get_popup()->add_separator();
PopupMenu *convert_case = memnew(PopupMenu);
convert_case->set_name("convert_case");
convert_case->set_name("ConvertCase");
edit_menu->get_popup()->add_child(convert_case);
edit_menu->get_popup()->add_submenu_item(TTR("Convert Case"), "convert_case");
edit_menu->get_popup()->add_submenu_item(TTR("Convert Case"), "ConvertCase");
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase")), EDIT_TO_UPPERCASE);
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase")), EDIT_TO_LOWERCASE);
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE);
convert_case->connect("id_pressed", callable_mp(this, &TextEditor::_edit_option));

highlighter_menu = memnew(PopupMenu);
highlighter_menu->set_name("highlighter_menu");
highlighter_menu->set_name("HighlighterMenu");
edit_menu->get_popup()->add_child(highlighter_menu);
edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "highlighter_menu");
edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "HighlighterMenu");
highlighter_menu->connect("id_pressed", callable_mp(this, &TextEditor::_change_syntax_highlighter));

Ref<EditorPlainTextSyntaxHighlighter> plain_highlighter;
Expand All @@ -696,9 +696,9 @@ TextEditor::TextEditor() {
goto_menu->get_popup()->add_separator();

bookmarks_menu = memnew(PopupMenu);
bookmarks_menu->set_name("Bookmarks");
bookmarks_menu->set_name("BookmarksMenu");
goto_menu->get_popup()->add_child(bookmarks_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "BookmarksMenu");
_update_bookmark_list();
bookmarks_menu->connect("about_to_popup", callable_mp(this, &TextEditor::_update_bookmark_list));
bookmarks_menu->connect("index_pressed", callable_mp(this, &TextEditor::_bookmark_item_pressed));
Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/text_shader_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,9 @@ TextShaderEditor::TextShaderEditor() {
goto_menu->get_popup()->add_separator();

bookmarks_menu = memnew(PopupMenu);
bookmarks_menu->set_name("Bookmarks");
bookmarks_menu->set_name("BookmarksMenu");
goto_menu->get_popup()->add_child(bookmarks_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "BookmarksMenu");
_update_bookmark_list();
bookmarks_menu->connect("about_to_popup", callable_mp(this, &TextShaderEditor::_update_bookmark_list));
bookmarks_menu->connect("index_pressed", callable_mp(this, &TextShaderEditor::_bookmark_item_pressed));
Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/theme_editor_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ DefaultThemeEditorPreview::DefaultThemeEditorPreview() {

PopupMenu *test_submenu = memnew(PopupMenu);
test_menu_button->get_popup()->add_child(test_submenu);
test_submenu->set_name("submenu");
test_menu_button->get_popup()->add_submenu_item(TTR("Submenu"), "submenu");
test_submenu->set_name("SubMenu");
test_menu_button->get_popup()->add_submenu_item(TTR("Submenu"), "SubMenu");
test_submenu->add_item(TTR("Subitem 1"));
test_submenu->add_item(TTR("Subitem 2"));
first_vb->add_child(test_menu_button);
Expand Down
8 changes: 4 additions & 4 deletions editor/plugins/version_control_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,18 +1443,18 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {

extra_options_remove_branch_list = memnew(PopupMenu);
extra_options_remove_branch_list->connect(SNAME("id_pressed"), callable_mp(this, &VersionControlEditorPlugin::_popup_branch_remove_confirm));
extra_options_remove_branch_list->set_name("Remove Branch");
extra_options_remove_branch_list->set_name("RemoveBranch");
extra_options->get_popup()->add_child(extra_options_remove_branch_list);
extra_options->get_popup()->add_submenu_item(TTR("Remove Branch"), "Remove Branch");
extra_options->get_popup()->add_submenu_item(TTR("Remove Branch"), "RemoveBranch");

extra_options->get_popup()->add_separator();
extra_options->get_popup()->add_item(TTR("Create New Remote"), EXTRA_OPTION_CREATE_REMOTE);

extra_options_remove_remote_list = memnew(PopupMenu);
extra_options_remove_remote_list->connect(SNAME("id_pressed"), callable_mp(this, &VersionControlEditorPlugin::_popup_remote_remove_confirm));
extra_options_remove_remote_list->set_name("Remove Remote");
extra_options_remove_remote_list->set_name("RemoveRemote");
extra_options->get_popup()->add_child(extra_options_remove_remote_list);
extra_options->get_popup()->add_submenu_item(TTR("Remove Remote"), "Remove Remote");
extra_options->get_popup()->add_submenu_item(TTR("Remove Remote"), "RemoveRemote");

change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_NEW] = TTR("New");
change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = TTR("Modified");
Expand Down
4 changes: 2 additions & 2 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3056,7 +3056,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) {
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj);

if (menu->get_item_count() == 0) {
menu->add_submenu_item(TTR("Sub-Resources"), "Sub-Resources");
menu->add_submenu_item(TTR("Sub-Resources"), "SubResources");
}
menu_subresources->add_icon_item(icon, E.name.capitalize(), EDIT_SUBRESOURCE_BASE + subresources.size());
menu_subresources->set_item_indent(-1, p_depth);
Expand Down Expand Up @@ -4142,7 +4142,7 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec
menu->connect("id_pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(false));

menu_subresources = memnew(PopupMenu);
menu_subresources->set_name("Sub-Resources");
menu_subresources->set_name("SubResources");
menu_subresources->connect("id_pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(false));
menu->add_child(menu_subresources);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ public override void _EnablePlugin()

AddChild(new HotReloadAssemblyWatcher { Name = "HotReloadAssemblyWatcher" });

_menuPopup = new PopupMenu();
_menuPopup = new PopupMenu
{
Name = "CSharpTools",
};
_menuPopup.Hide();

AddToolSubmenuItem("C#", _menuPopup);
Expand Down

0 comments on commit b04b546

Please sign in to comment.