|
31 | 31 | #include "editor_properties.h" |
32 | 32 |
|
33 | 33 | #include "core/config/project_settings.h" |
| 34 | +#include "core/input/input_map.h" |
34 | 35 | #include "editor/create_dialog.h" |
35 | 36 | #include "editor/editor_node.h" |
36 | 37 | #include "editor/editor_properties_array_dict.h" |
@@ -3638,6 +3639,38 @@ static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const Stri |
3638 | 3639 | return hint; |
3639 | 3640 | } |
3640 | 3641 |
|
| 3642 | +static EditorProperty *get_input_action_editor(const String &p_hint_text, bool is_string_name) { |
| 3643 | + // TODO: Should probably use a better editor GUI with a search bar. |
| 3644 | + // Said GUI could also handle showing builtin options, requiring 1 less hint. |
| 3645 | + EditorPropertyTextEnum *editor = memnew(EditorPropertyTextEnum); |
| 3646 | + Vector<String> options; |
| 3647 | + Vector<String> builtin_options; |
| 3648 | + List<PropertyInfo> pinfo; |
| 3649 | + ProjectSettings::get_singleton()->get_property_list(&pinfo); |
| 3650 | + Vector<String> hints = p_hint_text.remove_char(' ').split(",", false); |
| 3651 | + |
| 3652 | + HashMap<String, List<Ref<InputEvent>>> builtins = InputMap::get_singleton()->get_builtins(); |
| 3653 | + bool show_builtin = hints.has("show_builtin"); |
| 3654 | + |
| 3655 | + for (const PropertyInfo &pi : pinfo) { |
| 3656 | + if (!pi.name.begins_with("input/")) { |
| 3657 | + continue; |
| 3658 | + } |
| 3659 | + |
| 3660 | + const String action_name = pi.name.get_slicec('/', 1); |
| 3661 | + if (builtins.has(action_name)) { |
| 3662 | + if (show_builtin) { |
| 3663 | + builtin_options.append(action_name); |
| 3664 | + } |
| 3665 | + } else { |
| 3666 | + options.append(action_name); |
| 3667 | + } |
| 3668 | + } |
| 3669 | + options.append_array(builtin_options); |
| 3670 | + editor->setup(options, is_string_name, hints.has("loose_mode")); |
| 3671 | + return editor; |
| 3672 | +} |
| 3673 | + |
3641 | 3674 | EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide) { |
3642 | 3675 | double default_float_step = EDITOR_GET("interface/inspector/default_float_step"); |
3643 | 3676 |
|
@@ -3751,6 +3784,8 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ |
3751 | 3784 | Vector<String> options = p_hint_text.split(",", false); |
3752 | 3785 | editor->setup(options, false, (p_hint == PROPERTY_HINT_ENUM_SUGGESTION)); |
3753 | 3786 | return editor; |
| 3787 | + } else if (p_hint == PROPERTY_HINT_INPUT_NAME) { |
| 3788 | + return get_input_action_editor(p_hint_text, false); |
3754 | 3789 | } else if (p_hint == PROPERTY_HINT_MULTILINE_TEXT) { |
3755 | 3790 | EditorPropertyMultilineText *editor = memnew(EditorPropertyMultilineText); |
3756 | 3791 | return editor; |
@@ -3903,6 +3938,8 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ |
3903 | 3938 | Vector<String> options = p_hint_text.split(",", false); |
3904 | 3939 | editor->setup(options, true, (p_hint == PROPERTY_HINT_ENUM_SUGGESTION)); |
3905 | 3940 | return editor; |
| 3941 | + } else if (p_hint == PROPERTY_HINT_INPUT_NAME) { |
| 3942 | + return get_input_action_editor(p_hint_text, true); |
3906 | 3943 | } else { |
3907 | 3944 | EditorPropertyText *editor = memnew(EditorPropertyText); |
3908 | 3945 | if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) { |
|
0 commit comments