shader_create_dialog.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #ifndef SHADER_CREATE_DIALOG_H
  31. #define SHADER_CREATE_DIALOG_H
  32. #include "editor/editor_settings.h"
  33. #include "scene/gui/check_box.h"
  34. #include "scene/gui/dialogs.h"
  35. #include "scene/gui/grid_container.h"
  36. #include "scene/gui/line_edit.h"
  37. #include "scene/gui/option_button.h"
  38. #include "scene/gui/panel_container.h"
  39. class EditorFileDialog;
  40. class ShaderCreateDialog : public ConfirmationDialog {
  41. GDCLASS(ShaderCreateDialog, ConfirmationDialog);
  42. struct ShaderTypeData {
  43. List<String> extensions;
  44. String default_extension;
  45. bool use_templates = false;
  46. };
  47. List<ShaderTypeData> type_data;
  48. GridContainer *gc = nullptr;
  49. Label *error_label = nullptr;
  50. Label *path_error_label = nullptr;
  51. Label *builtin_warning_label = nullptr;
  52. PanelContainer *status_panel = nullptr;
  53. OptionButton *type_menu = nullptr;
  54. OptionButton *mode_menu = nullptr;
  55. OptionButton *template_menu = nullptr;
  56. CheckBox *internal = nullptr;
  57. LineEdit *file_path = nullptr;
  58. Button *path_button = nullptr;
  59. EditorFileDialog *file_browse = nullptr;
  60. AcceptDialog *alert = nullptr;
  61. String initial_base_path;
  62. bool is_new_shader_created = true;
  63. bool is_path_valid = false;
  64. bool is_built_in = false;
  65. bool built_in_enabled = true;
  66. bool load_enabled = false;
  67. bool re_check_path = false;
  68. int current_type = -1;
  69. int default_type = -1;
  70. int current_mode = 0;
  71. int current_template = 0;
  72. virtual void _update_language_info();
  73. void _path_hbox_sorted();
  74. void _path_changed(const String &p_path = String());
  75. void _path_submitted(const String &p_path = String());
  76. void _type_changed(int p_type = 0);
  77. void _built_in_toggled(bool p_enabled);
  78. void _template_changed(int p_template = 0);
  79. void _mode_changed(int p_mode = 0);
  80. void _browse_path();
  81. void _file_selected(const String &p_file);
  82. String _validate_path(const String &p_path);
  83. virtual void ok_pressed() override;
  84. void _create_new();
  85. void _load_exist();
  86. void _msg_script_valid(bool valid, const String &p_msg = String());
  87. void _msg_path_valid(bool valid, const String &p_msg = String());
  88. void _update_dialog();
  89. protected:
  90. void _update_theme();
  91. void _notification(int p_what);
  92. static void _bind_methods();
  93. public:
  94. 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);
  95. ShaderCreateDialog();
  96. };
  97. #endif // SHADER_CREATE_DIALOG_H