Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

Hide CrossOver options the FEX build cannot use

Loganb6a70290170f
diff --git a/Makefile b/Makefile
index 418fae2..b922c87 100644
--- a/Makefile
+++ b/Makefile
@@ -348,6 +348,7 @@ panel-behavior:
node $(PANEL_TESTS)/shell.js $(OUT_DIR)/panel-emit && \
node $(PANEL_TESTS)/migration.js $(OUT_DIR)/panel-emit && \
node $(PANEL_TESTS)/localization.js $(OUT_DIR)/panel-emit && \
+ node $(PANEL_TESTS)/fex.js $(OUT_DIR)/panel-emit && \
echo "==> panel behavior: renders as expected, no stale arguments"
CX_ROOT ?= /Applications/CrossOver Preview.app
diff --git a/dylib/feats/compat.c b/dylib/feats/compat.c
index bfb97b7..bb398ca 100644
--- a/dylib/feats/compat.c
+++ b/dylib/feats/compat.c
@@ -5,6 +5,7 @@
#include <dirent.h>
#include <pthread.h>
+#include <stdatomic.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -816,6 +817,23 @@ const char *np_compat_fallback_tool_name(void) {
return g_tool_count > 0 ? g_tools[0].name : TOOL_DIR_NAME;
}
+size_t np_compat_fex_tools(const char **names, size_t max) {
+ load_tool_list_once();
+ size_t n = 0;
+ for (int i = 0; i < g_tool_count; i++) {
+ if (strcmp(g_tools[i].flavor, "fex") != 0) continue;
+ if (n == max) {
+ static atomic_flag warned = ATOMIC_FLAG_INIT;
+ if (!atomic_flag_test_and_set(&warned))
+ NP_WARN("np_compat_fex_tools: more than %zu FEX tools, %s and later "
+ "are left out", max, g_tools[i].name);
+ break;
+ }
+ names[n++] = g_tools[i].name;
+ }
+ return n;
+}
+
void *np_compat_registered_tool(void *compat_mgr) {
if (!compat_mgr)
return NULL;
diff --git a/dylib/feats/compat.h b/dylib/feats/compat.h
index 8468070..9ae2334 100644
--- a/dylib/feats/compat.h
+++ b/dylib/feats/compat.h
@@ -120,6 +120,9 @@ void *np_compat_registered_tool(void *compat_mgr);
// Name of the first tool in the app's list, which unmapped Windows games run under.
const char *np_compat_fallback_tool_name(void);
+// Names of the listed tools whose flavor is fex, up to max. Returns how many it wrote.
+size_t np_compat_fex_tools(const char **names, size_t max);
+
uint32_t np_compat_manager_tools_max(void);
// Absolute path to the directory of the first tool in the app's list, or NULL.
diff --git a/dylib/feats/webpatch.c b/dylib/feats/webpatch.c
index 5564932..d5b8180 100644
--- a/dylib/feats/webpatch.c
+++ b/dylib/feats/webpatch.c
@@ -17,8 +17,13 @@
// Stands for the name set by np_webpatch_set_fallback_tool.
#define NP_FALLBACK_TOOL "\021"
+// Stands for the JS array set by np_webpatch_set_fex_tools.
+#define NP_FEX_TOOLS "\022"
-static _Thread_local char g_fallback_tool[128];
+#define NP_TOOL_NAME_MAX 128
+
+static _Thread_local char g_fallback_tool[NP_TOOL_NAME_MAX];
+static _Thread_local char g_fex_tools[NP_WEBPATCH_FEX_TOOLS_MAX * (NP_TOOL_NAME_MAX + 3) + 3] = "[]";
typedef struct {
const char *find;
@@ -37,15 +42,41 @@ static int cap_index(unsigned char c) {
return (c >= 1 && c <= NP_CAP_MAX) ? c - 1 : -1;
}
-void np_webpatch_set_fallback_tool(const char *name) {
- g_fallback_tool[0] = '\0';
- if (!name) return;
+static int is_tool_name(const char *name) {
size_t n = strlen(name);
- if (n >= sizeof(g_fallback_tool)) return;
+ if (n >= NP_TOOL_NAME_MAX) return 0;
for (size_t i = 0; i < n; i++)
if (!is_ident_char((unsigned char)name[i]) && name[i] != '.' && name[i] != '-')
- return;
- memcpy(g_fallback_tool, name, n + 1);
+ return 0;
+ return 1;
+}
+
+void np_webpatch_set_fallback_tool(const char *name) {
+ g_fallback_tool[0] = '\0';
+ if (name && is_tool_name(name))
+ memcpy(g_fallback_tool, name, strlen(name) + 1);
+}
+
+void np_webpatch_set_fex_tools(const char *const *names, size_t count) {
+ size_t n = 0;
+ g_fex_tools[n++] = '[';
+ for (size_t i = 0; i < count && i < NP_WEBPATCH_FEX_TOOLS_MAX; i++) {
+ if (!names[i] || !*names[i] || !is_tool_name(names[i])) continue;
+ size_t len = strlen(names[i]);
+ if (n > 1) g_fex_tools[n++] = ',';
+ g_fex_tools[n++] = '"';
+ memcpy(g_fex_tools + n, names[i], len);
+ n += len;
+ g_fex_tools[n++] = '"';
+ }
+ g_fex_tools[n++] = ']';
+ g_fex_tools[n] = '\0';
+}
+
+static const char *marker_text(char c) {
+ if (c == NP_FALLBACK_TOOL[0]) return g_fallback_tool;
+ if (c == NP_FEX_TOOLS[0]) return g_fex_tools;
+ return NULL;
}
static size_t match_at(const char *src, size_t len, size_t pos,
@@ -54,9 +85,10 @@ static size_t match_at(const char *src, size_t len, size_t pos,
size_t s = pos;
for (const char *f = find; *f; f++) {
- if (*f == NP_FALLBACK_TOOL[0]) {
- size_t n = strlen(g_fallback_tool);
- if (s + n > len || memcmp(src + s, g_fallback_tool, n) != 0) return 0;
+ const char *text = marker_text(*f);
+ if (text) {
+ size_t n = strlen(text);
+ if (s + n > len || memcmp(src + s, text, n) != 0) return 0;
s += n;
continue;
}
@@ -115,8 +147,9 @@ static int out_put(np_out_t *o, const char *p, size_t n) {
static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
for (const char *r = replace; *r; r++) {
- if (*r == NP_FALLBACK_TOOL[0]) {
- if (!out_put(o, g_fallback_tool, strlen(g_fallback_tool))) return 0;
+ const char *text = marker_text(*r);
+ if (text) {
+ if (!out_put(o, text, strlen(text))) return 0;
continue;
}
int ci = cap_index((unsigned char)*r);
@@ -179,11 +212,17 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
".MSCXPanel .MSCXRow{display:flex;flex-direction:row;padding:9px;margin:0;" \
"color:#dfe3e6;background:rgba(59,63,72,.5);border-radius:3px}" \
".MSCXPanel .MSCXRow:hover{box-shadow:0 6px 8px 0 rgba(0,0,0,.16)}" \
+ ".MSCXPanel .MSCXNote{padding:6px 2px 0;color:#ffc82c;font-size:13px}" \
".MSCXNoBottomGap{margin-bottom:0}\""
+// The FEX build runs arm64 Wine, so D3DMetal (x86_64 only) and its DLSS flag cannot
+// load, and Rosetta, which reads ROSETTA_ADVERTISE_AVX, never runs. A game already set
+// to D3DMetal keeps the entry and a note, so the page does not claim a backend the game
+// is not getting.
#define NP_CX_OPTIONS_BODY(ARG, RT, BARREL) \
ARG "=>{" \
"const t=" ARG ".details,o=t.strLaunchOptions||\"\"," \
+ "fex=" NP_FEX_TOOLS ".indexOf(t.strCompatToolName||\"" NP_FALLBACK_TOOL "\")>=0," \
"npZh=" NP_WEB_IS_ZH ",npL=(en,zh)=>npZh?zh:en," \
NP_CX_LAUNCH_PARSE \
"g=k=>{const p=E.e.filter(w=>o.startsWith(k+\"=\",w.start)).pop();" \
@@ -199,7 +238,8 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
"checked:g(ks[0])===on," \
"onChange:v=>s(ks.map(k=>[k,v?on:(off||\"\")]))},ks[0])," \
"b=g(\"CX_GRAPHICS_BACKEND\")," \
- "dm=\"\"===b||\"d3dmetal\"===b," \
+ "dk=fex&&\"d3dmetal\"===b," \
+ "dm=!fex&&(\"\"===b||\"d3dmetal\"===b)," \
"dx=\"\"===b||\"dxmt\"===b," \
"sw=\"1\"===g(\"DXMT_METALFX_SPATIAL_SWAPCHAIN\")," \
"F=\"d3d11.metalSpatialUpscaleFactor=\"," \
@@ -217,7 +257,7 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
"{data:\"d3dmetal\",label:\"D3DMetal\"}," \
"{data:\"dxmt\",label:\"DXMT\"}," \
"{data:\"dxvk\",label:\"DXVK\"}," \
- "{data:\"wined3d\",label:\"WineD3D\"}];" \
+ "{data:\"wined3d\",label:\"WineD3D\"}].filter(x=>!fex||dk||x.data!==\"d3dmetal\");" \
"if(t.unAppID<2147483648&&(t.vecPlatforms||[]).indexOf(\"osx\")>=0" \
"&&!t.strCompatToolName)return null;" \
"return(0," RT ".jsx)(\"div\",{className:\"MSCXPanel\",children:(0," RT ".jsxs)(" RT ".Fragment,{children:[" \
@@ -229,10 +269,14 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
".concat(\"\"===v.data||\"dxmt\"===v.data?[]:" \
"[[\"DXMT_METALFX_SPATIAL_SWAPCHAIN\",\"\"],[\"DXMT_CONFIG\",fx(\"\")]])" \
".concat(\"dxmt\"===v.data?[]:[[\"DXMT_ENABLE_NVEXT\",\"\"]]))})," \
+ "dk&&(0," RT ".jsx)(\"div\",{className:\"MSCXNote\"," \
+ "children:npL(\"D3DMetal needs the Rosetta build of CrossOver. On the FEX build, " \
+ "this game runs on another backend.\",\"D3DMetal 需要 Rosetta 版 CrossOver。" \
+ "在 FEX 版中,此游戏会使用其他图形后端。\")},\"fexnote\")," \
"T([\"MTL_HUD_ENABLED\"],npL(\"Metal HUD\",\"Metal 性能监视器\"),\"1\")," \
"dm&&T([\"D3DM_ENABLE_METALFX\"],\"DLSS\",\"1\")," \
"\"dxmt\"===b&&T([\"DXMT_ENABLE_NVEXT\"],\"DLSS\",\"1\")," \
- "T([\"ROSETTA_ADVERTISE_AVX\"],npL(\"Advertise AVX2 to Rosetta\",\"向 Rosetta 声明 AVX2 支持\"),\"1\",\"0\")," \
+ "!fex&&T([\"ROSETTA_ADVERTISE_AVX\"],npL(\"Advertise AVX2 to Rosetta\",\"向 Rosetta 声明 AVX2 支持\"),\"1\",\"0\")," \
"T([\"WINEMSYNC\"],\"MSync\",\"1\",\"0\")," \
"T([\"NOTPROTON_RETINA\"],npL(\"High Resolution\",\"高分辨率\"),\"1\",\"0\")" \
"]},\"gfx\")," \
diff --git a/dylib/feats/webpatch.h b/dylib/feats/webpatch.h
index 2d526cb..28c6793 100644
--- a/dylib/feats/webpatch.h
+++ b/dylib/feats/webpatch.h
@@ -11,6 +11,12 @@ int np_webpatch_should_patch(const char *path);
// letters, digits, '_', '$', '.' and '-' are dropped.
void np_webpatch_set_fallback_tool(const char *name);
+#define NP_WEBPATCH_FEX_TOOLS_MAX 16
+
+// Sets the tools this thread's CrossOver options panel treats as FEX. Names the
+// fallback would drop are skipped, as is anything past NP_WEBPATCH_FEX_TOOLS_MAX.
+void np_webpatch_set_fex_tools(const char *const *names, size_t count);
+
// The compat UIs, named so a caller can compare against the table rather than a literal
// of its own that a rename would leave behind. forcetool calls SpecifyCompatTool straight
// out; selecttool reads its list from the CompatManager routes.
diff --git a/dylib/hooks/hook_webpatch.c b/dylib/hooks/hook_webpatch.c
index 36bc867..122bbe7 100644
--- a/dylib/hooks/hook_webpatch.c
+++ b/dylib/hooks/hook_webpatch.c
@@ -121,6 +121,8 @@ static int open_patched(const char *path) {
close(in);
np_webpatch_set_fallback_tool(np_compat_fallback_tool_name());
+ const char *fex[NP_WEBPATCH_FEX_TOOLS_MAX];
+ np_webpatch_set_fex_tools(fex, np_compat_fex_tools(fex, NP_WEBPATCH_FEX_TOOLS_MAX));
size_t patched_len = 0;
const char *shape = NULL;
char *patched = np_webpatch_transform((const uint8_t *)raw, raw_len, &patched_len,
diff --git a/dylib/tests/compatcheck.c b/dylib/tests/compatcheck.c
index e1e497d..dde5d90 100644
--- a/dylib/tests/compatcheck.c
+++ b/dylib/tests/compatcheck.c
@@ -236,6 +236,7 @@ static void tool_list_cases(void) {
return;
}
fputs("notproton\t27.0.0.40921-fex\tfex\tCrossOver Preview (FEX)\n"
+ "notproton-fex-41069\t27.0.0.41069-fex\tfex\tCrossOver Preview 41069 (FEX)\n"
"notproton-fex-rosetta\t27.0.0.40921-fex\trosetta\tCrossOver Preview (Rosetta)\n"
"notproton-26.3\t26.3.0.39832\trosetta\tCrossOver 26.3\n"
"notproton\t26.3.0.39832\trosetta\tDuplicate\n"
@@ -249,11 +250,11 @@ static void tool_list_cases(void) {
int kept = np_compat_load_tool_list(path, "/tools");
unlink(path);
- check(kept == 3, "only well-formed, unique, notproton-named lines are kept");
+ check(kept == 4, "only well-formed, unique, notproton-named lines are kept");
check(strcmp(g_tools[0].name, "notproton") == 0
&& strcmp(g_tools[0].flavor, "fex") == 0, "the first line stays first");
- check(strcmp(g_tools[2].build, "26.3.0.39832") == 0
- && strcmp(g_tools[2].dir, "/tools/notproton-26.3") == 0,
+ check(strcmp(g_tools[3].build, "26.3.0.39832") == 0
+ && strcmp(g_tools[3].dir, "/tools/notproton-26.3") == 0,
"each tool carries its build and directory");
uint8_t *mgr = build_manager(3, -1);
@@ -264,6 +265,14 @@ static void tool_list_cases(void) {
check(np_compat_registered_tool(mgr) == entries,
"the first listed tool wins when the manager holds it");
+ const char *fex[3] = { NULL, NULL, NULL };
+ check(np_compat_fex_tools(fex, 3) == 2 && strcmp(fex[0], "notproton") == 0
+ && strcmp(fex[1], "notproton-fex-41069") == 0 && !fex[2],
+ "only the fex flavor counts as FEX, not a FEX build's Rosetta tool");
+ fex[0] = fex[1] = NULL;
+ check(np_compat_fex_tools(fex, 1) == 1 && strcmp(fex[0], "notproton") == 0 && !fex[1],
+ "the FEX list stops at its limit, keeping the first listed");
+
f = fopen(path, "w");
if (!f) {
check(0, "the long tool list fixture can be written");
@@ -278,6 +287,7 @@ static void tool_list_cases(void) {
&& strcmp(g_tools[0].dir, "/tools/notproton-0") == 0, "a long list keeps every tool");
check(strcmp(np_compat_fallback_tool_name(), "notproton-0") == 0,
"the fallback is the first configured tool");
+ check(np_compat_fex_tools(fex, 3) == 0, "a list with no FEX tool has no FEX names");
check(np_compat_load_tool_list("out/compatcheck-missing", "/tools") == 0
&& !g_tool_list_present, "a missing list keeps no tools and says so");
diff --git a/dylib/tests/gatecheck.c b/dylib/tests/gatecheck.c
index d3ed25a..d5126bd 100644
--- a/dylib/tests/gatecheck.c
+++ b/dylib/tests/gatecheck.c
@@ -63,6 +63,30 @@ static void check_fallback(void) {
np_log_level = saved;
}
+static void check_fex_tools(void) {
+ np_webpatch_set_fex_tools((const char *[]){ "notproton-fex", "bad name", NULL, "",
+ "x\"y", "notproton-fex-41069" }, 6);
+ if (strcmp(g_fex_tools, "[\"notproton-fex\",\"notproton-fex-41069\"]") != 0)
+ wrong("the FEX tool array is %s", g_fex_tools);
+
+ np_webpatch_set_fex_tools(NULL, 0);
+ if (strcmp(g_fex_tools, "[]") != 0) wrong("no FEX tools gives %s", g_fex_tools);
+
+ char names[NP_WEBPATCH_FEX_TOOLS_MAX + 1][NP_TOOL_NAME_MAX];
+ const char *list[NP_WEBPATCH_FEX_TOOLS_MAX + 1];
+ for (int i = 0; i <= NP_WEBPATCH_FEX_TOOLS_MAX; i++) {
+ memset(names[i], 'a', NP_TOOL_NAME_MAX - 1);
+ names[i][NP_TOOL_NAME_MAX - 1] = '\0';
+ names[i][0] = (char)('A' + i);
+ list[i] = names[i];
+ }
+ np_webpatch_set_fex_tools(list, NP_WEBPATCH_FEX_TOOLS_MAX + 1);
+ size_t want = 2 + NP_WEBPATCH_FEX_TOOLS_MAX * (NP_TOOL_NAME_MAX + 2) - 1;
+ if (strlen(g_fex_tools) != want || strchr(g_fex_tools, 'A' + NP_WEBPATCH_FEX_TOOLS_MAX))
+ wrong("the longest FEX tool array is %zu bytes, not %zu", strlen(g_fex_tools), want);
+ np_webpatch_set_fex_tools(NULL, 0);
+}
+
// Invariants the transform relies on but cannot check at run time. A replacement still
// holding its own anchor would be found again next pass, and an anchor inside another
// anchor would make the result depend on table order rather than on the chunk.
@@ -254,9 +278,10 @@ int main(int argc, char **argv) {
if (argc == 4 && strcmp(argv[1], "--extract") == 0)
return extract(argv[2], argv[3]);
- if (argc < 2) { selfcheck(); check_fallback(); return g_wrong; }
+ if (argc < 2) { selfcheck(); check_fallback(); check_fex_tools(); return g_wrong; }
np_webpatch_set_fallback_tool("notproton-fex");
+ np_webpatch_set_fex_tools((const char *[]){ "notproton-fex", "notproton-fex-41069" }, 2);
for (int i = 1; i < argc; i++) {
size_t len = 0;
diff --git a/dylib/tests/panel-behavior/emit.c b/dylib/tests/panel-behavior/emit.c
index e511034..854ce3d 100644
--- a/dylib/tests/panel-behavior/emit.c
+++ b/dylib/tests/panel-behavior/emit.c
@@ -9,13 +9,21 @@
int np_log_level = 0;
FILE *np_log_file = NULL;
-int main(int argc, char **argv) {
- if (argc == 2 && strcmp(argv[1], "component") == 0) {
- fputs(NP_CX_OPTIONS_COMPONENT, stdout);
- return 0;
+static void put_panel(const char *body) {
+ for (const char *p = body; *p; p++) {
+ const char *text = marker_text(*p);
+ if (text) fputs(text, stdout);
+ else putchar(*p);
}
- if (argc == 2 && strcmp(argv[1], "statement") == 0) {
- fputs(NP_CX_OPTIONS_STATEMENT, stdout);
+}
+
+int main(int argc, char **argv) {
+ if (argc >= 2 && (strcmp(argv[1], "component") == 0 || strcmp(argv[1], "statement") == 0)) {
+ np_webpatch_set_fallback_tool(argc >= 3 ? argv[2] : NULL);
+ np_webpatch_set_fex_tools((const char *const *)argv + 3,
+ argc > 3 ? (size_t)(argc - 3) : 0);
+ put_panel(strcmp(argv[1], "component") == 0 ? NP_CX_OPTIONS_COMPONENT
+ : NP_CX_OPTIONS_STATEMENT);
return 0;
}
if (argc == 2 && strcmp(argv[1], "migration") == 0) {
@@ -30,6 +38,7 @@ int main(int argc, char **argv) {
fputs(NP_IMAGE_FILES_LABEL, stdout);
return 0;
}
- fputs("usage: emit component|statement|migration|compat-hint|image-files-label\n", stderr);
+ fputs("usage: emit component|statement [fallback [fex-tool...]]|migration|compat-hint|"
+ "image-files-label\n", stderr);
return 2;
}
diff --git a/dylib/tests/panel-behavior/fex.js b/dylib/tests/panel-behavior/fex.js
new file mode 100644
index 0000000..ca35e4e
--- /dev/null
+++ b/dylib/tests/panel-behavior/fex.js
@@ -0,0 +1,94 @@
+// On the FEX build the panel drops the controls that cannot take effect there, and
+// the Rosetta build keeps every one of them.
+'use strict';
+const { panel, walk, details, runner, FORMS } = require('./harness');
+
+const emit = process.argv[2];
+if (!emit) { console.error('usage: fex.js <emit>'); process.exit(2); }
+
+const AVX = 'Advertise AVX2 to Rosetta';
+
+// The hook passes only FEX tools; notproton-rosetta stands for a Rosetta tool next to it.
+const FEX_TOOLS = ['notproton-fex'];
+
+let failed = 0;
+for (const form of Object.keys(FORMS)) {
+ for (const fex of [false, true]) {
+ const { render: P, written } = panel(emit, form, undefined, { fexTools: FEX_TOOLS });
+ const t = runner(`${form}, ${fex ? 'FEX' : 'Rosetta'}`);
+ const tool = fex ? 'notproton-fex' : 'notproton-rosetta';
+ const nodes = opts =>
+ walk(P({ details: details(opts + ' %command%', { strCompatToolName: tool }) }));
+ const toggles = ns => ns.filter(x => x.type === 'Toggle').map(x => x.props.label);
+ const backends = ns => ns.find(x => x.type === 'Dropdown').props.rgOptions.map(o => o.data);
+ const note = ns => ns.some(x => x.props.className === 'MSCXNote');
+
+ let r = nodes('');
+ t.ok(backends(r).includes('d3dmetal') === !fex,
+ `D3DMetal is ${fex ? 'not ' : ''}offered (${backends(r)})`);
+ t.ok(toggles(r).includes(AVX) === !fex, `the AVX2 row is ${fex ? 'hidden' : 'shown'}`);
+ t.ok(toggles(r).includes('DLSS') === !fex,
+ `automatic ${fex ? 'hides' : 'shows'} the D3DMetal DLSS row`);
+ t.ok(!note(r), 'automatic shows no note');
+
+ // Kept as an entry so the dropdown still names what the options say, with a note
+ // that the game is not getting it.
+ r = nodes('CX_GRAPHICS_BACKEND=d3dmetal D3DM_ENABLE_METALFX=1');
+ t.ok(backends(r).includes('d3dmetal'), 'a game set to D3DMetal still shows it selected');
+ t.ok(note(r) === fex, `the D3DMetal note is ${fex ? 'shown' : 'absent'}`);
+ t.ok(toggles(r).includes('DLSS') === !fex,
+ `D3DMetal ${fex ? 'hides' : 'shows'} its DLSS row`);
+
+ r = nodes('CX_GRAPHICS_BACKEND=dxmt');
+ t.ok(toggles(r).includes('DLSS') && r.some(x => x.type === 'Section' &&
+ x.props.label.startsWith('MetalFX')), 'dxmt keeps its DLSS row and MetalFX');
+ for (const l of ['Metal HUD', 'MSync', 'High Resolution'])
+ t.ok(toggles(r).includes(l), `${l} stays`);
+
+ written.length = 0;
+ nodes('CX_GRAPHICS_BACKEND=d3dmetal D3DM_ENABLE_METALFX=1').find(x => x.type === 'Dropdown')
+ .props.onChange({ data: 'dxmt' });
+ const opts = written[written.length - 1].opts;
+ t.ok(opts.includes('CX_GRAPHICS_BACKEND=dxmt') && !opts.includes('D3DM_ENABLE_METALFX'),
+ `switching off D3DMetal drops its flag (${opts})`);
+
+ // Hidden is not cleared: a value set under the Rosetta build is left for it.
+ written.length = 0;
+ const kept = 'ROSETTA_ADVERTISE_AVX=1 CX_GRAPHICS_BACKEND=dxvk';
+ r = nodes(kept);
+ r.find(x => x.type === 'Toggle' && x.props.label === 'Metal HUD').props.onChange(true);
+ t.ok(written[written.length - 1].opts.includes('ROSETTA_ADVERTISE_AVX=1'),
+ 'editing another row keeps the AVX2 value');
+ failed += t.failed;
+ }
+
+ // A game with no tool name runs under the fallback tool.
+ for (const first of [false, true]) {
+ const fallback = first ? 'notproton-fex' : 'notproton-rosetta';
+ const { render: P } = panel(emit, form, undefined, { fallback, fexTools: FEX_TOOLS });
+ const t = runner(`${form}, unmapped, fallback ${fallback}`);
+ const r = walk(P({ details: details('', { strCompatToolName: '' }) }));
+ const offered = r.find(x => x.type === 'Dropdown').props.rgOptions.map(o => o.data);
+ t.ok(offered.includes('d3dmetal') === !first,
+ `D3DMetal is ${first ? 'not ' : ''}offered (${offered})`);
+ failed += t.failed;
+ }
+
+ const { render: L } = panel(emit, form, undefined, { fexTools: ['notproton-fex-41069'] });
+ const tp = runner(`${form}, FEX tool name prefix`);
+ const pr = walk(L({ details: details('', { strCompatToolName: 'notproton-fex' }) }));
+ tp.ok(pr.find(x => x.type === 'Dropdown').props.rgOptions.some(o => o.data === 'd3dmetal'),
+ 'a tool whose name prefixes a FEX tool keeps the Rosetta options');
+ failed += tp.failed;
+
+ const { render: Z } = panel(emit, form, { document: { documentElement: { lang: 'zh-CN' } } },
+ { fexTools: FEX_TOOLS });
+ const t = runner(`${form}, FEX, Chinese`);
+ const zh = walk(Z({ details: details('CX_GRAPHICS_BACKEND=d3dmetal %command%',
+ { strCompatToolName: 'notproton-fex' }) }));
+ const text = (zh.find(x => x.props.className === 'MSCXNote') || { props: {} }).props.children;
+ t.ok(/^D3DMetal 需要/.test(text || ''), `the note is translated (${text})`);
+ failed += t.failed;
+}
+console.log(failed ? `\n${failed} failure(s)` : '\nFEX hides what it cannot run, Rosetta keeps everything');
+process.exit(failed ? 1 : 0);
diff --git a/dylib/tests/panel-behavior/harness.js b/dylib/tests/panel-behavior/harness.js
index 77784b9..8515e9a 100644
--- a/dylib/tests/panel-behavior/harness.js
+++ b/dylib/tests/panel-behavior/harness.js
@@ -25,8 +25,10 @@ const FORMS = {
statement: { arg: 'statement', react: 'R0', barrel: 'B0' },
};
-function panel(emit, form, globals = { document: { documentElement: { lang: 'en' } } }) {
- const raw = execFileSync(emit, [form], { encoding: 'utf8' }).trim();
+// `fallback` and `fexTools` stand in for what the hook sets before the transform.
+function panel(emit, form, globals = { document: { documentElement: { lang: 'en' } } },
+ { fallback = 'notproton', fexTools = [] } = {}) {
+ const raw = execFileSync(emit, [form, fallback, ...fexTools], { encoding: 'utf8' }).trim();
const src = form === 'component'
? 'var ' + raw.replace(/,$/, '')
: expand(raw).replace(/;$/, '');