From 741efa632afb0ea41926530c1bb40b2b2e8daa05 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Fri, 13 Sep 2024 08:53:29 -0700 Subject: Update the Android editor flavors to avoid vendor-specific references --- platform/android/java/editor/build.gradle | 12 +-- .../java/org/godotengine/editor/GodotEditor.kt | 39 ++++++++ .../java/org/godotengine/editor/GodotEditor.kt | 39 -------- .../java/editor/src/horizonos/AndroidManifest.xml | 99 +++++++++++++++++++++ .../java/editor/src/horizonos/assets/vr_splash.png | Bin 0 -> 14766 bytes .../java/org/godotengine/editor/GodotEditor.kt | 92 +++++++++++++++++++ .../java/org/godotengine/editor/GodotXRGame.kt | 78 ++++++++++++++++ .../java/org/godotengine/editor/BaseGodotEditor.kt | 4 + .../java/editor/src/meta/AndroidManifest.xml | 99 --------------------- .../java/editor/src/meta/assets/vr_splash.png | Bin 14766 -> 0 bytes .../java/org/godotengine/editor/GodotEditor.kt | 92 ------------------- .../java/org/godotengine/editor/GodotXRGame.kt | 78 ---------------- 12 files changed, 318 insertions(+), 314 deletions(-) create mode 100644 platform/android/java/editor/src/android/java/org/godotengine/editor/GodotEditor.kt delete mode 100644 platform/android/java/editor/src/google/java/org/godotengine/editor/GodotEditor.kt create mode 100644 platform/android/java/editor/src/horizonos/AndroidManifest.xml create mode 100644 platform/android/java/editor/src/horizonos/assets/vr_splash.png create mode 100644 platform/android/java/editor/src/horizonos/java/org/godotengine/editor/GodotEditor.kt create mode 100644 platform/android/java/editor/src/horizonos/java/org/godotengine/editor/GodotXRGame.kt delete mode 100644 platform/android/java/editor/src/meta/AndroidManifest.xml delete mode 100644 platform/android/java/editor/src/meta/assets/vr_splash.png delete mode 100644 platform/android/java/editor/src/meta/java/org/godotengine/editor/GodotEditor.kt delete mode 100644 platform/android/java/editor/src/meta/java/org/godotengine/editor/GodotXRGame.kt (limited to 'platform/android/java/editor') diff --git a/platform/android/java/editor/build.gradle b/platform/android/java/editor/build.gradle index 54d6b9b5f3..45222ca3b0 100644 --- a/platform/android/java/editor/build.gradle +++ b/platform/android/java/editor/build.gradle @@ -145,14 +145,14 @@ android { } } - flavorDimensions = ["vendor"] + flavorDimensions = ["android_distribution"] productFlavors { - google { - dimension "vendor" + android { + dimension "android_distribution" missingDimensionStrategy 'products', 'editor' } - meta { - dimension "vendor" + horizonos { + dimension "android_distribution" missingDimensionStrategy 'products', 'editor' ndk { //noinspection ChromeOsAbiSupport @@ -176,5 +176,5 @@ dependencies { implementation "org.bouncycastle:bcprov-jdk15to18:1.77" // Meta dependencies - metaImplementation "org.godotengine:godot-openxr-vendors-meta:3.0.0-stable" + horizonosImplementation "org.godotengine:godot-openxr-vendors-meta:3.0.0-stable" } diff --git a/platform/android/java/editor/src/android/java/org/godotengine/editor/GodotEditor.kt b/platform/android/java/editor/src/android/java/org/godotengine/editor/GodotEditor.kt new file mode 100644 index 0000000000..f15d9f7768 --- /dev/null +++ b/platform/android/java/editor/src/android/java/org/godotengine/editor/GodotEditor.kt @@ -0,0 +1,39 @@ +/**************************************************************************/ +/* GodotEditor.kt */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +package org.godotengine.editor + +/** + * Primary window of the Godot Editor. + * + * This is the implementation of the editor used when running on regular Android devices. + */ +open class GodotEditor : BaseGodotEditor() { +} diff --git a/platform/android/java/editor/src/google/java/org/godotengine/editor/GodotEditor.kt b/platform/android/java/editor/src/google/java/org/godotengine/editor/GodotEditor.kt deleted file mode 100644 index f15d9f7768..0000000000 --- a/platform/android/java/editor/src/google/java/org/godotengine/editor/GodotEditor.kt +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************/ -/* GodotEditor.kt */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -package org.godotengine.editor - -/** - * Primary window of the Godot Editor. - * - * This is the implementation of the editor used when running on regular Android devices. - */ -open class GodotEditor : BaseGodotEditor() { -} diff --git a/platform/android/java/editor/src/horizonos/AndroidManifest.xml b/platform/android/java/editor/src/horizonos/AndroidManifest.xml new file mode 100644 index 0000000000..06442ac4e6 --- /dev/null +++ b/platform/android/java/editor/src/horizonos/AndroidManifest.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/android/java/editor/src/horizonos/assets/vr_splash.png b/platform/android/java/editor/src/horizonos/assets/vr_splash.png new file mode 100644 index 0000000000..7bddd4325a Binary files /dev/null and b/platform/android/java/editor/src/horizonos/assets/vr_splash.png differ diff --git a/platform/android/java/editor/src/horizonos/java/org/godotengine/editor/GodotEditor.kt b/platform/android/java/editor/src/horizonos/java/org/godotengine/editor/GodotEditor.kt new file mode 100644 index 0000000000..6cb08ae94b --- /dev/null +++ b/platform/android/java/editor/src/horizonos/java/org/godotengine/editor/GodotEditor.kt @@ -0,0 +1,92 @@ +/**************************************************************************/ +/* GodotEditor.kt */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +package org.godotengine.editor + +import org.godotengine.godot.GodotLib +import org.godotengine.godot.utils.isNativeXRDevice + +/** + * Primary window of the Godot Editor. + * + * This is the implementation of the editor used when running on HorizonOS devices. + */ +open class GodotEditor : BaseGodotEditor() { + + companion object { + private val TAG = GodotEditor::class.java.simpleName + + internal val XR_RUN_GAME_INFO = EditorWindowInfo(GodotXRGame::class.java, 1667, ":GodotXRGame") + + internal const val USE_SCENE_PERMISSION = "com.oculus.permission.USE_SCENE" + } + + override fun getExcludedPermissions(): MutableSet { + val excludedPermissions = super.getExcludedPermissions() + // The USE_SCENE permission is requested when the "xr/openxr/enabled" project setting + // is enabled. + excludedPermissions.add(USE_SCENE_PERMISSION) + return excludedPermissions + } + + override fun retrieveEditorWindowInfo(args: Array): EditorWindowInfo { + var hasEditor = false + var xrModeOn = false + + var i = 0 + while (i < args.size) { + when (args[i++]) { + EDITOR_ARG, EDITOR_ARG_SHORT, EDITOR_PROJECT_MANAGER_ARG, EDITOR_PROJECT_MANAGER_ARG_SHORT -> hasEditor = true + XR_MODE_ARG -> { + val argValue = args[i++] + xrModeOn = xrModeOn || ("on" == argValue) + } + } + } + + return if (hasEditor) { + EDITOR_MAIN_INFO + } else { + val openxrEnabled = GodotLib.getGlobal("xr/openxr/enabled").toBoolean() + if (openxrEnabled && isNativeXRDevice()) { + XR_RUN_GAME_INFO + } else { + RUN_GAME_INFO + } + } + } + + override fun getEditorWindowInfoForInstanceId(instanceId: Int): EditorWindowInfo? { + return when (instanceId) { + XR_RUN_GAME_INFO.windowId -> XR_RUN_GAME_INFO + else -> super.getEditorWindowInfoForInstanceId(instanceId) + } + } +} diff --git a/platform/android/java/editor/src/horizonos/java/org/godotengine/editor/GodotXRGame.kt b/platform/android/java/editor/src/horizonos/java/org/godotengine/editor/GodotXRGame.kt new file mode 100644 index 0000000000..5db2879aad --- /dev/null +++ b/platform/android/java/editor/src/horizonos/java/org/godotengine/editor/GodotXRGame.kt @@ -0,0 +1,78 @@ +/*************************************************************************/ +/* GodotXRGame.kt */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +package org.godotengine.editor + +import org.godotengine.godot.GodotLib +import org.godotengine.godot.xr.XRMode + +/** + * Provide support for running XR apps / games from the editor window. + */ +open class GodotXRGame: GodotGame() { + + override fun overrideOrientationRequest() = true + + override fun updateCommandLineParams(args: List) { + val updatedArgs = ArrayList() + if (!args.contains(XRMode.OPENXR.cmdLineArg)) { + updatedArgs.add(XRMode.OPENXR.cmdLineArg) + } + if (!args.contains(XR_MODE_ARG)) { + updatedArgs.add(XR_MODE_ARG) + updatedArgs.add("on") + } + updatedArgs.addAll(args) + + super.updateCommandLineParams(updatedArgs) + } + + override fun getEditorWindowInfo() = XR_RUN_GAME_INFO + + override fun getProjectPermissionsToEnable(): MutableList { + val permissionsToEnable = super.getProjectPermissionsToEnable() + + val openxrEnabled = GodotLib.getGlobal("xr/openxr/enabled").toBoolean() + if (openxrEnabled) { + // We only request permissions when the `automatically_request_runtime_permissions` + // project setting is enabled. + // If the project setting is not defined, we fall-back to the default behavior which is + // to automatically request permissions. + val automaticallyRequestPermissionsSetting = GodotLib.getGlobal("xr/openxr/extensions/automatically_request_runtime_permissions") + val automaticPermissionsRequestEnabled = automaticallyRequestPermissionsSetting.isNullOrEmpty() || + automaticallyRequestPermissionsSetting.toBoolean() + if (automaticPermissionsRequestEnabled) { + permissionsToEnable.add(USE_SCENE_PERMISSION) + } + } + + return permissionsToEnable + } +} diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt index d296d6ad03..7b6d1f6bd1 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt @@ -517,6 +517,10 @@ abstract class BaseGodotEditor : GodotActivity() { return isNativeXRDevice(); } + if (featureTag == "horizonos") { + return isHorizonOSDevice() + } + return false } } diff --git a/platform/android/java/editor/src/meta/AndroidManifest.xml b/platform/android/java/editor/src/meta/AndroidManifest.xml deleted file mode 100644 index 06442ac4e6..0000000000 --- a/platform/android/java/editor/src/meta/AndroidManifest.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/android/java/editor/src/meta/assets/vr_splash.png b/platform/android/java/editor/src/meta/assets/vr_splash.png deleted file mode 100644 index 7bddd4325a..0000000000 Binary files a/platform/android/java/editor/src/meta/assets/vr_splash.png and /dev/null differ diff --git a/platform/android/java/editor/src/meta/java/org/godotengine/editor/GodotEditor.kt b/platform/android/java/editor/src/meta/java/org/godotengine/editor/GodotEditor.kt deleted file mode 100644 index 328ff9a3bd..0000000000 --- a/platform/android/java/editor/src/meta/java/org/godotengine/editor/GodotEditor.kt +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************/ -/* GodotEditor.kt */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -package org.godotengine.editor - -import org.godotengine.godot.GodotLib -import org.godotengine.godot.utils.isNativeXRDevice - -/** - * Primary window of the Godot Editor. - * - * This is the implementation of the editor used when running on Meta devices. - */ -open class GodotEditor : BaseGodotEditor() { - - companion object { - private val TAG = GodotEditor::class.java.simpleName - - internal val XR_RUN_GAME_INFO = EditorWindowInfo(GodotXRGame::class.java, 1667, ":GodotXRGame") - - internal const val USE_SCENE_PERMISSION = "com.oculus.permission.USE_SCENE" - } - - override fun getExcludedPermissions(): MutableSet { - val excludedPermissions = super.getExcludedPermissions() - // The USE_SCENE permission is requested when the "xr/openxr/enabled" project setting - // is enabled. - excludedPermissions.add(USE_SCENE_PERMISSION) - return excludedPermissions - } - - override fun retrieveEditorWindowInfo(args: Array): EditorWindowInfo { - var hasEditor = false - var xrModeOn = false - - var i = 0 - while (i < args.size) { - when (args[i++]) { - EDITOR_ARG, EDITOR_ARG_SHORT, EDITOR_PROJECT_MANAGER_ARG, EDITOR_PROJECT_MANAGER_ARG_SHORT -> hasEditor = true - XR_MODE_ARG -> { - val argValue = args[i++] - xrModeOn = xrModeOn || ("on" == argValue) - } - } - } - - return if (hasEditor) { - EDITOR_MAIN_INFO - } else { - val openxrEnabled = GodotLib.getGlobal("xr/openxr/enabled").toBoolean() - if (openxrEnabled && isNativeXRDevice()) { - XR_RUN_GAME_INFO - } else { - RUN_GAME_INFO - } - } - } - - override fun getEditorWindowInfoForInstanceId(instanceId: Int): EditorWindowInfo? { - return when (instanceId) { - XR_RUN_GAME_INFO.windowId -> XR_RUN_GAME_INFO - else -> super.getEditorWindowInfoForInstanceId(instanceId) - } - } -} diff --git a/platform/android/java/editor/src/meta/java/org/godotengine/editor/GodotXRGame.kt b/platform/android/java/editor/src/meta/java/org/godotengine/editor/GodotXRGame.kt deleted file mode 100644 index 5db2879aad..0000000000 --- a/platform/android/java/editor/src/meta/java/org/godotengine/editor/GodotXRGame.kt +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************/ -/* GodotXRGame.kt */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -package org.godotengine.editor - -import org.godotengine.godot.GodotLib -import org.godotengine.godot.xr.XRMode - -/** - * Provide support for running XR apps / games from the editor window. - */ -open class GodotXRGame: GodotGame() { - - override fun overrideOrientationRequest() = true - - override fun updateCommandLineParams(args: List) { - val updatedArgs = ArrayList() - if (!args.contains(XRMode.OPENXR.cmdLineArg)) { - updatedArgs.add(XRMode.OPENXR.cmdLineArg) - } - if (!args.contains(XR_MODE_ARG)) { - updatedArgs.add(XR_MODE_ARG) - updatedArgs.add("on") - } - updatedArgs.addAll(args) - - super.updateCommandLineParams(updatedArgs) - } - - override fun getEditorWindowInfo() = XR_RUN_GAME_INFO - - override fun getProjectPermissionsToEnable(): MutableList { - val permissionsToEnable = super.getProjectPermissionsToEnable() - - val openxrEnabled = GodotLib.getGlobal("xr/openxr/enabled").toBoolean() - if (openxrEnabled) { - // We only request permissions when the `automatically_request_runtime_permissions` - // project setting is enabled. - // If the project setting is not defined, we fall-back to the default behavior which is - // to automatically request permissions. - val automaticallyRequestPermissionsSetting = GodotLib.getGlobal("xr/openxr/extensions/automatically_request_runtime_permissions") - val automaticPermissionsRequestEnabled = automaticallyRequestPermissionsSetting.isNullOrEmpty() || - automaticallyRequestPermissionsSetting.toBoolean() - if (automaticPermissionsRequestEnabled) { - permissionsToEnable.add(USE_SCENE_PERMISSION) - } - } - - return permissionsToEnable - } -} -- cgit v1.2.3