export_template_manager.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**************************************************************************/
  2. /* export_template_manager.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 EXPORT_TEMPLATE_MANAGER_H
  31. #define EXPORT_TEMPLATE_MANAGER_H
  32. #include "scene/gui/dialogs.h"
  33. class EditorExportPreset;
  34. class ExportTemplateVersion;
  35. class FileDialog;
  36. class HTTPRequest;
  37. class MenuButton;
  38. class OptionButton;
  39. class ProgressBar;
  40. class Tree;
  41. class ExportTemplateManager : public AcceptDialog {
  42. GDCLASS(ExportTemplateManager, AcceptDialog);
  43. bool current_version_exists = false;
  44. bool mirrors_available = false;
  45. bool is_refreshing_mirrors = false;
  46. bool is_downloading_templates = false;
  47. float update_countdown = 0;
  48. Label *current_value = nullptr;
  49. Label *current_missing_label = nullptr;
  50. Label *current_installed_label = nullptr;
  51. HBoxContainer *current_installed_hb = nullptr;
  52. LineEdit *current_installed_path = nullptr;
  53. Button *current_uninstall_button = nullptr;
  54. VBoxContainer *install_options_vb = nullptr;
  55. OptionButton *mirrors_list = nullptr;
  56. enum MirrorAction {
  57. VISIT_WEB_MIRROR,
  58. COPY_MIRROR_URL,
  59. };
  60. MenuButton *mirror_options_button = nullptr;
  61. HBoxContainer *download_progress_hb = nullptr;
  62. ProgressBar *download_progress_bar = nullptr;
  63. Label *download_progress_label = nullptr;
  64. HTTPRequest *download_templates = nullptr;
  65. Button *install_file_button = nullptr;
  66. Button *download_current_button = nullptr;
  67. HTTPRequest *request_mirrors = nullptr;
  68. enum TemplatesAction {
  69. OPEN_TEMPLATE_FOLDER,
  70. UNINSTALL_TEMPLATE,
  71. };
  72. Tree *installed_table = nullptr;
  73. ConfirmationDialog *uninstall_confirm = nullptr;
  74. String uninstall_version;
  75. FileDialog *install_file_dialog = nullptr;
  76. AcceptDialog *hide_dialog_accept = nullptr;
  77. void _update_template_status();
  78. void _download_current();
  79. void _download_template(const String &p_url, bool p_skip_check = false);
  80. void _download_template_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);
  81. void _cancel_template_download();
  82. void _refresh_mirrors();
  83. void _refresh_mirrors_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);
  84. bool _humanize_http_status(HTTPRequest *p_request, String *r_status, int *r_downloaded_bytes, int *r_total_bytes);
  85. void _set_current_progress_status(const String &p_status, bool p_error = false);
  86. void _set_current_progress_value(float p_value, const String &p_status);
  87. void _install_file();
  88. bool _install_file_selected(const String &p_file, bool p_skip_progress = false);
  89. void _uninstall_template(const String &p_version);
  90. void _uninstall_template_confirmed();
  91. String _get_selected_mirror() const;
  92. void _mirror_options_button_cbk(int p_id);
  93. void _installed_table_button_cbk(Object *p_item, int p_column, int p_id, MouseButton p_button);
  94. void _open_template_folder(const String &p_version);
  95. virtual void ok_pressed() override;
  96. void _hide_dialog();
  97. protected:
  98. void _notification(int p_what);
  99. public:
  100. static String get_android_build_directory(const Ref<EditorExportPreset> &p_preset);
  101. static String get_android_source_zip(const Ref<EditorExportPreset> &p_preset);
  102. static String get_android_template_identifier(const Ref<EditorExportPreset> &p_preset);
  103. bool is_android_template_installed(const Ref<EditorExportPreset> &p_preset);
  104. bool can_install_android_template(const Ref<EditorExportPreset> &p_preset);
  105. Error install_android_template(const Ref<EditorExportPreset> &p_preset);
  106. Error install_android_template_from_file(const String &p_file, const Ref<EditorExportPreset> &p_preset);
  107. void popup_manager();
  108. ExportTemplateManager();
  109. };
  110. #endif // EXPORT_TEMPLATE_MANAGER_H