From f51a4e85c48e184e9cb41759ad1d571c73021b13 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 8 Nov 2025 18:43:50 -0800 Subject: [PATCH] Add more framework for workflow --- config/config.json5 | 15 +++++++++++++++ core/src/action.rs | 2 ++ win_installer/src/app.rs | 17 +++++++++++++++-- win_installer/src/state.rs | 10 ++++++++-- win_installer/src/wim.rs | 6 +++++- 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/config/config.json5 b/config/config.json5 index 81c4ee1..1ad0168 100644 --- a/config/config.json5 +++ b/config/config.json5 @@ -188,5 +188,20 @@ "": "Quit", "": "Suspend" }, + "ScanWinImages": { + "": "Process", + "": "FindWimNetwork", + "": "Quit", + "": "Quit", + "": "Quit", + "": "Suspend" + }, + "SetUserName": { + "": "Process", + "": "Process", + "": "Quit", + "": "Quit", + "": "Suspend" + }, }, } diff --git a/core/src/action.rs b/core/src/action.rs index 34bf83a..7675fd5 100644 --- a/core/src/action.rs +++ b/core/src/action.rs @@ -55,6 +55,8 @@ pub enum Action { OpenTerminal, Restart, Shutdown, + // App (Win-Installer) + FindWimNetwork, // Screens DismissPopup, DisplayPopup(PopupType, String), diff --git a/win_installer/src/app.rs b/win_installer/src/app.rs index aafa217..587ba2a 100644 --- a/win_installer/src/app.rs +++ b/win_installer/src/app.rs @@ -245,10 +245,23 @@ impl App<'_> { // } Action::Resize(w, h) => self.handle_resize(tui, w, h)?, Action::Render => self.render(tui)?, + Action::FindWimNetwork => { + self.state.reset_network(); + // TODO: Actually scan network! + } Action::SetMode(mode) => { self.mode = mode; - if self.mode == Mode::ScanDisks { - self.state.reset(); + match mode { + Mode::Done => { + self.action_tx.send(Action::DisplayPopup( + popup::Type::Success, + popup::fortune(), + ))?; + } + Mode::ScanDisks => { + self.state.reset_all(); + } + _ => {} } self.action_tx.send(Action::UpdateFooter(String::from( "(Enter) to select / (t) for terminal / (p) to power off / (r) to restart", diff --git a/win_installer/src/state.rs b/win_installer/src/state.rs index a52efd6..6156c61 100644 --- a/win_installer/src/state.rs +++ b/win_installer/src/state.rs @@ -40,13 +40,19 @@ impl State<'_> { } } - pub fn reset(&mut self) { + pub fn reset_all(&mut self) { self.disk_index_dest = None; self.part_index_boot = None; self.wim_file_index = None; self.wim_image_index = None; if let Ok(mut sources) = self.wim_sources.lock() { - sources.reset(); + sources.reset_all(); + } + } + + pub fn reset_network(&mut self) { + if let Ok(mut sources) = self.wim_sources.lock() { + sources.reset_network(); } } diff --git a/win_installer/src/wim.rs b/win_installer/src/wim.rs index 3d464c0..6a8326f 100644 --- a/win_installer/src/wim.rs +++ b/win_installer/src/wim.rs @@ -99,10 +99,14 @@ impl WimSources<'_> { Default::default() } - pub fn reset(&mut self) { + pub fn reset_all(&mut self) { self.local.clear(); self.network.clear(); } + + pub fn reset_network(&mut self) { + self.network.clear(); + } } fn get_wim_xml(wim_file: &str) -> std::io::Result {