Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocompletion for OS.has_feature() #86747

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions core/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#include "core/os/keyboard.h"
#include "core/os/thread_safe.h"
#include "core/variant/typed_array.h"
#ifdef TOOLS_ENABLED
#include "editor/export/editor_export.h"
Mickeon marked this conversation as resolved.
Show resolved Hide resolved
#endif // TOOLS_ENABLED

namespace core_bind {

Expand Down Expand Up @@ -557,6 +560,19 @@ String OS::get_unique_id() const {
return ::OS::get_singleton()->get_unique_id();
}

#ifdef TOOLS_ENABLED
void OS::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
String pf = p_function;
if (p_idx == 0 && pf == "has_feature") {
HashSet<String> presets = EditorExport::get_singleton()->get_available_features();
Mickeon marked this conversation as resolved.
Show resolved Hide resolved

for (const String &E : presets) {
r_options->push_back(E.quote());
}
}
}
#endif // TOOLS_ENABLED

OS *OS::singleton = nullptr;

void OS::_bind_methods() {
Expand Down
4 changes: 4 additions & 0 deletions core/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ class OS : public Object {
Vector<String> get_granted_permissions() const;
void revoke_granted_permissions();

#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
Mickeon marked this conversation as resolved.
Show resolved Hide resolved
#endif // TOOLS_ENABLED

static OS *get_singleton() { return singleton; }

OS() { singleton = this; }
Expand Down
47 changes: 47 additions & 0 deletions editor/export/editor_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,53 @@ Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() {
return export_plugins;
}

HashSet<String> EditorExport::get_available_features() {
HashSet<String> presets;

presets.insert("bptc");
presets.insert("s3tc");
presets.insert("etc");
presets.insert("etc2");
presets.insert("editor");
presets.insert("template_debug");
presets.insert("template_release");
presets.insert("debug");
presets.insert("release");
presets.insert("template");
presets.insert("double");
presets.insert("single");
presets.insert("32");
presets.insert("64");
presets.insert("movie");

for (int i = 0; i < get_export_platform_count(); i++) {
List<String> p;
get_export_platform(i)->get_platform_features(&p);
for (const String &E : p) {
presets.insert(E);
}
}

for (int i = 0; i < get_export_preset_count(); i++) {
List<String> p;
get_export_preset(i)->get_platform()->get_preset_features(get_export_preset(i), &p);
for (const String &E : p) {
presets.insert(E);
}

String custom = get_export_preset(i)->get_custom_features();
Vector<String> custom_list = custom.split(",");
for (int j = 0; j < custom_list.size(); j++) {
String f = custom_list[j].strip_edges();
if (!f.is_empty()) {
presets.insert(f);
}
}
}

return presets;
}

void EditorExport::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
Expand Down
2 changes: 2 additions & 0 deletions editor/export/editor_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class EditorExport : public Node {
void remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin);
Vector<Ref<EditorExportPlugin>> get_export_plugins();

HashSet<String> get_available_features();

void load_config();
void update_export_presets();
bool poll_export_platforms();
Expand Down
45 changes: 1 addition & 44 deletions editor/project_settings_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,50 +275,7 @@ String ProjectSettingsEditor::_get_setting_name() const {
}

void ProjectSettingsEditor::_add_feature_overrides() {
HashSet<String> presets;

presets.insert("bptc");
presets.insert("s3tc");
presets.insert("etc");
presets.insert("etc2");
presets.insert("editor");
presets.insert("template_debug");
presets.insert("template_release");
presets.insert("debug");
presets.insert("release");
presets.insert("template");
presets.insert("double");
presets.insert("single");
presets.insert("32");
presets.insert("64");
presets.insert("movie");

EditorExport *ee = EditorExport::get_singleton();

for (int i = 0; i < ee->get_export_platform_count(); i++) {
List<String> p;
ee->get_export_platform(i)->get_platform_features(&p);
for (const String &E : p) {
presets.insert(E);
}
}

for (int i = 0; i < ee->get_export_preset_count(); i++) {
List<String> p;
ee->get_export_preset(i)->get_platform()->get_preset_features(ee->get_export_preset(i), &p);
for (const String &E : p) {
presets.insert(E);
}

String custom = ee->get_export_preset(i)->get_custom_features();
Vector<String> custom_list = custom.split(",");
for (int j = 0; j < custom_list.size(); j++) {
String f = custom_list[j].strip_edges();
if (!f.is_empty()) {
presets.insert(f);
}
}
}
HashSet<String> presets = EditorExport::get_singleton()->get_available_features();

feature_box->clear();
feature_box->add_item(TTR("(All)"), 0); // So it is always on top.
Expand Down
Loading