use sdl2::pixels::Color;
use std::env;
use tinyfiledialogs as tfd;
pub const SPLITS_ON_SCREEN: usize = 8; pub static MAKING_UP_TIME: Color = Color::RGB(255, 90, 90); pub static LOSING_TIME: Color = Color::RGB(135, 255, 135); pub static GOLD: Color = Color::RGB(255, 255, 0); #[derive(Debug)]
pub enum TimerState {
OffsetCountdown {
amt: u128,
},
Running {
timestamp: u128,
},
Paused {
time: u128,
split: u128,
time_str: String,
},
NotStarted {
time_str: String,
},
Finished {
time_str: String,
},
}
pub fn save_check() -> bool {
match tfd::message_box_yes_no(
"Save run?",
"Your run was a PB; do you want to save it?",
tfd::MessageBoxIcon::Question,
tfd::YesNo::Yes,
) {
tfd::YesNo::No => {
return false;
}
tfd::YesNo::Yes => {
return true;
}
}
}
pub fn open_splits() -> String {
let cwd = env::current_dir().unwrap();
let mut dir = cwd.to_string_lossy();
dir.to_mut().push_str("/");
let mut path: Option<String> = None;
while path == None {
path = tfd::open_file_dialog("Open split file", &dir, Some((&["*.msf"], "")));
}
return path.unwrap();
}
pub fn bad_file_dialog(err: &str) -> bool {
match tfd::message_box_ok_cancel(
"file read error",
err,
tfd::MessageBoxIcon::Error,
tfd::OkCancel::Ok,
) {
tfd::OkCancel::Ok => true,
tfd::OkCancel::Cancel => false,
}
}