Unsure this is getting any better
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use std::io;
|
||||
use card_stuffs;
|
||||
use card_stuffs::{self, NUM_PILES_KLONDIKE};
|
||||
|
||||
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind};
|
||||
use ratatui::{
|
||||
@@ -46,6 +46,31 @@ fn card_widget(card: &card_stuffs::Card) -> List {
|
||||
.border_type(BorderType::Rounded))
|
||||
}
|
||||
|
||||
fn turned_over_card() -> List<'static> {
|
||||
let hidden_card = [
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
format!("###############"),
|
||||
];
|
||||
let card: Vec<ListItem> = hidden_card.iter().map(|(m)| {
|
||||
ListItem::new(m.to_string())
|
||||
})
|
||||
.collect();
|
||||
|
||||
List::new(card)
|
||||
.block(Block::new()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded))
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
||||
/// runs the application's main loop until the user quits
|
||||
@@ -89,29 +114,36 @@ impl App {
|
||||
);
|
||||
let horizontal = Layout::horizontal([
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(2),
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(2),
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(2),
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(2),
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(2),
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(2),
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(2),
|
||||
]);
|
||||
let piles_and_spacers: [Rect; 14] = horizontal.areas(piles_area);
|
||||
let pileses: [Rect; 7] = horizontal.areas(piles_area);
|
||||
let a_card = card_widget(&self.cards.piles[0][0]);
|
||||
|
||||
for pile in 0..card_stuffs::NUM_PILES_KLONDIKE {
|
||||
let mut constraints = Vec::new();
|
||||
for card in 0..(card_stuffs::NUM_PILES_KLONDIKE + 13) {
|
||||
constraints.push(Constraint::Min(2));
|
||||
}
|
||||
let vertical = Layout::vertical(constraints);
|
||||
let card_display: [Rect; 20] = vertical.areas(pileses[pile]);
|
||||
for (i, card) in card_display.iter().enumerate() {
|
||||
match self.cards.piles[pile].get(i) {
|
||||
None => break,
|
||||
Some(c) => {
|
||||
frame.render_widget(
|
||||
Block::new().borders(Borders::ALL).title(format!("pile {}", pile)),
|
||||
//&a_card,
|
||||
piles_and_spacers[pile*2]
|
||||
&a_card,
|
||||
*card
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_events(&mut self) -> io::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user