Skip to content

Commit

Permalink
wip Proper launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
fholger committed Aug 22, 2023
1 parent 32364a6 commit 2f071f6
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/Launcher/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

.idea
101 changes: 101 additions & 0 deletions Sources/Launcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Sources/Launcher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "farcry_vr"
version = "1.0.0"
edition = "2021"
description = "A launcher for Far Cry VR"

[[bin]]
name = "FarCryVR"
path = "src/main.rs"

[dependencies.windows]
version = "0.48"
features = [
"Win32_Foundation",
"Win32_System_LibraryLoader",
]

[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
37 changes: 37 additions & 0 deletions Sources/Launcher/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#![windows_subsystem = "windows"]
extern crate windows;

use std::env;
use std::path::Path;
use std::process::Command;
use windows::core::HSTRING;
use windows::Win32::System::LibraryLoader::SetDllDirectoryW;

fn main() {
let exe_path = env::current_exe().expect("Failed to determine path");
let install_dir = exe_path.parent().unwrap_or(Path::new("."));
let farcry_exe_path = install_dir.join("Bin32").join("FarCry.exe");
let mod_exe_path = install_dir.join("Mods").join("CryVR").join("Bin32");

let pass_on_args: Vec<String> = env::args().skip(1).collect();

let args = vec![
"-MOD:CryVR",
"-DEVMODE",
];

unsafe {
SetDllDirectoryW(&HSTRING::from(mod_exe_path.as_os_str()));
}

Command::new(farcry_exe_path)
.args(pass_on_args)
.args(&args)
.env("DXVK_ASYNC", "0")
.env("DXVK_GPLASYNCCACHE", "0")
.current_dir(install_dir.join("Bin32"))
.spawn()
.expect("Failed to launch Far Cry")
.wait()
.expect("Failed to run Far Cry");
}

0 comments on commit 2f071f6

Please sign in to comment.