mirror of
https://github.com/lightsoutgames/bevy_tts.git
synced 2024-11-22 07:25:56 +00:00
Bump to Bevy main.
This commit is contained in:
parent
380f2afb3d
commit
c63e43f0fd
|
@ -11,5 +11,6 @@ default = ["tolk"]
|
||||||
tolk = ["tts/tolk"]
|
tolk = ["tts/tolk"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.4"
|
bevy = { git = "https://github.com/bevyengine/bevy" }
|
||||||
|
crossbeam-channel = "0.5"
|
||||||
tts = { version = "0.14" }
|
tts = { version = "0.14" }
|
|
@ -63,11 +63,8 @@ fn setup(mut tts: ResMut<TTS>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reports events from TTS subsystem.
|
// Reports events from TTS subsystem.
|
||||||
fn event_poll(
|
fn event_poll(mut events: EventReader<TtsEvent>) {
|
||||||
mut tts_event_reader: Local<EventReader<TtsEvent>>,
|
for event in events.iter() {
|
||||||
tts_events: Res<Events<TtsEvent>>,
|
|
||||||
) {
|
|
||||||
for event in tts_event_reader.iter(&tts_events) {
|
|
||||||
println!("{:?}", event);
|
println!("{:?}", event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
src/lib.rs
13
src/lib.rs
|
@ -1,6 +1,5 @@
|
||||||
use std::sync::mpsc::{channel, Receiver};
|
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use crossbeam_channel::{unbounded, Receiver};
|
||||||
pub use tts::{Error, Features, UtteranceId, TTS};
|
pub use tts::{Error, Features, UtteranceId, TTS};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
@ -12,10 +11,8 @@ pub enum TtsEvent {
|
||||||
|
|
||||||
struct TtsChannel(Receiver<TtsEvent>);
|
struct TtsChannel(Receiver<TtsEvent>);
|
||||||
|
|
||||||
fn poll_callbacks(_: &mut World, resources: &mut Resources) {
|
fn poll_callbacks(channel: Res<TtsChannel>, mut events: ResMut<Events<TtsEvent>>) {
|
||||||
let channel = resources.get_thread_local::<TtsChannel>().unwrap();
|
|
||||||
if let Ok(msg) = channel.0.try_recv() {
|
if let Ok(msg) = channel.0.try_recv() {
|
||||||
let mut events = resources.get_mut::<Events<TtsEvent>>().unwrap();
|
|
||||||
events.send(msg);
|
events.send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +22,7 @@ pub struct TtsPlugin;
|
||||||
impl Plugin for TtsPlugin {
|
impl Plugin for TtsPlugin {
|
||||||
fn build(&self, app: &mut AppBuilder) {
|
fn build(&self, app: &mut AppBuilder) {
|
||||||
let tts = TTS::default().unwrap();
|
let tts = TTS::default().unwrap();
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = unbounded();
|
||||||
let tx_begin = tx.clone();
|
let tx_begin = tx.clone();
|
||||||
let tx_end = tx.clone();
|
let tx_end = tx.clone();
|
||||||
let tx_stop = tx;
|
let tx_stop = tx;
|
||||||
|
@ -48,8 +45,8 @@ impl Plugin for TtsPlugin {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
app.add_event::<TtsEvent>()
|
app.add_event::<TtsEvent>()
|
||||||
.add_thread_local_resource(TtsChannel(rx))
|
.insert_resource(TtsChannel(rx))
|
||||||
.add_resource(tts)
|
.insert_resource(tts)
|
||||||
.add_system(poll_callbacks.system());
|
.add_system(poll_callbacks.system());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user