From 9974b80d5ec66672e2ef130c2cba5b64c526db65 Mon Sep 17 00:00:00 2001 From: jugeeya <jugeeya@live.com> Date: Thu, 17 Aug 2023 12:16:53 -0700 Subject: [PATCH] Initial --- training_mod_consts/src/options.rs | 2 +- training_mod_tui/src/main.rs | 31 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/training_mod_consts/src/options.rs b/training_mod_consts/src/options.rs index 9b54a0f..465b583 100644 --- a/training_mod_consts/src/options.rs +++ b/training_mod_consts/src/options.rs @@ -86,7 +86,7 @@ macro_rules! extra_bitflag_impls { fn to_toggle_strings() -> Vec<String> { let all_options = <$e>::all().to_vec(); - all_options.iter().map(|i| i.to_string()).collect() + all_options.iter().map(|i| i.as_str().unwrap_or(" ").to_string()).collect() } } } diff --git a/training_mod_tui/src/main.rs b/training_mod_tui/src/main.rs index a10e722..8b43435 100644 --- a/training_mod_tui/src/main.rs +++ b/training_mod_tui/src/main.rs @@ -187,6 +187,37 @@ fn test_save_and_reset_defaults() -> Result<(), Box<dyn Error>> { Ok(()) } +#[test] +fn test_toggle_naming() -> Result<(), Box<dyn Error>> { + let menu; + let mut prev_menu; + let menu_defaults; + unsafe { + prev_menu = MENU.clone(); + menu = ui_menu(MENU); + menu_defaults = (ui_menu(MENU), serde_json::to_string(&MENU).unwrap()); + } + + let (mut terminal, mut app) = test_backend_setup(menu, menu_defaults)?; + // Enter Mash Toggles + app.on_a(); + // Set Mash Airdodge + app.on_a(); + + let frame_res = terminal.draw(|f| training_mod_tui::ui(f, &mut app))?; + let mut full_frame_buffer = String::new(); + for (i, cell) in frame_res.buffer.content().iter().enumerate() { + full_frame_buffer.push_str(&cell.symbol); + if i % frame_res.area.width as usize == frame_res.area.width as usize - 1 { + full_frame_buffer.push_str("\n"); + } + } + full_frame_buffer.push_str("\n"); + assert!(full_frame_buffer.contains("Airdodge")); + + Ok(()) +} + fn main() -> Result<(), Box<dyn Error>> { let args: Vec<String> = std::env::args().collect(); let inputs = args.get(1);