Added some of the wastes pile
It's not quite how I wanted to do it... but it'll work
This commit is contained in:
@@ -63,23 +63,20 @@ fn waste_widget(cards_in_waste: &Vec<card_stuffs::Card>) -> List {
|
||||
.border_type(BorderType::Rounded))
|
||||
}
|
||||
|
||||
fn deck_widget(cards_in_deck: &Vec<card_stuffs::Card>) -> List<'static> {
|
||||
let hidden_card = [
|
||||
format!("#############"),
|
||||
format!("#############"),
|
||||
format!("### Cards ###"),
|
||||
format!("### Left ###"),
|
||||
format!("#############"),
|
||||
format!("#### {:02} #####", cards_in_deck.len()),
|
||||
format!("#############"),
|
||||
format!("#############"),
|
||||
format!("#############"),
|
||||
];
|
||||
let card_image: Vec<ListItem> = hidden_card.iter().map(|m| {
|
||||
ListItem::new(m.to_string())
|
||||
})
|
||||
.collect();
|
||||
List::new(card_image)
|
||||
fn deck_widget(cards_in_deck: &Vec<card_stuffs::Card>) -> Paragraph<'static> {
|
||||
let card_image = format!(
|
||||
"#############\n\
|
||||
#############\n\
|
||||
### Cards ###\n\
|
||||
### Left ###\n\
|
||||
#############\n\
|
||||
#### {:02} #####\n\
|
||||
#############\n\
|
||||
#############\n\
|
||||
#############", cards_in_deck.len()
|
||||
);
|
||||
|
||||
Paragraph::new(card_image)
|
||||
.block(Block::new()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded))
|
||||
@@ -123,6 +120,24 @@ fn card_widget<'a>(card: &'a card_stuffs::Card, top: bool, highlight: bool, sele
|
||||
.border_type(BorderType::Rounded))
|
||||
}
|
||||
|
||||
fn partially_covered_card(card: &card_stuffs::Card) -> Paragraph {
|
||||
let card_image = format!(
|
||||
"{value}{suit}", value=card.value, suit=card.suit
|
||||
);
|
||||
let card_style = match card.suit.colour() {
|
||||
card_stuffs::Colour::Black => Style::new().black().bg(Color::White),
|
||||
card_stuffs::Colour::Red => Style::new().red().bg(Color::White),
|
||||
};
|
||||
let borders = Borders::TOP | Borders::LEFT | Borders::BOTTOM;
|
||||
let border_style = Style::new().white().on_black();
|
||||
Paragraph::new(card_image)
|
||||
.style(card_style)
|
||||
.block(Block::new()
|
||||
.style(border_style)
|
||||
.borders(borders)
|
||||
.border_type(BorderType::Rounded))
|
||||
}
|
||||
|
||||
struct CardWidget {
|
||||
card: card_stuffs::Card,
|
||||
// put display stuff in here?
|
||||
@@ -193,7 +208,7 @@ impl App {
|
||||
|
||||
let horizontal = Layout::horizontal([
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(3 + 3 + CARD_WIDTH), // 3+3 for 2 cards shown underneath
|
||||
Constraint::Length(3 + 3 + CARD_WIDTH), // for 2 cards shown underneath
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
@@ -203,10 +218,25 @@ impl App {
|
||||
let [deck_area, waste_area, fa, fb, fc, fd] = horizontal.areas(dwf_area);
|
||||
let foundation_areas = [fa, fb, fc, fd];
|
||||
|
||||
let horizontal = Layout::horizontal([
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(CARD_WIDTH),
|
||||
]);
|
||||
let [w1, w2, waste_area] = horizontal.areas(waste_area);
|
||||
|
||||
frame.render_widget(
|
||||
deck_widget(&self.cards.deck),
|
||||
deck_area
|
||||
);
|
||||
frame.render_widget(
|
||||
partially_covered_card(&self.cards.piles[0][0]),
|
||||
w1
|
||||
);
|
||||
frame.render_widget(
|
||||
partially_covered_card(&self.cards.piles[1][0]),
|
||||
w2
|
||||
);
|
||||
frame.render_widget(
|
||||
waste_widget(&self.cards.waste),
|
||||
waste_area
|
||||
|
||||
Reference in New Issue
Block a user