diff --git a/config/config.json5 b/config/config.json5 index 1ad0168..2eecb94 100644 --- a/config/config.json5 +++ b/config/config.json5 @@ -196,9 +196,18 @@ "": "Quit", "": "Suspend" }, + "SelectWinImage": { + "": "Process", + "": "KeyUp", + "": "KeyDown", + "": "Quit", + "": "Quit", + "": "Quit", + "": "Suspend" + }, "SetUserName": { "": "Process", - "": "Process", + "": "PrevScreen", "": "Quit", "": "Quit", "": "Suspend" diff --git a/win_installer/src/app.rs b/win_installer/src/app.rs index 3c77bc7..e3fbd9e 100644 --- a/win_installer/src/app.rs +++ b/win_installer/src/app.rs @@ -285,6 +285,9 @@ impl App { } Action::Resize(w, h) => self.handle_resize(tui, w, h)?, Action::Render => self.render(tui)?, + Action::InstallDriver => { + self.action_tx.send(Action::SetMode(Mode::InstallDrivers))?; + } Action::FindWimNetwork => { self.state.reset_network(); let mut wim_sources = self.state.wim_sources.lock().unwrap(); @@ -301,8 +304,17 @@ impl App { self.action_tx.send(Action::DismissPopup)?; self.action_tx.send(Action::SetMode(next_mode))?; } + Action::PrevScreen => match self.cur_mode { + Mode::SelectTableType => { + self.action_tx.send(Action::SetMode(Mode::SelectDisks))?; + } + Mode::SetUserName => { + self.action_tx.send(Action::SetMode(Mode::SelectWinImage))?; + } + _ => {} + }, Action::Process => match self.cur_mode { - Mode::Confirm => { + Mode::Confirm | Mode::ScanWinImages => { self.action_tx.send(Action::NextScreen)?; } Mode::Done => { @@ -310,6 +322,7 @@ impl App { } _ => {} }, + Action::ScanDisks => self.action_tx.send(Action::SetMode(Mode::ScanDisks))?, Action::Select(one, _two) => match self.cur_mode { Mode::InstallDrivers => { if let Some(index) = one @@ -347,9 +360,8 @@ impl App { }, Action::SetMode(mode) => { self.set_mode(mode)?; - self.action_tx.send(Action::UpdateFooter(String::from( - "(Enter) to select / (t) for terminal / (p) to power off / (r) to restart", - )))?; + self.action_tx + .send(Action::UpdateFooter(build_footer_string(self.cur_mode)))?; self.action_tx.send(build_left_items(self))?; self.action_tx.send(build_right_items(self))?; self.action_tx.send(Action::Select(None, None))?; @@ -391,6 +403,37 @@ impl App { } } +fn build_footer_string(cur_mode: Mode) -> String { + match cur_mode { + Mode::Home | Mode::ScanDisks => String::from("(q) to quit"), + Mode::InstallDrivers => String::from("(Enter) to select / (q) to quit"), + Mode::SelectDisks => String::from( + "(Enter) to select / / (i) to install driver / (r) to rescan / (q) to quit", + ), + Mode::SelectTableType => String::from("(Enter) to select / (b) to go back / (q) to quit"), + Mode::SelectWinImage => String::from("(Enter) to select / (q) to quit"), + Mode::ScanWinImages => { + String::from("(Enter) to continue / (n) to scan network / (q) to quit") + } + Mode::SetUserName => String::from("(Enter) to continue / (Esc) to go back"), + Mode::Confirm => String::from("(Enter) to confirm / (b) to go back / (q) to quit"), + Mode::Done | Mode::Failed | Mode::Process => String::from("(Enter) or (q) to quit"), + // Invalid States + Mode::BootDiags + | Mode::BootScan + | Mode::BootSetup + | Mode::Clone + | Mode::DiagMenu + | Mode::InjectDrivers + | Mode::LogView + | Mode::PEMenu + | Mode::PreClone + | Mode::PostClone + | Mode::SelectParts + | Mode::SetBootMode => panic!("This shouldn't happen?"), + } +} + fn build_left_items(app: &App) -> Action { let select_type: SelectionType; let title: String; @@ -422,7 +465,7 @@ fn build_left_items(app: &App) -> Action { Mode::SelectWinImage => { select_type = SelectionType::One; title = String::from("Select Windows Image"); - // TODO: FIXME + // TODO: FIXME, I think this whole section could be better... } Mode::SelectDisks => { select_type = SelectionType::One; @@ -485,12 +528,7 @@ fn build_right_items(app: &App) -> Action { }]); start_index = 2; } - Mode::ScanWinImages - | Mode::SelectWinImage - | Mode::SetUserName - | Mode::SelectDisks - | Mode::SelectTableType - | Mode::Confirm => { + Mode::SelectDisks => { // Labels let dest_dv_line = DVLine { line_parts: vec![ @@ -520,6 +558,38 @@ fn build_right_items(app: &App) -> Action { .iter() .for_each(|disk| items.push(get_disk_description_right(disk, &None))); } + Mode::SelectTableType | Mode::SelectWinImage | Mode::SetUserName | Mode::Confirm => { + // Labels + let dest_dv_line = DVLine { + line_parts: vec![ + String::from("Dest"), + String::from(" (WARNING: ALL DATA WILL BE DELETED!)"), + ], + line_colors: vec![Color::Cyan, Color::Red], + }; + if let Some(table_type) = &app.state.table_type { + // Show table type + let type_str = match table_type { + PartitionTableType::Guid => "GPT", + PartitionTableType::Legacy => "MBR", + }; + labels.push(vec![ + dest_dv_line, + DVLine { + line_parts: vec![format!(" (Will be formatted {type_str})")], + line_colors: vec![Color::Yellow], + }, + ]); + } else { + labels.push(vec![dest_dv_line]); + } + let disk_list = app.state.disk_list.lock().unwrap(); + if let Some(index) = app.state.disk_index_dest + && let Some(disk) = disk_list.get(index) + { + items.push(get_disk_description_right(disk, &None)); + } + } _ => {} } Action::UpdateRight(labels, start_index, items)