@@ -15,166 +15,164 @@ static const char *TOOLKIT_DEBUG_KEYSTORE_PROPERTIES_PATH = "res://addons/godot_
1515} // namespace
1616
1717MetaToolkitExportPlugin::MetaToolkitExportPlugin () {
18- _enable_meta_toolkit_option = _generate_export_option (
19- " meta_toolkit/enable_meta_toolkit" ,
20- " " ,
21- Variant::Type::BOOL,
22- PROPERTY_HINT_NONE,
23- " " ,
24- PROPERTY_USAGE_DEFAULT,
25- false ,
26- true );
18+ _enable_meta_toolkit_option = _generate_export_option (
19+ " meta_toolkit/enable_meta_toolkit" ,
20+ " " ,
21+ Variant::Type::BOOL,
22+ PROPERTY_HINT_NONE,
23+ " " ,
24+ PROPERTY_USAGE_DEFAULT,
25+ false ,
26+ true );
2727}
2828
2929void MetaToolkitExportPlugin::_bind_methods () {}
3030
3131Dictionary MetaToolkitExportPlugin::_generate_export_option (const godot::String &p_name,
32- const godot::String &p_class_name,
33- Variant::Type p_type,
34- godot::PropertyHint p_property_hint,
35- const godot::String &p_hint_string,
36- godot::PropertyUsageFlags p_property_usage,
37- const godot::Variant &p_default_value,
38- bool p_update_visibility) {
39- Dictionary option_info;
40- option_info[" name" ] = p_name;
41- option_info[" class_name" ] = p_class_name;
42- option_info[" type" ] = p_type;
43- option_info[" hint" ] = p_property_hint;
44- option_info[" hint_string" ] = p_hint_string;
45- option_info[" usage" ] = p_property_usage;
46-
47- Dictionary export_option;
48- export_option[" option" ] = option_info;
49- export_option[" default_value" ] = p_default_value;
50- export_option[" update_visibility" ] = p_update_visibility;
51-
52- return export_option;
32+ const godot::String &p_class_name,
33+ Variant::Type p_type,
34+ godot::PropertyHint p_property_hint,
35+ const godot::String &p_hint_string,
36+ godot::PropertyUsageFlags p_property_usage,
37+ const godot::Variant &p_default_value,
38+ bool p_update_visibility) {
39+ Dictionary option_info;
40+ option_info[" name" ] = p_name;
41+ option_info[" class_name" ] = p_class_name;
42+ option_info[" type" ] = p_type;
43+ option_info[" hint" ] = p_property_hint;
44+ option_info[" hint_string" ] = p_hint_string;
45+ option_info[" usage" ] = p_property_usage;
46+
47+ Dictionary export_option;
48+ export_option[" option" ] = option_info;
49+ export_option[" default_value" ] = p_default_value;
50+ export_option[" update_visibility" ] = p_update_visibility;
51+
52+ return export_option;
5353}
5454
5555bool MetaToolkitExportPlugin::_supports_platform (const Ref<godot::EditorExportPlatform> &p_platform) const {
56- return p_platform->is_class (EditorExportPlatformAndroid::get_class_static ());
56+ return p_platform->is_class (EditorExportPlatformAndroid::get_class_static ());
5757}
5858
5959bool MetaToolkitExportPlugin::_get_bool_option (const godot::String &p_option) const {
60- Variant option_enabled = get_option (p_option);
61- if (option_enabled.get_type () == Variant::Type::BOOL) {
62- return option_enabled;
63- }
64- return false ;
60+ Variant option_enabled = get_option (p_option);
61+ if (option_enabled.get_type () == Variant::Type::BOOL) {
62+ return option_enabled;
63+ }
64+ return false ;
6565}
6666
6767TypedArray<Dictionary> MetaToolkitExportPlugin::_get_export_options (const Ref<godot::EditorExportPlatform> &p_platform) const {
68- TypedArray<Dictionary> export_options;
69- if (!_supports_platform (p_platform)) {
70- return export_options;
71- }
68+ TypedArray<Dictionary> export_options;
69+ if (!_supports_platform (p_platform)) {
70+ return export_options;
71+ }
7272
73- export_options.append (_enable_meta_toolkit_option);
73+ export_options.append (_enable_meta_toolkit_option);
7474
75- return export_options;
75+ return export_options;
7676}
7777
7878String MetaToolkitExportPlugin::_get_export_option_warning (
79- const Ref<godot::EditorExportPlatform> &p_platform, const godot::String &p_option) const {
80- return " " ;
79+ const Ref<godot::EditorExportPlatform> &p_platform, const godot::String &p_option) const {
80+ return " " ;
8181}
8282
8383Dictionary MetaToolkitExportPlugin::_get_export_options_overrides (
84- const Ref<godot::EditorExportPlatform> &p_platform) const {
85- Dictionary overrides;
86- if (!_supports_platform (p_platform)) {
87- return overrides;
88- }
89-
90- // Check if this plugin is enabled
91- if (!_get_bool_option (" meta_toolkit/enable_meta_toolkit" )) {
92- return overrides;
93- }
94-
95- // Gradle build overrides
96- overrides[" gradle_build/use_gradle_build" ] = true ;
97- overrides[" gradle_build/export_format" ] = 0 ; // apk
98- overrides[" gradle_build/min_sdk" ] = " 29" ; // Android 10
99- overrides[" gradle_build/target_sdk" ] = " 32" ; // Android 12
100-
101- // Check if we have an alternate build template
102- if (FileAccess::file_exists (TOOLKIT_BUILD_TEMPLATE_ZIP_PATH)) {
103- overrides[" gradle_build/gradle_build_directory" ] = " res://addons/godot_meta_toolkit/build" ;
104- overrides[" gradle_build/android_source_template" ] = TOOLKIT_BUILD_TEMPLATE_ZIP_PATH;
105- }
106-
107- // Check if we have a debug keystore available
108- if (FileAccess::file_exists (TOOLKIT_DEBUG_KEYSTORE_PATH)
109- && FileAccess::file_exists (TOOLKIT_DEBUG_KEYSTORE_PROPERTIES_PATH)) {
110- // Read the debug keystore user and password from the properties file
111- // The file should contain the following lines:
112- // key.alias=platformkeystore
113- // key.alias.password=android
114- Ref<FileAccess> file_access = FileAccess::open (TOOLKIT_DEBUG_KEYSTORE_PROPERTIES_PATH, FileAccess::ModeFlags::READ);
115- if (file_access.is_valid ()) {
116- String debug_user;
117- String debug_password;
118-
119- while (file_access->get_position () < file_access->get_length ()
120- && (debug_user.is_empty () || debug_password.is_empty ())) {
121- String current_line = file_access->get_line ();
122- PackedStringArray current_line_splits = current_line.split (" =" , false );
123- if (current_line_splits.size () == 2 ) {
124- if (current_line_splits[0 ] == " key.alias" ) {
125- debug_user = current_line_splits[1 ];
126- } else if (current_line_splits[0 ] == " key.alias.password" ) {
127- debug_password = current_line_splits[1 ];
128- }
129- }
130- }
131-
132- if (!debug_user.is_empty () && !debug_password.is_empty ()) {
133- overrides[" keystore/debug" ] = ProjectSettings::get_singleton ()->globalize_path (TOOLKIT_DEBUG_KEYSTORE_PATH);
134- overrides[" keystore/debug_user" ] = debug_user;
135- overrides[" keystore/debug_password" ] = debug_password;
136- }
137- }
138- }
139-
140- // Architectures overrides
141- overrides[" architectures/armeabi-v7a" ] = false ;
142- overrides[" architectures/arm64-v8a" ] = true ;
143- overrides[" architectures/x86" ] = false ;
144- overrides[" architectures/x86_64" ] = false ;
145-
146- // Package overrides
147- overrides[" package/show_in_android_tv" ] = false ;
148-
149- // Screen overrides
150- overrides[" screen/immersive_mode" ] = true ;
151- overrides[" screen/support_small" ] = true ;
152- overrides[" screen/support_normal" ] = true ;
153- overrides[" screen/support_large" ] = true ;
154- overrides[" screen/support_xlarge" ] = true ;
155-
156- // XR features overrides
157- overrides[" xr_features/xr_mode" ] = 1 ; // OpenXR mode
158- overrides[" xr_features/enable_khronos_plugin" ] = false ;
159- overrides[" xr_features/enable_lynx_plugin" ] = false ;
160- overrides[" xr_features/enable_meta_plugin" ] = true ;
161- overrides[" xr_features/enable_pico_plugin" ] = false ;
162-
163- return overrides;
84+ const Ref<godot::EditorExportPlatform> &p_platform) const {
85+ Dictionary overrides;
86+ if (!_supports_platform (p_platform)) {
87+ return overrides;
88+ }
89+
90+ // Check if this plugin is enabled
91+ if (!_get_bool_option (" meta_toolkit/enable_meta_toolkit" )) {
92+ return overrides;
93+ }
94+
95+ // Gradle build overrides
96+ overrides[" gradle_build/use_gradle_build" ] = true ;
97+ overrides[" gradle_build/export_format" ] = 0 ; // apk
98+ overrides[" gradle_build/min_sdk" ] = " 29" ; // Android 10
99+ overrides[" gradle_build/target_sdk" ] = " 32" ; // Android 12
100+
101+ // Check if we have an alternate build template
102+ if (FileAccess::file_exists (TOOLKIT_BUILD_TEMPLATE_ZIP_PATH)) {
103+ overrides[" gradle_build/gradle_build_directory" ] = " res://addons/godot_meta_toolkit/build" ;
104+ overrides[" gradle_build/android_source_template" ] = TOOLKIT_BUILD_TEMPLATE_ZIP_PATH;
105+ }
106+
107+ // Check if we have a debug keystore available
108+ if (FileAccess::file_exists (TOOLKIT_DEBUG_KEYSTORE_PATH) && FileAccess::file_exists (TOOLKIT_DEBUG_KEYSTORE_PROPERTIES_PATH)) {
109+ // Read the debug keystore user and password from the properties file
110+ // The file should contain the following lines:
111+ // key.alias=platformkeystore
112+ // key.alias.password=android
113+ Ref<FileAccess> file_access = FileAccess::open (TOOLKIT_DEBUG_KEYSTORE_PROPERTIES_PATH, FileAccess::ModeFlags::READ);
114+ if (file_access.is_valid ()) {
115+ String debug_user;
116+ String debug_password;
117+
118+ while (file_access->get_position () < file_access->get_length () && (debug_user.is_empty () || debug_password.is_empty ())) {
119+ String current_line = file_access->get_line ();
120+ PackedStringArray current_line_splits = current_line.split (" =" , false );
121+ if (current_line_splits.size () == 2 ) {
122+ if (current_line_splits[0 ] == " key.alias" ) {
123+ debug_user = current_line_splits[1 ];
124+ } else if (current_line_splits[0 ] == " key.alias.password" ) {
125+ debug_password = current_line_splits[1 ];
126+ }
127+ }
128+ }
129+
130+ if (!debug_user.is_empty () && !debug_password.is_empty ()) {
131+ overrides[" keystore/debug" ] = ProjectSettings::get_singleton ()->globalize_path (TOOLKIT_DEBUG_KEYSTORE_PATH);
132+ overrides[" keystore/debug_user" ] = debug_user;
133+ overrides[" keystore/debug_password" ] = debug_password;
134+ }
135+ }
136+ }
137+
138+ // Architectures overrides
139+ overrides[" architectures/armeabi-v7a" ] = false ;
140+ overrides[" architectures/arm64-v8a" ] = true ;
141+ overrides[" architectures/x86" ] = false ;
142+ overrides[" architectures/x86_64" ] = false ;
143+
144+ // Package overrides
145+ overrides[" package/show_in_android_tv" ] = false ;
146+
147+ // Screen overrides
148+ overrides[" screen/immersive_mode" ] = true ;
149+ overrides[" screen/support_small" ] = true ;
150+ overrides[" screen/support_normal" ] = true ;
151+ overrides[" screen/support_large" ] = true ;
152+ overrides[" screen/support_xlarge" ] = true ;
153+
154+ // XR features overrides
155+ overrides[" xr_features/xr_mode" ] = 1 ; // OpenXR mode
156+ overrides[" xr_features/enable_khronos_plugin" ] = false ;
157+ overrides[" xr_features/enable_lynx_plugin" ] = false ;
158+ overrides[" xr_features/enable_meta_plugin" ] = true ;
159+ overrides[" xr_features/enable_pico_plugin" ] = false ;
160+
161+ return overrides;
164162}
165163
166164PackedStringArray MetaToolkitExportPlugin::_get_android_libraries (const Ref<godot::EditorExportPlatform> &p_platform, bool p_debug) const {
167- PackedStringArray dependencies;
168- if (!_supports_platform (p_platform)) {
169- return dependencies;
170- }
165+ PackedStringArray dependencies;
166+ if (!_supports_platform (p_platform)) {
167+ return dependencies;
168+ }
171169
172- // Check if the Godot Meta toolkit aar dependency is available
173- const String debug_label = p_debug ? " debug" : " release" ;
170+ // Check if the Godot Meta toolkit aar dependency is available
171+ const String debug_label = p_debug ? " debug" : " release" ;
174172 const String toolkit_aar_file_path = " res://addons/godot_meta_toolkit/.bin/android/" + debug_label + " /godot_meta_toolkit-" + debug_label + " .aar" ;
175173 if (FileAccess::file_exists (toolkit_aar_file_path)) {
176- dependencies.append (toolkit_aar_file_path);
177- }
174+ dependencies.append (toolkit_aar_file_path);
175+ }
178176
179- return dependencies;
177+ return dependencies;
180178}
0 commit comments