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