2019-09-03 13:54:36 +00:00
|
|
|
use gdnative::*;
|
2018-06-13 12:14:03 +00:00
|
|
|
|
2019-09-10 15:09:04 +00:00
|
|
|
use tts::{TTS as Tts};
|
2018-06-13 12:14:03 +00:00
|
|
|
|
2019-09-03 13:54:36 +00:00
|
|
|
#[derive(gdnative::NativeClass)]
|
|
|
|
#[inherit(gdnative::Node)]
|
2019-09-10 15:09:04 +00:00
|
|
|
struct TTS(Tts);
|
2019-09-03 13:54:36 +00:00
|
|
|
|
|
|
|
#[methods]
|
|
|
|
impl TTS {
|
|
|
|
fn _init(_owner: gdnative::Node) -> Self {
|
2019-09-10 15:09:04 +00:00
|
|
|
let tts = Tts::default().unwrap();
|
|
|
|
Self(tts)
|
2019-09-03 13:54:36 +00:00
|
|
|
}
|
2018-06-13 12:14:03 +00:00
|
|
|
|
2019-09-03 13:54:36 +00:00
|
|
|
#[export]
|
|
|
|
fn speak(&mut self, _owner: Node, message: GodotString, interrupt: bool) {
|
|
|
|
let message = message.to_string();
|
|
|
|
println!("{}: {}", message, interrupt);
|
2019-09-10 15:09:04 +00:00
|
|
|
self.0.speak(message, interrupt).unwrap();
|
2019-09-03 13:54:36 +00:00
|
|
|
}
|
2018-06-13 12:14:03 +00:00
|
|
|
|
2019-09-03 13:54:36 +00:00
|
|
|
#[export]
|
|
|
|
fn stop(&mut self, _owner: Node) {
|
2019-09-10 15:09:04 +00:00
|
|
|
self.0.stop().unwrap();
|
2018-06-13 12:14:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-03 13:54:36 +00:00
|
|
|
fn init(handle: gdnative::init::InitHandle) {
|
|
|
|
handle.add_class::<TTS>();
|
2018-06-13 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
godot_gdnative_init!();
|
|
|
|
godot_nativescript_init!(init);
|
|
|
|
godot_gdnative_terminate!();
|