Merge pull request #88419 from m4gr3d/add_export_preset_advanced_options_toggle

Add an `Advanced Options` toggle to the editor export preset
This commit is contained in:
Rémi Verschelde 2024-02-19 00:08:22 +01:00
commit ec0adfd23e
No known key found for this signature in database
GPG Key ID: C3336907360768E1
6 changed files with 64 additions and 6 deletions

View File

@ -47,6 +47,7 @@ void EditorExport::_save() {
config->set_value(section, "name", preset->get_name());
config->set_value(section, "platform", preset->get_platform()->get_name());
config->set_value(section, "runnable", preset->is_runnable());
config->set_value(section, "advanced_options", preset->are_advanced_options_enabled());
config->set_value(section, "dedicated_server", preset->is_dedicated_server());
config->set_value(section, "custom_features", preset->get_custom_features());
@ -234,6 +235,7 @@ void EditorExport::load_config() {
}
preset->set_name(config->get_value(section, "name"));
preset->set_advanced_options_enabled(config->get_value(section, "advanced_options", false));
preset->set_runnable(config->get_value(section, "runnable"));
preset->set_dedicated_server(config->get_value(section, "dedicated_server", false));

View File

@ -229,6 +229,19 @@ bool EditorExportPreset::is_runnable() const {
return runnable;
}
void EditorExportPreset::set_advanced_options_enabled(bool p_enabled) {
if (advanced_options_enabled == p_enabled) {
return;
}
advanced_options_enabled = p_enabled;
EditorExport::singleton->save_presets();
notify_property_list_changed();
}
bool EditorExportPreset::are_advanced_options_enabled() const {
return advanced_options_enabled;
}
void EditorExportPreset::set_dedicated_server(bool p_enable) {
dedicated_server = p_enable;
EditorExport::singleton->save_presets();

View File

@ -71,6 +71,7 @@ private:
HashSet<String> selected_files;
HashMap<String, FileExportMode> customized_files;
bool runnable = false;
bool advanced_options_enabled = false;
bool dedicated_server = false;
friend class EditorExport;
@ -128,6 +129,9 @@ public:
void set_runnable(bool p_enable);
bool is_runnable() const;
void set_advanced_options_enabled(bool p_enabled);
bool are_advanced_options_enabled() const;
void set_dedicated_server(bool p_enable);
bool is_dedicated_server() const;

View File

@ -240,6 +240,7 @@ void ProjectExportDialog::_edit_preset(int p_index) {
name->set_text("");
name->set_editable(false);
export_path->hide();
advanced_options->set_disabled(true);
runnable->set_disabled(true);
parameters->edit(nullptr);
presets->deselect_all();
@ -274,6 +275,8 @@ void ProjectExportDialog::_edit_preset(int p_index) {
export_path->setup(extension_vector, false, true);
export_path->update_property();
advanced_options->set_disabled(false);
advanced_options->set_pressed(current->are_advanced_options_enabled());
runnable->set_disabled(false);
runnable->set_pressed(current->is_runnable());
if (parameters->get_edited_object() != current.ptr()) {
@ -449,6 +452,18 @@ void ProjectExportDialog::_update_parameters(const String &p_edited_property) {
_update_current_preset();
}
void ProjectExportDialog::_advanced_options_pressed() {
if (updating) {
return;
}
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
current->set_advanced_options_enabled(advanced_options->is_pressed());
_update_presets();
}
void ProjectExportDialog::_runnable_pressed() {
if (updating) {
return;
@ -637,6 +652,7 @@ void ProjectExportDialog::_duplicate_preset() {
if (make_runnable) {
preset->set_runnable(make_runnable);
}
preset->set_advanced_options_enabled(current->are_advanced_options_enabled());
preset->set_dedicated_server(current->is_dedicated_server());
preset->set_export_filter(current->get_export_filter());
preset->set_include_filter(current->get_include_filter());
@ -1236,11 +1252,22 @@ ProjectExportDialog::ProjectExportDialog() {
name = memnew(LineEdit);
settings_vb->add_margin_child(TTR("Name:"), name);
name->connect("text_changed", callable_mp(this, &ProjectExportDialog::_name_changed));
runnable = memnew(CheckButton);
runnable->set_text(TTR("Runnable"));
runnable->set_tooltip_text(TTR("If checked, the preset will be available for use in one-click deploy.\nOnly one preset per platform may be marked as runnable."));
runnable->connect("pressed", callable_mp(this, &ProjectExportDialog::_runnable_pressed));
settings_vb->add_child(runnable);
advanced_options = memnew(CheckButton);
advanced_options->set_text(TTR("Advanced Options"));
advanced_options->set_tooltip_text(TTR("If checked, the advanced options will be shown."));
advanced_options->connect("pressed", callable_mp(this, &ProjectExportDialog::_advanced_options_pressed));
HBoxContainer *preset_configs_container = memnew(HBoxContainer);
preset_configs_container->add_spacer(true);
preset_configs_container->add_child(advanced_options);
preset_configs_container->add_child(runnable);
settings_vb->add_child(preset_configs_container);
export_path = memnew(EditorPropertyPath);
settings_vb->add_child(export_path);
@ -1413,6 +1440,7 @@ ProjectExportDialog::ProjectExportDialog() {
// Disable by default.
name->set_editable(false);
export_path->hide();
advanced_options->set_disabled(true);
runnable->set_disabled(true);
duplicate_preset->set_disabled(true);
delete_preset->set_disabled(true);

View File

@ -81,6 +81,7 @@ class ProjectExportDialog : public ConfirmationDialog {
EditorPropertyPath *export_path = nullptr;
EditorInspector *parameters = nullptr;
CheckButton *runnable = nullptr;
CheckButton *advanced_options = nullptr;
Button *button_export = nullptr;
bool updating = false;
@ -119,6 +120,7 @@ class ProjectExportDialog : public ConfirmationDialog {
bool exporting = false;
void _advanced_options_pressed();
void _runnable_pressed();
void _update_parameters(const String &p_edited_property);
void _name_changed(const String &p_string);

View File

@ -1911,13 +1911,22 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
}
bool EditorExportPlatformAndroid::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {
if (p_preset == nullptr) {
return true;
}
bool advanced_options_enabled = p_preset->are_advanced_options_enabled();
if (p_option == "graphics/opengl_debug" ||
p_option == "command_line/extra_args" ||
p_option == "permissions/custom_permissions") {
return advanced_options_enabled;
}
if (p_option == "gradle_build/gradle_build_directory" || p_option == "gradle_build/android_source_template") {
// @todo These are experimental options - keep them hidden for now.
//return (bool)p_preset->get("gradle_build/use_gradle_build");
return false;
} else if (p_option == "custom_template/debug" || p_option == "custom_template/release") {
return advanced_options_enabled && bool(p_preset->get("gradle_build/use_gradle_build"));
}
if (p_option == "custom_template/debug" || p_option == "custom_template/release") {
// The APK templates are ignored if Gradle build is enabled.
return !p_preset->get("gradle_build/use_gradle_build");
return advanced_options_enabled && !bool(p_preset->get("gradle_build/use_gradle_build"));
}
return true;
}