From 7b135970397be19e1453ce0a91d4cbc2dac0a6bc Mon Sep 17 00:00:00 2001 From: betalars Date: Sat, 15 Apr 2023 16:01:22 +0200 Subject: [PATCH] Introduced costum focus handling to global state --- src/singletons/global_state.gd | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/singletons/global_state.gd b/src/singletons/global_state.gd index 93bc818..f0645ae 100644 --- a/src/singletons/global_state.gd +++ b/src/singletons/global_state.gd @@ -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!") +