mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
[Export] Add readable descriptions and validation warnings to the export options.
This commit is contained in:
@@ -143,11 +143,13 @@ public:
|
||||
PropertyInfo option;
|
||||
Variant default_value;
|
||||
bool update_visibility = false;
|
||||
bool required = false;
|
||||
|
||||
ExportOption(const PropertyInfo &p_info, const Variant &p_default, bool p_update_visibility = false) :
|
||||
ExportOption(const PropertyInfo &p_info, const Variant &p_default, bool p_update_visibility = false, bool p_required = false) :
|
||||
option(p_info),
|
||||
default_value(p_default),
|
||||
update_visibility(p_update_visibility) {
|
||||
update_visibility(p_update_visibility),
|
||||
required(p_required) {
|
||||
}
|
||||
ExportOption() {}
|
||||
};
|
||||
@@ -196,9 +198,10 @@ public:
|
||||
|
||||
virtual bool fill_log_messages(RichTextLabel *p_log, Error p_err);
|
||||
|
||||
virtual void get_export_options(List<ExportOption> *r_options) = 0;
|
||||
virtual void get_export_options(List<ExportOption> *r_options) const = 0;
|
||||
virtual bool should_update_export_options() { return false; }
|
||||
virtual bool get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; }
|
||||
virtual bool get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const { return true; }
|
||||
virtual String get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const { return String(); }
|
||||
|
||||
virtual String get_os_name() const = 0;
|
||||
virtual String get_name() const = 0;
|
||||
|
||||
@@ -50,7 +50,7 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &
|
||||
r_features->push_back(p_preset->get("binary_format/architecture"));
|
||||
}
|
||||
|
||||
void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {
|
||||
void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) const {
|
||||
String ext_filter = (get_os_name() == "Windows") ? "*.exe" : "";
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, ext_filter), ""));
|
||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, ext_filter), ""));
|
||||
|
||||
@@ -46,7 +46,7 @@ private:
|
||||
public:
|
||||
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const override;
|
||||
|
||||
virtual void get_export_options(List<ExportOption> *r_options) override;
|
||||
virtual void get_export_options(List<ExportOption> *r_options) const override;
|
||||
|
||||
virtual String get_name() const override;
|
||||
virtual String get_os_name() const override;
|
||||
|
||||
@@ -52,9 +52,17 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditorExportPreset::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_get_property_warning", "name"), &EditorExportPreset::_get_property_warning);
|
||||
}
|
||||
|
||||
String EditorExportPreset::_get_property_warning(const StringName &p_name) const {
|
||||
return platform->get_export_option_warning(this, p_name);
|
||||
}
|
||||
|
||||
void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
for (const PropertyInfo &E : properties) {
|
||||
if (platform->get_export_option_visibility(this, E.name, values)) {
|
||||
if (platform->get_export_option_visibility(this, E.name)) {
|
||||
p_list->push_back(E);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,10 @@ protected:
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
|
||||
String _get_property_warning(const StringName &p_name) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
Ref<EditorExportPlatform> get_platform() const;
|
||||
|
||||
|
||||
@@ -241,6 +241,7 @@ void ProjectExportDialog::_edit_preset(int p_index) {
|
||||
export_path->update_property();
|
||||
runnable->set_disabled(false);
|
||||
runnable->set_pressed(current->is_runnable());
|
||||
parameters->set_object_class(current->get_platform()->get_class_name());
|
||||
parameters->edit(current.ptr());
|
||||
|
||||
export_filter->select(current->get_export_filter());
|
||||
@@ -1161,6 +1162,7 @@ ProjectExportDialog::ProjectExportDialog() {
|
||||
parameters->set_name(TTR("Options"));
|
||||
parameters->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
parameters->set_property_name_style(EditorPropertyNameProcessor::get_settings_style());
|
||||
parameters->set_use_doc_hints(true);
|
||||
parameters->connect("property_edited", callable_mp(this, &ProjectExportDialog::_update_parameters));
|
||||
EditorExport::get_singleton()->connect("export_presets_updated", callable_mp(this, &ProjectExportDialog::_force_update_current_preset_parameters));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user