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
27 changes: 27 additions & 0 deletions docs/DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,33 @@ the one on recomplauncher.com is used. Before anyone installs your release, the
that list to go on: ask for your games to be listed there (with their art), or the release shows
as one game until it's installed. Launchers older than 0.90 Beta 36 skip it and show one tile.

### `system`: what your game needs from the PC

Say what each of your builds needs, so a player with an older PC is told why the game won't start
instead of seeing it close:

```json
"system": {
"windows": { "version": "10", "graphics": { "d3d12": "12_0" } },
"linux": { "glibc": "2.35", "graphics": { "vulkan": "1.3" } },
"macos": { "version": "13", "graphics": { "metal": "3" } }
}
```

- One part for each system you ship a build for. A part or a key you leave out is no known need.
- `version`: the oldest Windows (`"10"`, `"11"`, or a build like `"10.0.19041"`) or macOS (`"13"`,
`"14.4"`).
- `glibc`, for Linux: the oldest glibc your build runs with. That's the glibc of the system you
built it on, so build on an old one (see [Releases that install cleanly](#releases-that-install-cleanly)).
- `graphics`: the API you draw with (`vulkan`, `opengl`, `d3d12`, `d3d11`, `d3d9` or `metal`) and
its oldest version.

The game's page lists these with the rest of what it needs, and the launcher checks the system's
version and glibc against the player's PC: when the PC is older, the page shows it in red and the
player is told when they press Play. The game still starts, since the PC may manage anyway. The
graphics version is only shown. A Windows build played through Proton on Linux is checked against
nothing: its Windows version means nothing there.

## Settings: in the launcher

### `config`: your settings files
Expand Down
37 changes: 37 additions & 0 deletions docs/recomplauncher.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,37 @@
"additionalProperties": false
}
},
"system": {
"description": "What your game needs from the PC, for each system you ship a build for. The launcher checks what it can (the Windows or macOS version, glibc on Linux) and tells the player when their PC is older, but never stops the game. A system or a key left out is no known need.",
"type": "object",
"properties": {
"windows": {
"type": "object",
"properties": {
"version": { "type": "string", "pattern": "^\\d+(\\.\\d+)*$", "description": "The oldest Windows it runs on: \"10\", \"11\", or a build like \"10.0.19041\"." },
"graphics": { "$ref": "#/definitions/systemGraphics" }
},
"additionalProperties": false
},
"linux": {
"type": "object",
"properties": {
"glibc": { "type": "string", "pattern": "^\\d+(\\.\\d+)*$", "description": "The oldest glibc your Linux build runs with, like \"2.35\": the glibc of the system you built it on." },
"graphics": { "$ref": "#/definitions/systemGraphics" }
},
"additionalProperties": false
},
"macos": {
"type": "object",
"properties": {
"version": { "type": "string", "pattern": "^\\d+(\\.\\d+)*$", "description": "The oldest macOS it runs on, like \"13\" or \"14.4\"." },
"graphics": { "$ref": "#/definitions/systemGraphics" }
},
"additionalProperties": false
}
},
"additionalProperties": false
},
"requires": {
"description": "The launcher features this profile uses. Parts needing a feature the player's launcher doesn't have are left out (no Easy Setup, no settings tab for it); the game still installs and plays.",
"type": "array",
Expand All @@ -933,6 +964,12 @@
},
"additionalProperties": false,
"definitions": {
"systemGraphics": {
"description": "The graphics API the build draws with, and the oldest version it needs: {\"vulkan\": \"1.3\"}. Shown on the game's page; the launcher doesn't check it.",
"type": "object",
"propertyNames": { "enum": ["vulkan", "opengl", "d3d12", "d3d11", "d3d9", "metal"] },
"additionalProperties": { "type": "string", "pattern": "^\\d+([._]\\d+)*$" }
},
"programs": {
"type": "array",
"minItems": 1,
Expand Down
32 changes: 31 additions & 1 deletion src-tauri/src/devtools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
use tauri::State;

const FILE: &str = "recomplauncher.json";
const TOP_KEYS: &[&str] = &["$schema", "format", "name", "repo", "game", "start", "config", "folders", "exit_codes", "settings", "groups", "actions", "prepare", "looks", "mods", "saves", "inputs", "requires", "min", "games"];
const TOP_KEYS: &[&str] = &["$schema", "format", "name", "repo", "game", "start", "config", "folders", "exit_codes", "settings", "groups", "actions", "prepare", "looks", "mods", "saves", "inputs", "requires", "min", "games", "system"];

fn now() -> u64 {
std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0)
Expand Down Expand Up @@ -538,10 +538,24 @@ fn check_profile(p: &profile::Profile, dir: &Path, g: &Installed, items: &mut Ve
}
items.extend(keeps_copy_items(p, dir));
}
items.extend(system_item(p));
items.extend(outside_item(p));
level
}

