From b4acee6dea1b48e36d3cdb65822242438a51c6d3 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Sat, 21 Dec 2019 09:54:12 -0600 Subject: [PATCH] Support .godot-accessibility-editor-settings.ini file in project root. Currently supports setting rate and globally disabling plugin. --- Plugin.gd | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Plugin.gd b/Plugin.gd index 4d3d160..4f7d61d 100644 --- a/Plugin.gd +++ b/Plugin.gd @@ -6,12 +6,21 @@ var ScreenReader = preload("ScreenReader.gd") var screen_reader func _enter_tree(): - add_autoload_singleton("TTS", "res://addons/godot-tts/TTS.gd") - screen_reader = ScreenReader.new() - get_tree().root.call_deferred("add_child", screen_reader) - call_deferred("connect", "scene_changed", screen_reader, "set_initial_scene_focus") - call_deferred("connect", "main_screen_changed", screen_reader, "set_initial_screen_focus") - add_custom_type("ScreenReader", "Node", preload("ScreenReader.gd"), null) + var enabled = true + var rate = 50 + var config = ConfigFile.new() + var err = config.load("res://.godot-accessibility-editor-settings.ini") + if not err: + enabled = config.get_value("global", "enabled", true) + rate = config.get_value("speech", "rate", 50) + if enabled: + add_autoload_singleton("TTS", "res://addons/godot-tts/TTS.gd") + TTS.call_deferred("set_rate", rate) + screen_reader = ScreenReader.new() + get_tree().root.call_deferred("add_child", screen_reader) + call_deferred("connect", "scene_changed", screen_reader, "set_initial_scene_focus") + call_deferred("connect", "main_screen_changed", screen_reader, "set_initial_screen_focus") + add_custom_type("ScreenReader", "Node", preload("ScreenReader.gd"), null) func _exit_tree(): remove_custom_type("ScreenReader")