Introduced costum focus handling to global state

This commit is contained in:
betalars 2023-04-15 16:01:22 +02:00
parent 22f14fb60e
commit 7b13597039
1 changed files with 33 additions and 1 deletions

View File

@ -6,4 +6,36 @@ var simplified_navigation:bool = false
var enable_subtitles: bool = false
var reduce_motion: bool = false
var show_content_notes: bool = false
var show_prompts: bool = false
var provide_summaries: bool = false
var allow_skipping: bool = false
var current_focus: Node
func request_focus(new_focus: Node, yoink:bool = false) -> bool:
if (current_focus == null or yoink) and new_focus != null:
current_focus = new_focus
return true
else: return false
func pass_focus_to(to: Node) -> bool:
if "has_focus" in to:
if not current_focus == null:
drop_focus_of(current_focus)
to.has_focus = true
return true
else: return false
func drop_own_focus(node: Node):
if current_focus == node:
current_focus = null
else:
push_error(node.name + " attempted to drop focus while not owning it!")
func drop_focus_of(node: Node):
if current_focus == node:
current_focus = null
if node.has_focus: node.has_focus = false
else:
node.has_focus = false
push_warning("Attempted to drop Focus for " + node.name + " while it wasn't focused!")