From 3cadecf17be08198f8a28e0674bfde30c8fc824f Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 2 Oct 2017 16:38:39 -0300 Subject: [PATCH] fixed the OS.has_feature() API, and added support for 32 and 64. --- core/bind/core_bind.cpp | 7 +++++++ core/bind/core_bind.h | 2 ++ core/io/resource_import.cpp | 2 +- core/os/os.cpp | 9 ++++++++- core/os/os.h | 2 +- core/project_settings.cpp | 2 +- editor/editor_export.cpp | 6 ++++++ editor/project_settings_editor.cpp | 2 ++ platform/osx/export/export.cpp | 10 ++++++++++ 9 files changed, 38 insertions(+), 4 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 7de1c7e6b91..9c655b94609 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -453,6 +453,11 @@ int _OS::get_power_percent_left() { return OS::get_singleton()->get_power_percent_left(); } +bool _OS::has_feature(const String &p_feature) const { + + return OS::get_singleton()->has_feature(p_feature); +} + /* enum Weekday { DAY_SUNDAY, @@ -1105,6 +1110,8 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_vsync", "enable"), &_OS::set_use_vsync); ClassDB::bind_method(D_METHOD("is_vsync_enabled"), &_OS::is_vsync_enabled); + ClassDB::bind_method(D_METHOD("has_feature", "tag_name"), &_OS::has_feature); + ClassDB::bind_method(D_METHOD("get_power_state"), &_OS::get_power_state); ClassDB::bind_method(D_METHOD("get_power_seconds_left"), &_OS::get_power_seconds_left); ClassDB::bind_method(D_METHOD("get_power_percent_left"), &_OS::get_power_percent_left); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 6f3606dcc3c..d69cb86e48f 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -317,6 +317,8 @@ public: int get_power_seconds_left(); int get_power_percent_left(); + bool has_feature(const String &p_feature) const; + static _OS *get_singleton() { return singleton; } _OS(); diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index bc7ea477627..401d7042225 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -77,7 +77,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy if (assign != String()) { if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) { String feature = assign.get_slicec('.', 1); - if (OS::get_singleton()->check_feature_support(feature)) { + if (OS::get_singleton()->has_feature(feature)) { r_path_and_type.path = value; path_found = true; //first match must have priority } diff --git a/core/os/os.cpp b/core/os/os.cpp index ff17cdb508d..f2295823b25 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -494,7 +494,7 @@ int OS::get_power_percent_left() { return -1; } -bool OS::check_feature_support(const String &p_feature) { +bool OS::has_feature(const String &p_feature) { if (p_feature == get_name()) return true; @@ -506,6 +506,13 @@ bool OS::check_feature_support(const String &p_feature) { return true; #endif + if (sizeof(void *) == 8 && p_feature == "64") { + return true; + } + if (sizeof(void *) == 4 && p_feature == "32") { + return true; + } + if (_check_internal_feature_support(p_feature)) return true; diff --git a/core/os/os.h b/core/os/os.h index 5de07be0055..e819666a735 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -427,7 +427,7 @@ public: virtual int get_power_seconds_left(); virtual int get_power_percent_left(); - bool check_feature_support(const String &p_feature); + bool has_feature(const String &p_feature); /** * Returns the stack bottom of the main thread of the application. diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 14ebe87dc55..3e27597e740 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -152,7 +152,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) { bool override_valid = false; for (int i = 1; i < s.size(); i++) { String feature = s[i].strip_edges(); - if (OS::get_singleton()->check_feature_support(feature) || custom_features.has(feature)) { + if (OS::get_singleton()->has_feature(feature) || custom_features.has(feature)) { override_valid = true; break; } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index db12998dd20..bc20a99809d 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1141,6 +1141,12 @@ void EditorExportPlatformPC::get_preset_features(const Ref & if (p_preset->get("texture_format/etc2")) { r_features->push_back("etc2"); } + + if (p_preset->get("binary_format/64_bits")) { + r_features->push_back("64"); + } else { + r_features->push_back("32"); + } } void EditorExportPlatformPC::get_export_options(List *r_options) { diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 56e593e34be..288328c7ed3 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -907,6 +907,8 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() { presets.insert("pvrtc"); presets.insert("debug"); presets.insert("release"); + presets.insert("32"); + presets.insert("64"); for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { List p; diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 2ec76fe0ddd..0fd21d62eea 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -97,6 +97,16 @@ void EditorExportPlatformOSX::get_preset_features(const Ref if (p_preset->get("texture_format/etc2")) { r_features->push_back("etc2"); } + + int bits = p_preset->get("application/bits_mode"); + + if (bits == 0 || bits == 1) { + r_features->push_back("64"); + } + + if (bits == 0 || bits == 2) { + r_features->push_back("32"); + } } void EditorExportPlatformOSX::get_export_options(List *r_options) {