script_create_dialog.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*************************************************************************/
  2. /* script_create_dialog.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  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 SCRIPT_CREATE_DIALOG_H
  31. #define SCRIPT_CREATE_DIALOG_H
  32. #include "editor/editor_file_dialog.h"
  33. #include "editor/editor_settings.h"
  34. #include "scene/gui/check_button.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. class ScriptCreateDialog : public ConfirmationDialog {
  41. GDCLASS(ScriptCreateDialog, ConfirmationDialog);
  42. LineEdit *class_name;
  43. Label *error_label;
  44. Label *path_error_label;
  45. LineEdit *parent_name;
  46. Button *parent_browse_button;
  47. OptionButton *language_menu;
  48. OptionButton *template_menu;
  49. LineEdit *file_path;
  50. Button *path_button;
  51. EditorFileDialog *file_browse;
  52. CheckButton *internal;
  53. VBoxContainer *path_vb;
  54. AcceptDialog *alert;
  55. bool path_valid;
  56. bool create_new;
  57. bool is_browsing_parent;
  58. String initial_bp;
  59. bool is_new_script_created;
  60. bool is_path_valid;
  61. bool has_named_classes;
  62. bool supports_built_in;
  63. bool can_inherit_from_file;
  64. bool is_parent_name_valid;
  65. bool is_class_name_valid;
  66. bool is_built_in;
  67. int current_language;
  68. bool re_check_path;
  69. String script_template;
  70. Vector<String> template_list;
  71. void _path_changed(const String &p_path = String());
  72. void _lang_changed(int l = 0);
  73. void _built_in_pressed();
  74. bool _validate(const String &p_string);
  75. void _class_name_changed(const String &p_name);
  76. void _parent_name_changed(const String &p_parent);
  77. void _template_changed(int p_template = 0);
  78. void _browse_path(bool browse_parent);
  79. void _file_selected(const String &p_file);
  80. virtual void ok_pressed();
  81. void _create_new();
  82. void _load_exist();
  83. void _msg_script_valid(bool valid, const String &p_msg = String());
  84. void _msg_path_valid(bool valid, const String &p_msg = String());
  85. void _update_dialog();
  86. protected:
  87. void _notification(int p_what);
  88. static void _bind_methods();
  89. public:
  90. void config(const String &p_base_name, const String &p_base_path);
  91. ScriptCreateDialog();
  92. };
  93. #endif // SCRIPT_CREATE_DIALOG_H