From 3a6d0469e54ad41f69bb66aa9d655c8a0f677524 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Thu, 22 Jul 2021 17:41:58 +0200 Subject: [PATCH] add optional property OVERLAY_PROPERTIES on overlay scenes, used for making main menu always visible --- ovr-utils/addons/openvr_overlay/overlay_instance.gd | 5 +++++ ovr-utils/overlay_scripts/main_menu.gd | 5 +++++ ovr-utils/ui/overlay_list_item.gd | 11 ++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ovr-utils/addons/openvr_overlay/overlay_instance.gd b/ovr-utils/addons/openvr_overlay/overlay_instance.gd index 2da2249..9c08712 100644 --- a/ovr-utils/addons/openvr_overlay/overlay_instance.gd +++ b/ovr-utils/addons/openvr_overlay/overlay_instance.gd @@ -31,6 +31,7 @@ var interaction_handler: Node var overlay_visible := true setget set_overlay_visible var path := "res://special_overlays/MainOverlay.tscn" setget set_path var path_invalid := false +var OVERLAY_PROPERTIES: Dictionary onready var container = $OverlayViewport/Container var overlay_scene: Node @@ -159,6 +160,10 @@ func set_path(new: String) -> void: if container.get_child_count() > 0: container.get_child(0).queue_free() container.add_child(overlay_scene) + + if overlay_scene.get("OVERLAY_PROPERTIES") != null: + OVERLAY_PROPERTIES = overlay_scene.OVERLAY_PROPERTIES + emit_signal("path_changed") diff --git a/ovr-utils/overlay_scripts/main_menu.gd b/ovr-utils/overlay_scripts/main_menu.gd index 39848f6..a8cfc35 100644 --- a/ovr-utils/overlay_scripts/main_menu.gd +++ b/ovr-utils/overlay_scripts/main_menu.gd @@ -1,5 +1,10 @@ extends Control +const OVERLAY_PROPERTIES = { + "no_hide": true, + "no_delete": true, +} + func _ready() -> void: OverlayManager.connect("added_overlay", self, "_add_overlay_to_list") diff --git a/ovr-utils/ui/overlay_list_item.gd b/ovr-utils/ui/overlay_list_item.gd index a54cc86..19e28de 100644 --- a/ovr-utils/ui/overlay_list_item.gd +++ b/ovr-utils/ui/overlay_list_item.gd @@ -31,9 +31,10 @@ func _update_warning(): func _on_Visibility_toggled(state: bool) -> void: - # TODO check always visible flag -# if overlay.type and overlay.type != "main": - overlay.overlay_visible = state + if overlay.OVERLAY_PROPERTIES.has("no_hide") and overlay.OVERLAY_PROPERTIES.no_hide: + overlay.overlay_visible = true + else: + overlay.overlay_visible = state func _on_Grab_toggled(state: bool) -> void: @@ -51,8 +52,8 @@ func _overlay_visible_changed(state: bool): func _on_Remove_pressed() -> void: - # TODO check stay flag -# if overlay.type and overlay.type != "main": + if overlay.OVERLAY_PROPERTIES.has("no_delete") and overlay.OVERLAY_PROPERTIES.no_delete: + return OverlayManager.remove_overlay(overlay_name)