diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/src/main.rs b/src/main.rs index 8ce24d2..c7cc30a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,11 +24,13 @@ mod consulter; mod game; mod gui; mod parser; +mod tui; use crate::consulter::consulter_clean_up; use crate::game::*; use crate::gui::*; use crate::parser::parse_start_type; +use crate::tui::*; use argparse::*; use chrono::Local; @@ -44,6 +46,7 @@ fn main() { let mut engine = String::new(); let mut name = String::new(); let mut size: u8 = 5; + let mut terminal = false; let mut start_type_string = String::new(); println!("Takwrap, a TUI for playing Tak and interacting with Tak engines.\n @@ -114,6 +117,13 @@ This program comes with ABSOLUTELY NO WARRANTY; and is made available under the Print(env!("CARGO_PKG_VERSION").to_string()), "Show version", ); + + ap.refer(&mut terminal).add_option( + &["-t", "--terminal"], + Store, + "Use the terminal user interface instead of the graphical one.", + ); + ap.parse_args_or_exit(); } @@ -162,23 +172,26 @@ This program comes with ABSOLUTELY NO WARRANTY; and is made available under the Game::new(size, &p2_name, &p1_name, &date_string, start_type) }; - let mut gui = GUI::new(&game, warning); + if terminal { + let mut tui = TUI::new(&game, warning); - loop { - let inp = gui.query_input(&game, call_proc, p1_white, &engine); - if !gui.handle_input(&mut game, call_proc, p1_white, inp) { - break; + loop { + let inp = tui.query_input(&game, call_proc, p1_white, &engine); + if !tui.handle_input(&mut game, call_proc, p1_white, inp) { + break; + } } - } - // Clean up file - if call_proc { - if let Err(e) = consulter_clean_up() { - gui.message_log - .log_error(format!("Error in cleaning up temporary files: {}", e)); + // Clean up file + if call_proc { + if let Err(e) = consulter_clean_up() { + tui.message_log + .log_error(format!("Error in cleaning up temporary files: {}", e)); + } } - } - // board_gui.read_action(); - endwin(); + endwin(); + } else { + gui_test(); + } } |
