| 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/settings/editor_settings.h" |
| 34 |
#include "scene/gui/check_box.h" |
| 35 |
#include "scene/gui/dialogs.h" |
| 36 |
#include "scene/gui/grid_container.h" |
| 37 |
#include "scene/gui/line_edit.h" |
| 38 |
#include "scene/gui/option_button.h" |
| 39 |
#include "scene/gui/panel_container.h" |
| 40 |
|
| 41 |
class EditorFileDialog; |
| 42 |
class EditorValidationPanel; |
| 43 |
|
| 44 |
class ShaderCreateDialog : public ConfirmationDialog { |
| 45 |
GDCLASS(ShaderCreateDialog, ConfirmationDialog); |
| 46 |
|
| 47 |
enum { |
| 48 |
MSG_ID_SHADER, |
| 49 |
MSG_ID_PATH, |
| 50 |
MSG_ID_BUILT_IN, |
| 51 |
}; |
| 52 |
|
| 53 |
struct ShaderTypeData { |
| 54 |
List<String> extensions; |
| 55 |
String default_extension; |
| 56 |
bool use_templates = false; |
| 57 |
}; |
| 58 |
|
| 59 |
List<ShaderTypeData> type_data; |
| 60 |
|
| 61 |
GridContainer *gc = nullptr; |
| 62 |
EditorValidationPanel *validation_panel = nullptr; |
| 63 |
OptionButton *type_menu = nullptr; |
| 64 |
OptionButton *mode_menu = nullptr; |
| 65 |
OptionButton *template_menu = nullptr; |
| 66 |
CheckBox *internal = nullptr; |
| 67 |
LineEdit *file_path = nullptr; |
| 68 |
Button *path_button = nullptr; |
| 69 |
EditorFileDialog *file_browse = nullptr; |
| 70 |
AcceptDialog *alert = nullptr; |
| 71 |
|
| 72 |
String initial_base_path; |
| 73 |
String path_error; |
| 74 |
bool is_new_shader_created = true; |
| 75 |
bool is_path_valid = false; |
| 76 |
bool is_built_in = false; |
| 77 |
bool built_in_enabled = true; |
| 78 |
bool load_enabled = false; |
| 79 |
bool re_check_path = false; |
| 80 |
int current_type = -1; |
| 81 |
int current_mode = 0; |
| 82 |
int current_template = 0; |
| 83 |
|
| 84 |
virtual void _update_language_info(); |
| 85 |
|
| 86 |
void _path_hbox_sorted(); |
| 87 |
void _path_changed(const String &p_path = String()); |
| 88 |
void _path_submitted(const String &p_path = String()); |
| 89 |
void _type_changed(int p_type = 0); |
| 90 |
void _built_in_toggled(bool p_enabled); |
| 91 |
void _template_changed(int p_template = 0); |
| 92 |
void _mode_changed(int p_mode = 0); |
| 93 |
void _browse_path(); |
| 94 |
void _file_selected(const String &p_file); |
| 95 |
void _refresh_type_icons(); |
| 96 |
String _validate_path(const String &p_path); |
| 97 |
virtual void ok_pressed() override; |
| 98 |
void _create_new(); |
| 99 |
void _load_exist(); |
| 100 |
void _update_dialog(); |
| 101 |
|
| 102 |
protected: |
| 103 |
void _notification(int p_what); |
| 104 |
static void _bind_methods(); |
| 105 |
|
| 106 |
public: |
| 107 |
void config(const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true, const String &p_preferred_type = "", int p_preferred_mode = -1); |
| 108 |
ShaderCreateDialog(); |
| 109 |
}; |