You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Add "Go Online" button on Export Template Manager
Godot 4.4 introduces network mode, which by default sets to offline. Some features are disabled on offline mode, including downloading export templates. Newcomers to the engine that has no knowledge about the network mode might be confused on why the Export Template Manager tells them that they're offline, despite them having internet connection. This commit introduces a message that tells the user that online mode is required, and a link button that user can click to enable online mode from the Export Template Manager popup UI. Some code changes also made to make sure that the button and message only shows on official build only.
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include "editor/progress_dialog.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "scene/gui/file_dialog.h"
|
||||
#include "scene/gui/link_button.h"
|
||||
#include "scene/gui/menu_button.h"
|
||||
#include "scene/gui/separator.h"
|
||||
#include "scene/gui/tree.h"
|
||||
@@ -56,9 +57,6 @@ enum DownloadsAvailability {
|
||||
|
||||
static DownloadsAvailability _get_downloads_availability() {
|
||||
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
|
||||
// (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;
|
||||
}
|
||||
|
||||
if (network_mode == EditorSettings::NETWORK_OFFLINE) {
|
||||
return DOWNLOADS_NOT_AVAILABLE_IN_OFFLINE_MODE;
|
||||
}
|
||||
|
||||
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) {
|
||||
*r_status = "";
|
||||
*r_downloaded_bytes = -1;
|
||||
@@ -694,6 +704,8 @@ void ExportTemplateManager::popup_manager() {
|
||||
if (!is_downloading_templates) {
|
||||
_refresh_mirrors();
|
||||
}
|
||||
|
||||
enable_online_hb->hide();
|
||||
} break;
|
||||
|
||||
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_tooltip_text(TTR("Template downloading is disabled in offline mode."));
|
||||
|
||||
enable_online_hb->show();
|
||||
} break;
|
||||
|
||||
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_tooltip_text(TTR("Official export templates aren't available for development builds."));
|
||||
|
||||
enable_online_hb->hide();
|
||||
} break;
|
||||
}
|
||||
|
||||
@@ -1053,6 +1069,19 @@ ExportTemplateManager::ExportTemplateManager() {
|
||||
install_file_hb->add_child(install_file_button);
|
||||
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.
|
||||
download_progress_hb = memnew(HBoxContainer);
|
||||
download_progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
||||
Reference in New Issue
Block a user