plugins
This commit is contained in:
parent
53e4047e6a
commit
178c344859
4 changed files with 125 additions and 118 deletions
|
|
@ -1,19 +1,12 @@
|
|||
// use bevy::ecs::message::MessageReader;
|
||||
use bevy::app::AppExit;
|
||||
use bevy::input::keyboard::Key;
|
||||
use bevy::prelude::*;
|
||||
use bevy_ratatui::crossterm::event::KeyCode;
|
||||
use bevy_ratatui::event::KeyMessage;
|
||||
|
||||
pub(crate) fn input_system(
|
||||
mut messages: MessageReader<KeyMessage>,
|
||||
mut exit: MessageWriter<AppExit>,
|
||||
pub(crate) fn keyboard_input_system(
|
||||
input: Res<ButtonInput<KeyCode>>,
|
||||
key_input: Res<ButtonInput<Key>>,
|
||||
) {
|
||||
for message in messages.read() {
|
||||
match message.code {
|
||||
KeyCode::Char('q') => {
|
||||
exit.write_default();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,31 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_ratatui::RatatuiContext;
|
||||
use std::time::Duration;
|
||||
|
||||
use bevy::{app::ScheduleRunnerPlugin, prelude::*};
|
||||
use bevy_ratatui::{RatatuiContext, RatatuiPlugins};
|
||||
|
||||
use crate::tiles::Tile;
|
||||
|
||||
pub(crate) mod input;
|
||||
mod input;
|
||||
|
||||
pub(crate) use input::input_system;
|
||||
pub struct RiichiTui;
|
||||
|
||||
impl Plugin for RiichiTui {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins((
|
||||
MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f32(
|
||||
1. / 1.,
|
||||
))),
|
||||
RatatuiPlugins {
|
||||
// enable_kitty_protocol: todo!(),
|
||||
// enable_mouse_capture: todo!(),
|
||||
enable_input_forwarding: true,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
.add_systems(Update, draw_system)
|
||||
.add_systems(Update, input::keyboard_input_system);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn draw_system(mut context: ResMut<RatatuiContext>, query: Query<&Tile>) -> Result {
|
||||
context.draw(|frame| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue