You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #103235 from etherealxx/export-template-online-button
Add "Go Online" button on Export Template Manager
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include "editor/progress_dialog.h"
|
#include "editor/progress_dialog.h"
|
||||||
#include "editor/themes/editor_scale.h"
|
#include "editor/themes/editor_scale.h"
|
||||||
#include "scene/gui/file_dialog.h"
|
#include "scene/gui/file_dialog.h"
|
||||||
|
#include "scene/gui/link_button.h"
|
||||||
#include "scene/gui/menu_button.h"
|
#include "scene/gui/menu_button.h"
|
||||||
#include "scene/gui/separator.h"
|
#include "scene/gui/separator.h"
|
||||||
#include "scene/gui/tree.h"
|
#include "scene/gui/tree.h"
|
||||||
@@ -56,9 +57,6 @@ enum DownloadsAvailability {
|
|||||||
|
|
||||||
static DownloadsAvailability _get_downloads_availability() {
|
static DownloadsAvailability _get_downloads_availability() {
|
||||||
const int network_mode = EDITOR_GET("network/connection/network_mode");
|
const int network_mode = EDITOR_GET("network/connection/network_mode");
|
||||||
if (network_mode == EditorSettings::NETWORK_OFFLINE) {
|
|
||||||
return DOWNLOADS_NOT_AVAILABLE_IN_OFFLINE_MODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Downloadable export templates are only available for stable and official alpha/beta/RC builds
|
// Downloadable export templates are only available for stable and official alpha/beta/RC builds
|
||||||
// (which always have a number following their status, e.g. "alpha1").
|
// (which always have a number following their status, e.g. "alpha1").
|
||||||
@@ -71,6 +69,10 @@ static DownloadsAvailability _get_downloads_availability() {
|
|||||||
return DOWNLOADS_NOT_AVAILABLE_FOR_DEV_BUILDS;
|
return DOWNLOADS_NOT_AVAILABLE_FOR_DEV_BUILDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (network_mode == EditorSettings::NETWORK_OFFLINE) {
|
||||||
|
return DOWNLOADS_NOT_AVAILABLE_IN_OFFLINE_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
return DOWNLOADS_AVAILABLE;
|
return DOWNLOADS_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,6 +337,14 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExportTemplateManager::_force_online_mode() {
|
||||||
|
EditorSettings::get_singleton()->set_setting("network/connection/network_mode", EditorSettings::NETWORK_ONLINE);
|
||||||
|
EditorSettings::get_singleton()->notify_changes();
|
||||||
|
EditorSettings::get_singleton()->save();
|
||||||
|
|
||||||
|
popup_manager();
|
||||||
|
}
|
||||||
|
|
||||||
bool ExportTemplateManager::_humanize_http_status(HTTPRequest *p_request, String *r_status, int *r_downloaded_bytes, int *r_total_bytes) {
|
bool ExportTemplateManager::_humanize_http_status(HTTPRequest *p_request, String *r_status, int *r_downloaded_bytes, int *r_total_bytes) {
|
||||||
*r_status = "";
|
*r_status = "";
|
||||||
*r_downloaded_bytes = -1;
|
*r_downloaded_bytes = -1;
|
||||||
@@ -694,6 +704,8 @@ void ExportTemplateManager::popup_manager() {
|
|||||||
if (!is_downloading_templates) {
|
if (!is_downloading_templates) {
|
||||||
_refresh_mirrors();
|
_refresh_mirrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enable_online_hb->hide();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case DOWNLOADS_NOT_AVAILABLE_IN_OFFLINE_MODE: {
|
case DOWNLOADS_NOT_AVAILABLE_IN_OFFLINE_MODE: {
|
||||||
@@ -708,6 +720,8 @@ void ExportTemplateManager::popup_manager() {
|
|||||||
|
|
||||||
download_current_button->set_disabled(true);
|
download_current_button->set_disabled(true);
|
||||||
download_current_button->set_tooltip_text(TTR("Template downloading is disabled in offline mode."));
|
download_current_button->set_tooltip_text(TTR("Template downloading is disabled in offline mode."));
|
||||||
|
|
||||||
|
enable_online_hb->show();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case DOWNLOADS_NOT_AVAILABLE_FOR_DEV_BUILDS: {
|
case DOWNLOADS_NOT_AVAILABLE_FOR_DEV_BUILDS: {
|
||||||
@@ -722,6 +736,8 @@ void ExportTemplateManager::popup_manager() {
|
|||||||
|
|
||||||
download_current_button->set_disabled(true);
|
download_current_button->set_disabled(true);
|
||||||
download_current_button->set_tooltip_text(TTR("Official export templates aren't available for development builds."));
|
download_current_button->set_tooltip_text(TTR("Official export templates aren't available for development builds."));
|
||||||
|
|
||||||
|
enable_online_hb->hide();
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1053,6 +1069,19 @@ ExportTemplateManager::ExportTemplateManager() {
|
|||||||
install_file_hb->add_child(install_file_button);
|
install_file_hb->add_child(install_file_button);
|
||||||
install_file_button->connect(SceneStringName(pressed), callable_mp(this, &ExportTemplateManager::_install_file));
|
install_file_button->connect(SceneStringName(pressed), callable_mp(this, &ExportTemplateManager::_install_file));
|
||||||
|
|
||||||
|
enable_online_hb = memnew(HBoxContainer);
|
||||||
|
install_options_vb->add_child(enable_online_hb);
|
||||||
|
|
||||||
|
Label *enable_online_label = memnew(Label);
|
||||||
|
enable_online_label->set_text(TTR("Online mode is needed to download the templates."));
|
||||||
|
enable_online_hb->add_child(enable_online_label);
|
||||||
|
|
||||||
|
LinkButton *enable_online_button = memnew(LinkButton);
|
||||||
|
enable_online_button->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
|
||||||
|
enable_online_button->set_text(TTR("Go Online"));
|
||||||
|
enable_online_hb->add_child(enable_online_button);
|
||||||
|
enable_online_button->connect(SceneStringName(pressed), callable_mp(this, &ExportTemplateManager::_force_online_mode));
|
||||||
|
|
||||||
// Templates are being downloaded; buttons unavailable.
|
// Templates are being downloaded; buttons unavailable.
|
||||||
download_progress_hb = memnew(HBoxContainer);
|
download_progress_hb = memnew(HBoxContainer);
|
||||||
download_progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
download_progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class ExportTemplateManager : public AcceptDialog {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MenuButton *mirror_options_button = nullptr;
|
MenuButton *mirror_options_button = nullptr;
|
||||||
|
HBoxContainer *enable_online_hb = nullptr;
|
||||||
HBoxContainer *download_progress_hb = nullptr;
|
HBoxContainer *download_progress_hb = nullptr;
|
||||||
ProgressBar *download_progress_bar = nullptr;
|
ProgressBar *download_progress_bar = nullptr;
|
||||||
Label *download_progress_label = nullptr;
|
Label *download_progress_label = nullptr;
|
||||||
@@ -95,6 +96,7 @@ class ExportTemplateManager : public AcceptDialog {
|
|||||||
void _cancel_template_download();
|
void _cancel_template_download();
|
||||||
void _refresh_mirrors();
|
void _refresh_mirrors();
|
||||||
void _refresh_mirrors_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);
|
void _refresh_mirrors_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);
|
||||||
|
void _force_online_mode();
|
||||||
|
|
||||||
bool _humanize_http_status(HTTPRequest *p_request, String *r_status, int *r_downloaded_bytes, int *r_total_bytes);
|
bool _humanize_http_status(HTTPRequest *p_request, String *r_status, int *r_downloaded_bytes, int *r_total_bytes);
|
||||||
void _set_current_progress_status(const String &p_status, bool p_error = false);
|
void _set_current_progress_status(const String &p_status, bool p_error = false);
|
||||||
|
|||||||
Reference in New Issue
Block a user