1 | /**************************************************************************/ |
2 | /* shader_create_dialog.h */ |
3 | /**************************************************************************/ |
4 | /* This file is part of: */ |
5 | /* GODOT ENGINE */ |
6 | /* https://godotengine.org */ |
7 | /**************************************************************************/ |
8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
10 | /* */ |
11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
12 | /* a copy of this software and associated documentation files (the */ |
13 | /* "Software"), to deal in the Software without restriction, including */ |
14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
17 | /* the following conditions: */ |
18 | /* */ |
19 | /* The above copyright notice and this permission notice shall be */ |
20 | /* included in all copies or substantial portions of the Software. */ |
21 | /* */ |
22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
29 | /**************************************************************************/ |
30 | |
31 | #ifndef SHADER_CREATE_DIALOG_H |
32 | #define SHADER_CREATE_DIALOG_H |
33 | |
34 | #include "editor/editor_settings.h" |
35 | #include "scene/gui/check_box.h" |
36 | #include "scene/gui/dialogs.h" |
37 | #include "scene/gui/grid_container.h" |
38 | #include "scene/gui/line_edit.h" |
39 | #include "scene/gui/option_button.h" |
40 | #include "scene/gui/panel_container.h" |
41 | |
42 | class EditorFileDialog; |
43 | class EditorValidationPanel; |
44 | |
45 | class ShaderCreateDialog : public ConfirmationDialog { |
46 | GDCLASS(ShaderCreateDialog, ConfirmationDialog); |
47 | |
48 | enum { |
49 | MSG_ID_SHADER, |
50 | MSG_ID_PATH, |
51 | MSG_ID_BUILT_IN, |
52 | }; |
53 | |
54 | struct ShaderTypeData { |
55 | List<String> extensions; |
56 | String default_extension; |
57 | bool use_templates = false; |
58 | }; |
59 | |
60 | List<ShaderTypeData> type_data; |
61 | |
62 | GridContainer *gc = nullptr; |
63 | EditorValidationPanel *validation_panel = nullptr; |
64 | OptionButton * = nullptr; |
65 | OptionButton * = nullptr; |
66 | OptionButton * = nullptr; |
67 | CheckBox *internal = nullptr; |
68 | LineEdit *file_path = nullptr; |
69 | Button *path_button = nullptr; |
70 | EditorFileDialog *file_browse = nullptr; |
71 | AcceptDialog *alert = nullptr; |
72 | |
73 | String initial_base_path; |
74 | String path_error; |
75 | bool is_new_shader_created = true; |
76 | bool is_path_valid = false; |
77 | bool is_built_in = false; |
78 | bool built_in_enabled = true; |
79 | bool load_enabled = false; |
80 | bool re_check_path = false; |
81 | int current_type = -1; |
82 | int default_type = -1; |
83 | int current_mode = 0; |
84 | int current_template = 0; |
85 | |
86 | virtual void _update_language_info(); |
87 | |
88 | void _path_hbox_sorted(); |
89 | void _path_changed(const String &p_path = String()); |
90 | void _path_submitted(const String &p_path = String()); |
91 | void _type_changed(int p_type = 0); |
92 | void _built_in_toggled(bool p_enabled); |
93 | void _template_changed(int p_template = 0); |
94 | void _mode_changed(int p_mode = 0); |
95 | void _browse_path(); |
96 | void _file_selected(const String &p_file); |
97 | String _validate_path(const String &p_path); |
98 | virtual void ok_pressed() override; |
99 | void _create_new(); |
100 | void _load_exist(); |
101 | void _update_dialog(); |
102 | |
103 | protected: |
104 | void _update_theme(); |
105 | void _notification(int p_what); |
106 | static void _bind_methods(); |
107 | |
108 | public: |
109 | void config(const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true, int p_preferred_type = -1, int p_preferred_mode = -1); |
110 | ShaderCreateDialog(); |
111 | }; |
112 | |
113 | #endif // SHADER_CREATE_DIALOG_H |
114 | |