mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-19 12:25:56 +00:00
Merge pull request #1188: opt-in quick save and quick load on rebindable keys with no menu on the screen, game 1.4.3 (itaskaev2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
6b0974f08d
20 files changed
+868
-20
No files matched your search
@@ -85,6 +85,7 @@ At a game resolution of another shape than 16:9 the game loads `romfs-patches-xb
|
||||
| F1 or Esc | Minus and Plus together | open or close the settings menu; the game gets no input while it is open |
|
||||
| F10 | L3 + R3 (both stick clicks) | performance overlay: off, frame rate, full panel |
|
||||
| F11 | | borderless fullscreen on or off, saved to `totk.ini` |
|
||||
| F6, F7 | | with `quicksave = 1`: quick save and quick load, as in Half-Life, with no menu; `quicksave_key` and `quickload_key` choose other keys ([Quick save](#quick-save)) |
|
||||
|
||||
The Minus+Plus combo never reaches the game. In the menu the arrow keys, the D-pad or the left stick move, Enter or A selects, Q and E or L and R switch tabs, Esc or B goes back (Switch button names, as in the table above).
|
||||
|
||||
@@ -213,6 +214,20 @@ With `map_click = 1` (off by default, so each key presses one controller button
|
||||
|
||||
With `dialogue_click = 1` (off by default, so each key presses one controller button as everywhere else), on game 1.4.3, while a dialogue box is open (the layout `MessageDialog_00`: a character's lines and the game's own messages), the left mouse button presses B and the right one A, instead of the buttons they are bound to. B continues the text as A does and also shows the rest of a line that is still scrolling in; the left button's default, Y, would open the dialogue log there, and the log stays in the way until B closes it. Dialogue choices are a menu with the focus box, so the pointer above takes their clicks and a left click is A on the choice under it: clicking through a conversation fast does not pick the choice the focus starts on. A press is the dialogue's button or the binding from the moment the button goes down until it is released: the click that closes the last box does not become an attack while it is still held, and a button held when the box opens does not skip its first line. Between two lines of a conversation the game closes the box and opens it again, so both buttons stay B and A for 500 ms after the box was last open (`DIALOGUE_GAP_MS`); the first clicks after a conversation fall in that time too, as they do for a player who taps the button through the last line. `TOTK_MENU_CURSOR_LOG=1` logs how long each such gap was. The dialogue window has no focus box of its own: the scan of `eui::ScreenMgr`'s open screens (every 100 ms) finds its screen, and from then on that screen's state is read at every pad read (`dialogue_shown` in `runtime/menu_cursor.c`), so the first click after a box opens is already the dialogue's. `dialogue_click = 1` (`TOTK_DIALOGUE_CLICK=1`, live; the *Clicks in dialogue* row of the Controls tab) turns it on and `0`, the default, leaves both buttons on their bindings; the setting does not depend on `menu_cursor`. The log names the first box it sees (`menu_cursor: a dialogue box is open ...`).
|
||||
|
||||
## Quick save
|
||||
|
||||
With `quicksave = 1` (off by default; the *Quick save and load* row of the Controls tab, live), on game 1.4.3, one key saves the game at once and another loads that save: F6 and F7 by default, the keys Half-Life has for them. No menu shows on the screen (`runtime/quicksave.c`). It is for the keyboard and the mouse only (a gamepad has no quick save button yet) and for game 1.4.3 only (the addresses below are 1.4.3's; on 1.2.1 the setting does nothing).
|
||||
|
||||
Quick save asks the game for one of its own autosaves, the way its event graphs do: it calls the AutoSaveMgr's request with the kind the sequence node `OneShotAutoSaveMgrRequestAutoSave` uses, after the game's own check whether it would autosave now. That check also holds autosaves back for some ten minutes after the game's last one; quick save, being the player's own, skips that wait (it sets the AutoSaveMgr's timer to 0, and puts it back when the game says no for another reason), as Save in the System tab does. The game then saves as it does after a shrine or a story event, its autosave icon included, into one of its autosave slots: the oldest autosave is replaced, as by any autosave of the game. The commit of that save names the slot folder it wrote (`fs_save_commits` in `runtime/fs_host.c`), and quick save keeps a copy of it: `<profile>/quicksave/slot`, with the slot's name in `<profile>/quicksave/slot.txt`. *Game saved* shows at the top of the picture for a few seconds (`menu_toast`, `runtime/ui/menu.cpp`). The game can take the request and still hold the autosave back (seen once in a fight in the Depths); when no save commit comes within 5 s, quick save takes its request back, so the game does not save some time later on its own, and says it is not possible right now. The game's manual save is not touched.
|
||||
|
||||
Quick load has no request in play to start from: the game starts a load only from its own load list (System tab) or its Game Over screen, and loads the slot that screen names. So quick load goes through the load list as a player with a controller would, but out of sight. *Loading the quick save* shows at the top of the picture, and from the next frames on the window keeps that picture (`gfx_present_hold` in `runtime/gfx_present.c`, as while the window is minimized) while quick load presses Plus, R until the System tab shows, Load, A on the list's first save and Load on the confirmation. From that confirmation on, every read the game makes of a file in a slot folder (`save:/slot_NN/<file>`) opens the quick save's file instead (`fs_save_read_from` in `runtime/fs_host.c`; the log names each one, `fs: quick load: ... read from ...`), so the game loads the quick save whichever slot the list offered first, and no slot of the save is written for it. The redirect ends with the load: once the game has read the quick save's files, its loading fade has closed and the HUD has been back for half a second (`quickload: slot reads go to the save again`); at once when a menu with the focus box opens, so a Load right after it lists and loads the slots as they are. The picture comes back with the game's loading fade, about 5 s after the key. When a step finds a screen it does not expect, or none within its time, the log names the step, B is pressed until no menu has the focus box, the picture comes back and the line says *Quick load failed*. The quick save stays in the profile, so F7 loads the same state again until F6 makes a new one.
|
||||
|
||||
Both start only in play: a save loaded, the HUD (`PlayerStatus_00`) open, no menu with the focus box, no dialogue box and no loading fade. Anywhere else, and wherever the game itself would not autosave (a cutscene, an event, a fight), nothing happens but a line at the top of the picture (*Quick save is not possible right now*), and the log says why (`quicksave: not now: ...`). Without a quick save F7 says so. Quick save's calls into the game run on the game thread in its pad read, between two of its own calls; while quick load runs the game gets only its presses, not the player's input. While the setting is on its two keys reach no binding; with it off nothing changes and nothing is logged.
|
||||
|
||||
The keys are `quicksave_key` and `quickload_key` (`TOTK_QUICKSAVE_KEY`, `TOTK_QUICKLOAD_KEY`, live). The *Quick save key* and *Quick load key* rows under the switch take any key or mouse button the way a binding's cell does: select the cell, press the key (Esc cancels); Delete, Backspace or X leaves that one without a key (`none`). In `totk.ini` the value is a key name of the [Remapping](#remapping) list, in any case, or `none`. A name the list does not have is logged (`quicksave: quickload_key: unknown key '...', f7 is used`) and the default is used; the same key for both saves and leaves loading without a key. With the setting on the log names the keys in use (`quicksave: f6 saves, f7 loads`). A key a binding also uses presses only quick save or quick load while the setting is on: the row says which button it took (*also A*).
|
||||
|
||||
`QUICKSAVE` and `QUICKLOAD` lines in an input script ([Scripted input](#scripted-input)) start it as the keys do.
|
||||
|
||||
## Gameplay tweaks
|
||||
|
||||
With `gameplay_tweaks_enabled = 1` (`TOTK_GAMEPLAY_TWEAKS_ENABLED=1`, live; off by default in `totk.ini`), the mouse wheel and keyboard can drive common gameplay interactions directly:
|
||||
@@ -244,6 +259,8 @@ Bridges that output a ViGEm DualShock 4 (ProCon2Windows, connectyourpro as teste
|
||||
@<ms> MOUSE <dx> <dy>
|
||||
<frame> WHEEL <notches> # scroll wheel notches, once; + away from the player
|
||||
@<ms> WHEEL <notches>
|
||||
<frame> QUICKSAVE|QUICKLOAD # quicksave = 1's save or load key, once
|
||||
@<ms> QUICKSAVE|QUICKLOAD
|
||||
```
|
||||
|
||||
`<frame>` counts 60 Hz ticks of game time since the first frame (presented frames at 60 fps), so the title menus get the presses at the same game time at any frame limit. `@<ms>` counts milliseconds of the world clock: game time stepped since the end of the first save load (the player leaves the title screen's origin), so a timed event lands at the same game time at any frame rate and load length. A later load, such as fast travel, still shifts what follows. In a script with timed lines the untimed ones stop when the world clock starts, as the load ends at another tick in each run. Each event logs once (`input: script frame N tick T: A`). `tools/input/load_save.txt` loads the first save from the title screen.
|
||||
|
||||
@@ -95,6 +95,9 @@ Many rows below are developer tools that only act together with another setting
|
||||
| Setting | What it does | Effect of changing it | Safety |
|
||||
| --- | --- | --- | --- |
|
||||
| `bind_<button>` | Remaps one Switch button or stick direction to `pad:<name>` or `key:<name>` entries; covers `bind_a`, `bind_b`, `bind_x`, `bind_y`, `bind_l`, `bind_r`, `bind_zl`, `bind_zr`, `bind_plus`, `bind_minus`, `bind_left`, `bind_up`, `bind_right`, `bind_down`, `bind_lclick`, `bind_rclick`, `bind_lstick_left`, `bind_lstick_up`, `bind_lstick_right`, `bind_lstick_down`, `bind_rstick_left`, `bind_rstick_up`, `bind_rstick_right`, `bind_rstick_down` and `bind_shake`. | A line replaces every default of that button; button prompts in the game still show the default layout. The Controls tab of the menu writes these lines; `docs/controls.md` lists the entry names. | Safe |
|
||||
| `quicksave` (default `0`) | `1`: `quicksave_key` makes one of the game's autosaves at once and keeps a copy as the quick save (`<profile>/quicksave`), `quickload_key` loads that copy (`runtime/quicksave.c`, game 1.4.3, keyboard and mouse keys only; `docs/controls.md`, "Quick save"). | No menu shows; a line at the top of the picture says *Game saved* or why nothing was saved. Quick save takes one of the game's autosave slots and so replaces the oldest autosave, as the game's own autosaves do (the manual save stays); quick load (about 5 s, the picture held while it runs the game's load list underneath) reloads the quick save, losing the progress since. | Save risk |
|
||||
| `quicksave_key` (default `f6`) | The key of quick save with `quicksave = 1`: a key name of the remapping list (`docs/controls.md`, "Remapping") or `none`; an unknown name is logged and `f6` is used. | While `quicksave = 1` the key reaches no binding. | Safe |
|
||||
| `quickload_key` (default `f7`) | The key of quick load with `quicksave = 1`, as `quicksave_key`; an unknown name is logged and `f7` is used, the same key as `quicksave_key` leaves loading without a key. | While `quicksave = 1` the key reaches no binding; it reloads the quick save, losing the progress since. | Safe |
|
||||
|
||||
## Paths and files
|
||||
|
||||
|
||||
+4
-2
@@ -58,7 +58,7 @@ static const char *const known[] = {
|
||||
"MV_SURVEY",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OPTREF_GUARD", "OUTPUT_RES", "PAD_LAYOUT", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_SCENE", "PCORE", "PCSS", "PCSS_K", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "PLUGIN_TICK_OFFSET", "PLUGIN_TRACE", "POINTER_IMAGE",
|
||||
"PREWARM_XLATE", "PROBE_MOVIE", "PROBE_MOVIE_BENCH", "PROBE_MOVIE_SHOT", "PROFILE", "PROFILE_CHAINS", "PROFILE_DIR", "PROFILE_FRAMES",
|
||||
"PROFILE_MAIN", "PROFILE_RENDER", "PROMPTS", "PUSH_SKIP", "PUSH_STAGE", "RDOC", "RDOC_DIR", "RDOC_DLL", "REALTIME", "REC_ASYNC", "REC_END", "REC_SPIN_US", "REEXEC", "REFLEX",
|
||||
"PROFILE_MAIN", "PROFILE_RENDER", "PROMPTS", "PUSH_SKIP", "PUSH_STAGE", "QUICKLOAD_KEY", "QUICKSAVE", "QUICKSAVE_KEY", "RDOC", "RDOC_DIR", "RDOC_DLL", "REALTIME", "REC_ASYNC", "REC_END", "REC_SPIN_US", "REEXEC", "REFLEX",
|
||||
"RENDER_SCALE", "REPLAY_ASYNC", "REPLAY_CHUNKS", "REPLAY_CHUNK_DRAWS", "REPLAY_SKEW_US", "REPLAY_STATE_CHECK", "REPLAY_WORKERS",
|
||||
"REPLAY_CHECK", "REPORT_GUARD", "RESOLVE_CHECK", "RESTART_WAIT", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES",
|
||||
"ROMFS_PROOF_DIR", "ROMFS_VERIFY", "RSTICK_DEADZONE", "RUMBLE", "RUMBLE_CURVE", "RUMBLE_STRENGTH", "RUMBLE_TRIGGERS", "SHADER_CACHE",
|
||||
@@ -98,7 +98,7 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"GYRO_BIAS_X", "input"}, {"GYRO_BIAS_Y", "input"}, {"GYRO_BIAS_Z", "input"}, {"GYRO_BIAS_PAD", "input"},
|
||||
{"PAD_LAYOUT", "input"}, {"PROMPTS", "input"}, {"STICK_DEADZONE", "input"}, {"LSTICK_DEADZONE", "input"}, {"RSTICK_DEADZONE", "input"},
|
||||
{"STICK_SENS", "input"},
|
||||
{"MENU_CURSOR", "input"}, {"MAP_CLICK", "input"}, {"DIALOGUE_CLICK", "input"}, {"POINTER_IMAGE", "input"}, {"MOUSE_MODE", "input"}, {"MOUSE_SENS", "input"}, {"MOUSE_AIM_SCALE", "input"}, {"WALK_KEY", "input"}, {"WALK_SCALE", "input"}, {"INPUT_RECORD", "input"},
|
||||
{"MENU_CURSOR", "input"}, {"MAP_CLICK", "input"}, {"DIALOGUE_CLICK", "input"}, {"POINTER_IMAGE", "input"}, {"QUICKSAVE", "input"}, {"QUICKSAVE_KEY", "input"}, {"QUICKLOAD_KEY", "input"}, {"MOUSE_MODE", "input"}, {"MOUSE_SENS", "input"}, {"MOUSE_AIM_SCALE", "input"}, {"WALK_KEY", "input"}, {"WALK_SCALE", "input"}, {"INPUT_RECORD", "input"},
|
||||
{"BIND_A", "input"}, {"BIND_B", "input"}, {"BIND_X", "input"}, {"BIND_Y", "input"}, {"BIND_LCLICK", "input"},
|
||||
{"BIND_RCLICK", "input"}, {"BIND_L", "input"}, {"BIND_R", "input"}, {"BIND_ZL", "input"}, {"BIND_ZR", "input"},
|
||||
{"BIND_PLUS", "input"}, {"BIND_MINUS", "input"}, {"BIND_LEFT", "input"}, {"BIND_UP", "input"},
|
||||
@@ -185,6 +185,8 @@ static const CfgMeta metas[] = {
|
||||
{"MAP_CLICK", "0", "0|1", LIVE}, // input.c: the left mouse button is A on the Purah Pad's map
|
||||
{"DIALOGUE_CLICK", "0", "0|1", LIVE}, // menu_cursor.c: in a dialogue box left click is B, right click A
|
||||
{"POINTER_IMAGE", "0", "0|1", LIVE}, // input_win.c / input_sdl.c: the game window's own pointer (cursor_art.c)
|
||||
{"QUICKSAVE", "0", "0|1", LIVE}, // quicksave.c: one key saves (an autosave), another loads it
|
||||
{"QUICKSAVE_KEY", "f6", NULL, LIVE}, {"QUICKLOAD_KEY", "f7", NULL, LIVE}, // Half-Life's keys; a key name or none
|
||||
{"WALK_KEY", "none", NULL, LIVE}, {"WALK_SCALE", "0.51", "0.2..0.9", LIVE},
|
||||
// Gameplay Tweaks
|
||||
{"GAMEPLAY_TWEAKS_ENABLED", "0", "0|1", LIVE},
|
||||
|
||||
@@ -66,3 +66,9 @@ int fs_save_busy(void); // a save is being wr
|
||||
// or save data changed in the last 3 s and not committed
|
||||
void fs_save_flush(void); // wait for a save Commit still running in the background;
|
||||
// every exit path calls it before the process ends
|
||||
uint32_t fs_save_commits(char *slot, size_t cap); // commits that changed save files; slot: the save folder
|
||||
// (slot_00 ...) the last one wrote first
|
||||
int fs_save_copy_slot(const char *slot, const char *dst); // a folder of the newest save copied to dst (replaced)
|
||||
void fs_save_read_from(const char *dir); // quick load: reads of save:/slot_NN/<file> open dir/<file>
|
||||
// while dir is set; NULL ends it
|
||||
int fs_save_read_from_hits(void); // opens redirected since the last fs_save_read_from(dir)
|
||||
+73
-1
@@ -281,6 +281,18 @@ static int same_file(const char *a, const char *b) {
|
||||
return same;
|
||||
}
|
||||
|
||||
// The folder of the save (slot_00 ...) whose file the running commit wrote first, for quick save (fs_save_commits):
|
||||
// note_changed takes the first path component under new_root of each file copy_tree copies instead of linking.
|
||||
static char changed_slot[64], last_slot[64];
|
||||
static uint32_t commits; // commits that changed a file, under tx_lock
|
||||
static void note_changed(const char *dst) {
|
||||
size_t n = strlen(new_root);
|
||||
if (changed_slot[0] || !n || strncmp(dst, new_root, n) || dst[n] != '/') return;
|
||||
const char *rel = dst + n + 1, *sl = strchr(rel, '/');
|
||||
size_t len = sl ? (size_t)(sl - rel) : sizeof changed_slot;
|
||||
if (len < sizeof changed_slot) memcpy(changed_slot, rel, len), changed_slot[len] = 0;
|
||||
}
|
||||
|
||||
// Copy the tree src to dst, which must not exist; links are skipped. durable: every file is flushed, and every
|
||||
// directory as far as the file system allows. base (or NULL): the committed save; a file whose bytes equal base's file
|
||||
// at the same path becomes a hard link to it instead of a copy (*nlinked), as committed files are never written in
|
||||
@@ -300,7 +312,7 @@ static int copy_tree(const char *src, const char *dst, const char *base, int dur
|
||||
if (l.e[i].kind == PLAT_FS_DIR) bad = copy_tree(s, d, b, durable, nfiles, nlinked, bytes);
|
||||
else {
|
||||
if (b && same_file(s, b) && !plat_fs_link(b, d)) bad = 0, ++*nlinked;
|
||||
else bad = copy_file(s, d, durable, bytes);
|
||||
else bad = copy_file(s, d, durable, bytes), note_changed(d);
|
||||
*nfiles += !bad;
|
||||
if (!bad && durable && crashed()) bad = -1;
|
||||
}
|
||||
@@ -509,6 +521,7 @@ static uint32_t save_commit_locked(void) {
|
||||
int nfiles = 0, linked = 0;
|
||||
tx_step = tx_dead = 0;
|
||||
const char *base = exists(newest_save()) ? newest_save() : NULL;
|
||||
changed_slot[0] = 0;
|
||||
if (remove_tree(new_root) || copy_tree(work_root, new_root, base, 1, &nfiles, &linked, &bytes)) {
|
||||
if (tx_dead) return FS_R_INVALID_ARGUMENT;
|
||||
rt_log("fs: save commit: copying the working copy failed; the newest save is unchanged");
|
||||
@@ -535,6 +548,8 @@ static uint32_t save_commit_locked(void) {
|
||||
ready_seq++;
|
||||
if (*ready_root) remove_tree(ready_root); // superseded: the working copy it was made from held all of it
|
||||
snprintf(ready_root, sizeof ready_root, "%s", ready);
|
||||
commits++;
|
||||
memcpy(last_slot, changed_slot, sizeof last_slot);
|
||||
plat_xchg32(&save_dirty, 0);
|
||||
if (crashed()) return FS_R_INVALID_ARGUMENT;
|
||||
int waits = swap_in();
|
||||
@@ -558,6 +573,34 @@ static void save_wait_commit(void) {
|
||||
|
||||
void fs_save_flush(void) { save_wait_commit(); }
|
||||
|
||||
// ---- quick save (quicksave.c): the save folder the last commit wrote, copied out of the newest save
|
||||
uint32_t fs_save_commits(char *slot, size_t cap) {
|
||||
plat_mutex_lock(&tx_lock);
|
||||
uint32_t n = commits;
|
||||
snprintf(slot, cap, "%s", last_slot);
|
||||
plat_mutex_unlock(&tx_lock);
|
||||
return n;
|
||||
}
|
||||
|
||||
// The folder slot of the newest save to dst (replaced). 0 on success.
|
||||
static int slot_name_ok(const char *slot) {
|
||||
return slot[0] && slot[0] != '.' && !strchr(slot, '/') && !strchr(slot, '\\') && !strchr(slot, ':');
|
||||
}
|
||||
|
||||
int fs_save_copy_slot(const char *slot, const char *dst) {
|
||||
if (!*save_root || !slot_name_ok(slot)) return -1;
|
||||
save_wait_commit();
|
||||
plat_mutex_lock(&tx_lock);
|
||||
char *src = join(newest_save(), slot);
|
||||
int n = 0, linked = 0;
|
||||
uint64_t bytes = 0;
|
||||
int bad = plat_fs_kind(src) != PLAT_FS_DIR || remove_tree(dst) || copy_tree(src, dst, NULL, 1, &n, &linked, &bytes);
|
||||
plat_mutex_unlock(&tx_lock);
|
||||
free(src);
|
||||
return bad ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t commit_run(void) {
|
||||
plat_mutex_lock(&tx_lock);
|
||||
uint32_t r = save_commit_locked();
|
||||
@@ -877,6 +920,33 @@ static int64_t host_read_at(PlatFile *f, void *buf, uint32_t n, uint64_t off) {
|
||||
return got < 0 ? -1 : got;
|
||||
}
|
||||
|
||||
// Quick load (quicksave.c, fs_save_read_from): while set, a read-only open of a file of any slot folder of the save
|
||||
// mount (save:/slot_NN/<file>) opens <file> of this folder instead, so the game loads the quick save whichever slot it
|
||||
// was asked to load, and no slot of the save is written for it.
|
||||
static char read_from[PATH_CAP];
|
||||
static volatile int32_t read_from_on, read_from_hits;
|
||||
|
||||
void fs_save_read_from(const char *dir) {
|
||||
if (dir) snprintf(read_from, sizeof read_from, "%s", dir), plat_xchg32(&read_from_hits, 0);
|
||||
plat_xchg32(&read_from_on, dir != NULL);
|
||||
}
|
||||
|
||||
int fs_save_read_from_hits(void) { return plat_cas32(&read_from_hits, 0, 0); }
|
||||
|
||||
static void redirect_slot_read(const char *path, char *p, size_t cap) {
|
||||
const char *rest = strstr(path, ":/slot_");
|
||||
if (!rest) return;
|
||||
const char *d = rest + 7, *file;
|
||||
while (*d >= '0' && *d <= '9') d++;
|
||||
if (d == rest + 7 || *d != '/' || !d[1] || strchr(d + 1, '/')) return;
|
||||
file = d + 1;
|
||||
char q[PATH_CAP];
|
||||
if (snprintf(q, sizeof q, "%s/%s", read_from, file) >= (int)sizeof q || plat_fs_kind(q) != PLAT_FS_FILE) return;
|
||||
rt_log("fs: quick load: %s read from %s", path, q);
|
||||
snprintf(p, cap, "%s", q);
|
||||
plat_inc32(&read_from_hits);
|
||||
}
|
||||
|
||||
static uint32_t open_file(uint64_t *out, const char *path, int mode) {
|
||||
if (romfs_owns(path)) return romfs_open(out, path, mode);
|
||||
fs_trace(mode & FS_OPEN_WRITE ? "write" : "read", path);
|
||||
@@ -885,6 +955,8 @@ static uint32_t open_file(uint64_t *out, const char *path, int mode) {
|
||||
int kind = M_FREE;
|
||||
uint32_t r = host_path_kind(path, p, sizeof p, &kind);
|
||||
if (r) return r;
|
||||
if (kind == M_SAVE && !(mode & FS_OPEN_WRITE) && plat_cas32(&read_from_on, 0, 0))
|
||||
redirect_slot_read(path, p, sizeof p);
|
||||
if (plat_fs_kind(p) != PLAT_FS_FILE) return FS_R_PATH_NOT_FOUND;
|
||||
if (kind == M_SAVE_RO && (mode & FS_OPEN_WRITE)) return FS_R_UNSUPPORTED_OPEN;
|
||||
int save_writer = kind == M_SAVE && (mode & FS_OPEN_WRITE);
|
||||
|
||||
@@ -24,6 +24,7 @@ uint64_t gfx_vsync_time_ns(uint64_t tick); // kern_now_ns() time
|
||||
double gfx_window_refresh_hz(void); // refresh rate of the window's monitor; 0 unknown
|
||||
int gfx_window_focused(void);
|
||||
int gfx_picture_rect(float out[4]); // where the last present put the picture, fractions of the swapchain (x, y, w, h); 0 before one
|
||||
void gfx_present_hold(int on); // 1: the window keeps its last picture, nothing new is presented (quick load)
|
||||
// NVIDIA Reflex (gfx_present.c, VK_NV_low_latency2): the NVN front end and the input service mark a frame's stages.
|
||||
// The markers and the sleep return at once with Reflex off or unsupported.
|
||||
void vk_reflex_marker(int marker, uint64_t present_id); // present_id: the frame's (vk_reflex_frame_begin)
|
||||
|
||||
@@ -795,12 +795,18 @@ void gfx_fit_rect(int cw, int ch, int dw, int dh, int out[4]) {
|
||||
out[0] = (dw - out[2]) / 2, out[1] = (dh - out[3]) / 2;
|
||||
}
|
||||
|
||||
// Quick load (quicksave.c) holds the window on its last picture while it drives the game's load menu underneath:
|
||||
// no new frame is presented until gfx_present_hold(0), as while the window is minimized.
|
||||
static volatile int32_t g_hold;
|
||||
void gfx_present_hold(int on) { plat_xchg32(&g_hold, on != 0); }
|
||||
|
||||
static void present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w, int h, const int crop[4], int defer) {
|
||||
int general = layout == VK_IMAGE_LAYOUT_GENERAL;
|
||||
gfx_window_start();
|
||||
VkCtx *c = vk_ctx();
|
||||
plat_rmutex_lock(&g_pl);
|
||||
flip_locked();
|
||||
if (plat_cas32(&g_hold, 0, 0)) goto out;
|
||||
if (!g_sc || plat_cas32(&g_dirty, 0, 0)) {
|
||||
if (!wsys_minimized() && !create_swapchain() && !g_sc) goto out;
|
||||
}
|
||||
|
||||
+13
-3
@@ -102,7 +102,10 @@ static void script_load(void) {
|
||||
ScriptEv e = {.at = (uint64_t)(at * unit + 0.5), .hold = timed ? 66667 : 4, .bit = -1, .timed = timed};
|
||||
long a, b;
|
||||
double c;
|
||||
if (!strcmp(name, "WHEEL")) {
|
||||
if (!strcmp(name, "QUICKSAVE") || !strcmp(name, "QUICKLOAD")) {
|
||||
e.stick = name[5] == 'S' ? 5 : 6, e.hold = 1; // once, as quicksave's keys
|
||||
snprintf(e.text, sizeof e.text, "%s", name);
|
||||
} else if (!strcmp(name, "WHEEL")) {
|
||||
if (sscanf(line + off, "%ld", &a) != 1) { rt_log("input: script line %d: WHEEL needs notches", ln); continue; }
|
||||
e.stick = 4, e.x = (int32_t)a, e.hold = 1; // one turn, never held
|
||||
snprintf(e.text, sizeof e.text, "WHEEL %d", e.x);
|
||||
@@ -150,7 +153,8 @@ static void script_apply(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
|
||||
if (e->timed) rt_log("input: script frame %llu at %.1f ms: %s", (unsigned long long)fr, w / 1000.0, e->text);
|
||||
else rt_log("input: script frame %llu tick %llu: %s", (unsigned long long)fr, (unsigned long long)tick, e->text);
|
||||
}
|
||||
if (e->stick == 4) script_wheel += e->x;
|
||||
if (e->stick >= 5) quicksave_request(e->stick == 6);
|
||||
else if (e->stick == 4) script_wheel += e->x;
|
||||
else if (e->stick == 3) {
|
||||
int64_t x = (int64_t)script_mouse[0] + e->x, y = (int64_t)script_mouse[1] + e->y;
|
||||
script_mouse[0] = (int32_t)(x < INT32_MIN ? INT32_MIN : x > INT32_MAX ? INT32_MAX : x);
|
||||
@@ -741,6 +745,9 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
else if (!click_held[i]) click_held[i] = 1, click_talk[i] = menu_cursor_dialogue();
|
||||
if (click_talk[i]) down[key] = 0, b |= 1ull << click_btn[i];
|
||||
}
|
||||
// The quick save and quick load keys are quicksave's while it is on (quicksave.c): they reach no binding
|
||||
// then, and do nothing while the settings menu or a text entry is open
|
||||
if (quicksave_on()) quicksave_keys(down, !g_menu && !g_block);
|
||||
if (cap && !g_menu && !g_block) gameplay_tweaks_prepare_keys(down, b);
|
||||
else gameplay_tweaks_reset();
|
||||
b |= input_map_buttons(down);
|
||||
@@ -852,7 +859,10 @@ static int blocked(volatile int32_t *flag, volatile uint64_t *closed, const char
|
||||
|
||||
void input_poll(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry) {
|
||||
poll_merged(buttons, lx, ly, rx, ry);
|
||||
if (!g_block && !g_menu) menu_cursor_poll(buttons);
|
||||
// While quick load drives the game's load menu the pointer leaves it alone and the game gets only its presses
|
||||
if (!g_block && !g_menu && !quicksave_busy()) menu_cursor_poll(buttons);
|
||||
// A quick load under way goes on while the settings menu or a text entry opens: the held picture ends with it
|
||||
if ((quicksave_busy() || (!g_block && !g_menu)) && quicksave_poll(buttons, lx, ly, rx, ry)) return;
|
||||
const int32_t axes[4] = {*lx, *ly, *rx, *ry};
|
||||
int text = blocked(&g_block, &g_block_closed, "text entry", *buttons, axes),
|
||||
menu = blocked(&g_menu, &g_menu_closed, "menu", *buttons, axes);
|
||||
|
||||
@@ -58,6 +58,27 @@ int menu_cursor_menu(void);
|
||||
int menu_cursor_strip(void);
|
||||
// The Purah Pad's camera is open: its frame and pointer without the map the Scope has. 0 with the menu cursor off.
|
||||
int menu_cursor_camera(void);
|
||||
// menu_cursor.c, the game's menus by name for quicksave.c (game thread, 1.4.3): a screen of that layout is open; the
|
||||
// screen with the focus box (its layout name) and the focused node, 0 with none; the focused screen's shown button of
|
||||
// parts layout parts with root pane root (usable_out: it can be pressed), 0 none; the load list's first entry with a
|
||||
// save; the focus to node (1 once it is there)
|
||||
int menu_ui_open(const char *layout);
|
||||
int menu_ui_focus(char *screen, size_t n, uint64_t *node);
|
||||
uint64_t menu_ui_button(const char *parts, const char *root, int *usable_out);
|
||||
uint64_t menu_ui_first_save(void);
|
||||
int menu_ui_focus_to(uint64_t node);
|
||||
// quicksave.c (TOTK_QUICKSAVE): keys: the keys held now, its two keys (TOTK_QUICKSAVE_KEY, TOTK_QUICKLOAD_KEY) start
|
||||
// it when pressed and act is set, and are cleared from down either way; request: save (0) or load (1), as the keys
|
||||
// and the script lines QUICKSAVE / QUICKLOAD do; guest: once per game pad read on the game thread, where quick save
|
||||
// calls into the game; poll: once per game pad read, 1 while quick load drives the game's load menu with its own
|
||||
// presses in place of the input; busy: quick load runs
|
||||
struct Cpu;
|
||||
int quicksave_on(void); // TOTK_QUICKSAVE is on and the game is 1.4.3
|
||||
void quicksave_keys(uint8_t *down, int act);
|
||||
void quicksave_request(int load);
|
||||
void quicksave_guest(struct Cpu *c);
|
||||
int quicksave_poll(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry);
|
||||
int quicksave_busy(void);
|
||||
// The same for host UI (the text entry): never blocked. input_block(1) while a text entry is open: input_poll then
|
||||
// reports nothing; input_block(0) when it closes: nothing until all buttons and stick directions are released.
|
||||
void input_poll_ui(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry);
|
||||
|
||||
@@ -499,3 +499,103 @@ int menu_cursor_shortcut(void) {
|
||||
if (f.screen) layout_name(f.screen, nm, sizeof nm);
|
||||
return f.screen && (!strcmp(nm, "ShortCutMainItem_00") || !strcmp(nm, "ShortCut_00"));
|
||||
}
|
||||
|
||||
// ---- The game's menus for quicksave.c, on the game thread: the same reads and focus writes as above, by name
|
||||
static void main_range(void) {
|
||||
if (!main_lo) main_lo = MOD_MAIN_BASE, main_hi = MOD_MAIN_BASE + MAIN_SIZE;
|
||||
}
|
||||
// nn::ui2d::Pane: its name (+0xb0, 24 characters) and its children, an intrusive list whose links (+0x8 in each
|
||||
// child) start at +0x20
|
||||
enum { PANE_CHILDREN = 0x20, PANE_LINK = 0x8, PANE_NAME = 0xb0, PANE_NAME_MAX = 24 };
|
||||
static int pane_named(uint64_t pane, const char *name) {
|
||||
if (!ok_at(pane, PANE_NAME + PANE_NAME_MAX)) return 0;
|
||||
char nm[PANE_NAME_MAX + 1];
|
||||
memcpy(nm, (const void *)(uintptr_t)(pane + PANE_NAME), PANE_NAME_MAX);
|
||||
nm[PANE_NAME_MAX] = 0;
|
||||
return !strcmp(nm, name);
|
||||
}
|
||||
// The pane called name in the tree under pane, depth first, 0: none
|
||||
static uint64_t pane_find(uint64_t pane, const char *name, int depth) {
|
||||
if (pane_named(pane, name)) return pane;
|
||||
if (depth >= 6 || !ok_at(pane, PANE_NAME + PANE_NAME_MAX)) return 0;
|
||||
uint64_t head = pane + PANE_CHILDREN;
|
||||
int n = 0;
|
||||
for (uint64_t link = rd64(head); link != head && n < 64; link = rd64(link), n++) {
|
||||
if (!ok_at(link, 16)) return 0;
|
||||
uint64_t child = link - PANE_LINK;
|
||||
if (!ok_at(child, PANE_NAME + PANE_NAME_MAX) || rd64(child + PANE_PARENT) != pane) return 0;
|
||||
uint64_t hit = pane_find(child, name, depth + 1);
|
||||
if (hit) return hit;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_ui_open(const char *layout) {
|
||||
main_range();
|
||||
uint64_t sm = screen_mgr();
|
||||
if (!sm) return 0;
|
||||
int32_t n = (int32_t)rd32(sm + SM_COUNT);
|
||||
uint64_t arr = rd64(sm + SM_SCREENS);
|
||||
if (n <= 0 || n > 1024 || !ok_at(arr, 8ull * (uint64_t)n)) return 0;
|
||||
for (int32_t i = 0; i < n; i++) {
|
||||
uint64_t scr = rd64(arr + 8ull * (uint64_t)i);
|
||||
if (!game_object(scr, SCR_REQUEST + 1) || rd8(scr + SCR_STATE) != SCR_OPENED) continue;
|
||||
char nm[48];
|
||||
layout_name(scr, nm, sizeof nm);
|
||||
if (!strcmp(nm, layout)) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_ui_focus(char *screen, size_t n, uint64_t *node) {
|
||||
main_range();
|
||||
Focus f = focus_now();
|
||||
screen[0] = 0, *node = f.node;
|
||||
if (f.screen) layout_name(f.screen, screen, n);
|
||||
return f.screen != 0;
|
||||
}
|
||||
|
||||
uint64_t menu_ui_button(const char *parts, const char *root, int *usable_out) {
|
||||
main_range();
|
||||
Focus f = focus_now();
|
||||
if (!f.screen) return 0;
|
||||
static uint64_t node[MAX_NODES], btn[MAX_NODES];
|
||||
int n = nodes_of(f.screen, node, btn);
|
||||
for (int i = 0; i < n; i++) {
|
||||
uint64_t pane = root_pane(btn[i]);
|
||||
char nm[48];
|
||||
layout_name(btn[i] - SCR_LAYOUT + BTN_LAYOUT, nm, sizeof nm); // the button's parts layout
|
||||
if (strcmp(nm, parts) || !pane_named(pane, root) || !pane_shown(pane)) continue;
|
||||
if (usable_out) *usable_out = usable(btn[i]);
|
||||
return node[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// SystemLoadList_00 lists the saves as PaDataFileBtn_00 entries, newest first; an entry without a save fades
|
||||
// N_Disable_00 out (and is not shown when the list is shorter). The first entry that holds a save, 0 none.
|
||||
uint64_t menu_ui_first_save(void) {
|
||||
main_range();
|
||||
Focus f = focus_now();
|
||||
if (!f.screen) return 0;
|
||||
static uint64_t node[MAX_NODES], btn[MAX_NODES];
|
||||
int n = nodes_of(f.screen, node, btn);
|
||||
for (int i = 0; i < n; i++) {
|
||||
uint64_t pane = root_pane(btn[i]);
|
||||
char nm[48];
|
||||
layout_name(btn[i] - SCR_LAYOUT + BTN_LAYOUT, nm, sizeof nm);
|
||||
if (strcmp(nm, "PaDataFileBtn_00") || !usable(btn[i]) || !pane_shown(pane)) continue;
|
||||
uint64_t filled = pane_find(pane, "N_Disable_00", 0);
|
||||
if (filled && rd8(filled + PANE_ALPHA) >= 128) return node[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_ui_focus_to(uint64_t node) {
|
||||
main_range();
|
||||
Focus f = focus_now();
|
||||
if (!f.screen || !node) return 0;
|
||||
if (f.node == node) return 1;
|
||||
move_focus(&f, node);
|
||||
return 0;
|
||||
}
|
||||
@@ -94,6 +94,7 @@ static void npad_states(Cpu *c, uint32_t want) {
|
||||
if (live) {
|
||||
s.attributes = ATTR_CONNECTED;
|
||||
input_poll(&s.buttons, &s.lx, &s.ly, &s.rx, &s.ry);
|
||||
quicksave_guest(c); // quick save and load call into the game here, between two of its own calls
|
||||
vk_reflex_marker(6, vk_reflex_frame()); // VK_LATENCY_MARKER_INPUT_SAMPLE_NV
|
||||
}
|
||||
*out = s;
|
||||
|
||||
@@ -0,0 +1,450 @@
|
||||
// Quick save and quick load, 1.4.3 only (TOTK_QUICKSAVE, live, default 0): one key saves the game at once and another
|
||||
// loads that save, F6 and F7 by default as in Half-Life (TOTK_QUICKSAVE_KEY, TOTK_QUICKLOAD_KEY: a key name of
|
||||
// input_map.c, or none; live). Keyboard and mouse keys only: a gamepad has no quick save button. No menu shows: quick
|
||||
// save asks the game directly, quick load runs the game's load menu under a held picture.
|
||||
//
|
||||
// Quick save asks the game for an autosave the way its own event graphs do (the execute of the sequence node
|
||||
// OneShotAutoSaveMgrRequestAutoSave, 1.4.3 main+0x24fed3c): component 10 of the game's root is the AutoSaveMgr,
|
||||
// main+0x513ab8 says whether it would autosave now (a cutscene, an event, a fight or a recent autosave say no) and
|
||||
// main+0x1f8ed24 queues the request with kind 4, as that node does. The game then writes one of its autosave slots and
|
||||
// commits the save; fs_host.c reports the slot folder that commit wrote (fs_save_commits), and quicksave copies it to
|
||||
// <profile>/quicksave/slot, its name to <profile>/quicksave/slot.txt. A toast at the top of the picture says "Game
|
||||
// saved" (ui/menu.cpp menu_toast), or why nothing was saved.
|
||||
//
|
||||
// Quick load: the game starts a load only from its own load list (System tab) or its Game Over screen, and loads the
|
||||
// slot that screen names; nothing in play requests one. So quick load drives the load list as a player with a
|
||||
// controller would, under a held picture: the toast "Loading the quick save" shows, the window keeps that picture
|
||||
// (gfx_present_hold) while Plus, R to the System tab, Load, the list's first save and the confirmation's Load are
|
||||
// pressed, and the picture comes back with the game's loading fade. From the confirmation on, the game's reads of the
|
||||
// files of a slot open the quick save's files instead (fs_save_read_from), so it loads the quick save whichever slot
|
||||
// the list offered first, and no slot of the save is written for it (quicksave_poll); the redirect ends with the load
|
||||
// (reads_watch).
|
||||
//
|
||||
// Both start only in play: the world loaded, the HUD's PlayerStatus_00 open, no screen with the focus box, no dialogue
|
||||
// box and no loading fade. Script lines QUICKSAVE and QUICKLOAD (input.c) start them as the keys do.
|
||||
//
|
||||
// Threads. 1.4.3 has no one thread for the AutoSaveMgr: a trace of the hooked functions (function-entry hooks on a test
|
||||
// build) saw the game itself call AUTOSAVE_REQ from at least four guest threads, as events and sequence nodes run on the
|
||||
// game's job workers, and the manager check its pending request (main+0x50ed8c, +0x50f3e8, with AUTOSAVE_CAN) on two
|
||||
// others; the pad was read on six. So quick save calls AUTOSAVE_CAN and AUTOSAVE_REQ the way those events do: from a
|
||||
// game thread between two of the game's own calls, the pad read (quicksave_guest, from ov_input.c's npad_states).
|
||||
// AUTOSAVE_REQ only sets the manager's request flag, and the manager checks AUTOSAVE_CAN again before it saves. As
|
||||
// several threads read the pad at once, one of them at a time steps quick save and quick load (qs_lock); the others give
|
||||
// the game the same presses.
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "fs.h"
|
||||
#include "host.h"
|
||||
#include "input.h"
|
||||
#include "input_map.h"
|
||||
#include "layout.h"
|
||||
#include "gfx.h"
|
||||
#include "platform/platform.h"
|
||||
#include "ui/menu.h"
|
||||
#include "ui_text.h"
|
||||
|
||||
// 1.4.3 main: offsets from MOD_MAIN_BASE
|
||||
#define GAME_ROOT 0x395dc70ull // ** the game's root object (the sequence nodes' first read)
|
||||
#define COMPONENT 0x89f9b0ull // (root, index): the root's component of that index, 0 when none
|
||||
#define AUTOSAVE_INDEX 10 // the AutoSaveMgr's component index
|
||||
#define AUTOSAVE_TYPE 0xc1e348ull // (): AutoSaveMgr's runtime type info, for its vtable's first method (the cast)
|
||||
#define AUTOSAVE_CAN 0x513ab8ull // (mgr, kind, 0): bit 0 when the game would autosave now
|
||||
#define AUTOSAVE_REQ 0x1f8ed24ull // (mgr, kind): queue an autosave
|
||||
#define AUTOSAVE_KIND 4 // the kind OneShotAutoSaveMgrRequestAutoSave asks for
|
||||
#define SAVE_MS 5000 // the most the game takes from the request to the commit of the save (0.5 s seen)
|
||||
#define REQ_FLAGS 0x128ull // mgr+0x128: the request flags; AUTOSAVE_REQ sets bit 0 of their byte 5
|
||||
|
||||
enum { REQ_NONE, REQ_SAVE, REQ_LOAD };
|
||||
static volatile int32_t g_request; // REQ_*, set by the keys or a script, taken by quicksave_guest
|
||||
static int saving; // 1 waiting for the commit of the requested autosave, 2 copying it
|
||||
static uint32_t commits_before;
|
||||
static uint64_t save_started;
|
||||
static uint64_t req_flags; // the request flags' byte AUTOSAVE_REQ set, 0 when the game had set it already
|
||||
|
||||
static int save_key = KEY_F6, load_key = KEY_F7; // KEY_NONE: that key is off
|
||||
static PlatMutex qs_lock = PLAT_MUTEX_INIT; // the pad-reading thread that steps quick save / quick load
|
||||
|
||||
static int key_id(const char *name) {
|
||||
for (int k = KEY_A; k < KEY_COUNT; k++)
|
||||
if (input_key_name(k) && !strcasecmp(name, input_key_name(k))) return k;
|
||||
return KEY_NONE;
|
||||
}
|
||||
|
||||
// A key setting as a KEY_*: a key name of input_map.c (any case) or "none"; anything else is logged and the default
|
||||
// from the settings table is used
|
||||
static int key_setting(const char *var, const char *ini) {
|
||||
const char *v = cfg_value(var), *def = cfg_meta(var)->def;
|
||||
if (!strcasecmp(v, "none")) return KEY_NONE;
|
||||
int k = key_id(v);
|
||||
if (k == KEY_NONE) rt_log("quicksave: %s: unknown key '%s', %s is used", ini, v, def), k = key_id(def);
|
||||
return k;
|
||||
}
|
||||
|
||||
// The keys are read with the switch, so with it off nothing is logged
|
||||
int quicksave_on(void) {
|
||||
static unsigned seen = ~0u;
|
||||
static int on;
|
||||
unsigned v = cfg_version();
|
||||
if (v == seen) return on;
|
||||
int was = on, want = cfg_bool("TOTK_QUICKSAVE");
|
||||
static int told;
|
||||
seen = v, on = RT_V143 && want;
|
||||
// The game's addresses below are 1.4.3's: on 1.1.0 and 1.2.1 the setting is refused once, and no call is made
|
||||
if (want && !RT_V143 && !told) told = 1, rt_log("quicksave: game 1.4.3 only; quick save and quick load stay off");
|
||||
if (!on) return 0;
|
||||
int s = key_setting("TOTK_QUICKSAVE_KEY", "quicksave_key"), l = key_setting("TOTK_QUICKLOAD_KEY", "quickload_key");
|
||||
if (l == s && l != KEY_NONE) {
|
||||
rt_log("quicksave: quickload_key is the quick save key %s: it saves, no key loads", input_key_name(l));
|
||||
l = KEY_NONE;
|
||||
}
|
||||
if (!was || s != save_key || l != load_key)
|
||||
rt_log("quicksave: %s saves, %s loads", s ? input_key_name(s) : "no key", l ? input_key_name(l) : "no key");
|
||||
save_key = s, load_key = l;
|
||||
return on;
|
||||
}
|
||||
|
||||
void quicksave_request(int load) {
|
||||
if (!quicksave_on()) return;
|
||||
plat_cas32(&g_request, load ? REQ_LOAD : REQ_SAVE, REQ_NONE);
|
||||
}
|
||||
|
||||
void quicksave_keys(uint8_t *down, int act) {
|
||||
static int held_s, held_l;
|
||||
int s = save_key && down[save_key], l = load_key && down[load_key];
|
||||
if (act && s && !held_s) quicksave_request(0);
|
||||
if (act && l && !held_l) quicksave_request(1);
|
||||
held_s = s, held_l = l;
|
||||
down[save_key] = down[load_key] = 0; // KEY_NONE is slot 0, never a key
|
||||
}
|
||||
|
||||
// Why play is not at a point where quick save or load may start, NULL when it is
|
||||
static const char *not_in_play(void) {
|
||||
char scr[48];
|
||||
uint64_t node;
|
||||
if (frame_step_world_us() < 0) return "no save is loaded";
|
||||
if (menu_ui_focus(scr, sizeof scr, &node)) return "a menu is open";
|
||||
if (menu_ui_open("LoadingFade_00") || menu_ui_open("EventFade_00")) return "the game is loading";
|
||||
if (menu_ui_open("MessageDialog_00")) return "a dialogue box is open";
|
||||
if (!menu_ui_open("PlayerStatus_00")) return "the HUD is hidden (a cutscene or an event)";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void say(int text, const char *what, const char *why) {
|
||||
rt_log("%s: %s", what, why);
|
||||
menu_toast(text, 2500);
|
||||
}
|
||||
|
||||
static int readable(uint64_t p, uint64_t n) { return p >= 0x10000 && p < (1ull << 47) && mem_guest_readable(p, n); }
|
||||
|
||||
// The game's AutoSaveMgr, found and cast as OneShotAutoSaveMgrRequestAutoSave's execute does; 0 when it has none
|
||||
static uint64_t autosave_mgr(Cpu *c) {
|
||||
uint64_t g = MOD_MAIN_BASE + GAME_ROOT;
|
||||
if (!readable(g, 8) || !readable(LD64(g), 8)) return 0;
|
||||
uint64_t root = LD64(LD64(g));
|
||||
if (!readable(root, 8)) return 0;
|
||||
uint64_t mgr = rt_call(c, MOD_MAIN_BASE + COMPONENT, 2, root, (uint64_t)AUTOSAVE_INDEX);
|
||||
if (!readable(mgr, 0x1a8) || !readable(LD64(mgr), 8)) return 0;
|
||||
uint64_t type = rt_call(c, MOD_MAIN_BASE + AUTOSAVE_TYPE, 0);
|
||||
return rt_call(c, LD64(LD64(mgr)), 2, mgr, type) ? mgr : 0;
|
||||
}
|
||||
|
||||
static void path_of(char *out, size_t cap, const char *leaf) {
|
||||
snprintf(out, cap, "%s/quicksave%s%s", rt_config()->profile, leaf ? "/" : "", leaf ? leaf : "");
|
||||
}
|
||||
|
||||
static void save_start(Cpu *c) {
|
||||
const char *why = not_in_play();
|
||||
if (why) { say(UI_QS_NOT_NOW, "quicksave: not now", why); return; }
|
||||
uint64_t mgr = autosave_mgr(c);
|
||||
if (!mgr) { say(UI_QS_FAILED, "quicksave", "the game has no AutoSaveMgr"); return; }
|
||||
// The manager's timer (+0x150, seconds) holds autosaves back for some ten minutes after the game's last one; a
|
||||
// quick save is the player's own and skips it, as Save in the System tab does. The other checks of AUTOSAVE_CAN
|
||||
// stay: its flags, the game's flag that turns autosaves off (events, fights) and the player's state. AUTOSAVE_REQ
|
||||
// itself drops the request while flag +0x1a0 is set and the state +0x1a4 is 3 (but for kind 2).
|
||||
float timer;
|
||||
memcpy(&timer, (const void *)(uintptr_t)(mgr + 0x150), 4);
|
||||
ST32(mgr + 0x150, 0);
|
||||
int can = rt_call(c, MOD_MAIN_BASE + AUTOSAVE_CAN, 3, mgr, (uint64_t)AUTOSAVE_KIND, 0ull) & 1;
|
||||
if (can && LD8(mgr + 0x1a0) && LD32(mgr + 0x1a4) == 3) can = 0;
|
||||
if (!can) {
|
||||
memcpy((void *)(uintptr_t)(mgr + 0x150), &timer, 4); // the game's own wait goes on as it was
|
||||
say(UI_QS_NOT_NOW, "quicksave: not now", "the game would not autosave here");
|
||||
return;
|
||||
}
|
||||
if (timer > 0) rt_log("quicksave: the game's autosave wait (%.0f s left) skipped", timer);
|
||||
char slot[64];
|
||||
commits_before = fs_save_commits(slot, sizeof slot);
|
||||
uint64_t flags = LD64(mgr + REQ_FLAGS) + 5;
|
||||
if (!readable(flags, 1)) { say(UI_QS_FAILED, "quicksave", "the AutoSaveMgr has no request flags"); return; }
|
||||
int pending = LD8(flags) & 1; // the game's own request, which quick save then waits for
|
||||
rt_call(c, MOD_MAIN_BASE + AUTOSAVE_REQ, 2, mgr, (uint64_t)AUTOSAVE_KIND);
|
||||
if (!(LD8(flags) & 1)) { say(UI_QS_NOT_NOW, "quicksave: not now", "the game dropped the request"); return; }
|
||||
req_flags = pending ? 0 : flags;
|
||||
saving = 1, save_started = plat_now_ms();
|
||||
rt_log("quicksave: autosave requested");
|
||||
}
|
||||
|
||||
// The slot the autosave wrote, copied to <profile>/quicksave on a thread of its own; saving goes back to 0 at its end
|
||||
static char copy_slot[64];
|
||||
static void copy_main(void *arg) {
|
||||
(void)arg;
|
||||
char dir[1200], data[1200], note[1200];
|
||||
path_of(dir, sizeof dir, NULL), path_of(data, sizeof data, "slot"), path_of(note, sizeof note, "slot.txt");
|
||||
plat_fs_mkdir(dir);
|
||||
if (fs_save_copy_slot(copy_slot, data) || !plat_file_write_atomic(note, copy_slot, strlen(copy_slot))) {
|
||||
say(UI_QS_FAILED, "quicksave", "the autosave could not be copied to the quick save");
|
||||
} else {
|
||||
rt_log("quicksave: saved: the game's autosave in %s (%.1f s), kept in %s", copy_slot,
|
||||
(plat_now_ms() - save_started) / 1000.0, data);
|
||||
menu_toast(UI_QS_SAVED, 2500);
|
||||
}
|
||||
__atomic_store_n(&saving, 0, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
// After the request: the first commit that wrote a slot folder is the autosave
|
||||
static void save_wait(void) {
|
||||
if (__atomic_load_n(&saving, __ATOMIC_ACQUIRE) != 1) return; // 2: the copy runs
|
||||
char slot[64];
|
||||
uint32_t n = fs_save_commits(slot, sizeof slot);
|
||||
if (n == commits_before || !slot[0]) {
|
||||
// The game can take the request and still hold the autosave back (a fight in the Depths did): quick save then
|
||||
// takes its request back, so the game does not save some time later on its own, and says so
|
||||
if (plat_now_ms() - save_started > SAVE_MS) {
|
||||
// Atomic: the game's job threads set and read other bits of this byte at the same time
|
||||
if (req_flags) __atomic_fetch_and((uint8_t *)(uintptr_t)req_flags, (uint8_t)~1u, __ATOMIC_SEQ_CST);
|
||||
saving = 0;
|
||||
say(UI_QS_NOT_NOW, "quicksave: not now",
|
||||
req_flags ? "the game held the autosave back; the request is withdrawn" : "the game held its autosave back");
|
||||
}
|
||||
return;
|
||||
}
|
||||
saving = 2; // the copy runs on its own thread: no file I/O on the game thread
|
||||
snprintf(copy_slot, sizeof copy_slot, "%s", slot);
|
||||
if (!plat_thread_spawn(copy_main, NULL, "quicksave", 0)) copy_main(NULL);
|
||||
}
|
||||
|
||||
// ---- quick load: the game's load menu, driven under a held picture
|
||||
enum { ST_IDLE, ST_TOAST, ST_OPEN, ST_TAB, ST_PICK, ST_LIST, ST_CONFIRM, ST_LOADING, ST_CLEANUP };
|
||||
#define PRESS_MS 100 // a press, held long enough for any of the game's reads
|
||||
#define GAP_MS 120 // released after each press before the next step looks again
|
||||
#define SETTLE_MS 200 // a screen that just took the focus box plays its opening: act after this
|
||||
#define TAB_MS 100 // a tab of the pause menu that just took the focus: act after this (R stops at the last)
|
||||
#define TOAST_MS 150 // the toast is presented before the picture is held
|
||||
#define STEP_MS 3000 // the most any step waits for its screen
|
||||
#define LOAD_MS 10000 // the most the game takes from the confirmation to its loading fade
|
||||
#define BACK_MS 500 // the load is over once the HUD has been back this long, the loading fade closed
|
||||
#define READ_MAX_MS 120000 // the redirect ends this long after the confirmation whatever happened
|
||||
#define MAX_TABS 12 // R presses to reach the System tab, the last one (R stops there)
|
||||
#define MAX_BACK 10 // B presses to leave the menus after a failure
|
||||
|
||||
static struct {
|
||||
int state, tries;
|
||||
uint64_t state_at, press_until, gap_until, press_bit, focus_since, started;
|
||||
uint64_t reading, back_since; // reading: when the redirect began, 0 none; back_since: the HUD back since then
|
||||
char focus[48];
|
||||
} m;
|
||||
|
||||
int quicksave_busy(void) { return m.state != ST_IDLE; }
|
||||
|
||||
static void enter(int state, uint64_t now) { m.state = state, m.state_at = now, m.tries = 0; }
|
||||
|
||||
static void press(int bit, uint64_t now) {
|
||||
m.press_bit = 1ull << bit, m.press_until = now + PRESS_MS, m.gap_until = now + PRESS_MS + GAP_MS;
|
||||
}
|
||||
|
||||
static void fail(const char *why, uint64_t now) {
|
||||
rt_log("quickload: %s; leaving the menus", why);
|
||||
fs_save_read_from(NULL);
|
||||
m.reading = m.back_since = 0;
|
||||
menu_toast(UI_QS_LOAD_FAILED, 2500);
|
||||
enter(ST_CLEANUP, now);
|
||||
}
|
||||
|
||||
static void end(uint64_t now) {
|
||||
gfx_present_hold(0);
|
||||
enter(ST_IDLE, now);
|
||||
}
|
||||
|
||||
// Once per pad read on the game thread, after menu_cursor_poll: 1 while quick load runs, with the game's input
|
||||
// replaced by its presses. Quick load shows "Loading the quick save", then holds the window on that picture
|
||||
// (gfx_present_hold) while it opens the pause menu, turns to the System tab, presses Load, picks the list's first save
|
||||
// and confirms; from the confirmation on, the game's reads of a slot's files open the quick save's (fs_save_read_from),
|
||||
// so whichever slot the list offered first, the game loads the quick save. The picture comes back with the game's
|
||||
// loading fade, or as soon as a step fails (B then closes the menus).
|
||||
// The redirect of the slot reads ends with the load: once the game read the quick save's files, its loading fade closed
|
||||
// and the HUD (PlayerStatus_00) has been back BACK_MS; at once when a menu with the focus box opens (the load list
|
||||
// must show and load the slots as they are); after READ_MAX_MS whatever happened.
|
||||
static void reads_end(const char *why) {
|
||||
fs_save_read_from(NULL);
|
||||
rt_log("quickload: slot reads go to the save again (%s, %d files read from the quick save)", why,
|
||||
fs_save_read_from_hits());
|
||||
m.reading = m.back_since = 0;
|
||||
}
|
||||
|
||||
static void reads_watch(uint64_t now) {
|
||||
char scr[48];
|
||||
uint64_t node;
|
||||
if (menu_ui_focus(scr, sizeof scr, &node)) { reads_end("a menu opened"); return; }
|
||||
if (now - m.reading > READ_MAX_MS) { reads_end("the load did not end in time"); return; }
|
||||
int back = fs_save_read_from_hits() > 0 && !menu_ui_open("LoadingFade_00") && menu_ui_open("PlayerStatus_00");
|
||||
if (!back) m.back_since = 0;
|
||||
else if (!m.back_since) m.back_since = now;
|
||||
else if (now - m.back_since >= BACK_MS) reads_end("the load is over");
|
||||
}
|
||||
|
||||
static int poll_locked(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry) {
|
||||
if (m.reading && m.state == ST_IDLE) reads_watch(plat_now_ms());
|
||||
if (m.state == ST_IDLE && __atomic_load_n(&g_request, __ATOMIC_RELAXED) != REQ_LOAD) return 0; // a plain read
|
||||
uint64_t now = plat_now_ms();
|
||||
if (m.state == ST_IDLE) {
|
||||
if (plat_cas32(&g_request, REQ_NONE, REQ_LOAD) != REQ_LOAD || !quicksave_on()) return 0;
|
||||
char data[1200];
|
||||
path_of(data, sizeof data, "slot");
|
||||
if (plat_fs_kind(data) != PLAT_FS_DIR) { say(UI_QS_NONE, "quickload", "there is no quick save"); return 0; }
|
||||
const char *why = not_in_play();
|
||||
if (why) { say(UI_QS_NOT_NOW, "quickload: not now", why); return 0; }
|
||||
rt_log("quickload: through the game's load menu, under the held picture");
|
||||
menu_toast(UI_QS_LOADING, 4000);
|
||||
m.started = now;
|
||||
enter(ST_TOAST, now);
|
||||
}
|
||||
plat_cas32(&g_request, REQ_NONE, REQ_LOAD); // a key pressed while it runs is dropped, not queued
|
||||
*buttons = 0, *lx = *ly = *rx = *ry = 0;
|
||||
if (now < m.press_until) { *buttons = m.press_bit; return 1; }
|
||||
if (now < m.gap_until) return 1;
|
||||
char scr[48];
|
||||
uint64_t node;
|
||||
int focus = menu_ui_focus(scr, sizeof scr, &node);
|
||||
if (!focus || strcmp(scr, m.focus)) m.focus_since = now, snprintf(m.focus, sizeof m.focus, "%s", focus ? scr : "");
|
||||
int settled = focus && now - m.focus_since >= SETTLE_MS;
|
||||
uint64_t waited = now - m.state_at;
|
||||
if (m.state != ST_CLEANUP && m.state != ST_LOADING && now - m.started > 4 * STEP_MS) {
|
||||
fail("took too long", now);
|
||||
return 1;
|
||||
}
|
||||
switch (m.state) {
|
||||
case ST_TOAST: // the toast reaches the screen; then the picture is held and Plus opens the pause menu
|
||||
if (waited < TOAST_MS) break;
|
||||
gfx_present_hold(1);
|
||||
press(B_PLUS, now);
|
||||
enter(ST_OPEN, now);
|
||||
break;
|
||||
case ST_OPEN: // the pause menu (Pouch_00) takes the focus box
|
||||
if (focus && strcmp(scr, "Pouch_00")) { fail("another menu opened", now); break; }
|
||||
if (settled) enter(ST_TAB, now);
|
||||
else if (waited > STEP_MS) fail("the pause menu did not open", now);
|
||||
break;
|
||||
case ST_TAB: { // R until the System tab's buttons show
|
||||
int ok;
|
||||
if (focus && strcmp(scr, "Pouch_00")) { fail("another menu opened", now); break; }
|
||||
if (!focus || now - m.focus_since < TAB_MS) {
|
||||
if (waited > STEP_MS) fail("the pause menu lost the focus", now);
|
||||
break;
|
||||
}
|
||||
if (menu_ui_button("PaCommonBtnThin_00", "Pa_Button_01", &ok)) { enter(ST_PICK, now); break; }
|
||||
if (m.tries++ >= MAX_TABS) { fail("the System tab was not found", now); break; }
|
||||
press(B_R, now);
|
||||
m.state_at = now; // each tab gets its own wait
|
||||
break;
|
||||
}
|
||||
case ST_PICK: { // Load (Pa_Button_01) takes the focus, then A
|
||||
int ok = 0;
|
||||
uint64_t b = menu_ui_button("PaCommonBtnThin_00", "Pa_Button_01", &ok);
|
||||
if (!b) { fail("the System tab closed", now); break; }
|
||||
if (!ok) { fail("the game does not allow loading now", now); break; }
|
||||
if (menu_ui_focus_to(b)) { press(B_A, now); enter(ST_LIST, now); }
|
||||
else if (waited > STEP_MS) fail("the focus did not move to Load", now);
|
||||
break;
|
||||
}
|
||||
case ST_LIST: { // the load list (SystemLoadList_00): its first save takes the focus, then A
|
||||
if (!settled || strcmp(scr, "SystemLoadList_00")) {
|
||||
if (focus && settled && strcmp(scr, "Pouch_00")) fail("another menu opened", now);
|
||||
else if (waited > STEP_MS) fail("the list of saves did not open", now);
|
||||
break;
|
||||
}
|
||||
uint64_t b = menu_ui_first_save();
|
||||
if (!b) { fail("the list holds no save", now); break; }
|
||||
if (menu_ui_focus_to(b)) { press(B_A, now); enter(ST_CONFIRM, now); }
|
||||
else if (waited > STEP_MS) fail("the focus did not move to the save", now);
|
||||
break;
|
||||
}
|
||||
case ST_CONFIRM: { // "Load this save?" (SystemSaveLoad_00): its first button and A, the slot reads redirected
|
||||
if (!settled || strcmp(scr, "SystemSaveLoad_00")) {
|
||||
if (focus && settled && strcmp(scr, "SystemLoadList_00")) fail("another menu opened", now);
|
||||
else if (waited > STEP_MS) fail("the game did not ask to confirm", now);
|
||||
break;
|
||||
}
|
||||
uint64_t b = menu_ui_button("PaCommonBtnThin_00", "Pa_CheckButton_00", NULL);
|
||||
if (!b) { fail("the confirmation has no first button", now); break; }
|
||||
if (menu_ui_focus_to(b)) {
|
||||
char data[1200];
|
||||
path_of(data, sizeof data, "slot");
|
||||
fs_save_read_from(data);
|
||||
m.reading = now, m.back_since = 0;
|
||||
press(B_A, now);
|
||||
enter(ST_LOADING, now);
|
||||
} else if (waited > STEP_MS) fail("the focus did not move to the confirmation", now);
|
||||
break;
|
||||
}
|
||||
case ST_LOADING: // the game fades out and loads: the picture comes back with its fade
|
||||
if (menu_ui_open("LoadingFade_00")) {
|
||||
rt_log("quickload: loading the quick save (%.1f s)", (now - m.started) / 1000.0);
|
||||
end(now);
|
||||
} else if (focus && settled && strcmp(scr, "SystemSaveLoad_00")) {
|
||||
fail("another menu opened instead of loading", now);
|
||||
}
|
||||
else if (waited > LOAD_MS) fail("the load did not start", now);
|
||||
break;
|
||||
case ST_CLEANUP: // B until no menu has the focus box; then the picture comes back
|
||||
if (!focus) { end(now); break; }
|
||||
if (m.tries++ >= MAX_BACK) {
|
||||
rt_log("quickload: a menu stays open after %d presses of B", MAX_BACK);
|
||||
end(now);
|
||||
break;
|
||||
}
|
||||
press(B_B, now);
|
||||
m.gap_until = now + PRESS_MS + 2 * GAP_MS;
|
||||
break;
|
||||
}
|
||||
if (now < m.press_until) *buttons = m.press_bit;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int quicksave_poll(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry) {
|
||||
if (!m.reading && m.state == ST_IDLE && __atomic_load_n(&g_request, __ATOMIC_RELAXED) != REQ_LOAD) return 0;
|
||||
if (!plat_mutex_trylock(&qs_lock)) { // another pad read steps it: this one gets the same presses
|
||||
if (m.state == ST_IDLE) return 0;
|
||||
*buttons = plat_now_ms() < m.press_until ? m.press_bit : 0, *lx = *ly = *rx = *ry = 0;
|
||||
return 1;
|
||||
}
|
||||
int r = poll_locked(buttons, lx, ly, rx, ry);
|
||||
plat_mutex_unlock(&qs_lock);
|
||||
return r;
|
||||
}
|
||||
|
||||
static void guest_locked(Cpu *c);
|
||||
|
||||
// Once per game pad read (ov_input.c), with the reading thread's Cpu: quick save
|
||||
void quicksave_guest(Cpu *c) {
|
||||
if (!saving && __atomic_load_n(&g_request, __ATOMIC_RELAXED) != REQ_SAVE) return; // a plain read when idle
|
||||
if (!plat_mutex_trylock(&qs_lock)) return;
|
||||
guest_locked(c);
|
||||
plat_mutex_unlock(&qs_lock);
|
||||
}
|
||||
|
||||
static void guest_locked(Cpu *c) {
|
||||
if (!saving && __atomic_load_n(&g_request, __ATOMIC_RELAXED) != REQ_SAVE) return; // a plain read when idle
|
||||
if (saving) {
|
||||
save_wait();
|
||||
plat_cas32(&g_request, REQ_NONE, REQ_SAVE); // a key pressed while it saves is dropped, not queued
|
||||
return;
|
||||
}
|
||||
if (plat_cas32(&g_request, REQ_NONE, REQ_SAVE) != REQ_SAVE || !quicksave_on()) return;
|
||||
if (m.state != ST_IDLE) return;
|
||||
save_start(c);
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
// gamepad cells show and change the table of the button layout in use (TOTK_PAD_LAYOUT).
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "imgui.h"
|
||||
#include "ui/binds_page.h"
|
||||
@@ -34,16 +35,22 @@ static const int kButtons[] = {B_A, B_B, B_X, B_Y, B_L, B_R, B_ZL, B_ZR, B_STICK
|
||||
static const int kMove[] = {B_SL_UP, B_SL_DOWN, B_SL_LEFT, B_SL_RIGHT};
|
||||
static const int kCamera[] = {B_SR_UP, B_SR_DOWN, B_SR_LEFT, B_SR_RIGHT};
|
||||
|
||||
// A key setting's row (binds_key_row) waits as this action, with the setting and its label beside it
|
||||
enum { ACTION_SETTING = ACTION_COUNT };
|
||||
static struct {
|
||||
int action = -1, cell; // the cell waiting for a press (0, 1 keys, 2 the controller); action -1 none
|
||||
bool reset; // the next capture poll takes what is held as the start
|
||||
uint64_t start, done; // plat_now_ns of the start and of the press, timeout or Esc (0 still waiting)
|
||||
const char *setting; // ACTION_SETTING: the TOTK_ name the key goes to
|
||||
UiTextId label; // and its row's label
|
||||
} g_cap;
|
||||
static char g_note[160]; // what the last change took or swapped, after its row's description
|
||||
static int g_note_action = -1;
|
||||
static uint64_t g_note_until;
|
||||
|
||||
static const char *action_label(int a) { return menu_text((UiTextId)(UI_BIND_A + a)); }
|
||||
static const char *action_label(int a) {
|
||||
return a == ACTION_SETTING ? menu_text(g_cap.label) : menu_text((UiTextId)(UI_BIND_A + a));
|
||||
}
|
||||
|
||||
static UiTextId action_desc(int a) {
|
||||
if (a <= B_MINUS) return (UiTextId)(UI_BIND_DESC_A + a);
|
||||
@@ -196,7 +203,11 @@ static void capture_window(void) {
|
||||
if (!g_cap.done) {
|
||||
int id = 0, got = input_capture(g_cap.reset, &id);
|
||||
g_cap.reset = false;
|
||||
if (got == INPUT_CAPTURE_KEY && !pad_cell) change(g_cap.action, g_cap.cell, id);
|
||||
if (got == INPUT_CAPTURE_KEY && g_cap.action == ACTION_SETTING) {
|
||||
cfg_set(g_cap.setting, input_key_name(id));
|
||||
opt_save_soon();
|
||||
rt_log("menu: %s = %s", g_cap.setting + 5, input_key_name(id));
|
||||
} else if (got == INPUT_CAPTURE_KEY && !pad_cell) change(g_cap.action, g_cap.cell, id);
|
||||
if (got == INPUT_CAPTURE_PAD && pad_cell) change(g_cap.action, g_cap.cell, id);
|
||||
if (got != INPUT_CAPTURE_NONE && !(got == INPUT_CAPTURE_KEY && pad_cell)) g_cap.done = now;
|
||||
if (now - g_cap.start > CAPTURE_SECONDS * 1000000000ull) g_cap.done = now;
|
||||
@@ -213,7 +224,8 @@ static void capture_window(void) {
|
||||
if (g_cap.done && now - g_cap.done > kDoneNs) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
char id[48];
|
||||
snprintf(id, sizeof id, "BIND_%s#%d", input_action_name(g_cap.action), g_cap.cell);
|
||||
if (g_cap.action == ACTION_SETTING) snprintf(id, sizeof id, "%s#0", g_cap.setting + 5);
|
||||
else snprintf(id, sizeof id, "BIND_%s#%d", input_action_name(g_cap.action), g_cap.cell);
|
||||
opt_focus_key(id); // back on the cell it came from
|
||||
g_cap.action = -1;
|
||||
}
|
||||
@@ -223,6 +235,29 @@ static void capture_window(void) {
|
||||
|
||||
bool binds_modal(void) { return g_cap.action >= 0; }
|
||||
|
||||
// A key setting (quick save's keys): its key in the first cell, taken by the same capture window as a binding's key;
|
||||
// Delete, Backspace or X sets it to none. The other two cells stay empty (no controller button for it). note: e.g. the
|
||||
// binding that also uses the key.
|
||||
void binds_key_row(const char *setting, UiTextId label, UiTextId desc, const char *note) {
|
||||
const char *cur = cfg_value(setting);
|
||||
int key = KEY_NONE;
|
||||
for (int k = KEY_A; k < KEY_COUNT && key == KEY_NONE; k++)
|
||||
if (input_key_name(k) && !strcasecmp(input_key_name(k), cur)) key = k;
|
||||
char b[48];
|
||||
const char *cells[3] = {key != KEY_NONE ? key_label(key, b, sizeof b) : strcasecmp(cur, "none") ? cur : "", "", ""};
|
||||
const bool enabled[3] = {true, false, false};
|
||||
int r = opt_bind_row(setting + 5, menu_text(label), desc, cells, enabled, note);
|
||||
if (g_cap.action >= 0 || r < 0) return;
|
||||
if (r == 0) {
|
||||
g_cap.action = ACTION_SETTING, g_cap.cell = 0, g_cap.setting = setting, g_cap.label = label;
|
||||
g_cap.reset = true, g_cap.start = plat_now_ns(), g_cap.done = 0;
|
||||
} else if (r == 10) {
|
||||
cfg_set(setting, "none");
|
||||
opt_save_soon();
|
||||
rt_log("menu: %s = none", setting + 5);
|
||||
}
|
||||
}
|
||||
|
||||
static bool g_reset_asked; // the reset row was chosen this frame (acted on after the page)
|
||||
|
||||
void binds_rows(float scale) {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// The remapping rows of the menu's Controls tab (ui/binds_page.cpp). Present path only (ImGui).
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include "ui_text.h"
|
||||
}
|
||||
|
||||
// Inside the page's opt_begin / opt_end: every action's two keys and its controller button, remapped by selecting a
|
||||
// cell and pressing the new one, and the reset of them all. binds_after_page, after opt_end: the window that waits for
|
||||
// the press.
|
||||
@@ -8,3 +12,6 @@ void binds_rows(float scale);
|
||||
void binds_after_page(void);
|
||||
// A cell waits for a press (or its press is still reaching the menu): B, Esc, L / R and the tab keys stay on the page.
|
||||
bool binds_modal(void);
|
||||
// A key setting (TOTK_ name) as a row of one key cell, set by pressing the key as a binding's cell is; Delete sets it
|
||||
// to none. note (NULL none) follows the description.
|
||||
void binds_key_row(const char *setting, UiTextId label, UiTextId desc, const char *note);
|
||||
+62
-11
@@ -855,6 +855,21 @@ static int key_action(const InputMap *m, int key) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// "also <action>" when the bindings also use the key the setting names, else NULL; note holds the text
|
||||
static const char *key_taken(const char *setting, char *note, size_t size) {
|
||||
const char *cur = cfg_value(setting);
|
||||
InputMap m;
|
||||
input_map_snapshot(&m);
|
||||
for (int k = KEY_A; k < KEY_COUNT; k++) {
|
||||
if (!input_key_name(k) || strcasecmp(input_key_name(k), cur)) continue;
|
||||
int a = key_action(&m, k);
|
||||
if (a < 0 || !input_action_name(a)) return nullptr;
|
||||
snprintf(note, size, menu_text(UI_MENU_WALK_KEY_TAKEN), input_action_name(a));
|
||||
return note;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The walk key as the handful of keys a player is likely to pick. "none" rather than an empty value closes it: an
|
||||
// unset key falls back to the default in the settings table, the same as a fresh installation. totk.ini takes any name
|
||||
// input_map.c knows (walks of the keyboard sticks, not of the gamepad). A key the current bindings also use says which
|
||||
@@ -862,18 +877,20 @@ static int key_action(const InputMap *m, int key) {
|
||||
static void row_walk_key(void) {
|
||||
static const char *const keys[] = {"none", "lshift", "lalt", "lctrl", "tab", "capslock"};
|
||||
const char *names[sizeof keys / sizeof *keys] = {menu_text(UI_MENU_OFF), "Shift", "Alt", "Ctrl", "Tab", "Caps Lock"};
|
||||
const char *cur = cfg_value("TOTK_WALK_KEY");
|
||||
static char note[64];
|
||||
const char *n = nullptr;
|
||||
InputMap m;
|
||||
input_map_snapshot(&m);
|
||||
for (int k = KEY_A; k < KEY_COUNT && !n; k++) {
|
||||
if (!input_key_name(k) || strcasecmp(input_key_name(k), cur)) continue;
|
||||
int a = key_action(&m, k);
|
||||
if (a >= 0 && input_action_name(a)) snprintf(note, sizeof note, menu_text(UI_MENU_WALK_KEY_TAKEN), input_action_name(a)), n = note;
|
||||
}
|
||||
opt_choice_list("TOTK_WALK_KEY", UI_MENU_WALK_KEY, keys, names, sizeof keys / sizeof *keys, UI_MENU_WALK_KEY_DESC,
|
||||
-1, n);
|
||||
-1, key_taken("TOTK_WALK_KEY", note, sizeof note));
|
||||
}
|
||||
|
||||
// Quick save's two keys (quicksave.c), F6 and F7 by default as Half-Life has them: any key or mouse button, taken by
|
||||
// the bindings' capture window (binds_key_row); Delete leaves that one without a key. A key the bindings also use says
|
||||
// which action it presses: while quick save is on it no longer does.
|
||||
static void row_quicksave_keys(void) {
|
||||
static char note[2][64];
|
||||
binds_key_row("TOTK_QUICKSAVE_KEY", UI_MENU_QUICKSAVE_KEY, UI_MENU_QUICKSAVE_KEY_DESC,
|
||||
key_taken("TOTK_QUICKSAVE_KEY", note[0], sizeof note[0]));
|
||||
binds_key_row("TOTK_QUICKLOAD_KEY", UI_MENU_QUICKLOAD_KEY, UI_MENU_QUICKSAVE_KEY_DESC,
|
||||
key_taken("TOTK_QUICKLOAD_KEY", note[1], sizeof note[1]));
|
||||
}
|
||||
|
||||
// The note under the prompts. The settings name a folder of prompts (input_prompts_folder: the prompts and the pad
|
||||
@@ -1005,6 +1022,8 @@ static void tab_controls(float scale) {
|
||||
opt_toggle("TOTK_MAP_CLICK", UI_MENU_MAP_CLICK, UI_MENU_MAP_CLICK_DESC);
|
||||
opt_toggle("TOTK_DIALOGUE_CLICK", UI_MENU_DIALOGUE_CLICK, UI_MENU_DIALOGUE_CLICK_DESC);
|
||||
opt_toggle("TOTK_POINTER_IMAGE", UI_MENU_POINTER_IMAGE, UI_MENU_POINTER_IMAGE_DESC);
|
||||
opt_toggle("TOTK_QUICKSAVE", UI_MENU_QUICKSAVE, UI_MENU_QUICKSAVE_DESC);
|
||||
row_quicksave_keys();
|
||||
row_walk_key();
|
||||
opt_slider("TOTK_WALK_SCALE", UI_MENU_WALK_SCALE, 0.2f, 0.9f, UI_MENU_WALK_SCALE_DESC, 0.01f, "%.2f");
|
||||
rows_gameplay_tweaks();
|
||||
@@ -1723,6 +1742,37 @@ static void perf_draw(const MenuTarget *t, float scale) {
|
||||
dl->AddText(ImVec2(p.x + pad, p.y + pad), IM_COL32(255, 255, 255, 235), g_perf_text);
|
||||
}
|
||||
|
||||
// ---- a toast: one short line of ui_text at the top centre of the picture, over the game, for a few seconds and fading
|
||||
// out in its last half second (quick save's "Game saved", quicksave.c). Any thread sets it; the overlay draws it.
|
||||
static std::atomic<int> g_toast_text{-1};
|
||||
static std::atomic<uint64_t> g_toast_until{0};
|
||||
extern "C" void menu_toast(int text, int ms) {
|
||||
g_toast_until.store(plat_now_ns() + (uint64_t)(ms > 0 ? ms : 1) * 1000000ull, std::memory_order_relaxed);
|
||||
g_toast_text.store(text, std::memory_order_release);
|
||||
}
|
||||
|
||||
static bool toast_live(void) {
|
||||
return g_toast_text.load(std::memory_order_acquire) >= 0 &&
|
||||
plat_now_ns() < g_toast_until.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
static void toast_draw(const MenuTarget *t, float scale) {
|
||||
int id = g_toast_text.load(std::memory_order_acquire);
|
||||
uint64_t now = plat_now_ns(), until = g_toast_until.load(std::memory_order_relaxed);
|
||||
if (id < 0 || id >= UI_TEXT_COUNT || now >= until) return;
|
||||
double left_ms = (until - now) / 1e6;
|
||||
float a = left_ms < 500 ? (float)(left_ms / 500) : 1.0f;
|
||||
const char *text = ui_text((UiTextId)id);
|
||||
ImDrawList *dl = ImGui::GetForegroundDrawList();
|
||||
ImFont *font = ImGui::GetFont();
|
||||
float size = ImGui::GetFontSize() * 1.25f, pad = 10 * scale;
|
||||
ImVec2 sz = font->CalcTextSizeA(size, FLT_MAX, 0, text);
|
||||
ImVec2 p((t->width - sz.x) / 2 - pad, 48 * scale); // under the top edge, between the hearts and the corner
|
||||
ImVec2 q(p.x + sz.x + 2 * pad, p.y + sz.y + 2 * pad);
|
||||
dl->AddRectFilled(p, q, IM_COL32(0, 0, 0, (int)(160 * a)), 6 * scale);
|
||||
dl->AddText(font, size, ImVec2(p.x + pad, p.y + pad), IM_COL32(255, 255, 255, (int)(240 * a)), text);
|
||||
}
|
||||
|
||||
extern "C" int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const char **shot) {
|
||||
*shot = NULL;
|
||||
cheats_frame(frame); // the data cheats and the buttons of the cheats that need them held
|
||||
@@ -1740,7 +1790,7 @@ extern "C" int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const cha
|
||||
g_tab_request = 0;
|
||||
set_open(1);
|
||||
open = true;
|
||||
} else if (!g_perf_mode) {
|
||||
} else if (!g_perf_mode && !toast_live()) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1792,6 +1842,7 @@ extern "C" int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const cha
|
||||
ImGui::NewFrame();
|
||||
if (open) layout_menu(t->width, t->height, scale);
|
||||
perf_draw(t, scale);
|
||||
toast_draw(t, scale);
|
||||
ImGui::Render();
|
||||
if (open) g_save_pending = opt_save_tick(0);
|
||||
g_cost_ns += plat_now_ns() - t0;
|
||||
|
||||
@@ -26,6 +26,7 @@ extern "C" {
|
||||
int menu_is_open(void);
|
||||
void menu_toggle(void); // F1 / Esc on the keyboard, Minus+Plus on the pad
|
||||
void menu_perf_cycle(void); // F10: the performance overlay off, fps, full
|
||||
void menu_toast(int text, int ms); // a short line (a UiTextId) at the top of the picture for ms, any thread
|
||||
|
||||
// ---- events from the window adapter, used only while the menu is open. key: an ImGuiKey; coordinates in pixels of the
|
||||
// window's client area, which is the swapchain image.
|
||||
|
||||
@@ -330,6 +330,17 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "While a dialogue box is open, left click presses B (it continues the text and skips its scroll) and right click presses A, instead of the buttons they are bound to (Y by default, which opens the dialogue log, and ZL). Dialogue choices keep the pointer: left click picks (game 1.4.3).",
|
||||
[UI_MENU_POINTER_IMAGE] = "Game pointer",
|
||||
[UI_MENU_POINTER_IMAGE_DESC] = "While the cursor is not captured (the game's menus, this menu, after Esc), the window shows a gold arrowhead of its own instead of the system arrow, sized for the screen's scale.",
|
||||
[UI_MENU_QUICKSAVE] = "Quick save and load",
|
||||
[UI_MENU_QUICKSAVE_DESC] = "One key saves the game at once and another loads that save (the two rows below: F6 and F7 by default, as in Half-Life), with no menu on the screen. Keyboard and mouse keys only, game 1.4.3 only. Quick save asks the game for one of its own autosaves, so it replaces the oldest autosave (the manual save stays), keeps a copy of it as the quick save (the quicksave folder of the profile) and shows \"Game saved\" at the top of the picture. Quick load holds the picture on \"Loading the quick save\" while it goes through the game's load list out of sight, and the game loads the quick save (about 5 s). Where the game would not make an autosave itself (a cutscene, a dialogue), nothing is saved and the line says so.",
|
||||
[UI_MENU_QUICKSAVE_KEY] = "Quick save key",
|
||||
[UI_MENU_QUICKLOAD_KEY] = "Quick load key",
|
||||
[UI_MENU_QUICKSAVE_KEY_DESC] = "The key that starts quick save or quick load; F6 and F7 by default, as in Half-Life. Select the cell and press any key or mouse button; Delete leaves that one without a key. While quick save is on, the two keys do nothing else (a note shows when a binding also uses the key). totk.ini takes any key name of the bindings (quicksave_key, quickload_key).",
|
||||
[UI_QS_SAVED] = "Game saved",
|
||||
[UI_QS_LOADING] = "Loading the quick save",
|
||||
[UI_QS_NOT_NOW] = "Quick save is not possible right now",
|
||||
[UI_QS_NONE] = "There is no quick save yet (the quick save key makes one)",
|
||||
[UI_QS_FAILED] = "Quick save failed: see totk.log",
|
||||
[UI_QS_LOAD_FAILED] = "Quick load failed: see totk.log",
|
||||
[UI_MENU_MOUSE_SENS] = "Mouse camera sensitivity",
|
||||
[UI_MENU_MOUSE_SENS_DESC] = "How fast the mouse turns the camera.",
|
||||
[UI_MENU_WALK_KEY] = "Walk key",
|
||||
@@ -917,6 +928,17 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "Пока открыто окно диалога, левый щелчок нажимает B (продолжает текст и пропускает его прокрутку), а правый — A, вместо назначенных им кнопок (по умолчанию Y, она открывает журнал диалога, и ZL). В вариантах ответа по-прежнему работает указатель: левый щелчок выбирает (версия игры 1.4.3).",
|
||||
[UI_MENU_POINTER_IMAGE] = "Игровой курсор",
|
||||
[UI_MENU_POINTER_IMAGE_DESC] = "Пока курсор не захвачен (меню игры, это меню, после Esc), окно показывает собственный золотой наконечник вместо системной стрелки, по масштабу экрана.",
|
||||
[UI_MENU_QUICKSAVE] = "Быстрое сохранение и загрузка",
|
||||
[UI_MENU_QUICKSAVE_DESC] = "Одна клавиша сразу сохраняет игру, другая загружает это сохранение (две строки ниже: по умолчанию F6 и F7, как в Half-Life), без всяких меню на экране. Только клавиатура и мышь, только версия игры 1.4.3. Быстрое сохранение просит игру сделать одно из её собственных автосохранений, поэтому заменяет самое старое автосохранение (ручное сохранение остаётся), держит его копию как быстрое сохранение (папка quicksave профиля) и пишет «Игра сохранена» вверху экрана. Быстрая загрузка держит картинку с надписью «Загрузка быстрого сохранения», пока за кадром проходит список загрузки игры, и игра загружает быстрое сохранение (около 5 с). Где игра сама не стала бы автосохраняться (сценка, диалог), ничего не сохраняется, и надпись говорит об этом.",
|
||||
[UI_MENU_QUICKSAVE_KEY] = "Клавиша быстрого сохранения",
|
||||
[UI_MENU_QUICKLOAD_KEY] = "Клавиша быстрой загрузки",
|
||||
[UI_MENU_QUICKSAVE_KEY_DESC] = "Клавиша, которая запускает быстрое сохранение или быструю загрузку; по умолчанию F6 и F7, как в Half-Life. Выберите ячейку и нажмите любую клавишу или кнопку мыши; Delete оставляет действие без клавиши. Пока быстрое сохранение включено, эти две клавиши больше ничего не делают (если клавиша занята в раскладке, это написано под значением). В totk.ini подходит любое имя клавиши из раскладки (quicksave_key, quickload_key).",
|
||||
[UI_QS_SAVED] = "Игра сохранена",
|
||||
[UI_QS_LOADING] = "Загрузка быстрого сохранения",
|
||||
[UI_QS_NOT_NOW] = "Сейчас быстрое сохранение невозможно",
|
||||
[UI_QS_NONE] = "Быстрого сохранения ещё нет (его делает клавиша быстрого сохранения)",
|
||||
[UI_QS_FAILED] = "Быстрое сохранение не удалось: см. totk.log",
|
||||
[UI_QS_LOAD_FAILED] = "Быстрая загрузка не удалась: см. totk.log",
|
||||
[UI_MENU_MOUSE_SENS] = "Чувствительность мыши",
|
||||
[UI_MENU_MOUSE_SENS_DESC] = "Как быстро мышь поворачивает камеру.",
|
||||
[UI_MENU_WALK_KEY] = "Клавиша шага",
|
||||
@@ -1671,6 +1693,17 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "Enquanto uma caixa de diálogo está aberta, o clique esquerdo aperta B (continua o texto e pula a rolagem) e o direito aperta A, em vez dos botões aos quais estão atribuídos (Y por padrão, que abre o registro do diálogo, e ZL). As escolhas de diálogo continuam com o ponteiro: o clique esquerdo escolhe (jogo 1.4.3).",
|
||||
[UI_MENU_POINTER_IMAGE] = "Ponteiro do jogo",
|
||||
[UI_MENU_POINTER_IMAGE_DESC] = "Enquanto o cursor não está capturado (os menus do jogo, este menu, depois de Esc), a janela mostra uma ponta de flecha dourada própria em vez da seta do sistema, no tamanho da escala da tela.",
|
||||
[UI_MENU_QUICKSAVE] = "Salvamento e carregamento rápidos",
|
||||
[UI_MENU_QUICKSAVE_DESC] = "Uma tecla salva o jogo na hora e outra carrega esse salvamento (as duas linhas abaixo: F6 e F7 por padrão, como no Half-Life), sem nenhum menu na tela. Só teclado e mouse, só o jogo 1.4.3. O salvamento rápido pede ao jogo um dos seus próprios salvamentos automáticos, então substitui o salvamento automático mais antigo (o salvamento manual fica), guarda uma cópia dele como salvamento rápido (a pasta quicksave do perfil) e mostra \"Jogo salvo\" no alto da imagem. O carregamento rápido segura a imagem em \"Carregando o salvamento rápido\" enquanto passa pela lista de carregamento do jogo fora de vista, e o jogo carrega o salvamento rápido (cerca de 5 s). Onde o próprio jogo não faria um salvamento automático (uma cena, um diálogo), nada é salvo e a linha avisa.",
|
||||
[UI_MENU_QUICKSAVE_KEY] = "Tecla de salvamento rápido",
|
||||
[UI_MENU_QUICKLOAD_KEY] = "Tecla de carregamento rápido",
|
||||
[UI_MENU_QUICKSAVE_KEY_DESC] = "A tecla que inicia o salvamento ou o carregamento rápido; F6 e F7 por padrão, como no Half-Life. Selecione a célula e aperte qualquer tecla ou botão do mouse; Delete deixa essa ação sem tecla. Com o salvamento rápido ligado, as duas teclas não fazem mais nada (uma nota aparece quando um mapeamento também usa a tecla). O totk.ini aceita qualquer nome de tecla dos mapeamentos (quicksave_key, quickload_key).",
|
||||
[UI_QS_SAVED] = "Jogo salvo",
|
||||
[UI_QS_LOADING] = "Carregando o salvamento rápido",
|
||||
[UI_QS_NOT_NOW] = "Salvamento rápido não é possível agora",
|
||||
[UI_QS_NONE] = "Ainda não há salvamento rápido (a tecla de salvamento rápido faz um)",
|
||||
[UI_QS_FAILED] = "O salvamento rápido falhou: veja o totk.log",
|
||||
[UI_QS_LOAD_FAILED] = "O carregamento rápido falhou: veja o totk.log",
|
||||
[UI_MENU_PROMPTS_MISSING] = "faltam os arquivos dos ícones: execute a instalação de novo",
|
||||
[UI_MENU_PROMPTS_FAILED] = "arquivos dos ícones danificados: execute a instalação de novo",
|
||||
[UI_MENU_PROMPTS_RESTART] = "os ícones mudam após reiniciar",
|
||||
@@ -2405,6 +2438,17 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "对话框打开时,鼠标左键按下 B 键(继续对话并跳过文字滚动),右键按下 A 键,而不是它们所绑定的按键(默认为 Y,会打开对话记录;以及 ZL)。对话选项仍使用指针:左键选择(游戏 1.4.3)。",
|
||||
[UI_MENU_POINTER_IMAGE] = "游戏指针",
|
||||
[UI_MENU_POINTER_IMAGE_DESC] = "光标未被捕获时(游戏菜单、本菜单、按 Esc 之后),窗口显示自带的金色箭头,而不是系统箭头,大小随屏幕缩放。",
|
||||
[UI_MENU_QUICKSAVE] = "快速存档与读档",
|
||||
[UI_MENU_QUICKSAVE_DESC] = "一个键立即保存游戏,另一个键读取该存档(见下方两行:默认 F6 和 F7,与 Half-Life 相同),屏幕上不会出现任何菜单。仅限键盘和鼠标按键,仅限游戏 1.4.3。快速存档会让游戏自己进行一次自动存档,因此会替换最旧的自动存档(手动存档保留),并将其副本保存为快速存档(配置文件中的 quicksave 文件夹),画面顶部显示“游戏已保存”。快速读档时画面停留在“正在读取快速存档”,同时在后台走完游戏的读档列表,游戏随即读取快速存档(约 5 秒)。在游戏本身不会自动存档的地方(过场动画、对话),不会保存,并会显示提示。",
|
||||
[UI_MENU_QUICKSAVE_KEY] = "快速存档键",
|
||||
[UI_MENU_QUICKLOAD_KEY] = "快速读档键",
|
||||
[UI_MENU_QUICKSAVE_KEY_DESC] = "启动快速存档或快速读档的按键;默认 F6 和 F7,与 Half-Life 相同。选中该格后按下任意键盘按键或鼠标按键;按 Delete 则该操作没有按键。快速存档开启时,这两个键不再有其他作用(若按键映射也使用该键,值下方会有提示)。totk.ini 接受按键映射中的任意按键名(quicksave_key、quickload_key)。",
|
||||
[UI_QS_SAVED] = "游戏已保存",
|
||||
[UI_QS_LOADING] = "正在读取快速存档",
|
||||
[UI_QS_NOT_NOW] = "现在无法快速存档",
|
||||
[UI_QS_NONE] = "还没有快速存档(按快速存档键创建)",
|
||||
[UI_QS_FAILED] = "快速存档失败:请查看 totk.log",
|
||||
[UI_QS_LOAD_FAILED] = "快速读档失败:请查看 totk.log",
|
||||
[UI_MENU_PROMPTS_MISSING] = "缺少按键提示文件:请重新运行安装程序",
|
||||
[UI_MENU_PROMPTS_FAILED] = "按键提示文件已损坏:请重新运行安装程序",
|
||||
[UI_MENU_PROMPTS_RESTART] = "按键提示重启后生效",
|
||||
|
||||
@@ -147,6 +147,8 @@ typedef enum {
|
||||
UI_MENU_MAP_CLICK, UI_MENU_MAP_CLICK_DESC,
|
||||
UI_MENU_DIALOGUE_CLICK, UI_MENU_DIALOGUE_CLICK_DESC,
|
||||
UI_MENU_POINTER_IMAGE, UI_MENU_POINTER_IMAGE_DESC,
|
||||
UI_MENU_QUICKSAVE, UI_MENU_QUICKSAVE_DESC, UI_MENU_QUICKSAVE_KEY, UI_MENU_QUICKLOAD_KEY, UI_MENU_QUICKSAVE_KEY_DESC,
|
||||
UI_QS_SAVED, UI_QS_LOADING, UI_QS_NOT_NOW, UI_QS_NONE, UI_QS_FAILED, UI_QS_LOAD_FAILED,
|
||||
UI_MENU_MOUSE_SENS, UI_MENU_MOUSE_SENS_DESC,
|
||||
UI_MENU_WALK_KEY, UI_MENU_WALK_KEY_DESC, UI_MENU_WALK_KEY_TAKEN, UI_MENU_WALK_SCALE, UI_MENU_WALK_SCALE_DESC,
|
||||
|
||||
|
||||
@@ -600,6 +600,11 @@ void gameplay_tweaks_apply(uint64_t f, int a, uint64_t *b, int32_t *lx, int32_t
|
||||
(void)f; (void)a; (void)b; (void)lx; (void)ly; (void)rx; (void)ry;
|
||||
}
|
||||
int cfg_bool(const char *key) { (void)key; abort(); }
|
||||
int quicksave_on(void) { return 0; }
|
||||
void quicksave_keys(uint8_t *d, int act) { (void)d; (void)act; abort(); }
|
||||
void quicksave_request(int load) { (void)load; abort(); }
|
||||
int quicksave_poll(uint64_t *b, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry) { (void)b;(void)lx;(void)ly;(void)rx;(void)ry; abort(); }
|
||||
int quicksave_busy(void) { return 0; }
|
||||
int input_menu_gate(int *h,int open,uint64_t *b,int32_t s[4]) { (void)h;(void)open;(void)b;(void)s;abort(); }
|
||||
int input_overlay_gate(int *h,uint64_t *b) { (void)h;(void)b;abort(); }
|
||||
int menu_is_open(void) { abort(); }
|
||||
|
||||
@@ -440,6 +440,20 @@
|
||||
# Esc). 1: a gold arrowhead with a dark edge and a turquoise gem, drawn by the port at the window's DPI, instead of
|
||||
# the system arrow. 0 (the default) keeps the system arrow. Changes while the game runs.
|
||||
# pointer_image = 0
|
||||
# Quick save and quick load, 1.4.3 only. 1: quicksave_key saves the game at once and quickload_key loads that save
|
||||
# (F6 and F7 by default, as in Half-Life), with no menu on the screen. Quick save makes one of the game's own
|
||||
# autosaves and keeps a copy of it in the profile's quicksave folder; quick load loads that copy through the game's
|
||||
# load list, which runs out of sight (the picture holds on "Loading the quick save" for about 5 s).
|
||||
# "Game saved" shows at the top of the picture. Where the game would not autosave itself (a cutscene, an event, a
|
||||
# fight), or while a menu or a dialogue box is open, nothing is saved and the line says so. A quick save replaces the
|
||||
# oldest autosave, as the game's own autosaves do; the manual save is not touched. Keyboard and mouse keys only.
|
||||
# While it is on, the two keys do nothing else. 0 (the default) leaves both keys alone. Changes while the game runs.
|
||||
# quicksave = 0
|
||||
# The keys of quick save and quick load: a key name of the bind_ lines below (f2-f7 f9 f12, letters, mouse buttons,
|
||||
# ...) or none; the Controls tab sets them by pressing the key. An unknown name is logged and the default is used.
|
||||
# Changes while the game runs.
|
||||
# quicksave_key = f6
|
||||
# quickload_key = f7
|
||||
# Mouse camera sensitivity (0 to 10; 0 = no mouse camera and no cursor capture). With mouse_mode = direct, 1 turns the
|
||||
# camera 0.08 degrees per count, the same in every camera mode (about 14.3 cm a turn at 800 DPI).
|
||||
# mouse_sens = 1
|
||||
|
||||
Reference in new issue
Block a user