Skip to content

Commit

Permalink
Add warning if multiple loaders are selected
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Oct 1, 2023
1 parent 8a99591 commit 602384e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Update to the new Godot 4.2 Android plugin packaging format
- Update the plugin to Godot v2 Android plugin
- Update to the Godot 4.2 Android library
- Add warning when multiple loaders are selected

## 1.1.0
- Update Meta OpenXR loader to version 54
Expand Down
13 changes: 13 additions & 0 deletions demo/addons/godotopenxr/.export/globals.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@tool

const META_VENDOR_NAME = "meta"
const PICO_VENDOR_NAME = "pico"
const LYNX_VENDOR_NAME = "lynx"
const KHRONOS_VENDOR_NAME = "khr"

const VENDORS_LIST = [
META_VENDOR_NAME,
PICO_VENDOR_NAME,
LYNX_VENDOR_NAME,
KHRONOS_VENDOR_NAME,
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@tool
class_name GodotOpenXREditorExportPlugin extends EditorExportPlugin

var globals = preload("globals.gd")

const OPENXR_MODE_VALUE = 1

var _vendor: String
Expand All @@ -26,14 +28,14 @@ func _get_android_maven_central_dependency() -> String:
return "org.godotengine:godot-openxr-loaders-" + _vendor + ":" + _plugin_version


func _get_vendor_toggle_option_name() -> String:
return "xr_features/enable_" + _vendor + "_plugin"
func _get_vendor_toggle_option_name(vendor_name: String = _vendor) -> String:
return "xr_features/enable_" + vendor_name + "_plugin"


func _get_vendor_toggle_option() -> Dictionary:
func _get_vendor_toggle_option(vendor_name: String = _vendor) -> Dictionary:
var toggle_option = {
"option": {
"name": _get_vendor_toggle_option_name(),
"name": _get_vendor_toggle_option_name(vendor_name),
"class_name": "",
"type": TYPE_BOOL,
"hint": PROPERTY_HINT_NONE,
Expand Down Expand Up @@ -69,7 +71,12 @@ func _get_export_option_warning(platform, option) -> String:
if not(_is_openxr_enabled()) and _get_bool_option(option):
return "\"Enable " + _vendor.capitalize() + " Plugin\" requires \"XR Mode\" to be \"OpenXR\".\n"

return ""
if _is_vendor_plugin_enabled():
for vendor_name in globals.VENDORS_LIST:
if (vendor_name != _vendor) and _is_vendor_plugin_enabled(vendor_name):
return "\"Disable " + _vendor.capitalize() + " Plugin before enabling another. Multiple plugins are not supported!\""

return ""


func _supports_platform(platform) -> bool:
Expand All @@ -92,8 +99,8 @@ func _get_int_option(option: String, default_value: int) -> int:
return default_value


func _is_vendor_plugin_enabled() -> bool:
return _get_bool_option(_get_vendor_toggle_option_name())
func _is_vendor_plugin_enabled(vendor_name: String = _vendor) -> bool:
return _get_bool_option(_get_vendor_toggle_option_name(vendor_name))


func _is_android_aar_file_available(debug: bool) -> bool:
Expand Down
10 changes: 6 additions & 4 deletions demo/addons/godotopenxr/.export/godot_openxr_editor_plugin.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@tool
extends EditorPlugin

var globals = preload("globals.gd")

# A class member to hold the export plugin during its lifecycle.
var meta_export_plugin : EditorExportPlugin
var pico_export_plugin : EditorExportPlugin
Expand All @@ -12,10 +14,10 @@ func _enter_tree():
var plugin_version = get_plugin_version()

# Initializing the export plugins
meta_export_plugin = preload("meta/godot_openxr_meta_editor_export_plugin.gd").new("meta", plugin_version)
pico_export_plugin = preload("pico/godot_openxr_pico_editor_export_plugin.gd").new("pico", plugin_version)
lynx_export_plugin = preload("lynx/godot_openxr_lynx_editor_export_plugin.gd").new("lynx", plugin_version)
khr_export_plugin = preload("khr/godot_openxr_khr_editor_export_plugin.gd").new("khr", plugin_version)
meta_export_plugin = preload("meta/godot_openxr_meta_editor_export_plugin.gd").new(globals.META_VENDOR_NAME, plugin_version)
pico_export_plugin = preload("pico/godot_openxr_pico_editor_export_plugin.gd").new(globals.PICO_VENDOR_NAME, plugin_version)
lynx_export_plugin = preload("lynx/godot_openxr_lynx_editor_export_plugin.gd").new(globals.LYNX_VENDOR_NAME, plugin_version)
khr_export_plugin = preload("khr/godot_openxr_khr_editor_export_plugin.gd").new(globals.KHRONOS_VENDOR_NAME, plugin_version)

add_export_plugin(meta_export_plugin)
add_export_plugin(pico_export_plugin)
Expand Down
1 change: 1 addition & 0 deletions demo/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ package/app_category=2
package/retain_data_on_uninstall=false
package/exclude_from_recents=false
package/show_in_android_tv=false
package/show_in_app_library=true
package/show_as_launcher_app=false
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
Expand Down

0 comments on commit 602384e

Please sign in to comment.