shader_create_dialog.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 EditorValidationPanel;
  41. class ShaderCreateDialog : public ConfirmationDialog {
  42. GDCLASS(ShaderCreateDialog, ConfirmationDialog);
  43. enum {
  44. MSG_ID_SHADER,
  45. MSG_ID_PATH,
  46. MSG_ID_BUILT_IN,
  47. };
  48. struct ShaderTypeData {
  49. List<String> extensions;
  50. String default_extension;
  51. bool use_templates = false;
  52. };
  53. List<ShaderTypeData> type_data;
  54. GridContainer *gc = nullptr;
  55. EditorValidationPanel *validation_panel = nullptr;
  56. OptionButton *type_menu = nullptr;
  57. OptionButton *mode_menu = nullptr;
  58. OptionButton *template_menu = nullptr;
  59. CheckBox *internal = nullptr;
  60. LineEdit *file_path = nullptr;
  61. Button *path_button = nullptr;
  62. EditorFileDialog *file_browse = nullptr;
  63. AcceptDialog *alert = nullptr;
  64. String initial_base_path;
  65. String path_error;
  66. bool is_new_shader_created = true;
  67. bool is_path_valid = false;
  68. bool is_built_in = false;
  69. bool built_in_enabled = true;
  70. bool load_enabled = false;
  71. bool re_check_path = false;
  72. int current_type = -1;
  73. int default_type = -1;
  74. int current_mode = 0;
  75. int current_template = 0;
  76. virtual void _update_language_info();
  77. void _path_hbox_sorted();
  78. void _path_changed(const String &p_path = String());
  79. void _path_submitted(const String &p_path = String());
  80. void _type_changed(int p_type = 0);
  81. void _built_in_toggled(bool p_enabled);
  82. void _template_changed(int p_template = 0);
  83. void _mode_changed(int p_mode = 0);
  84. void _browse_path();
  85. void _file_selected(const String &p_file);
  86. String _validate_path(const String &p_path);
  87. virtual void ok_pressed() override;
  88. void _create_new();
  89. void _load_exist();
  90. void _update_dialog();
  91. protected:
  92. void _notification(int p_what);
  93. static void _bind_methods();
  94. public:
  95. 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);
  96. ShaderCreateDialog();
  97. };
  98. #endif // SHADER_CREATE_DIALOG_H