Path: blob/master/editor/export/export_template_manager.h
9896 views
/**************************************************************************/1/* export_template_manager.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/gui/dialogs.h"3334class EditorExportPreset;35class ExportTemplateVersion;36class FileDialog;37class HTTPRequest;38class MenuButton;39class OptionButton;40class ProgressBar;41class Tree;4243class ExportTemplateManager : public AcceptDialog {44GDCLASS(ExportTemplateManager, AcceptDialog);4546bool current_version_exists = false;47bool mirrors_available = false;48bool is_refreshing_mirrors = false;49bool is_downloading_templates = false;50float update_countdown = 0;5152Label *current_value = nullptr;53Label *current_missing_label = nullptr;54Label *current_installed_label = nullptr;5556HBoxContainer *current_installed_hb = nullptr;57LineEdit *current_installed_path = nullptr;58Button *current_uninstall_button = nullptr;5960VBoxContainer *install_options_vb = nullptr;61OptionButton *mirrors_list = nullptr;6263enum MirrorAction {64VISIT_WEB_MIRROR,65COPY_MIRROR_URL,66};6768MenuButton *mirror_options_button = nullptr;69HBoxContainer *enable_online_hb = nullptr;70HBoxContainer *download_progress_hb = nullptr;71ProgressBar *download_progress_bar = nullptr;72Label *download_progress_label = nullptr;73HTTPRequest *download_templates = nullptr;74Button *install_file_button = nullptr;75Button *download_current_button = nullptr;76HTTPRequest *request_mirrors = nullptr;7778enum TemplatesAction {79OPEN_TEMPLATE_FOLDER,80UNINSTALL_TEMPLATE,81};8283Tree *installed_table = nullptr;8485ConfirmationDialog *uninstall_confirm = nullptr;86String uninstall_version;87FileDialog *install_file_dialog = nullptr;88AcceptDialog *hide_dialog_accept = nullptr;8990void _update_template_status();9192void _download_current();93void _download_template(const String &p_url, bool p_skip_check = false);94void _download_template_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);95void _cancel_template_download();96void _refresh_mirrors();97void _refresh_mirrors_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);98void _force_online_mode();99100bool _humanize_http_status(HTTPRequest *p_request, String *r_status, int *r_downloaded_bytes, int *r_total_bytes);101void _set_current_progress_status(const String &p_status, bool p_error = false);102void _set_current_progress_value(float p_value, const String &p_status);103104void _install_file();105bool _install_file_selected(const String &p_file, bool p_skip_progress = false);106107void _uninstall_template(const String &p_version);108void _uninstall_template_confirmed();109110String _get_selected_mirror() const;111void _mirror_options_button_cbk(int p_id);112void _installed_table_button_cbk(Object *p_item, int p_column, int p_id, MouseButton p_button);113114void _open_template_folder(const String &p_version);115116virtual void ok_pressed() override;117void _hide_dialog();118119protected:120void _notification(int p_what);121122public:123static String get_android_build_directory(const Ref<EditorExportPreset> &p_preset);124static String get_android_source_zip(const Ref<EditorExportPreset> &p_preset);125static String get_android_template_identifier(const Ref<EditorExportPreset> &p_preset);126127bool is_android_template_installed(const Ref<EditorExportPreset> &p_preset);128bool can_install_android_template(const Ref<EditorExportPreset> &p_preset);129Error install_android_template(const Ref<EditorExportPreset> &p_preset);130131Error install_android_template_from_file(const String &p_file, const Ref<EditorExportPreset> &p_preset);132133void popup_manager();134135ExportTemplateManager();136};137138139