Read cheat files from the mods folder instead of shipping them

A cheat file is now part of a mod: mods/<mod>/cheats/<build id>.txt, or the
Atmosphere places inside the mod folder, the file name in any case. The port
ships no cheat files any more (the MyNXCheats files and their notice row are
gone).

- tools/cheats.py --mods builds the code cheats of every mod folder; a
  cheat's key hashes "<mod folder>/<name>", so two mods' cheats of one name
  keep their own switches.
- The setup reads the cheats from <install>/mods and writes the status to
  build-cache/cheats.status.
- runtime/cheats.c reads the files of the enabled mods the port can use, in
  the Mods tab order, and the status from build-cache.
- A mod with only cheats is usable. The Cheats tab groups the cheats by mod,
  and the Mods tab says how many cheats a mod brought.
- The cheat texts are in all four menu languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-01 14:05:31 +03:00
1 parent 5e584ea966
commit ac69f39529
23 files changed
+296 -1093

No files matched your search

+12 -9
View File
@@ -1,5 +1,6 @@
// The Cheats tab of the in-game menu: the cheats of cheats\<build id>.txt (cheats.c), a row per cheat in file order and
// a heading per group label; a cheat that cannot be switched here is greyed out with the reason.
// The Cheats tab of the in-game menu: the cheats of the mods' cheat files (cheats.c), a heading per mod in the Mods
// tab's order, then a row per cheat in file order and a line per group label of the file; a cheat that cannot be
// switched here is greyed out with the reason.
#include <stdio.h>
#include <string.h>
@@ -16,22 +17,24 @@ extern "C" void tab_cheats(float scale) {
static char line[512], desc[768], buttons[192];
int n = cheats_count();
if (!n) {
snprintf(line, sizeof line, menu_text(UI_MENU_CHEATS_NONE),
cheats_file()[0] ? cheats_file() : "cheats\\<build id>.txt");
snprintf(line, sizeof line, menu_text(UI_MENU_CHEATS_NONE), cheats_file()[0] ? cheats_file() : "<build id>.txt");
opt_text_str(line);
opt_end();
return;
}
int listed = 0;
for (int i = 0; i < n; i++) listed += cheats_info(i)->kind != CHEAT_HEADING;
snprintf(line, sizeof line, menu_text(UI_MENU_CHEATS_FILE), cheats_file(), listed);
opt_text_str(line);
for (int i = 0; i < n; i++) {
const CheatInfo *c = cheats_info(i);
if (!i || strcmp(c->mod, cheats_info(i - 1)->mod)) {
int listed = 0;
for (int j = i; j < n && !strcmp(cheats_info(j)->mod, c->mod); j++)
listed += cheats_info(j)->kind != CHEAT_HEADING;
snprintf(line, sizeof line, menu_text(UI_MENU_CHEATS_MOD), c->mod, listed);
opt_group_text(line);
}
UiTextId text = UI_MENU_CHEAT_CODE_DESC;
switch (c->kind) {
case CHEAT_HEADING:
if (!strstr(c->name, "TID=")) opt_group_text(c->name); // the file's title line only names the game
if (!strstr(c->name, "TID=")) opt_text_str(c->name); // the file's title line only names the game
continue;
case CHEAT_CODE: break;
case CHEAT_KEY: text = UI_MENU_CHEAT_KEY_DESC; break;
+11 -3
View File
@@ -36,6 +36,7 @@ static int g_font_bad;
extern "C" {
#include "amiibo.h"
#include "cheats.h"
#include "cfg.h"
#include "fs.h"
#include "input.h"
@@ -1048,16 +1049,23 @@ static void tab_mods(float scale) {
char over[512] = "", other[512] = "";
if (m->overridden) snprintf(over, sizeof over, menu_text(UI_MENU_MODS_OVERRIDDEN), m->overridden, m->overridden_by);
if (m->other_version) snprintf(other, sizeof other, menu_text(UI_MENU_MODS_OTHER_VERSION), m->other_version);
char cheat[256] = "";
if (m->kind & MOD_CHEATS) { // its cheats as read at start, or the file they come from
int count = 0;
for (int j = 0; j < cheats_count(); j++)
count += !strcmp(cheats_info(j)->mod, m->name) && cheats_info(j)->kind != CHEAT_HEADING;
if (count) snprintf(cheat, sizeof cheat, menu_text(UI_MENU_MODS_CHEATS), count);
else snprintf(cheat, sizeof cheat, menu_text(UI_MENU_MODS_CHEATS_FILE), cheats_file());
}
UiTextId problem = m->problem == MOD_EMPTY ? UI_MENU_MODS_EMPTY
: m->problem == MOD_PLUGIN ? UI_MENU_MODS_SUBSDK
: m->problem == MOD_EXEFS_LATER ? UI_MENU_MODS_EXEFS_LATER
: m->problem == MOD_CHEATS_LATER ? UI_MENU_MODS_CHEATS_LATER
: m->problem == MOD_BAD_NAME ? UI_MENU_MODS_BAD_NAME
: UI_TEXT_COUNT;
int k = snprintf(desc, sizeof desc, menu_text(UI_MENU_MODS_ROW_DESC), m->replaced, m->added);
if (k >= 0 && k < (int)sizeof desc)
snprintf(desc + k, sizeof desc - k, "%s%s%s%s%s%s\n\n%s", over[0] ? "\n\n" : "", over,
other[0] ? "\n\n" : "", other, problem != UI_TEXT_COUNT ? "\n\n" : "",
snprintf(desc + k, sizeof desc - k, "%s%s%s%s%s%s%s%s\n\n%s", over[0] ? "\n\n" : "", over,
other[0] ? "\n\n" : "", other, cheat[0] ? "\n\n" : "", cheat, problem != UI_TEXT_COUNT ? "\n\n" : "",
problem != UI_TEXT_COUNT ? menu_text(problem) : "", menu_text(UI_MENU_MODS_MOVE_HINT));
const char *note = m->enabled && m->problem != MOD_OK ? menu_text(UI_MENU_MODS_UNUSED) : after;
int s = opt_text_row(id, m->name, menu_text(m->enabled ? UI_MENU_ON : UI_MENU_OFF), note, desc, true);