Skip to content

Commit

Permalink
Add an Advanced Options toggle to the editor export preset
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Feb 18, 2024
1 parent 8ff8216 commit 6ef3154
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 6 deletions.
2 changes: 2 additions & 0 deletions editor/export/editor_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -227,6 +228,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));

Expand Down
13 changes: 13 additions & 0 deletions editor/export/editor_export_preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,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();
Expand Down
4 changes: 4 additions & 0 deletions editor/export/editor_export_preset.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class EditorExportPreset : public RefCounted {
HashSet<String> selected_files;
HashMap<String, FileExportMode> customized_files;
bool runnable = false;
bool advanced_options_enabled = false;
bool dedicated_server = false;

friend class EditorExport;
Expand Down Expand Up @@ -128,6 +129,9 @@ class EditorExportPreset : public RefCounted {
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;

Expand Down
30 changes: 29 additions & 1 deletion editor/export/project_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions editor/export/project_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 14 additions & 5 deletions platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1883,13 +1883,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;
}
Expand Down

0 comments on commit 6ef3154

Please sign in to comment.