| 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/dialogs.h" |
| 34 |
|
| 35 |
class Button; |
| 36 |
class CheckBox; |
| 37 |
class CheckButton; |
| 38 |
class EditorValidationPanel; |
| 39 |
class Label; |
| 40 |
class LineEdit; |
| 41 |
class PopupMenu; |
| 42 |
class Tree; |
| 43 |
class TreeItem; |
| 44 |
|
| 45 |
class GroupsEditor : public VBoxContainer { |
| 46 |
GDCLASS(GroupsEditor, VBoxContainer); |
| 47 |
|
| 48 |
const String GLOBAL_GROUP_PREFIX = "global_group/"; |
| 49 |
|
| 50 |
bool updating_tree = false; |
| 51 |
bool updating_groups = false; |
| 52 |
bool groups_dirty = false; |
| 53 |
bool update_groups_and_tree_queued = false; |
| 54 |
|
| 55 |
LocalVector<Node *> selection; |
| 56 |
Node *scene_root_node = nullptr; |
| 57 |
SceneTree *scene_tree = nullptr; |
| 58 |
|
| 59 |
ConfirmationDialog *add_group_dialog = nullptr; |
| 60 |
LineEdit *add_group_name = nullptr; |
| 61 |
LineEdit *add_group_description = nullptr; |
| 62 |
CheckButton *global_group_button = nullptr; |
| 63 |
EditorValidationPanel *add_validation_panel = nullptr; |
| 64 |
|
| 65 |
ConfirmationDialog *rename_group_dialog = nullptr; |
| 66 |
LineEdit *rename_group = nullptr; |
| 67 |
CheckBox *rename_check_box = nullptr; |
| 68 |
EditorValidationPanel *rename_validation_panel = nullptr; |
| 69 |
|
| 70 |
ConfirmationDialog *remove_group_dialog = nullptr; |
| 71 |
CheckBox *remove_check_box = nullptr; |
| 72 |
Label *remove_label = nullptr; |
| 73 |
|
| 74 |
PopupMenu *menu = nullptr; |
| 75 |
|
| 76 |
VBoxContainer *holder = nullptr; |
| 77 |
LineEdit *filter = nullptr; |
| 78 |
Button *add = nullptr; |
| 79 |
Tree *tree = nullptr; |
| 80 |
Label *select_a_node = nullptr; |
| 81 |
|
| 82 |
HashMap<ObjectID, HashMap<StringName, bool>> scene_groups_cache; |
| 83 |
HashMap<StringName, bool> scene_groups_for_caching; |
| 84 |
|
| 85 |
HashMap<StringName, bool> scene_groups; |
| 86 |
HashMap<StringName, String> global_groups; |
| 87 |
|
| 88 |
void _update_scene_groups(const ObjectID &p_id); |
| 89 |
void _cache_scene_groups(const ObjectID &p_id); |
| 90 |
|
| 91 |
void _show_add_group_dialog(); |
| 92 |
void _show_rename_group_dialog(); |
| 93 |
void _show_remove_group_dialog(); |
| 94 |
|
| 95 |
void _check_add(); |
| 96 |
void _check_rename(); |
| 97 |
void _validate_name(const String &p_name, EditorValidationPanel *p_validation_panel); |
| 98 |
|
| 99 |
void _update_tree(); |
| 100 |
|
| 101 |
void _update_groups(); |
| 102 |
void _load_scene_groups(Node *p_node); |
| 103 |
|
| 104 |
void _add_scene_group(const String &p_name); |
| 105 |
void _rename_scene_group(const String &p_old_name, const String &p_new_name); |
| 106 |
void _remove_scene_group(const String &p_name); |
| 107 |
|
| 108 |
bool _has_group(const String &p_name); |
| 109 |
void _set_group_checked(const String &p_name, bool p_checked); |
| 110 |
|
| 111 |
void _confirm_add(); |
| 112 |
void _confirm_rename(); |
| 113 |
void _confirm_delete(); |
| 114 |
|
| 115 |
void _item_edited(); |
| 116 |
void _item_mouse_selected(const Vector2 &p_pos, MouseButton p_mouse_button); |
| 117 |
void _modify_group(Object *p_item, int p_column, int p_id, MouseButton p_mouse_button); |
| 118 |
void _menu_id_pressed(int p_id); |
| 119 |
|
| 120 |
void _update_groups_and_tree(); |
| 121 |
void _queue_update_groups_and_tree(); |
| 122 |
|
| 123 |
void _groups_gui_input(Ref<InputEvent> p_event); |
| 124 |
|
| 125 |
void _node_removed(Node *p_node); |
| 126 |
|
| 127 |
void _add_to_group(const StringName &p_name, bool p_persist, const Array &p_nodes); |
| 128 |
void _remove_from_group(const StringName &p_name, const Array &p_nodes); |
| 129 |
void _get_group_mask(const StringName &p_name, Array &r_nodes, bool p_invert); |
| 130 |
bool _can_edit(const StringName &p_group); |
| 131 |
|
| 132 |
protected: |
| 133 |
void _notification(int p_what); |
| 134 |
static void _bind_methods(); |
| 135 |
|
| 136 |
public: |
| 137 |
enum ModifyButton { |
| 138 |
DELETE_GROUP, |
| 139 |
COPY_GROUP, |
| 140 |
RENAME_GROUP, |
| 141 |
CONVERT_GROUP, |
| 142 |
}; |
| 143 |
|
| 144 |
void set_selection(const Vector<Node *> &p_nodes); |
| 145 |
|
| 146 |
GroupsEditor(); |
| 147 |
}; |