project_dialog.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**************************************************************************/
  2. /* project_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 PROJECT_DIALOG_H
  31. #define PROJECT_DIALOG_H
  32. #include "scene/gui/dialogs.h"
  33. class Button;
  34. class CheckBox;
  35. class CheckButton;
  36. class EditorFileDialog;
  37. class LineEdit;
  38. class OptionButton;
  39. class TextureRect;
  40. class ProjectDialog : public ConfirmationDialog {
  41. GDCLASS(ProjectDialog, ConfirmationDialog);
  42. public:
  43. enum Mode {
  44. MODE_NEW,
  45. MODE_IMPORT,
  46. MODE_INSTALL,
  47. MODE_RENAME,
  48. };
  49. private:
  50. enum MessageType {
  51. MESSAGE_ERROR,
  52. MESSAGE_WARNING,
  53. MESSAGE_SUCCESS,
  54. };
  55. enum InputType {
  56. PROJECT_PATH,
  57. INSTALL_PATH,
  58. };
  59. Mode mode = MODE_NEW;
  60. bool is_folder_empty = true;
  61. ConfirmationDialog *nonempty_confirmation = nullptr;
  62. CheckButton *create_dir = nullptr;
  63. Button *project_browse = nullptr;
  64. Button *install_browse = nullptr;
  65. VBoxContainer *name_container = nullptr;
  66. VBoxContainer *project_path_container = nullptr;
  67. VBoxContainer *install_path_container = nullptr;
  68. VBoxContainer *renderer_container = nullptr;
  69. Label *renderer_info = nullptr;
  70. HBoxContainer *default_files_container = nullptr;
  71. Ref<ButtonGroup> renderer_button_group;
  72. bool rendering_device_supported = false;
  73. Label *rd_not_supported = nullptr;
  74. Label *msg = nullptr;
  75. LineEdit *project_name = nullptr;
  76. LineEdit *project_path = nullptr;
  77. LineEdit *install_path = nullptr;
  78. TextureRect *project_status_rect = nullptr;
  79. TextureRect *install_status_rect = nullptr;
  80. OptionButton *vcs_metadata_selection = nullptr;
  81. CheckBox *edit_check_box = nullptr;
  82. EditorFileDialog *fdialog_project = nullptr;
  83. EditorFileDialog *fdialog_install = nullptr;
  84. AcceptDialog *dialog_error = nullptr;
  85. String zip_path;
  86. String zip_title;
  87. void _set_message(const String &p_msg, MessageType p_type, InputType input_type = PROJECT_PATH);
  88. void _validate_path();
  89. // Project path for MODE_NEW and MODE_INSTALL. Install path for MODE_IMPORT.
  90. // Install path is only visible when importing a ZIP.
  91. String _get_target_path();
  92. void _set_target_path(const String &p_text);
  93. // Calculated from project name / ZIP name.
  94. String auto_dir;
  95. // Updates `auto_dir`. If the target path dir name is equal to `auto_dir` (the default state), the target path is also updated.
  96. void _update_target_auto_dir();
  97. // While `create_dir` is disabled, stores the last target path dir name, or an empty string if equal to `auto_dir`.
  98. String last_custom_target_dir;
  99. void _create_dir_toggled(bool p_pressed);
  100. void _project_name_changed();
  101. void _project_path_changed();
  102. void _install_path_changed();
  103. void _browse_project_path();
  104. void _browse_install_path();
  105. void _project_path_selected(const String &p_path);
  106. void _install_path_selected(const String &p_path);
  107. void _reset_name();
  108. void _renderer_selected();
  109. void _nonempty_confirmation_ok_pressed();
  110. void ok_pressed() override;
  111. protected:
  112. static void _bind_methods();
  113. void _notification(int p_what);
  114. public:
  115. void set_mode(Mode p_mode);
  116. void set_project_name(const String &p_name);
  117. void set_project_path(const String &p_path);
  118. void set_zip_path(const String &p_path);
  119. void set_zip_title(const String &p_title);
  120. void ask_for_path_and_show();
  121. void show_dialog(bool p_reset_name = true);
  122. ProjectDialog();
  123. };
  124. #endif // PROJECT_DIALOG_H