| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "editor/doc/editor_help.h" |
| 34 |
#include "scene/gui/button.h" |
| 35 |
#include "scene/gui/dialogs.h" |
| 36 |
#include "scene/gui/item_list.h" |
| 37 |
#include "scene/gui/line_edit.h" |
| 38 |
#include "scene/gui/tree.h" |
| 39 |
|
| 40 |
class CreateDialog : public ConfirmationDialog { |
| 41 |
GDCLASS(CreateDialog, ConfirmationDialog); |
| 42 |
|
| 43 |
enum TypeCategory { |
| 44 |
CPP_TYPE, |
| 45 |
PATH_TYPE, |
| 46 |
OTHER_TYPE |
| 47 |
}; |
| 48 |
|
| 49 |
struct TypeInfo { |
| 50 |
StringName type_name; |
| 51 |
PackedStringArray search_keywords; |
| 52 |
}; |
| 53 |
|
| 54 |
LineEdit *search_box = nullptr; |
| 55 |
Tree *search_options = nullptr; |
| 56 |
|
| 57 |
String base_type; |
| 58 |
bool is_base_type_node = false; |
| 59 |
bool allow_abstract_scripts = false; |
| 60 |
String icon_fallback; |
| 61 |
String preferred_search_result_type; |
| 62 |
|
| 63 |
Button *favorite = nullptr; |
| 64 |
Vector<String> favorite_list; |
| 65 |
Tree *favorites = nullptr; |
| 66 |
ItemList *recent = nullptr; |
| 67 |
EditorHelpBit *help_bit = nullptr; |
| 68 |
|
| 69 |
HashMap<String, TreeItem *> search_options_types; |
| 70 |
HashMap<String, String> custom_type_parents; |
| 71 |
HashMap<String, int> custom_type_indices; |
| 72 |
List<TypeInfo> type_info_list; |
| 73 |
HashSet<StringName> type_blacklist; |
| 74 |
HashSet<StringName> custom_type_blocklist; |
| 75 |
|
| 76 |
void _update_search(); |
| 77 |
bool _should_hide_type(const StringName &p_type) const; |
| 78 |
void _add_type(const StringName &p_type, TypeCategory p_type_category, const String &p_match_keyword); |
| 79 |
void _configure_search_option_item(TreeItem *r_item, const StringName &p_type, TypeCategory p_type_category, const String &p_match_keyword); |
| 80 |
float _score_type(const String &p_type, const String &p_search) const; |
| 81 |
bool _is_type_preferred(const String &p_type) const; |
| 82 |
void _script_button_clicked(TreeItem *p_item, int p_column, int p_button_id, MouseButton p_mouse_button_index); |
| 83 |
|
| 84 |
void _fill_type_list(); |
| 85 |
void _cleanup(); |
| 86 |
|
| 87 |
void _sbox_input(const Ref<InputEvent> &p_event); |
| 88 |
void _text_changed(const String &p_newtext); |
| 89 |
void select_type(const String &p_type, bool p_center_on_item = true); |
| 90 |
void _item_selected(); |
| 91 |
void _hide_requested(); |
| 92 |
|
| 93 |
void _confirmed(); |
| 94 |
virtual void cancel_pressed() override; |
| 95 |
|
| 96 |
void _favorite_toggled(); |
| 97 |
|
| 98 |
void _history_selected(int p_idx); |
| 99 |
void _favorite_selected(); |
| 100 |
|
| 101 |
void _history_activated(int p_idx); |
| 102 |
void _favorite_activated(); |
| 103 |
|
| 104 |
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); |
| 105 |
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; |
| 106 |
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); |
| 107 |
|
| 108 |
bool _is_class_disabled_by_feature_profile(const StringName &p_class) const; |
| 109 |
void _load_favorites_and_history(); |
| 110 |
|
| 111 |
protected: |
| 112 |
void _notification(int p_what); |
| 113 |
static void _bind_methods(); |
| 114 |
|
| 115 |
void _save_and_update_favorite_list(); |
| 116 |
|
| 117 |
public: |
| 118 |
Variant instantiate_selected(); |
| 119 |
String get_selected_type(); |
| 120 |
String get_selected_type_name(); |
| 121 |
|
| 122 |
void set_base_type(const String &p_base); |
| 123 |
String get_base_type() const { return base_type; } |
| 124 |
void select_base(); |
| 125 |
|
| 126 |
void set_type_blocklist(const HashSet<StringName> &p_blocklist) { custom_type_blocklist = p_blocklist; } |
| 127 |
void set_preferred_search_result_type(const String &p_preferred_type) { preferred_search_result_type = p_preferred_type; } |
| 128 |
|
| 129 |
void popup_create(bool p_dont_clear, bool p_replace_mode = false, const String &p_current_type = "", const String &p_current_name = ""); |
| 130 |
void for_inherit(); |
| 131 |
|
| 132 |
CreateDialog(); |
| 133 |
}; |