mirror of https://github.com/godotengine/godot
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.
This commit is contained in:
parent
01545c995b
commit
074d33fb6f
|
|
@ -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"
|
||||
|
|
@ -335,6 +336,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 +703,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 +719,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 +735,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 +1068,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);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class EditorExportPreset;
|
|||
class ExportTemplateVersion;
|
||||
class FileDialog;
|
||||
class HTTPRequest;
|
||||
class LinkButton;
|
||||
class MenuButton;
|
||||
class OptionButton;
|
||||
class ProgressBar;
|
||||
|
|
@ -68,6 +69,7 @@ class ExportTemplateManager : public AcceptDialog {
|
|||
};
|
||||
|
||||
MenuButton *mirror_options_button = nullptr;
|
||||
HBoxContainer *enable_online_hb = nullptr;
|
||||
HBoxContainer *download_progress_hb = nullptr;
|
||||
ProgressBar *download_progress_bar = nullptr;
|
||||
Label *download_progress_label = nullptr;
|
||||
|
|
@ -96,6 +98,7 @@ class ExportTemplateManager : public AcceptDialog {
|
|||
void _cancel_template_download();
|
||||
void _refresh_mirrors();
|
||||
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);
|
||||
void _set_current_progress_status(const String &p_status, bool p_error = false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue