pass active plugins to fomod installer
This commit is contained in:
@@ -5,7 +5,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use globset::{Glob, GlobSet, GlobSetBuilder};
|
use globset::{Glob, GlobSet, GlobSetBuilder};
|
||||||
use log::warn;
|
use log::{debug, trace, warn};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -114,14 +114,21 @@ fn determain_mod_kind(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn install_fomod(
|
fn install_fomod(
|
||||||
_instance: &ModdedInstance,
|
instance: &ModdedInstance,
|
||||||
module_config_path: impl AsRef<Path>,
|
module_config_path: impl AsRef<Path>,
|
||||||
mod_root: impl AsRef<Path>,
|
mod_root: impl AsRef<Path>,
|
||||||
) -> anyhow::Result<Vec<ModFile>> {
|
) -> anyhow::Result<Vec<ModFile>> {
|
||||||
|
debug!("Running FOmod installer");
|
||||||
let module_config = fomod::Config::load_from_file(module_config_path)?;
|
let module_config = fomod::Config::load_from_file(module_config_path)?;
|
||||||
|
|
||||||
// TODO: add active plugins from instance config
|
let active_plugins: Vec<_> = instance
|
||||||
let files = run_fomod_installer(module_config, &[], install_prompt::prompt)
|
.active_plugins()
|
||||||
|
.map(|e| e.to_string_lossy())
|
||||||
|
.map(|e| e.to_string())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
trace!("Current loded plugins: {:?}", active_plugins);
|
||||||
|
let files = run_fomod_installer(module_config, &active_plugins, install_prompt::prompt)
|
||||||
.map_err(|_| InststanceError::FomodRunInstaller)?;
|
.map_err(|_| InststanceError::FomodRunInstaller)?;
|
||||||
|
|
||||||
let mod_files: Vec<_> = files
|
let mod_files: Vec<_> = files
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use std::{
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
use crate::types::{self, ModdedInstance, RootConfig};
|
use crate::{types::{self, ModdedInstance, RootConfig}, utils::is_plugin_file};
|
||||||
|
|
||||||
pub fn create_loadorder(
|
pub fn create_loadorder(
|
||||||
root_config: &RootConfig,
|
root_config: &RootConfig,
|
||||||
@@ -76,13 +76,6 @@ pub fn create_loadorder(
|
|||||||
Ok(sorted)
|
Ok(sorted)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_plugin_file(filename: impl AsRef<Path>) -> bool {
|
|
||||||
filename
|
|
||||||
.as_ref()
|
|
||||||
.extension()
|
|
||||||
.is_some_and(|ext| ext == "esp" || ext == "esm" || ext == "esl")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum LoadOrderError {
|
pub enum LoadOrderError {
|
||||||
#[error("Failed to read game directory")]
|
#[error("Failed to read game directory")]
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
|
use std::ffi::OsStr;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::types::{link::Link, mod_file::ModFile};
|
use crate::{
|
||||||
|
types::{link::Link, mod_file::ModFile},
|
||||||
|
utils::is_plugin_file,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct InstalledMod {
|
pub struct InstalledMod {
|
||||||
@@ -36,4 +41,12 @@ impl InstalledMod {
|
|||||||
pub fn files(&self) -> &[Link] {
|
pub fn files(&self) -> &[Link] {
|
||||||
&self.files
|
&self.files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn active_plugins(&self) -> impl Iterator<Item = &OsStr> {
|
||||||
|
self.files
|
||||||
|
.iter()
|
||||||
|
.filter(|e| is_plugin_file(e.dst()))
|
||||||
|
.map(|e| e.dst())
|
||||||
|
.flat_map(|e| e.file_name())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
ffi::OsStr,
|
||||||
fs::{self, read_to_string},
|
fs::{self, read_to_string},
|
||||||
io::Write,
|
io::Write,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
@@ -88,4 +89,8 @@ impl ModdedInstance {
|
|||||||
pub fn mods(&self) -> &[InstalledMod] {
|
pub fn mods(&self) -> &[InstalledMod] {
|
||||||
&self.mods
|
&self.mods
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn active_plugins(&self) -> impl Iterator<Item = &OsStr> {
|
||||||
|
self.mods.iter().flat_map(|e| e.active_plugins())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,3 +56,10 @@ pub fn walk_all_files(
|
|||||||
|
|
||||||
Ok(a)
|
Ok(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_plugin_file(filename: impl AsRef<Path>) -> bool {
|
||||||
|
filename
|
||||||
|
.as_ref()
|
||||||
|
.extension()
|
||||||
|
.is_some_and(|ext| ext == "esp" || ext == "esm" || ext == "esl")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user