diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.sh index ad49e99d..7b7abcba 100755 --- a/dylib/feats/compat_run.sh +++ b/dylib/feats/compat_run.sh @@ -525,8 +525,8 @@ NP_CONF_NAMES BEGIN { nkv = 0; records = 0; id = ""; code = ""; detail = "" if (kind == "plugin") { - split("label description description_on section on off depends requires inject env overrides stage tools type choice min max step default suffix hide_crossover apps patch variants group improves needed_for", f, " ") - split("1 1 16 1 1 1 1 4 1 16 1 1 8 1 16 1 1 1 1 1 1 16 16 8 1 16 16", m, " ") + split("label description description_on section on off depends requires inject env overrides stage tools type choice min max step default suffix hide_crossover apps patch variants group improves needed_for launcher", f, " ") + split("1 1 16 1 1 1 1 4 1 16 1 1 8 1 16 1 1 1 1 1 1 16 16 8 1 16 16 1", m, " ") split("label", req, " "); nreq = 1 } else { split("label variant src dst build remove apps", f, " ") @@ -3352,6 +3352,8 @@ stage_step="plugins" np_feat_dylibs="" np_feat_envs="" np_feat_patches="" +np_feat_launcher="" +np_feat_launcher_key="" while IFS= read -r np_feat_key; do [ -n "$np_feat_key" ] || continue if ! np_feat_installed "$np_feat_key"; then @@ -3412,6 +3414,20 @@ while IFS= read -r np_feat_key; do fi fi + # A Windows program the game is started through. The first one found wins. + np_feat_exe=$(np_feat_first "$np_feat_key" launcher) + if [ -n "$np_feat_exe" ]; then + np_feat_exe=$(np_home_path "$np_feat_exe") + if [ -n "$np_feat_launcher" ]; then + np_feat_log "$np_feat_key's launcher is skipped as $np_feat_launcher_key already set one" + elif [ ! -f "$np_feat_exe" ]; then + np_feat_log "$np_feat_key's launcher is skipped as $np_feat_exe doesn't exist" + else + np_feat_launcher=$np_feat_exe + np_feat_launcher_key=$np_feat_key + fi + fi + np_feat_over=$(np_feat_first "$np_feat_key" overrides) if [ -n "$np_feat_over" ]; then export WINEDLLOVERRIDES="${WINEDLLOVERRIDES:+$WINEDLLOVERRIDES;}$np_feat_over" @@ -3512,6 +3528,12 @@ $np_feat_envs" np_feat_dylibs="" fi +# The shim starts its first argument, so the launcher gets the game and its arguments. +if [ -n "$np_feat_launcher" ] && [ "$verb" = waitforexitandrun ]; then + set -- "$np_feat_launcher" "$@" + np_feat_log "$np_feat_launcher_key starts the game through $np_feat_launcher" +fi + game_cwd="$(pwd)" if [ -n "$STEAM_DYLD_INSERT_LIBRARIES" ]; then echo "=== overlay injected from $STEAM_DYLD_INSERT_LIBRARIES ===" >> "$log" 2>&1 || true diff --git a/dylib/feats/conf.c b/dylib/feats/conf.c index 4bfab538..5f8e014a 100644 --- a/dylib/feats/conf.c +++ b/dylib/feats/conf.c @@ -23,7 +23,7 @@ static const np_conf_spec_t kPlugin[] = { { "max", 1, 0 }, { "step", 1, 0 }, { "default", 1, 0 }, { "suffix", 1, 0 }, { "hide_crossover", 1, 0 }, { "apps", 16, 0 }, { "patch", 16, 0 }, { "variants", 8, 0 }, { "group", 1, 0 }, - { "improves", 16, 0 }, { "needed_for", 16, 0 }, + { "improves", 16, 0 }, { "needed_for", 16, 0 }, { "launcher", 1, 0 }, { NULL, 0, 0 } }; diff --git a/dylib/tests/featstagecheck.sh b/dylib/tests/featstagecheck.sh index 510579bd..f3328016 100755 --- a/dylib/tests/featstagecheck.sh +++ b/dylib/tests/featstagecheck.sh @@ -344,6 +344,42 @@ out=$(run np_tool_name=notproton-fex-rosetta NOTPROTON_PICKY=1 NOTPROTON_ANY=1) ok "and does on a tool its pattern matches" "$(line "$out" 1)" \ "steamclient=n;lsteamclient=b;picky=n;any=n" +# Plugin launchers: the first one found wins. +launcher() { + # shellcheck disable=SC2016 # expanded by the inner shell + env -i PATH="$PATH" HOME="$work" np_support="$work/Library/Application Support/notproton" \ + log="$work/log" WINEPREFIX="$work/pfx" "$@" \ + sh -c 'set -e; . "$1/block.sh"; printf "%s|%s" "$np_feat_launcher" "$np_feat_launcher_key"' \ + sh "$work" +} +printf 'exe\n' > "$work/lib/first.exe" +printf 'exe\n' > "$work/lib/second.exe" +reset +conf 10-first.conf <