UI tweaks

master
Mark 2024-03-05 10:18:03 -08:00
parent 65e8eb7998
commit 3e080ad89d
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
1 changed files with 23 additions and 1 deletions

View File

@ -1,6 +1,7 @@
use std::io::{stdin, stdout, Write}; use std::io::{stdin, stdout, Write};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use itertools::Itertools;
use termion::{color, cursor::HideCursor, event::Key, input::TermRead, raw::IntoRawMode}; use termion::{color, cursor::HideCursor, event::Key, input::TermRead, raw::IntoRawMode};
use crate::{ use crate::{
@ -94,7 +95,7 @@ impl PlayerAgent {
// Ask for input until we get a valid move // Ask for input until we get a valid move
loop { loop {
print!( print!(
"\r{}{}{} ╙{}{}{}{}{}╜", "\r{}{}{} ╙{}{}{}{}{}╜ {}",
// Goal // Goal
color::Fg(self.player.color()), color::Fg(self.player.color()),
if minimize { "Min" } else { "Max" }, if minimize { "Min" } else { "Max" },
@ -109,6 +110,27 @@ impl PlayerAgent {
}, },
color::Fg(color::Reset), color::Fg(color::Reset),
" ".repeat(cursor_max - self.cursor), " ".repeat(cursor_max - self.cursor),
self.symbol_selector
.symbols
.iter()
.map(|x| {
if board.contains(Symb::from_char(*x).unwrap()) {
format!(
"{}{x}{}",
color::Fg(color::LightBlack),
color::Fg(color::Reset),
)
} else if *x == self.symbol_selector.current() {
format!(
"{}{x}{}",
color::Fg(self.player.color()),
color::Fg(color::Reset),
)
} else {
format!("{x}",)
}
})
.join("")
); );
stdout.flush()?; stdout.flush()?;