You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Fix create_instance in android GodotApp so non-editor apps can restart
Enables OS.create_instance(args) and OS.set_restart_on_exit(true, args) on android. Borrowed the logic from the editor, so it completely restarts the process so you can pass --rendering-method, --rendering-driver to switch between forward_plus, mobile, gl_compatibility etc on an exported app. Related: https://github.com/godotengine/godot-proposals/issues/6423
This commit is contained in:
@@ -71,8 +71,6 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||
|
||||
private const val WAIT_FOR_DEBUGGER = false
|
||||
|
||||
@JvmStatic
|
||||
protected val EXTRA_COMMAND_LINE_PARAMS = "command_line_params"
|
||||
@JvmStatic
|
||||
protected val EXTRA_PIP_AVAILABLE = "pip_available"
|
||||
@JvmStatic
|
||||
@@ -130,7 +128,6 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||
}
|
||||
|
||||
private val editorMessageDispatcher = EditorMessageDispatcher(this)
|
||||
private val commandLineParams = ArrayList<String>()
|
||||
private val editorLoadingIndicator: View? by lazy { findViewById(R.id.editor_loading_indicator) }
|
||||
|
||||
override fun getGodotAppLayout() = R.layout.godot_editor_layout
|
||||
@@ -183,10 +180,6 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||
// requested on demand based on use cases.
|
||||
PermissionsUtil.requestManifestPermissions(this, getExcludedPermissions())
|
||||
|
||||
val params = intent.getStringArrayExtra(EXTRA_COMMAND_LINE_PARAMS)
|
||||
Log.d(TAG, "Starting intent $intent with parameters ${params.contentToString()}")
|
||||
updateCommandLineParams(params?.asList() ?: emptyList())
|
||||
|
||||
editorMessageDispatcher.parseStartIntent(packageManager, intent)
|
||||
|
||||
if (BuildConfig.BUILD_TYPE == "dev" && WAIT_FOR_DEBUGGER) {
|
||||
@@ -219,20 +212,16 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
protected open fun updateCommandLineParams(args: List<String>) {
|
||||
// Update the list of command line params with the new args
|
||||
commandLineParams.clear()
|
||||
if (args.isNotEmpty()) {
|
||||
commandLineParams.addAll(args)
|
||||
}
|
||||
if (BuildConfig.BUILD_TYPE == "dev") {
|
||||
commandLineParams.add("--benchmark")
|
||||
protected override fun updateCommandLineParams(args: Array<String>) {
|
||||
val args = if (BuildConfig.BUILD_TYPE == "dev") {
|
||||
args + "--benchmark"
|
||||
} else {
|
||||
args
|
||||
}
|
||||
super.updateCommandLineParams(args);
|
||||
}
|
||||
|
||||
final override fun getCommandLine() = commandLineParams
|
||||
|
||||
protected fun retrieveEditorWindowInfo(args: Array<String>): EditorWindowInfo {
|
||||
protected open fun retrieveEditorWindowInfo(args: Array<String>): EditorWindowInfo {
|
||||
var hasEditor = false
|
||||
var xrMode = XR_MODE_DEFAULT
|
||||
|
||||
@@ -335,14 +324,7 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||
val newInstance = getNewGodotInstanceIntent(editorWindowInfo, args)
|
||||
if (editorWindowInfo.windowClassName == javaClass.name) {
|
||||
Log.d(TAG, "Restarting ${editorWindowInfo.windowClassName} with parameters ${args.contentToString()}")
|
||||
val godot = godot
|
||||
if (godot != null) {
|
||||
godot.destroyAndKillProcess {
|
||||
ProcessPhoenix.triggerRebirth(this, activityOptions?.toBundle(), newInstance)
|
||||
}
|
||||
} else {
|
||||
ProcessPhoenix.triggerRebirth(this, activityOptions?.toBundle(), newInstance)
|
||||
}
|
||||
triggerRebirth(activityOptions?.toBundle(), newInstance)
|
||||
} else {
|
||||
Log.d(TAG, "Starting ${editorWindowInfo.windowClassName} with parameters ${args.contentToString()}")
|
||||
newInstance.putExtra(EXTRA_NEW_LAUNCH, true)
|
||||
|
||||
@@ -40,7 +40,7 @@ open class GodotXRGame: GodotGame() {
|
||||
|
||||
override fun overrideOrientationRequest() = true
|
||||
|
||||
override fun updateCommandLineParams(args: List<String>) {
|
||||
override fun updateCommandLineParams(args: Array<String>) {
|
||||
val updatedArgs = ArrayList<String>()
|
||||
if (!args.contains(XRMode.OPENXR.cmdLineArg)) {
|
||||
updatedArgs.add(XRMode.OPENXR.cmdLineArg)
|
||||
@@ -51,7 +51,7 @@ open class GodotXRGame: GodotGame() {
|
||||
}
|
||||
updatedArgs.addAll(args)
|
||||
|
||||
super.updateCommandLineParams(updatedArgs)
|
||||
super.updateCommandLineParams(updatedArgs.toTypedArray())
|
||||
}
|
||||
|
||||
override fun getEditorWindowInfo() = XR_RUN_GAME_INFO
|
||||
|
||||
Reference in New Issue
Block a user