Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Editor: Add immersive mode option #94285

Closed
wants to merge 3 commits into from

Conversation

20kdc
Copy link
Contributor

@20kdc 20kdc commented Jul 12, 2024

This allows using the Android Godot Editor in immersive mode, making the most of available screen space.

When this setting is enabled, Godot will change into immersive mode mid-startup, as the editor settings are not available until then. (A marker file was considered, but this seemed neater, all things considered. If it works well enough, it also implies that dynamically switching to immersive mode might be a future feature.)

Pre-commit hooks were skipped due to errors in the class reference that, to my knowledge, are outside of the scope of this PR. See the commit message for details. No code formatting errors were detected by the stages that did succeed.

This allows using the Android Godot Editor in immersive mode, making the most of available screen space.

Pre-commit hooks were skipped due to the following errors, that, to my knowledge, are outside of the scope of this PR:

ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_dependencies" description.
ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_dependencies_maven_repos" description.
ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_libraries" description.
ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_manifest_activity_element_contents" description.
ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_manifest_application_element_contents" description.
ERROR: EditorExportPlugin.xml: Unresolved type reference "EditorExportPlatformAndroid" in method reference "EditorExportPlatformAndroid.gradle_build/use_gradle_build" in method "_get_android_manifest_element_contents" description.
@20kdc 20kdc requested a review from a team as a code owner July 12, 2024 21:02
Copy link
Contributor

@m4gr3d m4gr3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested how immersive mode behaves on tablet when the editor window is opened side-by-side with the running project window?

* For now, once you go immersive, you can't go back.
* Call only from UI thread.
*/
fun goImmersive() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename the method to enableImmersive() and give it internal visibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be both internal and also accessed from GodotEditor, so I'll do the latter.

Comment on lines 306 to 307
if (useImmersive)
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing brackets

Comment on lines 666 to 672
} else {
val shouldGoImmersive = java.lang.Boolean.parseBoolean(GodotLib.getEditorSetting("interface/editor/android/immersive_mode"))

runOnUiThread {
if (shouldGoImmersive)
goImmersive()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this logic to GodotEditor and have that class invoke Godot::enableImmersive() as needed.

There is one additional thing we need to consider; should the running project window also open in immersive mode if the editor is immersive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a separate option for the game. This option uses the --use_immersive functionality that already existed.

Copy link
Contributor

@m4gr3d m4gr3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@20kdc Sorry for the delay - I've tested the changes and they look pretty good! This will be a good feature to include for the Godot 4.4 release!

A couple of feedback on the PR:

EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/android/editor_immersive_mode", false, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/android/game_immersive_mode", false, "", PROPERTY_USAGE_DEFAULT)
  • Instead of having two editor settings, let's use a single interface/editor/android/immersive_mode to control immersive mode for both the editor and the play/game window
    • Also let's remove the ANDROID_ENABLED guards around the setting. The fact it's under the android section should be sufficient to point out the setting is only active on Android.

This option uses the --use_immersive functionality that already existed.

I like the approach of re-using the --use_immersive functionality and I think we can update the PR logic to only use that approach for both the editor and the play/game window. In order to do so

  • The logic in editor_run should be moved to GodotEditor#onNewGodotInstanceRequested(...).
  • As done in editor_run, the logic should check if immersive_mode is enabled, and if so add the immersive flag in the args parameter if it doesn't contain it already.
    • With this approach, the PR should only require changes in editor_settings to introduce the setting, and in GodotEditor to update the launch parameters as needed
    • This also means that the project settings will not launch in immersive mode when launch from the library, but I think that's fine as the primary use case is to have the editor window in immersive mode.

@m4gr3d
Copy link
Contributor

m4gr3d commented Aug 27, 2024

This option uses the --use_immersive functionality that already existed.

I like the approach of re-using the --use_immersive functionality and I think we can update the PR logic to only use that approach for both the editor and the play/game window. In order to do so

  • The logic in editor_run should be moved to GodotEditor#onNewGodotInstanceRequested(...).

  • As done in editor_run, the logic should check if immersive_mode is enabled, and if so add the immersive flag in the args parameter if it doesn't contain it already.

    • With this approach, the PR should only require changes in editor_settings to introduce the setting, and in GodotEditor to update the launch parameters as needed
    • This also means that the project settings will not launch in immersive mode when launch from the library, but I think that's fine as the primary use case is to have the editor window in immersive mode.

Found out from testing that saving and reading the editor setting at restart time does not seem to work for some reason (the update editor setting value is not being picked up).
So let's also use your current approach of exposing Godot#enableImmersive() and have GodotEditor invoke it in onGodotMainLoopStarted based on the editor setting.
You should be able to remove the changes in editor_run since, as mentioned in the previous comment, you should use a single setting to control immersive mode for both the editor and the play / game window.

@m4gr3d
Copy link
Contributor

m4gr3d commented Aug 28, 2024

@20kdc I ended up adding the functionality in #96208 while I was cleaning some of the immersive mode logic.
Thanks for kicking off the thread on this feature!

@m4gr3d m4gr3d closed this Aug 28, 2024
@AThousandShips AThousandShips removed this from the 4.4 milestone Aug 28, 2024
@20kdc
Copy link
Contributor Author

20kdc commented Aug 28, 2024

Ah, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants