Expose get_export_option_visibility to editor plugins

This commit is contained in:
Fredia Huya-Kouadio 2024-09-13 13:05:20 -07:00 committed by Fredia Huya-Kouadio
parent 84dcdde908
commit 7a909896f7
4 changed files with 41 additions and 2 deletions

View file

@ -159,6 +159,15 @@
Return a [PackedStringArray] of additional features this preset, for the given [param platform], should have. Return a [PackedStringArray] of additional features this preset, for the given [param platform], should have.
</description> </description>
</method> </method>
<method name="_get_export_option_visibility" qualifiers="virtual const">
<return type="bool" />
<param index="0" name="platform" type="EditorExportPlatform" />
<param index="1" name="option" type="String" />
<description>
[b]Optional.[/b]
Validates [param option] and returns the visibility for the specified [param platform]. The default implementation returns [code]true[/code] for all options.
</description>
</method>
<method name="_get_export_option_warning" qualifiers="virtual const"> <method name="_get_export_option_warning" qualifiers="virtual const">
<return type="String" /> <return type="String" />
<param index="0" name="platform" type="EditorExportPlatform" /> <param index="0" name="platform" type="EditorExportPlatform" />

View file

@ -295,6 +295,12 @@ bool EditorExportPlugin::_should_update_export_options(const Ref<EditorExportPla
return ret; return ret;
} }
bool EditorExportPlugin::_get_export_option_visibility(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const {
bool ret = true;
GDVIRTUAL_CALL(_get_export_option_visibility, p_export_platform, p_option_name, ret);
return ret;
}
String EditorExportPlugin::_get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const { String EditorExportPlugin::_get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const {
String ret; String ret;
GDVIRTUAL_CALL(_get_export_option_warning, p_export_platform, p_option_name, ret); GDVIRTUAL_CALL(_get_export_option_warning, p_export_platform, p_option_name, ret);
@ -354,6 +360,7 @@ void EditorExportPlugin::_bind_methods() {
GDVIRTUAL_BIND(_get_export_options, "platform"); GDVIRTUAL_BIND(_get_export_options, "platform");
GDVIRTUAL_BIND(_get_export_options_overrides, "platform"); GDVIRTUAL_BIND(_get_export_options_overrides, "platform");
GDVIRTUAL_BIND(_should_update_export_options, "platform"); GDVIRTUAL_BIND(_should_update_export_options, "platform");
GDVIRTUAL_BIND(_get_export_option_visibility, "platform", "option");
GDVIRTUAL_BIND(_get_export_option_warning, "platform", "option"); GDVIRTUAL_BIND(_get_export_option_warning, "platform", "option");
GDVIRTUAL_BIND(_get_export_features, "platform", "debug"); GDVIRTUAL_BIND(_get_export_features, "platform", "debug");

View file

@ -132,6 +132,7 @@ protected:
GDVIRTUAL1RC(TypedArray<Dictionary>, _get_export_options, const Ref<EditorExportPlatform> &); GDVIRTUAL1RC(TypedArray<Dictionary>, _get_export_options, const Ref<EditorExportPlatform> &);
GDVIRTUAL1RC(Dictionary, _get_export_options_overrides, const Ref<EditorExportPlatform> &); GDVIRTUAL1RC(Dictionary, _get_export_options_overrides, const Ref<EditorExportPlatform> &);
GDVIRTUAL1RC(bool, _should_update_export_options, const Ref<EditorExportPlatform> &); GDVIRTUAL1RC(bool, _should_update_export_options, const Ref<EditorExportPlatform> &);
GDVIRTUAL2RC(bool, _get_export_option_visibility, const Ref<EditorExportPlatform> &, String);
GDVIRTUAL2RC(String, _get_export_option_warning, const Ref<EditorExportPlatform> &, String); GDVIRTUAL2RC(String, _get_export_option_warning, const Ref<EditorExportPlatform> &, String);
GDVIRTUAL0RC(String, _get_name) GDVIRTUAL0RC(String, _get_name)
@ -160,6 +161,7 @@ protected:
virtual void _get_export_options(const Ref<EditorExportPlatform> &p_export_platform, List<EditorExportPlatform::ExportOption> *r_options) const; virtual void _get_export_options(const Ref<EditorExportPlatform> &p_export_platform, List<EditorExportPlatform::ExportOption> *r_options) const;
virtual Dictionary _get_export_options_overrides(const Ref<EditorExportPlatform> &p_export_platform) const; virtual Dictionary _get_export_options_overrides(const Ref<EditorExportPlatform> &p_export_platform) const;
virtual bool _should_update_export_options(const Ref<EditorExportPlatform> &p_export_platform) const; virtual bool _should_update_export_options(const Ref<EditorExportPlatform> &p_export_platform) const;
virtual bool _get_export_option_visibility(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const;
virtual String _get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const; virtual String _get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const;
public: public:

View file

@ -135,11 +135,32 @@ String EditorExportPreset::_get_property_warning(const StringName &p_name) const
void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const { void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
for (const KeyValue<StringName, PropertyInfo> &E : properties) { for (const KeyValue<StringName, PropertyInfo> &E : properties) {
if (!value_overrides.has(E.key) && platform->get_export_option_visibility(this, E.key)) { if (!value_overrides.has(E.key)) {
bool property_visible = platform->get_export_option_visibility(this, E.key);
if (!property_visible) {
continue;
}
// Get option visibility from editor export plugins.
Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
for (int i = 0; i < export_plugins.size(); i++) {
if (!export_plugins[i]->supports_platform(platform)) {
continue;
}
export_plugins.write[i]->set_export_preset(Ref<EditorExportPreset>(this));
property_visible = export_plugins[i]->_get_export_option_visibility(platform, E.key);
if (!property_visible) {
break;
}
}
if (property_visible) {
p_list->push_back(E.value); p_list->push_back(E.value);
} }
} }
} }
}
Ref<EditorExportPlatform> EditorExportPreset::get_platform() const { Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
return platform; return platform;