| 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/box_container.h" |
| 34 |
#include "scene/gui/button.h" |
| 35 |
#include "scene/gui/tree.h" |
| 36 |
|
| 37 |
class EditorFileDialog; |
| 38 |
|
| 39 |
class EditorAutoloadSettings : public VBoxContainer { |
| 40 |
GDCLASS(EditorAutoloadSettings, VBoxContainer); |
| 41 |
|
| 42 |
enum { |
| 43 |
BUTTON_OPEN, |
| 44 |
BUTTON_MOVE_UP, |
| 45 |
BUTTON_MOVE_DOWN, |
| 46 |
BUTTON_DELETE |
| 47 |
}; |
| 48 |
|
| 49 |
String path = "res://"; |
| 50 |
String autoload_changed = "autoload_changed"; |
| 51 |
|
| 52 |
struct AutoloadInfo { |
| 53 |
String name; |
| 54 |
String path; |
| 55 |
bool is_singleton = false; |
| 56 |
bool in_editor = false; |
| 57 |
int order = 0; |
| 58 |
Node *node = nullptr; |
| 59 |
|
| 60 |
bool operator==(const AutoloadInfo &p_info) const { |
| 61 |
return order == p_info.order; |
| 62 |
} |
| 63 |
}; |
| 64 |
|
| 65 |
List<AutoloadInfo> autoload_cache; |
| 66 |
|
| 67 |
bool updating_autoload = false; |
| 68 |
String selected_autoload; |
| 69 |
|
| 70 |
Tree *tree = nullptr; |
| 71 |
LineEdit *autoload_add_name = nullptr; |
| 72 |
Button *add_autoload = nullptr; |
| 73 |
LineEdit *autoload_add_path = nullptr; |
| 74 |
Label *error_message = nullptr; |
| 75 |
Button *browse_button = nullptr; |
| 76 |
EditorFileDialog *file_dialog = nullptr; |
| 77 |
|
| 78 |
bool _autoload_name_is_valid(const String &p_name, String *r_error = nullptr); |
| 79 |
|
| 80 |
void _autoload_add(); |
| 81 |
void _autoload_selected(); |
| 82 |
void _autoload_edited(); |
| 83 |
void _autoload_button_pressed(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button); |
| 84 |
void _autoload_activated(); |
| 85 |
void _autoload_path_text_changed(const String &p_path); |
| 86 |
void _autoload_text_submitted(const String &p_name); |
| 87 |
void _autoload_text_changed(const String &p_name); |
| 88 |
void _autoload_open(const String &fpath); |
| 89 |
void _autoload_file_callback(const String &p_path); |
| 90 |
Node *_create_autoload(const String &p_path); |
| 91 |
|
| 92 |
void _script_created(Ref<Script> p_script); |
| 93 |
|
| 94 |
Variant get_drag_data_fw(const Point2 &p_point, Control *p_control); |
| 95 |
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const; |
| 96 |
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control); |
| 97 |
|
| 98 |
void _set_autoload_add_path(const String &p_text); |
| 99 |
void _browse_autoload_add_path(); |
| 100 |
|
| 101 |
protected: |
| 102 |
void _notification(int p_what); |
| 103 |
static void _bind_methods(); |
| 104 |
|
| 105 |
public: |
| 106 |
void init_autoloads(); |
| 107 |
void update_autoload(); |
| 108 |
bool autoload_add(const String &p_name, const String &p_path); |
| 109 |
void autoload_remove(const String &p_name); |
| 110 |
|
| 111 |
LineEdit *get_path_box() const; |
| 112 |
|
| 113 |
EditorAutoloadSettings(); |
| 114 |
~EditorAutoloadSettings(); |
| 115 |
}; |