Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/export/export_template_manager.h
9896 views
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
#pragma once
32
33
#include "scene/gui/dialogs.h"
34
35
class EditorExportPreset;
36
class ExportTemplateVersion;
37
class FileDialog;
38
class HTTPRequest;
39
class MenuButton;
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 mirrors_available = false;
49
bool is_refreshing_mirrors = false;
50
bool is_downloading_templates = false;
51
float update_countdown = 0;
52
53
Label *current_value = nullptr;
54
Label *current_missing_label = nullptr;
55
Label *current_installed_label = nullptr;
56
57
HBoxContainer *current_installed_hb = nullptr;
58
LineEdit *current_installed_path = nullptr;
59
Button *current_uninstall_button = nullptr;
60
61
VBoxContainer *install_options_vb = nullptr;
62
OptionButton *mirrors_list = nullptr;
63
64
enum MirrorAction {
65
VISIT_WEB_MIRROR,
66
COPY_MIRROR_URL,
67
};
68
69
MenuButton *mirror_options_button = nullptr;
70
HBoxContainer *enable_online_hb = nullptr;
71
HBoxContainer *download_progress_hb = nullptr;
72
ProgressBar *download_progress_bar = nullptr;
73
Label *download_progress_label = nullptr;
74
HTTPRequest *download_templates = nullptr;
75
Button *install_file_button = nullptr;
76
Button *download_current_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 &headers, 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 &headers, const PackedByteArray &p_data);
99
void _force_online_mode();
100
101
bool _humanize_http_status(HTTPRequest *p_request, String *r_status, int *r_downloaded_bytes, int *r_total_bytes);
102
void _set_current_progress_status(const String &p_status, bool p_error = false);
103
void _set_current_progress_value(float p_value, const String &p_status);
104
105
void _install_file();
106
bool _install_file_selected(const String &p_file, bool p_skip_progress = false);
107
108
void _uninstall_template(const String &p_version);
109
void _uninstall_template_confirmed();
110
111
String _get_selected_mirror() const;
112
void _mirror_options_button_cbk(int p_id);
113
void _installed_table_button_cbk(Object *p_item, int p_column, int p_id, MouseButton p_button);
114
115
void _open_template_folder(const String &p_version);
116
117
virtual void ok_pressed() override;
118
void _hide_dialog();
119
120
protected:
121
void _notification(int p_what);
122
123
public:
124
static String get_android_build_directory(const Ref<EditorExportPreset> &p_preset);
125
static String get_android_source_zip(const Ref<EditorExportPreset> &p_preset);
126
static String get_android_template_identifier(const Ref<EditorExportPreset> &p_preset);
127
128
bool is_android_template_installed(const Ref<EditorExportPreset> &p_preset);
129
bool can_install_android_template(const Ref<EditorExportPreset> &p_preset);
130
Error install_android_template(const Ref<EditorExportPreset> &p_preset);
131
132
Error install_android_template_from_file(const String &p_file, const Ref<EditorExportPreset> &p_preset);
133
134
void popup_manager();
135
136
ExportTemplateManager();
137
};
138
139