mirror of
https://github.com/lightsoutgames/godot-tts
synced 2024-11-22 03:55:56 +00:00
Implement screen reader detection for everything but Android.
Android support is waiting on Godot 3.2.2 when the new plugin system lands.
This commit is contained in:
parent
4495b89ff3
commit
aa718c5fe6
|
@ -10,3 +10,6 @@ crate-type = ["cdylib"]
|
|||
[dependencies]
|
||||
gdnative = "0.8"
|
||||
tts = { git = "https://gitlab.com/ndarilek/tts-rs" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
tolk = "0.2"
|
22
TTS.gd
22
TTS.gd
|
@ -127,13 +127,27 @@ func get_is_rate_supported():
|
|||
|
||||
var is_rate_supported setget , get_is_rate_supported
|
||||
|
||||
func get_can_detect_screen_reader():
|
||||
if OS.get_name() == "Windows":
|
||||
func _get_can_detect_screen_reader():
|
||||
if Engine.has_singleton("AndroidTTS"):
|
||||
return true
|
||||
else:
|
||||
elif OS.has_feature('JavaScript'):
|
||||
return false
|
||||
elif tts != null:
|
||||
return tts.can_detect_screen_reader
|
||||
return false
|
||||
|
||||
var can_detect_screen_reader setget , get_can_detect_screen_reader
|
||||
var can_detect_screen_reader setget , _get_can_detect_screen_reader
|
||||
|
||||
func _get_has_screen_reader():
|
||||
if Engine.has_singleton("AndroidTTS"):
|
||||
return tts.has_screen_reader()
|
||||
elif OS.has_feature('JavaScript'):
|
||||
return false
|
||||
elif tts != null:
|
||||
return tts.has_screen_reader
|
||||
return false
|
||||
|
||||
var has_screen_reader setget , _get_has_screen_reader
|
||||
|
||||
func singular_or_plural(count, singular, plural):
|
||||
if count == 1:
|
||||
|
|
19
src/lib.rs
19
src/lib.rs
|
@ -79,6 +79,25 @@ impl TTS {
|
|||
}
|
||||
})
|
||||
.done();
|
||||
builder
|
||||
.add_property("can_detect_screen_reader")
|
||||
.with_getter(|_: &TTS, _| {
|
||||
#[cfg(windows)]
|
||||
return true;
|
||||
return false;
|
||||
})
|
||||
.done();
|
||||
builder
|
||||
.add_property("has_screen_reader")
|
||||
.with_getter(|_: &TTS, _| {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let tolk = tolk::Tolk::new();
|
||||
tolk.detect_screen_reader().is_some()
|
||||
}
|
||||
false
|
||||
})
|
||||
.done();
|
||||
}
|
||||
|
||||
#[export]
|
||||
|
|
Loading…
Reference in New Issue
Block a user