From 7bd1c539bda02c2a031e045fe5b515fe76e0169f Mon Sep 17 00:00:00 2001 From: itaskaev2 <165683571+itaskaev2@users.noreply.github.com> Date: Sun, 15 Nov 2026 17:23:15 +0100 Subject: [PATCH] Quick save and quick load with no menu on the screen F6 asks the game for its own autosave, as the sequence node OneShotAutoSaveMgrRequestAutoSave does, after the game's own check (its wait between autosaves skipped), from the pad read: the game itself makes that request from several threads. The slot the commit wrote is copied to /quicksave; a request the game holds back for 5 s is taken back. F7 holds the window on its last picture, runs the game's load list underneath and, from the confirmation until the load is over, opens the quick save's files for every read of a slot folder. A toast at the top of the picture says what happened. The two keys are set on the Controls tab by pressing them. Keyboard and mouse keys only, game 1.4.3. Co-Authored-By: Claude Opus 5.5 --- docs/controls.md | 17 ++ docs/settings.md | 3 + runtime/cfg.c | 6 +- runtime/fs.h | 6 + runtime/fs_host.c | 74 +++++- runtime/gfx.h | 1 + runtime/gfx_present.c | 6 + runtime/input.c | 15 +- runtime/input.h | 21 ++ runtime/menu_cursor.c | 100 ++++++++ runtime/ov_input.c | 1 + runtime/quicksave.c | 446 ++++++++++++++++++++++++++++++++++++ runtime/ui/binds_page.cpp | 41 +++- runtime/ui/binds_page.h | 7 + runtime/ui/menu.cpp | 73 +++++- runtime/ui/menu.h | 1 + runtime/ui_text.c | 44 ++++ runtime/ui_text.h | 2 + tests/mouse_direct_check.py | 5 + totk.ini.example | 14 ++ 20 files changed, 863 insertions(+), 20 deletions(-) create mode 100644 runtime/quicksave.c diff --git a/docs/controls.md b/docs/controls.md index 8f41313d..963b8c1a 100644 --- a/docs/controls.md +++ b/docs/controls.md @@ -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: `/quicksave/slot`, with the slot's name in `/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/`) 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 @ MOUSE WHEEL # scroll wheel notches, once; + away from the player @ WHEEL + QUICKSAVE|QUICKLOAD # quicksave = 1's save or load key, once +@ QUICKSAVE|QUICKLOAD ``` `` 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. `@` 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. diff --git a/docs/settings.md b/docs/settings.md index 1b0193fe..8a50cd6f 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -86,6 +86,9 @@ Many rows below are developer tools that only act together with another setting | Setting | What it does | Effect of changing it | Safety | | --- | --- | --- | --- | | `bind_