Compare commits

..

2 Commits

Author SHA1 Message Date
1f4691cb72 added create plugin txt to linker 2026-03-02 16:16:26 +01:00
eb337e67f4 added load_order to moddedInstance 2026-03-02 16:15:56 +01:00
2 changed files with 34 additions and 6 deletions

View File

@@ -1,16 +1,15 @@
use quick_xml::se;
use serde::{Deserialize, Serialize};
use std::{
error::Error,
fs::{self, read_to_string},
io::{self, Write},
io::Write,
path::{Path, PathBuf},
};
use crate::{
conflict_resolver::{Conflict, ConflictSolver},
conflict_resolver::ConflictSolver,
fomod::{FileType, FileTypeEnum},
utils::{path_to_lowercase, walk_files_recursive},
utils::walk_files_recursive,
};
#[derive(Debug, Clone, Deserialize, PartialEq)]
@@ -72,7 +71,12 @@ impl ModConfig {
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub struct ModdedInstance {
pub name: String,
#[serde(default)]
pub mods: Vec<InstalledMod>,
#[serde(default)]
pub load_order: Vec<String>,
}
impl ModdedInstance {
@@ -80,6 +84,7 @@ impl ModdedInstance {
Self {
name: name.to_owned(),
mods: Vec::new(),
load_order: Vec::new(),
}
}
@@ -130,6 +135,14 @@ impl ModdedInstance {
self.mods.push(new_mod);
}
pub fn set_load_order(&mut self, order: Vec<String>) {
self.load_order = order;
}
pub fn load_order(&self) -> &[String] {
&self.load_order
}
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]

View File

@@ -1,9 +1,9 @@
use std::{fs, io, os::unix, path::Path};
use crate::{
basic_types::{ModdedInstance, RootConfig},
utils::walk_files_recursive,
};
use std::io::Write;
use std::{fs, io, os::unix, path::Path};
pub fn link_instance_to_target(
root_config: &RootConfig,
@@ -46,6 +46,21 @@ fn link_file(target: &Path, link_name: &Path) -> Result<(), io::Error> {
Ok(())
}
pub fn create_plugins_txt(
instance: &ModdedInstance,
target: impl AsRef<Path>,
) -> Result<(), io::Error> {
let mut file = fs::File::create(target.as_ref().join("plugins.txt"))?;
writeln!(file, "# Auto generated. DO NOT EDIT MANUALLY!")?;
for plugin in instance.load_order() {
writeln!(file, "*{}", plugin)?;
}
Ok(())
}
fn create_symlink_for_file(target: &Path, link_name: &Path) -> io::Result<()> {
let absolute_path = fs::canonicalize(target)?;