Unsure this is getting any better
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use std::io;
|
use std::io;
|
||||||
use card_stuffs;
|
use card_stuffs::{self, NUM_PILES_KLONDIKE};
|
||||||
|
|
||||||
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind};
|
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
@@ -46,6 +46,31 @@ fn card_widget(card: &card_stuffs::Card) -> List {
|
|||||||
.border_type(BorderType::Rounded))
|
.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 {
|
impl App {
|
||||||
|
|
||||||
/// runs the application's main loop until the user quits
|
/// runs the application's main loop until the user quits
|
||||||
@@ -89,28 +114,35 @@ impl App {
|
|||||||
);
|
);
|
||||||
let horizontal = Layout::horizontal([
|
let horizontal = Layout::horizontal([
|
||||||
Constraint::Length(CARD_WIDTH),
|
Constraint::Length(CARD_WIDTH),
|
||||||
Constraint::Length(2),
|
|
||||||
Constraint::Length(CARD_WIDTH),
|
Constraint::Length(CARD_WIDTH),
|
||||||
Constraint::Length(2),
|
|
||||||
Constraint::Length(CARD_WIDTH),
|
Constraint::Length(CARD_WIDTH),
|
||||||
Constraint::Length(2),
|
|
||||||
Constraint::Length(CARD_WIDTH),
|
Constraint::Length(CARD_WIDTH),
|
||||||
Constraint::Length(2),
|
|
||||||
Constraint::Length(CARD_WIDTH),
|
Constraint::Length(CARD_WIDTH),
|
||||||
Constraint::Length(2),
|
|
||||||
Constraint::Length(CARD_WIDTH),
|
Constraint::Length(CARD_WIDTH),
|
||||||
Constraint::Length(2),
|
|
||||||
Constraint::Length(CARD_WIDTH),
|
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]);
|
let a_card = card_widget(&self.cards.piles[0][0]);
|
||||||
|
|
||||||
for pile in 0..card_stuffs::NUM_PILES_KLONDIKE {
|
for pile in 0..card_stuffs::NUM_PILES_KLONDIKE {
|
||||||
frame.render_widget(
|
let mut constraints = Vec::new();
|
||||||
Block::new().borders(Borders::ALL).title(format!("pile {}", pile)),
|
for card in 0..(card_stuffs::NUM_PILES_KLONDIKE + 13) {
|
||||||
//&a_card,
|
constraints.push(Constraint::Min(2));
|
||||||
piles_and_spacers[pile*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(
|
||||||
|
&a_card,
|
||||||
|
*card
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user