|
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" |
@@ -3570,6 +3571,38 @@ static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const Stri |
3570 | 3571 | return hint; |
3571 | 3572 | } |
3572 | 3573 |
|
| 3574 | +static EditorProperty *get_input_action_editor(const String &p_hint_text, bool is_string_name) { |
| 3575 | + // TODO: Should probably use a better editor GUI with a search bar. |
| 3576 | + // Said GUI could also handle showing builtin options, requiring 1 less hint. |
| 3577 | + EditorPropertyTextEnum *editor = memnew(EditorPropertyTextEnum); |
| 3578 | + Vector<String> options; |
| 3579 | + Vector<String> builtin_options; |
| 3580 | + List<PropertyInfo> pinfo; |
| 3581 | + ProjectSettings::get_singleton()->get_property_list(&pinfo); |
| 3582 | + Vector<String> hints = p_hint_text.remove_char(' ').split(",", false); |
| 3583 | + |
| 3584 | + HashMap<String, List<Ref<InputEvent>>> builtins = InputMap::get_singleton()->get_builtins(); |
| 3585 | + bool show_builtin = hints.has("show_builtin"); |
| 3586 | + |
| 3587 | + for (const PropertyInfo &pi : pinfo) { |
| 3588 | + if (!pi.name.begins_with("input/")) { |
| 3589 | + continue; |
| 3590 | + } |
| 3591 | + |
| 3592 | + const String action_name = pi.name.get_slicec('/', 1); |
| 3593 | + if (builtins.has(action_name)) { |
| 3594 | + if (show_builtin) { |
| 3595 | + builtin_options.append(action_name); |
| 3596 | + } |
| 3597 | + } else { |
| 3598 | + options.append(action_name); |
| 3599 | + } |
| 3600 | + } |
| 3601 | + options.append_array(builtin_options); |
| 3602 | + editor->setup(options, is_string_name, hints.has("loose_mode")); |
| 3603 | + return editor; |
| 3604 | +} |
| 3605 | + |
3573 | 3606 | 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) { |
3574 | 3607 | double default_float_step = EDITOR_GET("interface/inspector/default_float_step"); |
3575 | 3608 |
|
@@ -3680,6 +3713,8 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ |
3680 | 3713 | Vector<String> options = p_hint_text.split(",", false); |
3681 | 3714 | editor->setup(options, false, (p_hint == PROPERTY_HINT_ENUM_SUGGESTION)); |
3682 | 3715 | return editor; |
| 3716 | + } else if (p_hint == PROPERTY_HINT_INPUT_NAME) { |
| 3717 | + return get_input_action_editor(p_hint_text, false); |
3683 | 3718 | } else if (p_hint == PROPERTY_HINT_MULTILINE_TEXT) { |
3684 | 3719 | EditorPropertyMultilineText *editor = memnew(EditorPropertyMultilineText); |
3685 | 3720 | return editor; |
@@ -3832,6 +3867,8 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ |
3832 | 3867 | Vector<String> options = p_hint_text.split(",", false); |
3833 | 3868 | editor->setup(options, true, (p_hint == PROPERTY_HINT_ENUM_SUGGESTION)); |
3834 | 3869 | return editor; |
| 3870 | + } else if (p_hint == PROPERTY_HINT_INPUT_NAME) { |
| 3871 | + return get_input_action_editor(p_hint_text, true); |
3835 | 3872 | } else { |
3836 | 3873 | EditorPropertyText *editor = memnew(EditorPropertyText); |
3837 | 3874 | if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) { |
|
0 commit comments