Skip to content

Commit c703195

Browse files
authored
Update the configuration and launch mechanism for the hybrid app feature (#280)
1 parent 1f4d075 commit c703195

File tree

10 files changed

+229
-81
lines changed

10 files changed

+229
-81
lines changed

Diff for: config.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ext {
1919

2020
// Parse the release version from the gradle project properties (e.g: -Prelease_version=<version>)
2121
getReleaseVersion = { ->
22-
final String defaultVersion = "3.1.0-dev-SNAPSHOT"
22+
final String defaultVersion = "4.0.0-dev-SNAPSHOT"
2323

2424
String releaseVersion = project.hasProperty("release_version") ? project.property("release_version") : defaultVersion
2525
if (releaseVersion == null || releaseVersion.isEmpty()) {

Diff for: plugin/src/main/cpp/export/export_plugin.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,15 @@ Dictionary OpenXREditorExportPlugin::_get_vendor_toggle_option(const String &ven
9191
true);
9292
}
9393

94-
OpenXREditorExportPlugin::HybridType OpenXREditorExportPlugin::_get_hybrid_app_setting_value() const {
95-
return (HybridType)(int)ProjectSettings::get_singleton()->get_setting_with_override("xr/openxr/hybrid_app");
94+
bool OpenXREditorExportPlugin::_is_hybrid_app_enabled() const {
95+
return ProjectSettings::get_singleton()->get_setting_with_override("xr/hybrid_app/enabled");
96+
}
97+
98+
OpenXRHybridApp::HybridMode OpenXREditorExportPlugin::_get_hybrid_app_launch_mode() const {
99+
if (!_is_hybrid_app_enabled()) {
100+
return OpenXRHybridApp::HYBRID_MODE_NONE;
101+
}
102+
return (OpenXRHybridApp::HybridMode)(int)ProjectSettings::get_singleton()->get_setting_with_override("xr/hybrid_app/launch_mode");
96103
}
97104

98105
String OpenXREditorExportPlugin::_get_opening_activity_tag_for_panel_app() const {
@@ -127,6 +134,12 @@ String OpenXREditorExportPlugin::_get_common_activity_intent_filter_contents() c
127134
<category android:name="android.intent.category.HOME" />
128135
)";
129136
}
137+
138+
if (_is_hybrid_app_enabled()) {
139+
contents += R"(
140+
<category android:name="org.godotengine.xr.hybrid.IMMERSIVE" />
141+
)";
142+
}
130143
return contents;
131144
}
132145

@@ -198,11 +211,11 @@ Dictionary OpenXREditorExportPlugin::_get_export_options_overrides(const Ref<Edi
198211
return overrides;
199212
}
200213

201-
HybridType hybrid_type = _get_hybrid_app_setting_value();
202-
if (hybrid_type != HYBRID_TYPE_DISABLED) {
214+
OpenXRHybridApp::HybridMode hybrid_launch_mode = _get_hybrid_app_launch_mode();
215+
if (hybrid_launch_mode != OpenXRHybridApp::HYBRID_MODE_NONE) {
203216
// Unless this is a hybrid app that launches as a panel, then we want to force this option on.
204217
// Otherwise, it needs to be off, so that the panel activity can be the one that's launched by default.
205-
overrides["package/show_in_app_library"] = (hybrid_type != HYBRID_TYPE_START_AS_PANEL);
218+
overrides["package/show_in_app_library"] = (hybrid_launch_mode != OpenXRHybridApp::HYBRID_MODE_PANEL);
206219
}
207220

208221
return overrides;

Diff for: plugin/src/main/cpp/export/meta_export_plugin.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ PackedStringArray MetaEditorExportPlugin::_get_export_features(const Ref<EditorE
291291
}
292292

293293
// Add a feature to indicate that this is a hybrid app.
294-
if (_is_openxr_enabled() && _get_hybrid_app_setting_value() != HYBRID_TYPE_DISABLED) {
294+
if (_is_openxr_enabled() && _is_hybrid_app_enabled()) {
295295
features.append(HYBRID_APP_FEATURE);
296296
}
297297

@@ -514,17 +514,18 @@ String MetaEditorExportPlugin::_get_android_manifest_application_element_content
514514
contents += " <meta-data android:name=\"com.oculus.ossplash.background\" android:value=\"passthrough-contextual\" />\n";
515515
}
516516

517-
HybridType hybrid_type = _get_hybrid_app_setting_value();
518-
if (hybrid_type != HYBRID_TYPE_DISABLED) {
517+
OpenXRHybridApp::HybridMode hybrid_launch_mode = _get_hybrid_app_launch_mode();
518+
if (hybrid_launch_mode != OpenXRHybridApp::HYBRID_MODE_NONE) {
519519
contents += _get_opening_activity_tag_for_panel_app();
520520

521521
contents +=
522522
" <intent-filter>\n"
523523
" <action android:name=\"android.intent.action.MAIN\" />\n"
524524
" <category android:name=\"android.intent.category.DEFAULT\" />\n"
525+
" <category android:name=\"org.godotengine.xr.hybrid.PANEL\" />\n"
525526
" <category android:name=\"com.oculus.intent.category.2D\" />\n";
526527

527-
if (hybrid_type == HYBRID_TYPE_START_AS_PANEL) {
528+
if (hybrid_launch_mode == OpenXRHybridApp::HYBRID_MODE_PANEL) {
528529
contents += " <category android:name=\"android.intent.category.LAUNCHER\" />\n";
529530
}
530531

@@ -545,6 +546,8 @@ String MetaEditorExportPlugin::_get_android_manifest_activity_element_contents(c
545546
<intent-filter>
546547
<action android:name="android.intent.action.MAIN" />
547548
549+
<category android:name="android.intent.category.DEFAULT" />
550+
548551
<!-- Enable access to OpenXR on Oculus mobile devices, no-op on other Android
549552
platforms. -->
550553
<category android:name="com.oculus.intent.category.VR" />

Diff for: plugin/src/main/cpp/include/export/export_plugin.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#pragma once
3131

32+
#include "classes/openxr_hybrid_app.h"
33+
3234
#include <godot_cpp/classes/display_server.hpp>
3335
#include <godot_cpp/classes/editor_export_platform.hpp>
3436
#include <godot_cpp/classes/editor_export_plugin.hpp>
@@ -70,12 +72,6 @@ class OpenXREditorExportPlugin : public EditorExportPlugin {
7072
GDCLASS(OpenXREditorExportPlugin, EditorExportPlugin)
7173

7274
public:
73-
enum HybridType {
74-
HYBRID_TYPE_DISABLED,
75-
HYBRID_TYPE_START_AS_IMMERSIVE,
76-
HYBRID_TYPE_START_AS_PANEL,
77-
};
78-
7975
OpenXREditorExportPlugin();
8076

8177
String _get_name() const override;
@@ -114,7 +110,8 @@ class OpenXREditorExportPlugin : public EditorExportPlugin {
114110

115111
Dictionary _get_vendor_toggle_option(const String &vendor_name) const;
116112

117-
HybridType _get_hybrid_app_setting_value() const;
113+
bool _is_hybrid_app_enabled() const;
114+
OpenXRHybridApp::HybridMode _get_hybrid_app_launch_mode() const;
118115

119116
String _get_opening_activity_tag_for_panel_app() const;
120117

Diff for: plugin/src/main/cpp/register_types.cpp

+24-11
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,32 @@ void add_plugin_project_settings() {
291291
}
292292

293293
{
294-
String hybrid_app_setting = "xr/openxr/hybrid_app";
295-
if (!project_settings->has_setting(hybrid_app_setting)) {
296-
project_settings->set_setting(hybrid_app_setting, OpenXRHybridApp::HYBRID_MODE_NONE);
294+
String hybrid_app_enabled_setting = "xr/hybrid_app/enabled";
295+
if (!project_settings->has_setting(hybrid_app_enabled_setting)) {
296+
project_settings->set_setting(hybrid_app_enabled_setting, false);
297297
}
298298

299-
project_settings->set_initial_value(hybrid_app_setting, OpenXRHybridApp::HYBRID_MODE_NONE);
300-
project_settings->set_as_basic(hybrid_app_setting, false);
301-
Dictionary property_info;
302-
property_info["name"] = hybrid_app_setting;
303-
property_info["type"] = Variant::Type::INT;
304-
property_info["hint"] = PROPERTY_HINT_ENUM;
305-
property_info["hint_string"] = "Disabled:-1,Start As Immersive:0,Start As Panel:1";
306-
project_settings->add_property_info(property_info);
299+
project_settings->set_initial_value(hybrid_app_enabled_setting, false);
300+
project_settings->set_as_basic(hybrid_app_enabled_setting, true);
301+
Dictionary hybrid_app_enabled_property_info;
302+
hybrid_app_enabled_property_info["name"] = hybrid_app_enabled_setting;
303+
hybrid_app_enabled_property_info["type"] = Variant::Type::BOOL;
304+
hybrid_app_enabled_property_info["hint"] = PROPERTY_HINT_NONE;
305+
project_settings->add_property_info(hybrid_app_enabled_property_info);
306+
307+
String hybrid_app_launch_mode_setting = "xr/hybrid_app/launch_mode";
308+
if (!project_settings->has_setting(hybrid_app_launch_mode_setting)) {
309+
project_settings->set_setting(hybrid_app_launch_mode_setting, OpenXRHybridApp::HYBRID_MODE_IMMERSIVE);
310+
}
311+
312+
project_settings->set_initial_value(hybrid_app_launch_mode_setting, OpenXRHybridApp::HYBRID_MODE_IMMERSIVE);
313+
project_settings->set_as_basic(hybrid_app_launch_mode_setting, true);
314+
Dictionary hybrid_app_launch_mode_property_info;
315+
hybrid_app_launch_mode_property_info["name"] = hybrid_app_launch_mode_setting;
316+
hybrid_app_launch_mode_property_info["type"] = Variant::Type::INT;
317+
hybrid_app_launch_mode_property_info["hint"] = PROPERTY_HINT_ENUM;
318+
hybrid_app_launch_mode_property_info["hint_string"] = "Start As Immersive:0,Start As Panel:1";
319+
project_settings->add_property_info(hybrid_app_launch_mode_property_info);
307320
}
308321
}
309322

0 commit comments

Comments
 (0)