Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The release notes for each tag are taken from the section for that version.
- **Frame-rate report after each session** (in the log), after KLBF Lab's shared measurement method: average, median, 5 % and 1 % lows, and the share of time spent at 60+, 30-60, 20-30, 10-20, 5-10 and under 5 fps. The first two minutes, while shaders compile, are left out.

### Fixed
- **F1 menu settings on VIctory NVIDIA builds:** DLSS, frame generation and the other F1 choices now apply at the next start, and "Save and restart" restarts the game. The launcher starts such a build through its own `play` whenever the build offers it, also for a ZIP or a build next to the game, and whatever output is chosen. Before, it often started the game another way, in which saved F1 choices were ignored. When a launch argument keeps it from doing so, the log says which (#56).
- **A project's play.ps1 defaults:** only what the script sets when run with no arguments is used. Before, both sides of an `if ($Safe) { ... } else { ... }` were applied together. A value the script fills from a variable (`VICTORY_GAME_DIR = $Game`) was passed on as that text, and replaced the game folder.
- **Builds that start only from their own launcher:** when a build refuses to start from another launcher (KLBF Lab since v26.11.9), the log now says so and names the launcher to use, instead of only showing the failure.
- **Fix and verify after a rebuild:** when the build finishes but its program is missing, the launcher says where it expected it and suggests checking antivirus, instead of telling you to press Install.
Expand Down
132 changes: 93 additions & 39 deletions src-tauri/src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4280,65 +4280,85 @@ fn fix_known_problems(
run_fixes(job, ctx, p, l, true)
}

fn nvidia_overlay_source(root: &Path) -> bool {
/// Whether a build's `play --help` is the play command of VIctory-NVIDIA and the forks with its
/// code: the one that applies the F1 menu's `victory-settings.txt` at every start and restarts the
/// game for it. Told from the program itself, so a build from git, a ZIP or one beside the game
/// is played the same way.
fn has_native_play(help: &str) -> bool {
[
"Get-NVIDIA-DLSS.cmd",
"scripts/play-foxhound.ps1",
"apps/victory/src/play.rs",
]
.iter()
.all(|file| root.join(file).is_file())
}

fn native_nvidia_args(l: &Launch, help: &str) -> Option<Vec<String>> {
let supports = |flag: &str| help.split_whitespace().any(|word| word == flag);
if ![
"--series-s",
"--res",
"--dlss",
"--set",
"--no-framegen-ready",
]
.into_iter()
.all(supports)
{
return None;
}
.all(|flag| help.split_whitespace().any(|word| word == flag))
}

/// The `victory play` arguments for this start, and notes for the log. Err: a launch argument
/// `play` does not take, so the start goes through `run`, where the F1 menu's choices do not apply.
fn native_nvidia_args(l: &Launch, help: &str) -> Result<(Vec<String>, Vec<String>), String> {
let supports = |flag: &str| help.split_whitespace().any(|word| word == flag);
let mut notes = Vec::new();
let mut given: Vec<String> = Vec::new();
let mut args = l.args.iter();
while let Some(arg) = args.next() {
let (flag, inline) = arg
.split_once('=')
.map_or((arg.as_str(), false), |(flag, _)| (flag, true));
.map_or((arg.as_str(), None), |(flag, value)| (flag, Some(value)));
// `run`'s console choice, as `play` says it.
if flag == "--console" {
let value = inline.map(str::to_owned).or_else(|| args.next().cloned());
match value.as_deref() {
Some("series-s") => given.push("--series-s".into()),
Some("series-x") => {}
_ => return Err(format!("{arg} names no console")),
}
continue;
}
if !supports(flag) {
return None;
return Err(format!(
"the launch argument {flag} is one `play` does not take"
));
}
given.push(arg.clone());
match flag {
"--series-s" | "--no-framegen-ready" | "--preload" if !inline => (),
"--series-s" | "--no-framegen-ready" | "--framegen-ready" | "--preload"
if inline.is_none() => {}
"--res" | "--dlss" | "--framegen" | "--fg-type" | "--fps" | "--set" => {
if !inline && args.next().is_none_or(|value| value.starts_with("--")) {
return None;
if inline.is_none() {
match args.next() {
Some(value) if !value.starts_with("--") => given.push(value.clone()),
_ => return Err(format!("the launch argument {flag} has no value")),
}
}
}
_ => return None,
_ => {
return Err(format!(
"the launch argument {arg} is one `play` does not take"
))
}
}
}
let has = |flag| l.args.iter().any(|arg| arg.split('=').next() == Some(flag));
let series_s = l.series_s || has("--series-s");
let has = |flag: &str| given.iter().any(|arg| arg.split('=').next() == Some(flag));
let mut native = Vec::new();
if l.series_s && !has("--series-s") {
native.push("--series-s".into());
}
if !has("--res") {
// The F1 menu's own picture size wins over this one; it is only the first start's.
match l.output {
OutputResolution::Default | OutputResolution::P1440 => {}
OutputResolution::P1080 => native.extend(["--res".into(), "1080to1440".into()]),
OutputResolution::P2160 => native.extend(["--res".into(), "4k".into()]),
OutputResolution::P936 => return None,
OutputResolution::P720 if !series_s => return None,
_ => (),
other => notes.push(format!(
"this build's play has no {other:?} output: it uses its own picture size (F1 menu, else 1440p)"
)),
}
}
native.extend(l.args.iter().cloned());
Some(native)
native.extend(given);
Ok((native, notes))
}

/// The file the F1 menu of `victory play` saves its choices in: `victory-settings.txt` in
Expand Down Expand Up @@ -4465,7 +4485,8 @@ fn native_nvidia_play_keeps_f1_defaults_and_passes_profile_overrides() {
launch.foxhound_preset = true;
launch.extra = "VICTORY_DLSS=quality\nVICTORY_AMBIENT=0.6".into();
let help = "--series-s --res --dlss --set --no-framegen-ready";
let args = native_nvidia_args(&launch, help).unwrap();
assert!(has_native_play(help) && !has_native_play("--series-s --res"));
let (args, _) = native_nvidia_args(&launch, help).unwrap();
let command = native_nvidia_command(
&root.join("victory.exe"),
&root,
Expand All @@ -4484,8 +4505,27 @@ fn native_nvidia_play_keeps_f1_defaults_and_passes_profile_overrides() {
.iter()
.any(|arg| arg.starts_with("VICTORY_DLSS=")));
launch.args = vec!["--strict".into()];
assert!(native_nvidia_args(&launch, help).is_none());
assert!(native_nvidia_args(&launch, "").is_none());
assert!(native_nvidia_args(&launch, help)
.unwrap_err()
.contains("--strict"));
// `run`'s console flag is said the `play` way, and no output refuses `play`.
launch.series_s = false;
launch.args = vec!["--console".into(), "series-s".into()];
for output in [
OutputResolution::P720,
OutputResolution::P936,
OutputResolution::Screen,
] {
launch.output = output;
let (args, notes) = native_nvidia_args(&launch, help).unwrap();
assert_eq!(args, ["--series-s"]);
assert_eq!(notes.len(), 1, "{output:?}");
}
launch.args = vec!["--console=series-x".into(), "--dlss".into(), "dlaa".into()];
launch.output = OutputResolution::P1080;
let (args, notes) = native_nvidia_args(&launch, help).unwrap();
assert_eq!(args, ["--res", "1080to1440", "--dlss", "dlaa"]);
assert!(notes.is_empty());
std::fs::remove_file(script).unwrap();
std::fs::remove_dir(root.join("scripts")).unwrap();
std::fs::remove_dir(root).unwrap();
Expand Down Expand Up @@ -4563,15 +4603,29 @@ fn play(
}
prepare_ahead(job, ctx, p, l, &exe)?;
stage(job, ctx, msg_str!("Playing"));
// The build's folder: its repo for a build made here, else the program's own folder.
let root = repo_dir(&p.repo);
let root = cargo_workspace(&root).unwrap_or(root);
let native = if p.local_exe.is_none() && p.archive_exe.is_none() && nvidia_overlay_source(&root)
{
victory_help(&exe, "play")
.and_then(|help| native_nvidia_args(l, &help))
.map(|args| native_nvidia_command(&exe, &root, p, l, &args))
let root = if root.is_dir() {
cargo_workspace(&root).unwrap_or(root)
} else {
None
exe.parent().map_or(root, Path::to_path_buf)
};
// A build whose own `play` applies the F1 menu's saved choices is started through it: through
// `run`, those choices would never apply, and its "save and restart" could not restart.
let native = match victory_help(&exe, "play").filter(|help| has_native_play(help)) {
None => None,
Some(help) => match native_nvidia_args(l, &help) {
Ok((args, notes)) => {
job.lock().unwrap().log.extend(notes);
Some(native_nvidia_command(&exe, &root, p, l, &args))
}
Err(reason) => {
job.lock().unwrap().log.push(format!(
"Not starting through this build's own play, so the F1 menu's saved choices do not apply this time: {reason}. Remove it from Launch options to use them."
));
None
}
},
};
let mut c = if let Some(command) = native {
job.lock()
Expand Down
Loading