| 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 "scene/gui/control.h" |
| 34 |
|
| 35 |
class AcceptDialog; |
| 36 |
class Button; |
| 37 |
class CheckButton; |
| 38 |
class EditorEventSearchBar; |
| 39 |
class EventListenerLineEdit; |
| 40 |
class HBoxContainer; |
| 41 |
class InputEventConfigurationDialog; |
| 42 |
class LineEdit; |
| 43 |
class Tree; |
| 44 |
|
| 45 |
class ActionMapEditor : public Control { |
| 46 |
GDCLASS(ActionMapEditor, Control); |
| 47 |
|
| 48 |
public: |
| 49 |
struct ActionInfo { |
| 50 |
String name; |
| 51 |
Dictionary action; |
| 52 |
bool has_initial = false; |
| 53 |
Dictionary action_initial; |
| 54 |
|
| 55 |
Ref<Texture2D> icon; |
| 56 |
bool editable = true; |
| 57 |
}; |
| 58 |
|
| 59 |
private: |
| 60 |
enum ItemButton { |
| 61 |
BUTTON_ADD_EVENT, |
| 62 |
BUTTON_EDIT_EVENT, |
| 63 |
BUTTON_REMOVE_ACTION, |
| 64 |
BUTTON_REMOVE_EVENT, |
| 65 |
BUTTON_REVERT_ACTION, |
| 66 |
}; |
| 67 |
|
| 68 |
Vector<ActionInfo> actions_cache; |
| 69 |
Tree *action_tree = nullptr; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
Dictionary current_action; |
| 74 |
String current_action_name; |
| 75 |
int current_action_event_index = -1; |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
InputEventConfigurationDialog *event_config_dialog = nullptr; |
| 80 |
AcceptDialog *message = nullptr; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
bool show_builtin_actions = false; |
| 85 |
CheckButton *show_builtin_actions_checkbutton = nullptr; |
| 86 |
EditorEventSearchBar *action_list_search_bar = nullptr; |
| 87 |
|
| 88 |
HBoxContainer *add_hbox = nullptr; |
| 89 |
LineEdit *add_edit = nullptr; |
| 90 |
Button *add_button = nullptr; |
| 91 |
|
| 92 |
void _event_config_confirmed(); |
| 93 |
|
| 94 |
void _add_action_pressed(); |
| 95 |
void _add_edit_text_changed(const String &p_name); |
| 96 |
String _check_new_action_name(const String &p_name); |
| 97 |
bool _has_action(const String &p_name) const; |
| 98 |
void _add_action(const String &p_name); |
| 99 |
void _action_edited(); |
| 100 |
|
| 101 |
void _tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button); |
| 102 |
void _tree_item_activated(); |
| 103 |
void _on_search_bar_value_changed(); |
| 104 |
bool _should_display_action(const String &p_name, const Array &p_events) const; |
| 105 |
|
| 106 |
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); |
| 107 |
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; |
| 108 |
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); |
| 109 |
|
| 110 |
void _set_show_builtin_actions(bool p_show); |
| 111 |
|
| 112 |
protected: |
| 113 |
void _notification(int p_what); |
| 114 |
static void _bind_methods(); |
| 115 |
|
| 116 |
public: |
| 117 |
LineEdit *get_search_box() const; |
| 118 |
LineEdit *get_path_box() const; |
| 119 |
InputEventConfigurationDialog *get_configuration_dialog(); |
| 120 |
|
| 121 |
|
| 122 |
void update_action_list(const Vector<ActionInfo> &p_action_infos = Vector<ActionInfo>()); |
| 123 |
void show_message(const String &p_message); |
| 124 |
|
| 125 |
ActionMapEditor(); |
| 126 |
}; |