add optional property OVERLAY_PROPERTIES on overlay scenes, used for making main menu always visible

This commit is contained in:
Crispy 2021-07-22 17:41:58 +02:00
parent 73d9d9b88b
commit 3a6d0469e5
3 changed files with 16 additions and 5 deletions

View file

@ -31,6 +31,7 @@ var interaction_handler: Node
var overlay_visible := true setget set_overlay_visible var overlay_visible := true setget set_overlay_visible
var path := "res://special_overlays/MainOverlay.tscn" setget set_path var path := "res://special_overlays/MainOverlay.tscn" setget set_path
var path_invalid := false var path_invalid := false
var OVERLAY_PROPERTIES: Dictionary
onready var container = $OverlayViewport/Container onready var container = $OverlayViewport/Container
var overlay_scene: Node var overlay_scene: Node
@ -159,6 +160,10 @@ func set_path(new: String) -> void:
if container.get_child_count() > 0: if container.get_child_count() > 0:
container.get_child(0).queue_free() container.get_child(0).queue_free()
container.add_child(overlay_scene) container.add_child(overlay_scene)
if overlay_scene.get("OVERLAY_PROPERTIES") != null:
OVERLAY_PROPERTIES = overlay_scene.OVERLAY_PROPERTIES
emit_signal("path_changed") emit_signal("path_changed")

View file

@ -1,5 +1,10 @@
extends Control extends Control
const OVERLAY_PROPERTIES = {
"no_hide": true,
"no_delete": true,
}
func _ready() -> void: func _ready() -> void:
OverlayManager.connect("added_overlay", self, "_add_overlay_to_list") OverlayManager.connect("added_overlay", self, "_add_overlay_to_list")

View file

@ -31,8 +31,9 @@ func _update_warning():
func _on_Visibility_toggled(state: bool) -> void: func _on_Visibility_toggled(state: bool) -> void:
# TODO check always visible flag if overlay.OVERLAY_PROPERTIES.has("no_hide") and overlay.OVERLAY_PROPERTIES.no_hide:
# if overlay.type and overlay.type != "main": overlay.overlay_visible = true
else:
overlay.overlay_visible = state overlay.overlay_visible = state
@ -51,8 +52,8 @@ func _overlay_visible_changed(state: bool):
func _on_Remove_pressed() -> void: func _on_Remove_pressed() -> void:
# TODO check stay flag if overlay.OVERLAY_PROPERTIES.has("no_delete") and overlay.OVERLAY_PROPERTIES.no_delete:
# if overlay.type and overlay.type != "main": return
OverlayManager.remove_overlay(overlay_name) OverlayManager.remove_overlay(overlay_name)