mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-11 09:51:02 +00:00
Code cheats need the game lifted and compiled with them. Running the setup again did that, but it lifted and compiled everything and prepared the shaders again. - The setup keeps the generated C and the objects in its temp folder (about 1.3 GB). gen.py rewrites only the chunks whose C changed, so Ninja recompiles only those. One new code cheat on 1.4.3 took a 47 s lift and 19 s of compile and link on 24 cores. - Prepare's key no longer follows the compile key, only the runtime, the translator and the game version, so a rebuild keeps the prepared shaders. - The cleanup writes build-cache/rebuild.txt, the command that opens the setup window in a new --rebuild mode on the install folder. That mode runs at once and starts the game again when it succeeds. - At start, runtime/cheats.c runs that command and exits when an enabled mod has code cheats the build lacks (plat_spawn, new for Windows and Linux). build-cache/rebuild.skip keeps a failed or cancelled rebuild from starting again for the same cheats. "Rebuild the game now" on the Cheats tab tries again, and [mods] mods_rebuild = off turns the rebuild off. Scripted runs never start it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.9 KiB
C++
67 lines
2.9 KiB
C++
// 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. While code cheats wait for a rebuild, a row on top restarts the game
|
|
// into it.
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "imgui.h"
|
|
#include "ui/option_rows.h"
|
|
|
|
extern "C" {
|
|
#include "cheats.h"
|
|
#include "ui_text.h"
|
|
}
|
|
|
|
// Returns true when "Rebuild the game now" was chosen: the menu then asks to restart (ui/menu.cpp restart_confirm).
|
|
extern "C" bool tab_cheats(float scale) {
|
|
opt_begin("##cheats", 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() : "<build id>.txt");
|
|
opt_text_str(line);
|
|
opt_end();
|
|
return false;
|
|
}
|
|
bool rebuild =
|
|
cheats_rebuild_pending() && opt_button("##restart", UI_MENU_CHEATS_REBUILD, UI_MENU_CHEATS_REBUILD_DESC);
|
|
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_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;
|
|
case CHEAT_DATA: text = UI_MENU_CHEAT_DATA_DESC; break;
|
|
case CHEAT_MASTER: text = UI_MENU_CHEAT_MASTER_DESC, opt_disable_next(UI_MENU_CHEAT_MASTER); break;
|
|
case CHEAT_RESTORE: text = UI_MENU_CHEAT_RESTORE_DESC, opt_disable_next(UI_MENU_CHEAT_RESTORE); break;
|
|
case CHEAT_REBUILD: text = UI_MENU_CHEAT_REBUILD_DESC, opt_disable_next(UI_MENU_CHEAT_REBUILD); break;
|
|
case CHEAT_UNSUPPORTED:
|
|
text = UI_MENU_CHEAT_UNSUPPORTED_DESC, opt_disable_next(UI_MENU_CHEAT_UNSUPPORTED);
|
|
break;
|
|
}
|
|
if (c->kind == CHEAT_KEY)
|
|
snprintf(desc, sizeof desc, menu_text(text), cheats_buttons(c->buttons, buttons, sizeof buttons));
|
|
else if (c->kind == CHEAT_UNSUPPORTED)
|
|
snprintf(desc, sizeof desc, "%s %s", menu_text(text), c->note);
|
|
else
|
|
snprintf(desc, sizeof desc, "%s", menu_text(text));
|
|
if (opt_toggle_text(c->key, c->name, desc, cheats_on(i) != 0)) {
|
|
cheats_set(i, !cheats_on(i));
|
|
opt_save_soon();
|
|
}
|
|
}
|
|
opt_end();
|
|
return rebuild;
|
|
}
|