2026-01-13 04:11:09 -08:00
|
|
|
use bevy::prelude::*;
|
2026-01-13 17:05:56 -08:00
|
|
|
use bevy_ratatui::RatatuiContext;
|
2026-01-15 01:36:35 -08:00
|
|
|
use ratatui::{
|
|
|
|
|
Frame,
|
|
|
|
|
widgets::{Block, Clear},
|
|
|
|
|
};
|
|
|
|
|
use tui_logger::TuiLoggerWidget;
|
2026-01-13 04:11:09 -08:00
|
|
|
|
2026-01-11 22:32:30 -08:00
|
|
|
pub(crate) mod hand;
|
|
|
|
|
pub(crate) mod ingame;
|
2026-01-13 17:05:56 -08:00
|
|
|
pub(crate) mod menu;
|
2026-01-13 03:32:08 -08:00
|
|
|
pub(crate) mod tile;
|
2026-01-13 04:11:09 -08:00
|
|
|
|
2026-01-13 17:05:56 -08:00
|
|
|
#[derive(Resource, Default)]
|
|
|
|
|
pub(crate) struct WidgetStack(pub(crate) Vec<Box<dyn FnOnce(&mut Frame) + Send + Sync>>);
|
|
|
|
|
|
2026-01-13 04:11:09 -08:00
|
|
|
#[derive(Component)]
|
|
|
|
|
pub(crate) struct Hovered;
|
2026-01-13 17:05:56 -08:00
|
|
|
|
2026-01-15 01:36:35 -08:00
|
|
|
pub(crate) fn draw_console(mut widgets: ResMut<WidgetStack>) {
|
|
|
|
|
widgets.0.push(Box::new(|frame| {
|
|
|
|
|
let block = Block::bordered().title("console");
|
|
|
|
|
frame.render_widget(Clear, frame.area());
|
|
|
|
|
frame.render_widget(
|
|
|
|
|
TuiLoggerWidget::default().block(block),
|
|
|
|
|
frame.area(), /* .inner(Margin { horizontal: 8, vertical: 8 }) */
|
|
|
|
|
);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-13 17:05:56 -08:00
|
|
|
pub(crate) fn draw_system(
|
|
|
|
|
mut tui_ctx: ResMut<RatatuiContext>,
|
2026-01-15 01:36:35 -08:00
|
|
|
mut widgets: ResMut<WidgetStack>,
|
2026-01-13 17:05:56 -08:00
|
|
|
) -> Result {
|
|
|
|
|
tui_ctx.draw(|frame| {
|
2026-01-15 01:36:35 -08:00
|
|
|
for widget in widgets.0.drain(..) {
|
2026-01-13 17:05:56 -08:00
|
|
|
widget(frame)
|
|
|
|
|
}
|
|
|
|
|
})?;
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|