Add WIM Image selection section

This commit is contained in:
2Shirt 2025-11-29 02:33:24 -08:00
parent 89e768e3a4
commit 88dfe52b07
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -341,10 +341,10 @@ impl App {
}
}
Mode::SelectWinSource => {
// TODO: FIXME
// PLAN: Abuse Action::Select to send (file_index, image_index) to set all at once
// self.state.wim_file_index = TODO;
// self.state.wim_image_index = TODO;
self.state.wim_file_index = one;
}
Mode::SelectWinImage => {
self.state.wim_image_index = one;
}
_ => {}
},
@ -401,8 +401,9 @@ fn build_footer_string(cur_mode: Mode) -> String {
"(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::SelectWinSource => String::from("(Enter) to select / (q) to quit"),
Mode::SelectWinImage => String::from("(Enter) to select / (q) to quit"),
Mode::SelectWinSource | Mode::SelectWinImage => {
String::from("(Enter) to select / (q) to quit")
}
Mode::ScanWinSources => {
String::from("(Enter) to continue / (n) to scan network / (q) to quit")
}
@ -466,7 +467,15 @@ fn build_left_items(app: &App) -> Action {
Mode::SelectWinImage => {
select_type = SelectionType::One;
title = String::from("Select Windows Image");
// TODO: FIXME
if let Ok(wim_sources) = app.state.wim_sources.lock()
&& let Some(index) = app.state.wim_file_index
{
wim_sources
.get_file(index)
.images
.iter()
.for_each(|image| items.push(format!("{image}")));
}
}
Mode::SelectDisks => {
select_type = SelectionType::One;
@ -606,6 +615,7 @@ fn build_right_items(app: &App) -> Action {
line_parts: vec![String::from("Images")],
line_colors: vec![Color::Blue],
},
DVLine::blank(),
];
source.images.iter().for_each(|image| {
wim_dv_lines.push(DVLine {
@ -617,6 +627,68 @@ fn build_right_items(app: &App) -> Action {
});
}
}
Mode::SelectWinImage => {
let source;
if let Ok(wim_sources) = app.state.wim_sources.lock()
&& let Some(index) = app.state.wim_file_index
{
source = wim_sources.get_file(index);
} else {
panic!("Failed to get source WIM file");
}
// Disk Info
let type_str = match app.state.table_type.clone().unwrap() {
PartitionTableType::Guid => "GPT",
PartitionTableType::Legacy => "MBR",
};
let mut label_dv_lines = vec![
DVLine {
line_parts: vec![
String::from("Dest"),
String::from(" (WARNING: ALL DATA WILL BE DELETED!)"),
],
line_colors: vec![Color::Cyan, Color::Red],
},
DVLine {
line_parts: vec![format!(" (Will be formatted {type_str})")],
line_colors: vec![Color::Yellow],
},
DVLine::blank(),
];
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)
{
get_disk_description_right(disk, &None)
.into_iter()
.for_each(|dv_line| label_dv_lines.push(dv_line));
}
label_dv_lines.append(&mut vec![
DVLine::blank(),
DVLine {
line_parts: vec![String::from("WIM Info")],
line_colors: vec![Color::Cyan],
},
DVLine {
line_parts: vec![source.path.clone()],
line_colors: vec![Color::Reset],
},
DVLine::blank(),
DVLine {
line_parts: vec![String::from("Image")],
line_colors: vec![Color::Blue],
},
]);
labels.push(label_dv_lines);
// WIM Info
source.images.iter().for_each(|image| {
items.push(vec![DVLine {
line_parts: vec![format!("{image}")],
line_colors: vec![Color::Reset],
}])
});
}
Mode::SelectTableType | Mode::SetUserName | Mode::Confirm => {
// Labels
let dest_dv_line = DVLine {