Skip to content
Open
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
4 changes: 4 additions & 0 deletions .github/workflows/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ jobs:
make -s compatsvc-check
make -s prefixstate-check
make -s defaults-check
make -s verdict-check
make -s game-check
make -s badge-check
make -s catalog-check
make -s compatpage-check
make -s defaults-drift
make -s shortcutcheck
Expand Down
48 changes: 46 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ SRCS := \
dylib/feats/defaults.c \
dylib/feats/compatpage.c \
dylib/feats/prefixstate.c \
dylib/feats/verdict.c \
dylib/feats/game.c \
dylib/feats/badge.c \
dylib/feats/catalog.c \
dylib/feats/usershortcuts.c \
dylib/feats/conf.c \
dylib/feats/webpatch.c \
Expand Down Expand Up @@ -78,7 +82,7 @@ DEPS := $(OBJS:.o=.d)
tests-list overlay-shim overlay-shim-install overlay-shim-tests \
overlay-shim-bench iconmaker icon \
appinfo helpers-install ntdll-resolve bridge runcheck compatcheck envpasscheck \
compatsvc-check prefixstate-check defaults-check compatpage-check defaults-drift shortcutcheck scriptcheck envcheck buildcheck settingscheck routecheck bridgecheck gamedrivecheck launchercheck bundlecheck launch-shell activatecheck FORCE
compatsvc-check prefixstate-check defaults-check verdict-check game-check badge-check catalog-check compatpage-check defaults-drift shortcutcheck scriptcheck envcheck buildcheck settingscheck routecheck bridgecheck gamedrivecheck launchercheck bundlecheck launch-shell activatecheck FORCE

APP_PAYLOAD := app/Sources/NotProtonApp/Resources/payload

Expand Down Expand Up @@ -194,7 +198,7 @@ PREFIXSTATE_CHECK := $(OUT_DIR)/prefixstate-check
prefixstate-check:
@if [ ! -f dylib/tests/prefixstate-check.c ]; then $(call SKIP,prefixstate-check,dylib/tests/prefixstate-check.c); exit 0; fi; \
mkdir -p $(OUT_DIR) && \
$(TEST_CC) -o $(PREFIXSTATE_CHECK) dylib/tests/prefixstate-check.c && \
$(TEST_CC) -o $(PREFIXSTATE_CHECK) dylib/tests/prefixstate-check.c dylib/feats/verdict.c && \
$(PREFIXSTATE_CHECK)

COMPATSVC_CHECK := $(OUT_DIR)/compatsvc-check
Expand All @@ -215,6 +219,45 @@ $(DEFAULTS_CHECK): dylib/tests/defaults-check.c dylib/feats/defaults.c dylib/fea
defaults-check: $(DEFAULTS_CHECK)
@$(DEFAULTS_CHECK)

CATALOG_CHECK := $(OUT_DIR)/catalog-check

$(CATALOG_CHECK): dylib/tests/catalog-check.c dylib/feats/catalog.c dylib/feats/catalog.h \
dylib/feats/badge.c dylib/feats/game.c dylib/feats/verdict.c dylib/util/file.c
@mkdir -p $(dir $@)
$(TEST_CC) -o $@ dylib/tests/catalog-check.c dylib/feats/badge.c dylib/feats/game.c \
dylib/feats/verdict.c dylib/util/file.c dylib/util/log.c

catalog-check: $(CATALOG_CHECK)
@$(CATALOG_CHECK)

GAME_CHECK := $(OUT_DIR)/game-check

$(GAME_CHECK): dylib/tests/game-check.c dylib/feats/game.c dylib/feats/game.h
@mkdir -p $(dir $@)
$(TEST_CC) -o $@ dylib/tests/game-check.c

BADGE_CHECK := $(OUT_DIR)/badge-check

$(BADGE_CHECK): dylib/tests/badge-check.c dylib/feats/badge.c dylib/feats/badge.h \
dylib/feats/game.c dylib/feats/verdict.c
@mkdir -p $(dir $@)
$(TEST_CC) -o $@ dylib/tests/badge-check.c dylib/feats/game.c dylib/feats/verdict.c

