Unsure this is getting any better

This commit is contained in:
2025-02-25 22:53:42 +00:00
parent 778a5c48e2
commit added3ad03

View File

@@ -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,29 +114,36 @@ 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 {
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( frame.render_widget(
Block::new().borders(Borders::ALL).title(format!("pile {}", pile)), &a_card,
//&a_card, *card
piles_and_spacers[pile*2]
) )
} }
}
}
}
} }
fn handle_events(&mut self) -> io::Result<()> { fn handle_events(&mut self) -> io::Result<()> {