controls
This commit is contained in:
parent
1471751231
commit
556c6a869f
34
src/app.rs
34
src/app.rs
|
@ -1,7 +1,7 @@
|
|||
use std::rc::Rc;
|
||||
|
||||
use crossterm::event::{read, Event, KeyCode};
|
||||
use tui::{Terminal, backend::Backend, Frame};
|
||||
use tui::{Terminal, backend::Backend, Frame, layout::Layout};
|
||||
|
||||
use crate::{state::{self, GameState}, person::Person};
|
||||
|
||||
|
@ -115,13 +115,43 @@ impl<'a> App<'a> {
|
|||
pub fn draw_initial<B: Backend>(&mut self, f: &mut Frame<B>) {}
|
||||
|
||||
pub fn draw_guest_selection<B: Backend>(&mut self, f: &mut Frame<B>) {
|
||||
let chunks = Layout::default()
|
||||
.direction(tui::layout::Direction::Vertical)
|
||||
.constraints(
|
||||
[
|
||||
tui::layout::Constraint::Min(3),
|
||||
tui::layout::Constraint::Length(2)
|
||||
]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(f.size());
|
||||
|
||||
let main_window = tui::widgets::List::new(self.guest_list.clone())
|
||||
.block(tui::widgets::Block::default().title("Guests").borders(tui::widgets::Borders::ALL))
|
||||
.style(tui::style::Style::default().fg(tui::style::Color::White))
|
||||
.highlight_style(tui::style::Style::default().add_modifier(tui::style::Modifier::ITALIC))
|
||||
.highlight_symbol(">>");
|
||||
|
||||
f.render_stateful_widget(main_window, f.size(), &mut self.guest_state);
|
||||
let key_style = tui::style::Style::default()
|
||||
.add_modifier(tui::style::Modifier::BOLD)
|
||||
.fg(tui::style::Color::Green)
|
||||
.bg(tui::style::Color::Black);
|
||||
let control_text = tui::text::Spans::from(vec![
|
||||
tui::text::Span::styled("↑↓", key_style),
|
||||
tui::text::Span::raw(" select guest"),
|
||||
tui::text::Span::raw(" "),
|
||||
tui::text::Span::styled("⏎", key_style),
|
||||
tui::text::Span::raw(" talk to guest"),
|
||||
tui::text::Span::raw(" "),
|
||||
tui::text::Span::styled("Esc", key_style),
|
||||
tui::text::Span::raw(" quit"),
|
||||
|
||||
]);
|
||||
let controls = tui::widgets::Paragraph::new(control_text)
|
||||
.style(tui::style::Style::default().fg(tui::style::Color::White));
|
||||
|
||||
f.render_stateful_widget(main_window, chunks[0], &mut self.guest_state);
|
||||
f.render_widget(controls, chunks[1]);
|
||||
}
|
||||
|
||||
fn draw_talk_to_guest<B: Backend>(&self, f: &mut Frame<B>, guest: Rc<Person>) {
|
||||
|
|
Loading…
Reference in New Issue