the great refactor

This commit is contained in:
2026-03-04 22:50:37 +01:00
parent b6efa0a818
commit c81178567a
15 changed files with 519 additions and 448 deletions

View File

@@ -10,17 +10,21 @@ use std::{
use thiserror::Error;
use walkdir::WalkDir;
use crate::basic_types::{self, ModdedInstance, RootConfig};
use crate::types::{self, ModdedInstance, RootConfig};
pub fn create_loadorder(
root_config: &RootConfig,
game: &basic_types::Game,
game: &types::Game,
instance: &ModdedInstance,
) -> Result<Vec<String>, LoadOrderError> {
let mut loot_game = Game::new(GameType::SkyrimSE, &game.install_location)?;
let mut loot_game = Game::with_local_path(
GameType::SkyrimSE,
game.install_location(),
&game.install_location().join(PathBuf::from("appdata")),
)?;
// Add plugins files from the game install
let install_plugins: Vec<PathBuf> = WalkDir::new(game.install_location.join("Data"))
let install_plugins: Vec<PathBuf> = WalkDir::new(game.install_location().join("Data"))
.into_iter()
.map(|entry| {
let entry = entry?;
@@ -43,17 +47,17 @@ pub fn create_loadorder(
// Add plugins from the instance
let instance_plugins: Vec<_> = instance
.mods
.mods()
.iter()
.flat_map(|installed_mod| {
let mod_config = root_config.get_mod_by_id(&installed_mod.mod_id()).unwrap();
let mod_source_root = root_config.get_mod_location(&mod_config);
let mod_config = root_config.get_mod_by_id(installed_mod.mod_id()).unwrap();
let mod_source_root = root_config.mod_location().join(mod_config.path());
installed_mod
.files()
.iter()
.filter(|f| is_plugin_file(&f.dst))
.map(move |link| mod_source_root.join(&link.src))
.filter(|f| is_plugin_file(f.dst()))
.map(move |link| mod_source_root.join(link.src()))
})
.collect();