/// `system`: values the launcher can't read as a version, or a graphics API it doesn't know. Those
/// are ignored, so the PC is never checked against them.
fn system_item(p: &profile::Profile) -> Option<Item> {
let bad = crate::sysneeds::bad_values(p.system.as_ref()?);
if bad.is_empty() {
return None;
}
Some(warn(
format!("Not read in \"system\": {}", bad.join(", ")),
format!("Versions are numbers with dots (\"10\", \"2.35\", \"1.3\"), and graphics APIs are {}. Linux builds give glibc, not a version.", crate::sysneeds::GRAPHICS.join(", ")),
))
}

/// A step that builds the game from the player's copy, without `prepare.done`: the launcher can't
/// tell the build is there, so it can't keep the game set up after an update, or use a build the
/// player already has. Only then: a step that only fetches extras needs no list. A keeps_copy
Expand Down Expand Up @@ -774,6 +788,22 @@ mod tests {
assert!(super::outside_item(&p).is_none());
}

#[test]
fn a_system_value_the_launcher_cant_read_is_named() {
let p: crate::profile::Profile = serde_json::from_str(r#"{"format":1,"system":{"linux":{"glibc":"latest","graphics":{"vulkan":"1.3"}}}}"#).unwrap();
let item = super::system_item(&p).unwrap();
assert_eq!(item.level, "warn");
assert!(item.text.contains("system.linux.glibc"), "{}", item.text);
}

#[test]
fn a_system_part_that_reads_well_is_left_alone() {
let p: crate::profile::Profile = serde_json::from_str(r#"{"format":1,"system":{"windows":{"version":"10","graphics":{"d3d12":"12_0"}},"linux":{"glibc":"2.35"}}}"#).unwrap();
assert!(super::system_item(&p).is_none());
let none: crate::profile::Profile = serde_json::from_str(r#"{"format":1}"#).unwrap();
assert!(super::system_item(&none).is_none());
}

#[test]
fn the_setup_steps_version_is_named_in_the_check() {
assert!(super::version_item("").is_none());
Expand Down
24 changes: 24 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub mod setup_state;
#[cfg(test)]
mod setup_window_tests;
pub mod sysenv;
pub mod sysneeds;
mod emus;
pub mod roms;
pub mod saves;
Expand Down Expand Up @@ -3207,6 +3208,13 @@ fn start_game_with_monitor_context(
let through_proton = !cfg!(windows) && matches!(ext.as_str(), "exe" | "cmd" | "bat");
cmd.env("RECOMPLAUNCHER_DATA", if through_proton { profile::wine_path(&shown) } else { shown });
}
// The PC is older than the game says it needs: said, so a game that won't start isn't a mystery,
// but it still starts (the developer may be wrong, or the PC may manage).
let too_old = profile_of(&st, id, &g).and_then(|p| system_needs(&p, &g)).map(|(_, old)| old).unwrap_or_default();
if !too_old.is_empty() {
trail::note(format!("Play {id}: this PC is older than the game needs: {too_old:?}"));
let _ = app.emit("system-old", json!({ "name": g.name, "old": too_old }));
}
// A Python set up elsewhere on the PC (PYTHONHOME, PYTHONPATH) breaks the Python some games
// carry inside them ("No module named 'encodings'"). Games with their own Python never want them.
if ext != "py" {
Expand Down Expand Up @@ -5147,6 +5155,10 @@ struct Setup {
build_at: Option<PathBuf>,
/// Set up, or why not: the answer Play gives too (setup_state).
status: setup_state::Status,
/// What the installed build needs from the PC (`system`), for the game page's list.
system: Option<sysneeds::OsNeeds>,
/// What of that this PC is too old for: shown in red, and said when it plays.
system_old: Vec<sysneeds::TooOld>,
}

#[derive(Serialize, Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -5215,6 +5227,7 @@ fn game_setup(app: AppHandle, st: State<'_, App>, id: String) -> Option<Setup> {
let built = p.build_done(&g.path) == Some(true) || (g.prebuilt && p.build_folder_here(&g.path).is_some());
let set_up = if p.inputs.is_empty() { copy.is_some() || built } else { inputs_ready };
let status = easy_status(&st, &id, &g, &p, inputs_ready);
let system = system_needs(&whole, &g);
Some(Setup {
inputs: inputs::rows(&p, &g, &st.dir).unwrap_or_default(),
inputs_error: inputs::validate(&p).err(),
Expand Down Expand Up @@ -5272,9 +5285,20 @@ fn game_setup(app: AppHandle, st: State<'_, App>, id: String) -> Option<Setup> {
spare: if pick.is_some() || setup_busy(&id) { None } else { spare_copy(&g, &p, &st.lib.lock().unwrap().installed.values().cloned().collect::<Vec<_>>()) },
build_at: if pick.is_some() { None } else { build_folder_now(&st, &id, &g) },
status,
system_old: system.as_ref().map(|(_, old)| old.clone()).unwrap_or_default(),
system: system.map(|(n, _)| n),
})
}

/// What the installed build needs from the PC (`system` in its recomplauncher.json), and what of it
/// this PC is too old for.
fn system_needs(p: &profile::Profile, g: &Installed) -> Option<(sysneeds::OsNeeds, Vec<sysneeds::TooOld>)> {
let build_os = if is_windows_build(g) { "windows" } else { assets::os_now() };
let needs = p.system.as_ref()?.for_build(build_os)?.clone();
let old = sysneeds::too_old(&needs, build_os, assets::os_now(), sysneeds::os_version().as_deref(), sysneeds::glibc_version().as_deref());
Some((needs, old))
}

/// A game built into a folder of its own (its setup's, or the player's build in use): that folder,
/// when it's there.
fn build_folder_now(st: &App, id: &str, g: &Installed) -> Option<PathBuf> {
Expand Down
7 changes: 7 additions & 0 deletions src-tauri/src/manage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,17 @@ pub struct PcCheck {
pub clang: Option<bool>,
/// Python 3's version ("3.12.4"); empty when there's none. For setups that run Python.
pub python: Option<String>,
/// Windows' ("10.0.22631") or macOS's ("14.5") version, for what a game says it needs
/// (sysneeds.rs). None on Linux.
pub os_version: Option<String>,
/// glibc's version ("2.39") on Linux, for a game's Linux build.
pub glibc: Option<String>,
}

pub fn pc_check() -> PcCheck {
let mut c = PcCheck { cores: std::thread::available_parallelism().map(|n| n.get()).unwrap_or(1), ..Default::default() };
c.os_version = crate::sysneeds::os_version();
c.glibc = crate::sysneeds::glibc_version();
#[cfg(target_arch = "x86_64")]
{
c.avx = std::arch::is_x86_feature_detected!("avx");
Expand Down
17 changes: 17 additions & 0 deletions src-tauri/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ pub struct Profile {
/// Whether looks (ReShade filters) can be used with it, and how.
#[serde(default)]
pub looks: Option<crate::looks::ProfileLooks>,
/// What it needs from the PC, by system (sysneeds.rs). Left out of the profile when it isn't
/// given, so setups fingerprinted before it existed stay as they were.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub system: Option<crate::sysneeds::SystemNeeds>,
/// Where the game keeps its saves: folders, files, or `*` patterns, with the same {local},
/// {documents}, {install}... as everywhere else. Backups and cloud saves copy these.
#[serde(default)]
Expand Down Expand Up @@ -2666,6 +2670,19 @@ fn place_z64(from: &Path, to: &Path) -> std::io::Result<bool> {
#[cfg(test)]
mod tests {

#[test]
fn system_reads_each_part_and_a_profile_without_it_writes_none() {
let p: super::Profile = serde_json::from_str(r#"{"format":1,"system":{"linux":{"glibc":"2.35","graphics":{"vulkan":"1.3"}},"windows":{"version":"11"}}}"#).unwrap();
let s = p.system.as_ref().unwrap();
assert_eq!(s.for_build("linux").unwrap().glibc, "2.35");
assert_eq!(s.for_build("linux").unwrap().graphics["vulkan"], "1.3");
assert_eq!(s.for_build("windows").unwrap().version, "11");
assert!(s.for_build("macos").is_none());
// Setups fingerprinted from the profile before `system` existed stay set up.
let plain: super::Profile = serde_json::from_str(r#"{"format":1}"#).unwrap();
assert!(!serde_json::to_string(&plain).unwrap().contains("system"));
}

#[test]
fn easy_setup_follows_the_websites_rule() {
let p = |v: serde_json::Value| serde_json::from_value::<super::Profile>(v).unwrap().easy_setup();
Expand Down
Loading
Loading