fixed the OS.has_feature() API, and added support for 32 and 64.

This commit is contained in:
Juan Linietsky 2017-10-02 16:38:39 -03:00
parent a848fa6cde
commit 3cadecf17b
9 changed files with 38 additions and 4 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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
}

View file

@ -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;

View file

@ -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.

View file

@ -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;
}

View file

@ -1141,6 +1141,12 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &
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<ExportOption> *r_options) {

View file

@ -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<String> p;

View file

@ -97,6 +97,16 @@ void EditorExportPlatformOSX::get_preset_features(const Ref<EditorExportPreset>
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<ExportOption> *r_options) {