moved group prompt constructor
This commit is contained in:
@@ -7,11 +7,7 @@ use crate::fomod::{
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InstallerState {
|
pub struct InstallerState {
|
||||||
/// Flags set by plugin selections throughout the install
|
|
||||||
flags: HashMap<String, String>,
|
flags: HashMap<String, String>,
|
||||||
|
|
||||||
/// Files to install, keyed by destination path.
|
|
||||||
/// Higher priority value wins when destinations conflict.
|
|
||||||
selected_files: Vec<FileTypeEnum>,
|
selected_files: Vec<FileTypeEnum>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,24 +95,8 @@ pub struct GroupPrompt {
|
|||||||
pub options: Vec<InstallOption>,
|
pub options: Vec<InstallOption>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InstallOption {
|
impl GroupPrompt {
|
||||||
pub name: String,
|
fn new(group: &Group, state: &InstallerState, installed_plugins: &[String]) -> Self {
|
||||||
pub option_type: PluginTypeEnum,
|
|
||||||
pub idx: usize,
|
|
||||||
pub description: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for InstallOption {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f, "{} ({:?})", self.name, self.option_type)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_group_prompt(
|
|
||||||
group: &Group,
|
|
||||||
state: &InstallerState,
|
|
||||||
installed_plugins: &[String],
|
|
||||||
) -> GroupPrompt {
|
|
||||||
let options = group
|
let options = group
|
||||||
.plugins
|
.plugins
|
||||||
.plugin
|
.plugin
|
||||||
@@ -130,11 +110,25 @@ fn create_group_prompt(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
GroupPrompt {
|
Self {
|
||||||
name: group.name.clone(),
|
name: group.name.clone(),
|
||||||
select_type: group.typ,
|
select_type: group.typ,
|
||||||
options,
|
options,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct InstallOption {
|
||||||
|
pub name: String,
|
||||||
|
pub option_type: PluginTypeEnum,
|
||||||
|
pub idx: usize,
|
||||||
|
pub description: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for InstallOption {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{} ({:?})", self.name, self.option_type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Each plugin in the install steps have a type. e.g.: Optional, Required, Recommended
|
/// Each plugin in the install steps have a type. e.g.: Optional, Required, Recommended
|
||||||
@@ -207,7 +201,7 @@ impl FomodInstaller {
|
|||||||
for group in &step.optional_file_groups.group {
|
for group in &step.optional_file_groups.group {
|
||||||
// TODO: Skip groups where all plugins are NotUsable
|
// TODO: Skip groups where all plugins are NotUsable
|
||||||
|
|
||||||
let prompt = create_group_prompt(group, &state, &self.installed_plugins);
|
let prompt = GroupPrompt::new(group, &state, &self.installed_plugins);
|
||||||
|
|
||||||
let selected_plugins = (self.group_prompt)(prompt);
|
let selected_plugins = (self.group_prompt)(prompt);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user