badge-check: $(BADGE_CHECK)
@$(BADGE_CHECK)

game-check: $(GAME_CHECK)
@$(GAME_CHECK)

VERDICT_CHECK := $(OUT_DIR)/verdict-check

$(VERDICT_CHECK): dylib/tests/verdict-check.c dylib/feats/verdict.c dylib/feats/verdict.h
@mkdir -p $(dir $@)
$(TEST_CC) -o $@ dylib/tests/verdict-check.c

verdict-check: $(VERDICT_CHECK)
@$(VERDICT_CHECK)

COMPATPAGE_CHECK := $(OUT_DIR)/compatpage-check

compatpage-check:
Expand Down Expand Up @@ -500,6 +543,7 @@ panel-behavior:
node $(PANEL_TESTS)/behavior.js $(OUT_DIR)/panel-emit && \
node $(PANEL_TESTS)/switching.js $(OUT_DIR)/panel-emit && \
node $(PANEL_TESTS)/launch-options.js $(OUT_DIR)/panel-emit && \
node $(PANEL_TESTS)/badge.js $(OUT_DIR)/panel-emit && \
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 && \
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ I would have done things differently had I been aware of that.

Thanks to everyone who has positively contributed to macOS gaming.

Mac compatibility:

Each installed game gets an Apple badge in the corner of its library tile and a MAC stat on its
page: green if it has run well on this Mac, yellow if a launcher is in the way or it has crashed
here, red if it carries an anti-cheat or has only ever crashed, and a dashed ring if it has not run
here yet. It is all worked out from this Mac. Turn it off under Steam → Preferences → Compatibility.
See ```docs/mac-compatibility.md```.

Developer Notes:

As far as the source structure goes, the macOS app itself is located in the ```app``` folder. The core logic is in ```dylib```.
Expand Down
67 changes: 67 additions & 0 deletions docs/mac-compatibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Mac compatibility badges

An Apple badge on each installed game, in the corner of its library tile where Steam
puts the Steam Deck badge, and a `MAC` stat on the game's page next to Play Time. Hover
either one for the reason.

Everything comes from this Mac. Nothing is fetched, nothing is applied to a game, and
no Steam Deck data is used.

## The badges

| Badge | Label | When |
|---|---|---|
| Green | Verified | It has run here at least twice, for 20 minutes or more, without crashing. Or it ships a native macOS build. |
| Yellow | Playable | It starts through a third-party launcher (EA app, Ubisoft Connect, Epic, Rockstar), or some of its sessions here crashed. |
| Red | Unsupported | Its folder carries an anti-cheat (Easy Anti-Cheat, BattlEye, Vanguard), or every session here crashed. |
| Dashed ring | Unknown | It has not run here yet. |

An anti-cheat outranks any history.

## Where it comes from

- **Sessions.** At the end of each launch, the run script already decides whether the
session was healthy, failed, or neither (`session_health`). It now also keeps a running
count beside the prefix in `notproton-sessions`.
- **The game's folder.** A walk of the install (5 levels, 20,000 entries at most) for
anti-cheat and launcher files and a macOS app bundle. File names only. The result is
kept in `notproton-scan` beside the prefix and redone when the game updates.

The Compatibility page's rebuild row also shows the verdict with its numbers: runs,
crashes, time played, the CrossOver build and backend of the last session.

## Turning it off

Steam → Preferences → Compatibility → **Show Mac compatibility badges**. It takes effect
at once. Or create an empty `no-mac-badges` in `~/Library/Application Support/notproton/`.

## Files

| File | Does |
|---|---|
| `dylib/feats/compat_run.sh` | `record_history` keeps the session counts. |
| `dylib/feats/verdict.c` | Session counts → a tier. |
| `dylib/feats/game.c` | Install folder → anti-cheat, launcher, native build. |
| `dylib/feats/badge.c` | Game + history → badge and reason. |
| `dylib/feats/catalog.c` | One pass over the installed games, on a thread. Writes `badges` in the support folder and hands the map to the library. |
| `dylib/feats/webpatch.c` | Tile badge, game page stat, Preferences switch. |
| `dylib/feats/prefixstate.c` | Adds the verdict to the Compatibility page's state. |

