summaryrefslogtreecommitdiffstats
path: root/platform/android
diff options
context:
space:
mode:
authorNikita <nikitf777@gmail.com>2024-10-08 21:39:29 +0300
committerNikita <nikitf777@gmail.com>2024-11-17 22:25:39 +0300
commitc6f42287068fe359eefd0f7744ec294eccae68c5 (patch)
treebfafa920dbf3a4345d6a9e5ac4b8a1db3876be2d /platform/android
parent4c4e67334412f73c9deba5e5d29afa8651418af2 (diff)
downloadredot-engine-c6f42287068fe359eefd0f7744ec294eccae68c5.tar.gz
Add default value of editor propetry "export/android/android_sdk_path" for Windows, Linux, and macOS
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/export/export.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 93ac498ab3..ed53c1e687 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -37,6 +37,8 @@
#include "editor/editor_settings.h"
#include "editor/export/editor_export.h"
+String get_default_android_sdk_path();
+
void register_android_exporter_types() {
GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformAndroid);
}
@@ -52,8 +54,10 @@ void register_android_exporter() {
#ifndef ANDROID_ENABLED
EDITOR_DEF_BASIC("export/android/java_sdk_path", OS::get_singleton()->get_environment("JAVA_HOME"));
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/java_sdk_path", PROPERTY_HINT_GLOBAL_DIR));
- EDITOR_DEF_BASIC("export/android/android_sdk_path", OS::get_singleton()->get_environment("ANDROID_HOME"));
+
+ EDITOR_DEF_BASIC("export/android/android_sdk_path", OS::get_singleton()->has_environment("ANDROID_HOME") ? OS::get_singleton()->get_environment("ANDROID_HOME") : get_default_android_sdk_path());
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/android_sdk_path", PROPERTY_HINT_GLOBAL_DIR));
+
EDITOR_DEF("export/android/force_system_user", false);
EDITOR_DEF("export/android/shutdown_adb_on_exit", true);
@@ -67,3 +71,15 @@ void register_android_exporter() {
Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>(memnew(EditorExportPlatformAndroid));
EditorExport::get_singleton()->add_export_platform(exporter);
}
+
+inline String get_default_android_sdk_path() {
+#ifdef WINDOWS_ENABLED
+ return OS::get_singleton()->get_environment("LOCALAPPDATA").path_join("Android/Sdk");
+#elif LINUXBSD_ENABLED
+ return OS::get_singleton()->get_environment("HOME").path_join("Android/Sdk");
+#elif MACOS_ENABLED
+ return OS::get_singleton()->get_environment("HOME").path_join("Library/Android/sdk");
+#else
+ return String();
+#endif
+}