Merge PR #1892 (openragee): a mods folder, every DLL in %LOCALAPPDATA%\victory\mods loaded before the title runs
# Conflicts: # apps/victory/src/main.rs
This commit is contained in:
@ -632,6 +632,8 @@ fn main() -> Result<()> {
|
||||
victory_core::logging::init("info");
|
||||
// F1's MFG UNLOCKER: the mod, before the layer makes its device or loads Streamline.
|
||||
play::load_mfg();
|
||||
// Other mods, each in its own place: after MFG's slot, before the title runs.
|
||||
play::load_mods();
|
||||
let console = if ready.series_s { Console::SeriesS } else { Console::SeriesX };
|
||||
run::run(&ready.exe, Unimplemented::Trap, false, true, console)
|
||||
});
|
||||
@ -774,6 +776,9 @@ fn main() -> Result<()> {
|
||||
play::load_mfg_from_menu();
|
||||
}
|
||||
}
|
||||
// The mods folder is every path's, not only play's: a script that runs the
|
||||
// title directly loads the same DLLs.
|
||||
play::load_mods();
|
||||
run::run(&exe, unimplemented, strict, execute, console)
|
||||
}
|
||||
#[cfg(all(windows, feature = "diagnostics"))]
|
||||
|
||||
@ -860,6 +860,31 @@ pub(crate) fn load_mfg_from_menu() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Loads every mod DLL of `%LOCALAPPDATA%\victory\mods`, by name, after MFG Unlocker's own
|
||||
/// slot: mods that are not it, in their own place, each named in the log. A DLL that does not
|
||||
/// load says so and costs the run nothing.
|
||||
pub(crate) fn load_mods() {
|
||||
let Some(dir) = home().ok().map(|h| h.join("mods")) else {
|
||||
return;
|
||||
};
|
||||
let Ok(listed) = std::fs::read_dir(&dir) else {
|
||||
return;
|
||||
};
|
||||
let mut dlls: Vec<PathBuf> = listed
|
||||
.flatten()
|
||||
.map(|entry| entry.path())
|
||||
.filter(|path| path.extension().is_some_and(|e| e.eq_ignore_ascii_case("dll")))
|
||||
.collect();
|
||||
dlls.sort();
|
||||
for dll in dlls {
|
||||
let name = dll.file_stem().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
|
||||
match victory_hle::streamline::load_mod(&format!("mod {name} (victory\\mods)"), &dll) {
|
||||
Ok(()) => println!("Mod {name} loaded ({}).", dll.display()),
|
||||
Err(code) => println!("Mod {name} did not load (Windows error {code}): running without it."),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `D3D12` beside this program: where Windows looks for Microsoft's newer
|
||||
/// Direct3D 12 runtime (main.rs's `D3D12SDKPath`).
|
||||
fn d3d12_dir() -> Result<PathBuf> {
|
||||
|
||||
Reference in New Issue
Block a user