## Notes for changing the UI

- Steam runs its JavaScript in a hidden `SharedJSContext` and draws into a separate
window, so a `<style>` added by injected code never reaches the page. Everything is
styled inline.
- The tile's own icon row only shows while it is hovered, so the badge is a sibling of
that row, placed by its own style. On the wide featured tile it moves to the top
corner, off the Play button.
- The tile anchors are checked together before any is written. If Steam moves one, the
badges switch off with a warning in `notproton.log` and nothing else is affected. The
game page stat has its own anchor for the same reason.
- Written against Steam client build 1794536281.

## Checks

`make verdict-check game-check badge-check catalog-check`, plus `panel-behavior`,
`prefixstate-check` and `buildcheck`, which cover the injected code, the page state and
the session record.
49 changes: 49 additions & 0 deletions dylib/feats/badge.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "badge.h"

#include <stdio.h>

np_badge_t np_badge_for(const np_game_t *game, const np_verdict_t *history,
char *reason, size_t size) {
const int scanned = game && game->scanned;
// Most serious first: an anti-cheat outranks any history.
if (scanned && game->anticheat != NP_AC_NONE) {
snprintf(reason, size, "This game uses %s, which does not run under CrossOver on macOS.",
np_game_anticheat_name(game->anticheat));
return NP_BADGE_BLOCKED;
}
if (history && history->tier == NP_VERDICT_BROKEN) {
snprintf(reason, size, "This game has crashed every time it was started on this Mac (%d of %d).",
history->failed, history->failed);
return NP_BADGE_BLOCKED;
}
if (scanned && game->launcher != NP_LAUNCHER_NONE) {
snprintf(reason, size, "This game starts through %s, which may need setting up inside the "
"prefix before the game itself will run.",
np_game_launcher_name(game->launcher));
return NP_BADGE_ISSUES;
}
if (history && history->tier == NP_VERDICT_PLAYABLE && history->failed) {
snprintf(reason, size, "This game runs on this Mac, but %d of its %d sessions here crashed.",
history->failed, history->failed + history->healthy);
return NP_BADGE_ISSUES;
}
if (history && history->tier == NP_VERDICT_VERIFIED) {
snprintf(reason, size, "This game has run on this Mac %d times without crashing.", history->healthy);
return NP_BADGE_GOOD;
}
if (scanned && game->native) {
snprintf(reason, size, "This game has a native macOS version, which Steam runs without CrossOver.");
return NP_BADGE_GOOD;
}
snprintf(reason, size, "This game has not run on this Mac yet.");
return NP_BADGE_UNKNOWN;
}

const char *np_badge_name(np_badge_t badge) {
switch (badge) {
case NP_BADGE_GOOD: return "good";
case NP_BADGE_ISSUES: return "issues";
case NP_BADGE_BLOCKED: return "blocked";
default: return "unknown";
}
}
25 changes: 25 additions & 0 deletions dylib/feats/badge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// The Mac badge a game wears in the library.
#ifndef NOTPROTON_FEATS_BADGE_H
#define NOTPROTON_FEATS_BADGE_H

#include "game.h"
#include "verdict.h"

#include <stddef.h>

// Green is only ever what this Mac has seen. Red is a game that cannot work here.
typedef enum {
NP_BADGE_UNKNOWN = 0,
NP_BADGE_GOOD,
NP_BADGE_ISSUES,
NP_BADGE_BLOCKED,
} np_badge_t;

// game and history may be NULL. Writes one sentence for the tooltip into reason.
np_badge_t np_badge_for(const np_game_t *game, const np_verdict_t *history,
char *reason, size_t size);

// "good", "issues", "blocked" or "unknown".
const char *np_badge_name(np_badge_t badge);

#endif // NOTPROTON_FEATS_BADGE_H
Loading