Add PlayStation button prompts (#180)

prompts = playstation shows the face buttons as circle, cross, triangle and square, L1 R1 L2 R2, Options and Share.
The setup writes romfs-patches-playstation (pad_layout = nintendo) and romfs-patches-playstation-xbox (xbox, auto) on
every install, next to the Xbox folders, and the Shapes step and the settings menu make their shaped folders like the
other styles. playstation-xbox lays the action prompt's diamond out as xbox-label does, cross at the bottom.

Rebased onto dev from pull request #741 by fabiomode2: the shaped folders, hud_width, the Xbox diamond and the
keyboard prompts' text glyphs of dev are kept, and cfg.c's shape default uses input_prompts_folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
fabiomode2andClaude Opus 5.5 authored and Valiantsin Dzerakh committed 2026-11-18 18:10:32 +03:00
1 parent 13ff0d7b52
commit bae687a10d
24 files changed
+465 -171

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@ Report problems as issues, following [CONTRIBUTING.md](CONTRIBUTING.md).
- Setup and in-game menu in English, Russian, Brazilian Portuguese and Simplified Chinese
- Keyboard, mouse and gamepad with remapping, rumble and gyro
- Stereo or 5.1 surround sound output
- Xbox button prompts: LB, RB, LT, RT, Menu and View, and A, B, X and Y as labelled on the button to press, with either button layout
- Xbox and PlayStation button prompts: Xbox's LB, RB, LT, RT, Menu, View and A, B, X, Y, or PlayStation's ○ × △ □, L1, R1, L2, R2, Options and Share, as labelled on the button to press, with either button layout
- Shaders prepared at install instead of during play
- Mods made for emulators: unpack a mod into the `mods` folder next to `totk.exe`; switch and order them in the menu. RomFS
mods, TKMM's merged output and ExeFS code patches (`.ips`, `.pchtxt`) work; the game rebuilds itself for code patches
+7 -5
View File
@@ -122,13 +122,15 @@ of them.
reason, and `--full-build` compiles everything.
`--patches` builds in the frame-rate, resolution and other patch sets, switchable at run time. The link copies
`SDL3.dll`, `libiconv-2.dll` and `libopus-0.dll` next to the exe.
For Xbox button prompts, run `make_romfs_patches.py` twice more, with `--prompts xbox` and `--prompts xbox-label`:
they write `build\<ver>\romfs-patches-xbox` and `romfs-patches-xbox-label` ([controls.md](controls.md), "Xbox
button prompts"), which `build_game.py` copies next to `totk.exe` like `romfs-patches`. `--prompts pc` writes
`romfs-patches-pc`, the keyboard and mouse prompts ([controls.md](controls.md), "PC button prompts").
For Xbox and PlayStation button prompts, run `make_romfs_patches.py` twice more for each, with `--prompts xbox`,
`--prompts xbox-label`, `--prompts playstation` and `--prompts playstation-xbox`: they write
`build\<ver>␍omfs-patches-xbox`, `-xbox-label`, `-playstation` and `-playstation-xbox`
([controls.md](controls.md), "Xbox and PlayStation button prompts"), which `build_game.py` copies next to `totk.exe`
like `romfs-patches`. `--prompts pc` writes `romfs-patches-pc`, the keyboard and mouse prompts
([controls.md](controls.md), "PC button prompts").
`--aspect <w>x<h>` writes the UI laid out for a game resolution of another shape; with `--hud 16:9` or `--hud 21:9`
(a screen wider than that) the HUD stays within the middle 16:9 or 21:9 instead of the screen's corners. The default
`--out` then is `build\<ver>\romfs-patches-<w>x<h>-hud16x9` (`-hud21x9`), which the game loads for `hud_width = 16:9`
`--out` then is `build\<ver>␍omfs-patches-<w>x<h>-hud16x9` (`-hud21x9`), which the game loads for `hud_width = 16:9`
(`21:9`) in `totk.ini` ([totk.ini.example](../totk.ini.example)).
Setup's Shapes step builds only the currently selected cap for the canonical shapes needed by connected displays
and `output_res`, together with the selected prompts. `full` generates no capped folders. After changing the HUD
+22 -6
View File
@@ -8,7 +8,7 @@ Input comes from the first SDL3 gamepad, the keyboard and the mouse, merged into
- `xbox`: south A, east B, west X, north Y, as an Xbox pad labels them; on a PlayStation pad cross is A, circle B, square X, triangle Y.
- `auto` (default): `nintendo` for a pad whose east button SDL reports labelled A (Switch Pro Controller, Nintendo-layout pads), `xbox` for the others.
The log names the layout in effect (`input: gamepad layout ...`); the menu shows it under *Automatic*. Which controller's buttons the game's prompts show is `TOTK_PROMPTS` (see Xbox button prompts below). 0.1.9's `pad_layout = xbox_prompts` is read as `pad_layout = nintendo` with `prompts = xbox`, and the menu writes it that way.
The log names the layout in effect (`input: gamepad layout ...`); the menu shows it under *Automatic*. Which controller's buttons the game's prompts show is `TOTK_PROMPTS` (see Button prompts below). 0.1.9's `pad_layout = xbox_prompts` is read as `pad_layout = nintendo` with `prompts = xbox`, and the menu writes it that way.
| Switch | Gamepad (by position, Nintendo layout) | Keyboard and mouse | Action in the world |
|---|---|---|---|
@@ -31,9 +31,9 @@ The log names the layout in effect (`input: gamepad layout ...`); the menu shows
Esc is unbound in the game; it opens the settings menu and releases the mouse cursor (see Mouse camera). Z and X duplicate ZL and ZR so menu pages turn with two neighbouring keys; the menu tabs (L, R) are Q and R. T duplicates Y for the game's menus, where the left mouse button is A while the pointer is shown (sort the inventory with T). The mouse wheel zooms the Purah Pad's map and its camera, steps the game's menus and the d-pad strips (see Mouse in the game's menus), and is unbound elsewhere. The bindings are the tables of `input_map` in `runtime/input_map.c`: the keys (platform-neutral key ids) and one gamepad table per layout (gamepad inputs by position); `runtime/input_win.c` translates Win32 virtual keys and SDL buttons.
## Xbox button prompts
## Xbox and PlayStation button prompts
`TOTK_PROMPTS` (`prompts`, the *Button prompts* row on the Controls tab, read at start) picks the controller whose buttons the game's prompts show: `nintendo` (default) keeps the game's own, `xbox` shows an Xbox controller's, `pc` the keyboard and mouse (PC button prompts, below).
`TOTK_PROMPTS` (`prompts`, the *Button prompts* row on the Controls tab, read at start) picks the controller whose buttons the game's prompts show: `nintendo` (default) keeps the game's own, `xbox` shows an Xbox controller's, `playstation` a PlayStation controller's, `pc` the keyboard and mouse (PC button prompts, below).
- L, R, ZL, ZR, Plus and Minus become LB, RB, LT, RT, Menu and View, and the d-pad prompts a cross with an arrow for each direction meant. The letters on the keys are cut out in the game's own text font.
- A, B, X and Y name the label of the button the pad layout presses, so each prompt names the button to press. `pad_layout = nintendo` plays an Xbox pad by position: the right button, labelled B, does Switch A (interact, confirm), and the bottom one, labelled A, does Switch B (run, cancel), so the prompts swap A with B and X with Y. `xbox` and `auto` put Switch A on the button labelled A, and the letters stay.
@@ -48,16 +48,32 @@ Esc is unbound in the game; it opens the settings menu and releases the mouse cu
The action prompt (`DoCommand_00`) shows its button in a diamond whose shape gives the face buttons' positions as on a Switch, with the other three letters around it. With `nintendo` its letters are swapped with the rest and every one names the button in that place. With `xbox` and `auto` the letters stay and the diamond is laid out as an Xbox pad: A at the bottom, B on the right, X on the left and Y at the top, the button the prompt names lit in its place, its bar reaching left from X and right from the others (`tools/make_romfs_patches.py`, `bflyt_xbox_diamond`: the panes of `blyt/DoCommand_00.bflyt` take their partner's place, A's of B and X's of Y). The sticks keep the Switch icons, and so do prompts drawn as fixed images (some tutorial animations).
The prompts are part of the game's fonts, textures and messages, so they follow the layout and not the bindings. A button remapped with a `bind_` line or on the Controls tab keeps the prompt the game draws for it, which then names the wrong button. Use the Xbox prompts with the default bindings.
### PlayStation
`prompts = playstation` shows a PlayStation pad's buttons: the face buttons as ○ (circle), × (cross), △ (triangle) and □ (square), L1, R1, L2 and R2 on the shoulders and triggers, Options and Share on Plus and Minus, and the d-pad as a cross. Each prompt names the button to press, so the shapes follow `pad_layout`:
| Switch | `nintendo` layout | `xbox` or `auto` layout |
|---|---|---|
| A, B, X, Y | ○, ×, △, □ | ×, ○, □, △ |
| L, R | L1, R1 | L1, R1 |
| ZL, ZR | L2, R2 | L2, R2 |
| Plus, Minus | Options, Share | Options, Share |
| D-pad | cross | cross |
The game's text fonts already have the four shapes (U+25CB, U+00D7, U+25B3 and U+25A1), so the action prompt's diamond uses them as text; the action prompt's button image and the button guide's images are drawn with the same shapes. The game loads `romfs-patches-playstation` (`pad_layout = nintendo`) or `romfs-patches-playstation-xbox` (`xbox`, `auto`) in place of `romfs-patches`; the setup writes both with `tools/make_romfs_patches.py --prompts playstation` and `--prompts playstation-xbox` (`tools/button_icons.py`, `playstation_icons`). With `xbox` and `auto` the diamond is laid out as for the Xbox prompts: × at the bottom, ○ on the right, □ on the left and △ at the top. At a game resolution of another shape the prompts follow the shape's UI layout as the Xbox ones do (below).
The prompts are part of the game's fonts, textures and messages, so they follow the layout and not the bindings. A button remapped with a `bind_` line or on the Controls tab keeps the prompt the game draws for it, which then names the wrong button. Use the Xbox or PlayStation prompts with the default bindings.
The game reads its UI archive and fonts once at boot, so the prompts change at the next start, also after `pad_layout` changes between `nintendo` and the others (the menu says *prompts change after restart*); the buttons change at once. Under that note the menu offers *Restart now*: after a confirmation it writes `totk.ini`, closes the game as *Quit game* does and starts the game again with the same command line, which waits until the old process is gone before it opens the log and the saves (`runtime/gfx_present.c`, `gfx_window_closed`; `plat_restart` and `plat_restart_wait` in `runtime/platform/win32.c` and `linux.c`). Progress since the last save is lost, as with *Quit game*; while the game writes a save, the confirmation waits. With `prompts = xbox` the game loads `romfs-patches-xbox` (`pad_layout = nintendo`) or `romfs-patches-xbox-label` (`xbox`, `auto`) next to `romfs-index.bin` in place of `romfs-patches` (`runtime/romfs.c`, `overlay_init`; `runtime/input_map.c`, `input_prompts_folder`): the same 60 fps patches, with the prompts drawn from the game's own files by `tools/make_romfs_patches.py --prompts xbox` or `--prompts xbox-label` (`tools/button_icons.py`, after MacNativeGames' `make_button_icons.py`), which the setup runs next to the plain one:
- every prompt but the button guide in play is text in the button font, `scft/External.bfotf` in each `Font/Font*.Nin_NX_NVN.bfarc.zs`: glyphs U+E040 to U+E043 (A B X Y), U+E044 to U+E047 (L R ZL ZR), U+E04B and U+E04C (Plus, Minus), U+E049 and U+E060 to U+E065 (the d-pad). fontTools writes the font again, so the archives grow and the folder also carries the resource size table (`System/Resource/ResourceSizeTable.Product.<n>...rsizetable.zs`) with their entries raised by as much; without that the game stops at start.
- the button guide in play draws L and ZL from the images `Nt_KeyTexL_00` and `Nt_KeyTexZL_00` of the Common archive's `timg/__Combined.bntx`, painted with the same icons. The action prompt draws its button from `Nt_KeyTexA/B/X/Y_00`, whose image data is swapped for `nintendo`, and the diamond's letters are text the game takes from `LayoutMsg/DoCommand_00.msbt` of each language's `Mals` archive (and the layout's own text panes behind it), swapped the same way.
The Switch prompts stay, with a note under *Button prompts* and a `RomFS overlay: ...` line in the log, when the folder is missing (an install made by an older setup, or one where the setup could not prepare it and showed a warning; running the setup again on the install folder writes it), when it fails its check, with a game resolution of another shape than 16:9 that has no folder of its own (below), and when the `romfs_mods` folder replaces one of its files: `romfs-patches` then loads in its place, where two overlays replacing one file would stop the game. In a source build, `.venv-py314\Scripts\python tools\make_romfs_patches.py --version <ver> --prompts xbox` (and `--prompts xbox-label`) writes `build\<ver>\romfs-patches-xbox` (`-label`); it needs fontTools from `tools/requirements-py314.txt`. `--xbox-prompts` is the older name of `--prompts xbox`.
With `prompts = playstation` the game loads `romfs-patches-playstation` (`pad_layout = nintendo`) or `romfs-patches-playstation-xbox` (`xbox`, `auto`) the same way, written by `tools/make_romfs_patches.py --prompts playstation` and `--prompts playstation-xbox`: the same 60 fps patches, with the face buttons' images and the diamond's letters drawn as ○ × △ □, the shoulders and triggers as L1 R1 L2 R2, Options and Share, and the button guide's L and ZL images. The game's text fonts already have the four shapes, so the diamond's panes and messages hold those characters instead of the letters.
At a game resolution of another shape than 16:9 the game loads `romfs-patches-xbox-<w>x<h>` (or `romfs-patches-xbox-label-<w>x<h>`) in place of `romfs-patches-<w>x<h>`: the same prompts with that shape's UI layout, `make_romfs_patches.py --prompts xbox --aspect <w>x<h> --reuse <install>\romfs-patches-xbox --out <install>\romfs-patches-xbox-<w>x<h>`. The setup writes both for each of the fifteen sizes it lays the UI out for, as for the PC prompts below, so on a display of one of those shapes the game resolution follows the display with these prompts too. At another size, without that folder, the Switch prompts stay (*off at this game resolution*).
The Switch prompts stay, with a note under *Button prompts* and a `RomFS overlay: ...` line in the log, when the folder is missing (an install made by an older setup, or one where the setup could not prepare it and showed a warning; running the setup again on the install folder writes it), when it fails its check, with a game resolution of another shape than 16:9 that has no folder of its own (below), and when the `romfs_mods` folder replaces one of its files: `romfs-patches` then loads in its place, where two overlays replacing one file would stop the game. In a source build, `.venv-py314\Scripts\python tools\make_romfs_patches.py --version <ver> --prompts xbox` (and `--prompts xbox-label`) writes `build\<ver>␍omfs-patches-xbox` (`-label`); `--prompts playstation` and `--prompts playstation-xbox` write `build\<ver>␍omfs-patches-playstation` and `-playstation-xbox` the same way. It needs fontTools from `tools/requirements-py314.txt`. `--xbox-prompts` is the older name of `--prompts xbox`.
At a game resolution of another shape than 16:9 the game loads `romfs-patches-<style>-<w>x<h>` (`romfs-patches-xbox-<w>x<h>`, `-xbox-label-`, `-playstation-` or `-playstation-xbox-`) in place of `romfs-patches-<w>x<h>`: the same prompts with that shape's UI layout, `make_romfs_patches.py --prompts <style> --aspect <w>x<h> --reuse <install>␍omfs-patches-<style> --out <install>␍omfs-patches-<style>-<w>x<h>`. The setup writes it for the shapes of the connected displays and `output_res`, for the selected prompts only (installer Shapes step), as for the PC prompts below. At another size, without that folder, the Switch prompts stay (*off at this game resolution*).
## PC button prompts
+5 -3
View File
@@ -90,12 +90,14 @@ loads the saves 1.4.3 wrote.
`totk.exe --prepare-shaders`) in the install folder, then fold the shader cache's loose files (four per shader, about
117,000) into `shader-cache/shader-cache.pack` (`tools/pack_shader_cache.py`). totk.exe reads the pack first and
writes the translations it makes in play as loose files; running the tool again with the game closed folds those in.
The patches are written three times: `romfs-patches`, `romfs-patches-xbox` and `romfs-patches-xbox-label`
The patches are written five times: `romfs-patches`, `romfs-patches-xbox` and `romfs-patches-xbox-label`
(`--prompts`: Xbox button prompts for `prompts = xbox`, the first for `pad_layout = nintendo`, the second for `xbox`
and `auto`). The prompt folders are optional: when one cannot be made, the setup warns and finishes.
and `auto`), `romfs-patches-playstation` and `romfs-patches-playstation-xbox` (PlayStation prompts for
`prompts = playstation`, the same split). The prompt folders are optional: when one cannot be made, the setup warns
and finishes.
**PC prompts** (step `pc_prompts`): `romfs-patches-pc`, the keyboard and mouse prompts for `prompts = pc`, drawn
from the `bind_` lines of `totk.ini` (`--binds`). Its key holds those lines, so a setup run after a change of the
bindings draws only these again. Optional like the Xbox prompts. All four 16:9 folders are always written, so a
bindings draws only these again. Optional like the Xbox prompts. All six 16:9 folders are always written, so a
switch of the prompts style at 16:9 needs no setup run.
When the graphics driver crashes while building the shaders, `prepare_shaders.py` runs that part again without the
variants it was building ([building.md](building.md), step 6), and the setup finishes with a warning that names how
+16 -6
View File
@@ -140,16 +140,26 @@ def ini_value(text, name):
return value
# The pad prompts' folder suffixes (make_romfs_patches.py --prompts), each written at 16:9 on every install
# (steps.Prepare): the Xbox and PlayStation ones, for the Nintendo pad layout and for xbox and auto
PAD_PROMPTS = ('xbox', 'xbox-label', 'playstation', 'playstation-xbox')
# Every prompts folder suffix: the pad ones and the keyboard and mouse one (steps.PcPrompts)
PROMPTS_STYLES = PAD_PROMPTS + ('pc',)
def prompts_style(text):
"""The prompts' folder suffix the settings select, as runtime/input_map.c input_prompts_pick and
input_prompts_folder pick it at start: 'pc', 'xbox' (Nintendo pad layout), 'xbox-label' (any other) or None for the
game's own prompts, the default without a totk.ini."""
p, layout = ini_value(text, 'prompts'), (ini_value(text, 'pad_layout') or '').lower()
if p and p.lower() == 'pc':
input_prompts_folder pick it at start: 'pc', 'xbox' or 'playstation' (Nintendo pad layout), 'xbox-label' or
'playstation-xbox' (any other), or None for the game's own prompts, the default without a totk.ini."""
p, layout = (ini_value(text, 'prompts') or '').lower(), (ini_value(text, 'pad_layout') or '').lower()
if p == 'pc':
return 'pc'
if not (p.lower() == 'xbox' if p else layout == 'xbox_prompts'):
nintendo = layout in ('nintendo', 'xbox_prompts')
if p in ('playstation', 'ps'):
return 'playstation' if nintendo else 'playstation-xbox'
if not (p == 'xbox' if p else layout == 'xbox_prompts'):
return None
return 'xbox' if layout in ('nintendo', 'xbox_prompts') else 'xbox-label'
return 'xbox' if nintendo else 'xbox-label'
def wanted(dest, screens=None):
+9 -6
View File
@@ -1303,14 +1303,15 @@ class Prepare(Step):
dest / 'romfs-patches'])
if code:
raise InstallError('prepare.romfs_patches_failed', code=code, log=str(log))
# The same with Xbox button icons in the prompts, for prompts = xbox (make_romfs_patches.py --prompts):
# romfs-patches-xbox for the Nintendo pad layout, romfs-patches-xbox-label for xbox and auto (runtime/input_map.c
# input_prompts_folder). Both are written on every install, so the menu choices work without another run of
# The same with Xbox and PlayStation button icons in the prompts, for prompts = xbox and playstation
# (make_romfs_patches.py --prompts): romfs-patches-xbox for the Nintendo pad layout, romfs-patches-xbox-label
# for xbox and auto, and romfs-patches-playstation / -playstation-xbox likewise (runtime/input_map.c
# input_prompts_folder). All are written on every install, so the menu choices work without another run of
# the setup. Optional: when one fails, the game keeps the Switch prompts with that layout and the menu says the
# files are missing, so the setup warns once and goes on. The keyboard and mouse prompts are the PcPrompts
# step's: they follow totk.ini's bindings.
failed = None
for style in ('xbox', 'xbox-label'):
for style in screens.PAD_PROMPTS:
out = dest / f'romfs-patches-{style}'
remove(out)
code, log = run_tool(ctx, f'prepare-{style}', layout.tools / 'make_romfs_patches.py',
@@ -1407,7 +1408,8 @@ class PcPrompts(Step):
# ---- 6b. screen shapes
SHAPED_FOLDER = re.compile(r'^romfs-patches(?:-xbox|-xbox-label|-pc)?-\d+x\d+(?:-hud(?:16|21)x9)?$')
SHAPED_FOLDER = re.compile(r'^romfs-patches(?:-(?:%s))?-\d+x\d+(?:-hud(?:16|21)x9)?$'
% '|'.join(map(re.escape, screens.PROMPTS_STYLES)))
def hud_width(dest):
@@ -1428,7 +1430,8 @@ def shape_hud(size, hud):
class Shapes(Step):
"""romfs-patches-<w>x<h> (the UI laid out for a shape, make_romfs_patches.py --aspect) and, with Xbox or PC prompts
"""romfs-patches-<w>x<h> (the UI laid out for a shape, make_romfs_patches.py --aspect) and, with Xbox, PlayStation or
PC prompts
in totk.ini, romfs-patches-<style>-<w>x<h> (that layout with those prompts), for the shapes this player needs:
those of the connected displays and of the totk.ini output_res, one folder per shape (installer/screens.py; the
game maps its resolution to the folder in runtime/romfs.c overlay_init). A setup before this step wrote all 15
+1 -1
View File
@@ -113,7 +113,7 @@
"warn.cheats_skipped": "The cheats of the mods folder that change the game's code could not be built; the game installs without them. Details: {log}",
"warn.exefs_skipped": "The mods' ExeFS patches (.ips, .pchtxt) could not be built; the game installs without them. Details: {log}",
"warn.plugins_skipped": "The mods' code plugins (exefs subsdk) could not be built; the game installs without them. Details: {log}",
"warn.xbox_prompts_failed": "The Xbox or PC button prompts could not be prepared (exit code {code}); the game keeps the Switch prompts. Details: {log}",
"warn.xbox_prompts_failed": "The Xbox, PlayStation or PC button prompts could not be prepared (exit code {code}); the game keeps the Switch prompts. Details: {log}",
"warn.shaders_skipped": "The graphics driver crashed while building some shaders, so {count} were left out of the preparation. The game builds them when it first needs them, and the driver may crash there too; a driver update may fix it. Details: {log}",
"warn.kernel_old": "Linux {version} lacks the write tracking the game relies on (6.7 or later); the game may run very slowly. Updating the system fixes this.",
"warn.dlss_kept": "A DLSS library is already in the install folder ({path}); the setup keeps it.",
+1 -1
View File
@@ -113,7 +113,7 @@
"warn.exefs_skipped": "Não foi possível compilar os patches ExeFS dos mods (.ips, .pchtxt); o jogo é instalado sem eles. Detalhes: {log}",
"warn.plugins_skipped": "Não foi possível compilar os plugins de código dos mods (exefs subsdk); o jogo é instalado sem eles. Detalhes: {log}",
"warn.npdm_differs": "O main.npdm difere do dump de referência da versão {version}; só os módulos de código são usados.",
"warn.xbox_prompts_failed": "Não foi possível preparar os ícones de botão do Xbox ou do PC (código de saída {code}); o jogo mantém os ícones do Switch. Detalhes: {log}",
"warn.xbox_prompts_failed": "Não foi possível preparar os ícones de botão do Xbox, do PlayStation ou do PC (código de saída {code}); o jogo mantém os ícones do Switch. Detalhes: {log}",
"warn.shaders_skipped": "O driver gráfico travou ao compilar alguns shaders, então {count} ficaram fora da preparação. O jogo os compila quando precisar deles pela primeira vez, e o driver pode travar ali também; uma atualização do driver pode resolver. Detalhes: {log}",
"warn.kernel_old": "O Linux {version} não tem o rastreamento de escrita de que o jogo depende (6.7 ou mais novo); o jogo pode rodar muito devagar. Atualizar o sistema resolve.",
"warn.dlss_kept": "Já existe uma biblioteca DLSS na pasta de instalação ({path}); a instalação a mantém.",
+1 -1
View File
@@ -113,7 +113,7 @@
"warn.cheats_skipped": "Не удалось собрать читы из папки модов, меняющие код игры; игра установится без них. Подробности: {log}",
"warn.exefs_skipped": "Не удалось собрать ExeFS-патчи модов (.ips, .pchtxt); игра установится без них. Подробности: {log}",
"warn.plugins_skipped": "Не удалось собрать плагины кода модов (exefs subsdk); игра установится без них. Подробности: {log}",
"warn.xbox_prompts_failed": "Не удалось подготовить подсказки кнопок Xbox или PC (код выхода {code}); игра оставит подсказки Switch. Подробности: {log}",
"warn.xbox_prompts_failed": "Не удалось подготовить подсказки кнопок Xbox, PlayStation или PC (код выхода {code}); игра оставит подсказки Switch. Подробности: {log}",
"warn.shaders_skipped": "Графический драйвер аварийно завершился при сборке части шейдеров, поэтому {count} из них пропущены при подготовке. Игра соберёт их, когда они впервые понадобятся, и драйвер может упасть и там; обновление драйвера может это исправить. Подробности: {log}",
"warn.kernel_old": "В Linux {version} нет отслеживания записи, на которое опирается игра (нужна версия 6.7 или новее); игра может работать очень медленно. Обновление системы это исправит.",
"warn.dlss_kept": "В папке установки уже есть библиотека DLSS ({path}); установка её оставляет.",
+1 -1
View File
@@ -113,7 +113,7 @@
"warn.exefs_skipped": "无法构建模组的 ExeFS 补丁(.ips、.pchtxt);游戏将不含它们进行安装。详情:{log}",
"warn.plugins_skipped": "无法构建模组的代码插件(exefs subsdk);游戏将不含它们进行安装。详情:{log}",
"warn.npdm_differs": "main.npdm 与参考的 {version} 导出不同;只使用其中的代码模块。",
"warn.xbox_prompts_failed": "无法准备 Xbox 或 PC 按键提示(退出代码 {code});游戏将继续使用 Switch 按键提示。详情:{log}",
"warn.xbox_prompts_failed": "无法准备 Xbox、PlayStation 或 PC 按键提示(退出代码 {code});游戏将继续使用 Switch 按键提示。详情:{log}",
"warn.shaders_skipped": "显卡驱动在编译部分着色器时崩溃,因此有 {count} 个着色器未被预先准备。游戏会在首次需要时编译它们,驱动在那时也可能崩溃;更新驱动可能会解决。详情:{log}",
"warn.kernel_old": "Linux {version} 缺少游戏依赖的写入跟踪功能(需要 6.7 或更新版本);游戏可能运行得很慢。更新系统即可解决。",
"warn.dlss_kept": "安装文件夹中已有 DLSS 库({path});安装程序将保留它。",
+18 -18
View File
@@ -14,6 +14,7 @@
#include "cfg.h"
#include "host.h"
#include "input_map.h"
#include "platform/platform.h"
#define PREFIX "TOTK_"
@@ -177,7 +178,7 @@ static const CfgMeta metas[] = {
{"GYRO_BIAS_X", "", NULL, RESTART}, {"GYRO_BIAS_Y", "", NULL, RESTART}, {"GYRO_BIAS_Z", "", NULL, RESTART},
{"GYRO_BIAS_PAD", "", NULL, RESTART},
{"RUMBLE_TRIGGERS", "0", "0|1", LIVE}, {"PAD_LAYOUT", "auto", "auto|nintendo|xbox", LIVE},
{"PROMPTS", "nintendo", "nintendo|xbox|pc", RESTART},
{"PROMPTS", "nintendo", "nintendo|xbox|playstation|pc", RESTART},
{"STICK_DEADZONE", "8", "0..50", LIVE}, {"STICK_SENS", "1", "0.1..3", RESTART},
{"LSTICK_DEADZONE", "", "0..50", LIVE}, {"RSTICK_DEADZONE", "", "0..50", LIVE},
{"MOUSE_MODE", "direct", "stick|direct", LIVE},
@@ -391,8 +392,8 @@ static const char *raw_get(const char *name) {
// picture between black bars. The sizes are the ones the installer lays the HUD out for (installer/steps.py
// ASPECT_SIZES, ui/menu.cpp row_output_res): of the display's shape within 1%, the smallest at least 1080 high that fits
// the display, else the largest that fits. A 16:9 display, an unknown one or one of another shape keeps 1920x1080.
// Xbox and keyboard prompts need their folder for that size's shape too (romfs-patches-xbox-<w>x<h>, -xbox-label-,
// -pc-, written by installer/steps.py Shapes for the style totk.ini selects and the connected displays' shapes): they
// Xbox, PlayStation and keyboard prompts need their folder for that size's shape too (romfs-patches-<style>-<w>x<h>,
// written by installer/steps.py Shapes for the style totk.ini selects and the connected displays' shapes): they
// keep 1920x1080 when it is missing, as in a source build without make_romfs_patches.py --prompts <style> --aspect or
// after a switch of prompts in the menu, where a default of another shape would trade the prompts the player chose for
// the Switch ones.
@@ -422,22 +423,21 @@ int cfg_shape_size(unsigned w, unsigned h, unsigned out[2]) {
}
static char screen_res[16]; // set once by cfg_init, "" for none
// romfs-patches-xbox-, romfs-patches-xbox-label- and romfs-patches-pc-<screen_res> have a manifest (set once by
// cfg_init)
static const char *const screen_folders[3] = {"romfs-patches-xbox", "romfs-patches-xbox-label", "romfs-patches-pc"};
static int screen_prompts[3];
// Which pad and keyboard prompts' folders have a manifest at screen_res's shape (<folder>-<screen_res>; set once by
// cfg_init): the folders input_map.c input_prompts_folder names
static const char *const screen_folders[5] = {"romfs-patches-xbox", "romfs-patches-xbox-label",
"romfs-patches-playstation", "romfs-patches-playstation-xbox",
"romfs-patches-pc"};
static int screen_prompts[5];
// Whether the prompts in effect have their folder at screen_res. The same picks as input_map.c input_prompts_pick and
// input_prompts_folder: an unknown or empty value is the Nintendo prompts, an unset one Xbox while the pad layout is
// "xbox_prompts"; the Xbox prompts take romfs-patches-xbox with the Nintendo pad layout (or "xbox_prompts") and
// romfs-patches-xbox-label with any other.
// Whether the prompts in effect have their folder at screen_res: the folder input_map.c input_prompts_pick and
// input_prompts_folder pick at start. The game's own prompts need none.
static int shape_keeps_prompts(void) {
const char *p = raw_get(PREFIX "PROMPTS"), *l = raw_get(PREFIX "PAD_LAYOUT");
if (p && *p && !strcasecmp(p, "pc")) return screen_prompts[2];
int xbox = p && *p ? !strcasecmp(p, "xbox") : l && !strcasecmp(l, "xbox_prompts");
if (!xbox) return 1;
int by_position = l && (!strcasecmp(l, "nintendo") || !strcasecmp(l, "xbox_prompts"));
return screen_prompts[by_position ? 0 : 1];
const char *layout = raw_get(PREFIX "PAD_LAYOUT");
const char *want = input_prompts_folder(input_prompts_pick(raw_get(PREFIX "PROMPTS"), layout), layout);
for (int i = 0; want && i < 5; i++)
if (!strcmp(screen_folders[i], want)) return screen_prompts[i];
return 1;
}
static void screen_default(void) {
@@ -455,7 +455,7 @@ static void screen_default(void) {
if (best < 0) best = fit;
if (best < 0) return;
snprintf(screen_res, sizeof screen_res, "%ux%u", SHAPED[best][0], SHAPED[best][1]);
for (int i = 0; i < 3; i++)
for (int i = 0; i < 5; i++)
screen_prompts[i] = romfs_shaped_prompts_ready(screen_folders[i], SHAPED[best][0], SHAPED[best][1]);
if (!raw_get(PREFIX "OUTPUT_RES") && shape_keeps_prompts())
rt_log("cfg: the display is %dx%d: output_res defaults to %s, its shape (totk.ini output_res sets another)", sw,
+14 -1
View File
@@ -334,14 +334,27 @@ int probe_cfg(void) {
EQ(input_prompts_folder(PROMPTS_XBOX, "auto"), "romfs-patches-xbox-label") &&
EQ(input_prompts_folder(PROMPTS_XBOX, NULL), "romfs-patches-xbox-label"),
"prompts: the face buttons by position for the Nintendo layout, by label for xbox and auto");
CHECK(input_prompts_pick("PlayStation", "nintendo") == PROMPTS_PLAYSTATION &&
input_prompts_pick("playstation", "xbox") == PROMPTS_PLAYSTATION &&
input_prompts_pick("ps", "auto") == PROMPTS_PLAYSTATION,
"prompts: PlayStation, any case");
CHECK(EQ(input_prompts_folder(PROMPTS_PLAYSTATION, "nintendo"), "romfs-patches-playstation") &&
EQ(input_prompts_folder(PROMPTS_PLAYSTATION, "xbox_prompts"), "romfs-patches-playstation") &&
EQ(input_prompts_folder(PROMPTS_PLAYSTATION, "xbox"), "romfs-patches-playstation-xbox") &&
EQ(input_prompts_folder(PROMPTS_PLAYSTATION, "auto"), "romfs-patches-playstation-xbox") &&
EQ(input_prompts_folder(PROMPTS_PLAYSTATION, NULL), "romfs-patches-playstation-xbox"),
"prompts: the PlayStation shapes by position for the Nintendo layout, by label for xbox and auto");
// romfs-patches-xbox shows A as B (tests/romfs_prompts_test.py checks the folders' contents). It is right exactly
// where the layout puts A on the east button, which an Xbox pad labels B.
// where the layout puts A on the east button, which an Xbox pad labels B. The PlayStation folder shows A as the
// circle there, so its name follows the same split.
input_map_reset();
static const char *const layouts[] = {"nintendo", "xbox", "auto", "xbox_prompts"};
for (int i = 0; i < 4; i++) {
int a_east = input_map_pad_buttons((uint8_t[PAD_COUNT]){[PAD_EAST] = 1}, input_pad_layout_pick(layouts[i], 0)) == 1ull << B_A;
CHECK(a_east == EQ(input_prompts_folder(PROMPTS_XBOX, layouts[i]), "romfs-patches-xbox"),
"prompts: the folder names A as B exactly when the layout puts A on the button labelled B");
CHECK(a_east == EQ(input_prompts_folder(PROMPTS_PLAYSTATION, layouts[i]), "romfs-patches-playstation"),
"prompts: the PlayStation folder puts A on the circle exactly when the layout puts A on the east button");
}
// One folder per screen shape (cfg.c cfg_shape_size, installer/screens.py shape_size): the closest aspect ratio of
// SHAPED within 1%, the first of equal ones; 16:9 and unlisted shapes have none.
+6 -1
View File
@@ -307,12 +307,17 @@ int input_pad_layout_pick(const char *setting, int east_labelled_a) {
int input_prompts_pick(const char *prompts, const char *pad_layout) {
if (prompts && *prompts)
return !strcasecmp(prompts, "xbox") ? PROMPTS_XBOX : !strcasecmp(prompts, "pc") ? PROMPTS_PC : PROMPTS_NINTENDO;
return !strcasecmp(prompts, "xbox") ? PROMPTS_XBOX
: !strcasecmp(prompts, "playstation") || !strcasecmp(prompts, "ps") ? PROMPTS_PLAYSTATION
: !strcasecmp(prompts, "pc") ? PROMPTS_PC : PROMPTS_NINTENDO;
return pad_layout && !strcasecmp(pad_layout, "xbox_prompts") ? PROMPTS_XBOX : PROMPTS_NINTENDO;
}
const char *input_prompts_folder(int prompts, const char *pad_layout) {
if (prompts == PROMPTS_PC) return "romfs-patches-pc";
if (prompts == PROMPTS_PLAYSTATION)
return input_pad_layout_pick(pad_layout, 0) == PAD_LAYOUT_NINTENDO ? "romfs-patches-playstation"
: "romfs-patches-playstation-xbox";
if (prompts != PROMPTS_XBOX) return NULL;
// The folders are read at start, before a pad is open: auto counts as Xbox, as for a pad without Nintendo labels.
// A Nintendo-labelled pad under auto plays by label too (its A is on the button labelled A), so it matches as well.
+10 -7
View File
@@ -91,18 +91,21 @@ int input_pad_layout_pick(const char *setting, int east_labelled_a);
// Button prompts (TOTK_PROMPTS): the controller whose buttons the game's prompts show. Nintendo: the game's own. Xbox:
// LB RB LT RT, Menu, View and a d-pad cross for the other buttons, and the face buttons named by the label of the
// button the pad layout presses (runtime/romfs.c overlay_init, tools/make_romfs_patches.py --prompts). PC: the key or
// button the pad layout presses (runtime/romfs.c overlay_init, tools/make_romfs_patches.py --prompts). PlayStation: the
// face buttons as ○ × △ □, L1 R1 L2 R2, Options and Share, likewise on the button the pad layout presses. PC: the key or
// mouse button the keyboard defaults press each button with, the mouse for the right stick.
enum { PROMPTS_NINTENDO, PROMPTS_XBOX, PROMPTS_PC };
// The prompts for a TOTK_PROMPTS value ("nintendo", "xbox" or "pc", any case). Unset or empty: Xbox while the pad
// layout setting is "xbox_prompts", else Nintendo.
enum { PROMPTS_NINTENDO, PROMPTS_XBOX, PROMPTS_PLAYSTATION, PROMPTS_PC };
// The prompts for a TOTK_PROMPTS value ("nintendo", "xbox", "playstation" or "pc", any case). Unset or empty: Xbox
// while the pad layout setting is "xbox_prompts", else Nintendo.
int input_prompts_pick(const char *prompts, const char *pad_layout);
// The folder next to romfs-index.bin that holds those prompts for a TOTK_PAD_LAYOUT value, NULL for the game's own. The
// Nintendo layout plays an Xbox pad by position, so its folder names the face buttons the other way round
// (romfs-patches-xbox: the right button does A and is labelled B); xbox and auto put every Switch button on the button
// labelled with its letter (auto picks the layout per pad by its labels), so they share romfs-patches-xbox-label. The PC
// prompts follow no pad: romfs-patches-pc whatever the layout (romfs.c overlay_init serves romfs-patches-pc-<w>x<h>
// under that name at a game resolution of another shape).
// labelled with its letter (auto picks the layout per pad by its labels), so they share romfs-patches-xbox-label. The
// PlayStation prompts have the same two folders: romfs-patches-playstation (Nintendo layout, A on the right button is
// circle) and romfs-patches-playstation-xbox (xbox and auto, A on the bottom button is cross). The PC prompts follow no
// pad: romfs-patches-pc whatever the layout (romfs.c overlay_init serves romfs-patches-pc-<w>x<h> under that name at a
// game resolution of another shape).
const char *input_prompts_folder(int prompts, const char *pad_layout);
// down[pad] != 0 for the gamepad inputs held. Returns the Switch button bits (0..15) the layout's pad table presses.
uint64_t input_map_pad_buttons(const uint8_t down[PAD_COUNT], int layout);
+25 -18
View File
@@ -934,14 +934,15 @@ static void camera_overlay(void) {
// did not load (ROMFS_PROMPTS_*). The menu compares them with the settings in effect (ui/menu.cpp prompts_note).
// Each folder keeps its name, but at a game resolution of another shape than 16:9 its files come from dir,
// <name>-<w>x<h> (overlay_init), and ready is that one's.
static struct { const char *name; int ready; char dir[64]; } prompts_folders[3];
#define PROMPTS_FOLDERS 5 // the two Xbox folders, the two PlayStation ones, the PC one (overlay_init)
static struct { const char *name; int ready; char dir[64]; } prompts_folders[PROMPTS_FOLDERS];
static const char *prompts_wanted, *prompts_loaded;
static int prompts_off;
const char *romfs_prompts(void) { return prompts_loaded; }
int romfs_prompts_ready(const char *folder) {
for (int i = 0; i < 3; i++)
for (int i = 0; i < PROMPTS_FOLDERS; i++)
if (folder && prompts_folders[i].name && !strcmp(prompts_folders[i].name, folder)) return prompts_folders[i].ready;
return 0;
}
@@ -1014,16 +1015,16 @@ static void overlay_init(void) {
// size, else the folder of its shape): the same overlay with the UI laid out for that shape
// (make_romfs_patches.py --aspect), when the game version has the camera aspect patch the layout goes with
// (res_wants_wide_overlay).
// With prompts = xbox, the Xbox prompts' folder for the pad layout in its place (input_prompts_folder): the same
// patches with Xbox button icons (make_romfs_patches.py --prompts); prompts = pc takes romfs-patches-pc whatever
// the pad layout. The game reads the archives once at boot, so the prompts stay until restart even though the
// layout itself changes live. Each folder replaces romfs-patches as a whole. At a game resolution of another shape
// the prompts come from <folder>-<w>x<h> (make_romfs_patches.py --prompts <style> --aspect): it carries that
// shape's UI layout too, so it replaces romfs-patches-<w>x<h> as the folder replaces romfs-patches. Without it the
// Switch prompts stay with the shape's layout. So they do when a RomFS mod (the TOTK_ROMFS_MODS manifest or a
// player mod) replaces one of the prompts' fonts: romfs-patches loads in their place, so the mod's file is not
// served beside prompts files made for the game's own. A mod's resource size table is no clash: restbl_overlay
// merges it with the prompts' one.
// With prompts = xbox or playstation, that controller's prompts' folder for the pad layout in its place
// (input_prompts_folder): the same patches with Xbox or PlayStation button icons (make_romfs_patches.py
// --prompts); prompts = pc takes romfs-patches-pc whatever the pad layout. The game reads the archives once at
// boot, so the prompts stay until restart even though the layout itself changes live. Each folder replaces
// romfs-patches as a whole. At a game resolution of another shape the prompts come from <folder>-<w>x<h>
// (make_romfs_patches.py --prompts <style> --aspect): it carries that shape's UI layout too, so it replaces
// romfs-patches-<w>x<h> as the folder replaces romfs-patches. Without it the Switch prompts stay with the shape's
// layout. So they do when a RomFS mod (the TOTK_ROMFS_MODS manifest or a player mod) replaces one of the prompts'
// fonts: romfs-patches loads in their place, so the mod's file is not served beside prompts files made for the
// game's own. A mod's resource size table is no clash: restbl_overlay merges it with the prompts' one.
char def[2100], path[2100];
const char *patches = cfg_get("TOTK_ROMFS_PATCHES"), *mods = cfg_get("TOTK_ROMFS_MODS");
int wide = 0;
@@ -1047,9 +1048,12 @@ static void overlay_init(void) {
"or tools/make_romfs_patches.py --aspect %ux%u)", name, shape[0], shape[1]);
}
}
static const char *const layouts[2] = {"nintendo", "xbox"}; // one of each Xbox folder, then the PC one
for (int i = 0; i < 3; i++) {
const char *name = i < 2 ? input_prompts_folder(PROMPTS_XBOX, layouts[i]) : input_prompts_folder(PROMPTS_PC, 0);
// one of each Xbox and PlayStation folder, then the PC one
static const char *const layouts[2] = {"nintendo", "xbox"};
for (int i = 0; i < PROMPTS_FOLDERS; i++) {
const char *name = i < 2 ? input_prompts_folder(PROMPTS_XBOX, layouts[i])
: i < 4 ? input_prompts_folder(PROMPTS_PLAYSTATION, layouts[i - 2])
: input_prompts_folder(PROMPTS_PC, 0);
char *dir = prompts_folders[i].dir;
prompts_folders[i].name = name;
if (wide) {
@@ -1063,10 +1067,12 @@ static void overlay_init(void) {
}
const char *layout = cfg_value("TOTK_PAD_LAYOUT");
int pick = input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout);
const char *style = pick == PROMPTS_PC ? "keyboard and mouse" : "Xbox";
const char *style = pick == PROMPTS_PC ? "keyboard and mouse"
: pick == PROMPTS_PLAYSTATION ? "PlayStation"
: "Xbox";
prompts_wanted = input_prompts_folder(pick, layout);
const char *wanted_dir = prompts_wanted; // the folder its files come from
for (int i = 0; i < 3; i++)
for (int i = 0; i < PROMPTS_FOLDERS; i++)
if (prompts_wanted && !strcmp(prompts_folders[i].name, prompts_wanted)) wanted_dir = prompts_folders[i].dir;
const char *suffix = hud_suffix(out[0], out[1]);
if (wide && prompts_wanted && romfs_prompts_ready(prompts_wanted) && *suffix && !ends_with(wanted_dir, suffix))
@@ -1098,7 +1104,8 @@ static void overlay_init(void) {
snprintf(why, sizeof why, "%s", prompts_off == ROMFS_PROMPTS_PATCHES
? "TOTK_ROMFS_PATCHES is set"
: "their folder has no manifest.tsv (run the setup again)");
rt_log("RomFS overlay: prompts = %s, but %s; Switch prompts stay", pick == PROMPTS_PC ? "pc" : "xbox", why);
rt_log("RomFS overlay: prompts = %s, but %s; Switch prompts stay",
pick == PROMPTS_PC ? "pc" : pick == PROMPTS_PLAYSTATION ? "playstation" : "xbox", why);
}
size_t prompts_end = noverlay;
char plain[2100]; // romfs-patches, when it has a manifest
+3 -2
View File
@@ -988,10 +988,11 @@ static void tab_controls(float scale) {
opt_begin("##controls", scale);
static const UiTextId layout[] = {UI_MENU_PAD_LAYOUT_AUTO, UI_MENU_PAD_LAYOUT_NINTENDO, UI_MENU_PAD_LAYOUT_XBOX};
opt_choice("TOTK_PAD_LAYOUT", UI_MENU_PAD_LAYOUT, layout, 3, UI_MENU_PAD_LAYOUT_DESC, pad_layout_note());
static const UiTextId prompts[] = {UI_MENU_PROMPTS_NINTENDO, UI_MENU_PROMPTS_XBOX, UI_MENU_PROMPTS_PC};
static const UiTextId prompts[] = {UI_MENU_PROMPTS_NINTENDO, UI_MENU_PROMPTS_XBOX, UI_MENU_PROMPTS_PLAYSTATION,
UI_MENU_PROMPTS_PC};
bool restart;
const char *note = prompts_note(&restart);
opt_choice("TOTK_PROMPTS", UI_MENU_PROMPTS, prompts, 3, UI_MENU_PROMPTS_DESC, note);
opt_choice("TOTK_PROMPTS", UI_MENU_PROMPTS, prompts, 4, UI_MENU_PROMPTS_DESC, note);
bool ask = restart && opt_button("##restart", UI_MENU_RESTART, UI_MENU_RESTART_DESC);
opt_toggle("TOTK_MOTION", UI_MENU_MOTION, UI_MENU_MOTION_DESC);
opt_toggle("TOTK_GYRO_CALIBRATION", UI_MENU_GYRO_CALIBRATION, UI_MENU_GYRO_CALIBRATION_DESC);
+26 -16
View File
@@ -296,11 +296,14 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_PROMPTS_DESC] = "Which controller's buttons the game's prompts show. Nintendo: the game's own. Xbox: LB, "
"RB, LT, RT, Menu, View and a d-pad cross, and A, B, X and Y as labelled on the button "
"the layout above presses (with Nintendo (A right) the right button is labelled B, so the "
"prompts for A show B). PC: the keys and mouse buttons of the keyboard's default layout "
"(E, Shift, Space, left click...) and the mouse for the camera. The game reads its prompts "
"at start, so they change after a restart. They are part of the game's files, so a button "
"you remap in Controls keeps its old prompt on screen.",
[UI_MENU_PROMPTS_NINTENDO] = "Nintendo", [UI_MENU_PROMPTS_XBOX] = "Xbox", [UI_MENU_PROMPTS_PC] = "PC",
"prompts for A show B). PlayStation: the shapes on a PlayStation pad (○ × △ □, L1, R1, "
"L2, R2, Options and Share), on the button the layout above presses. PC: the keys and "
"mouse buttons of the keyboard's default layout (E, Shift, Space, left click...) and the "
"mouse for the camera. The game reads its prompts at start, so they change after a "
"restart. They are part of the game's files, so a button you remap in Controls keeps its "
"old prompt on screen.",
[UI_MENU_PROMPTS_NINTENDO] = "Nintendo", [UI_MENU_PROMPTS_XBOX] = "Xbox",
[UI_MENU_PROMPTS_PLAYSTATION] = "PlayStation", [UI_MENU_PROMPTS_PC] = "PC",
[UI_MENU_PROMPTS_MISSING] = "prompt files missing: run the setup again",
[UI_MENU_PROMPTS_FAILED] = "prompt files damaged: run the setup again",
[UI_MENU_PROMPTS_RESTART] = "prompts change after restart",
@@ -898,11 +901,14 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_PROMPTS_DESC] = "Кнопки какого контроллера показывают подсказки игры. Nintendo: как в самой игре. Xbox: "
"LB, RB, LT, RT, Menu, View и крестовина, а A, B, X и Y подписаны так же, как кнопка, "
"которую нажимает раскладка выше (в Nintendo (A справа) правая кнопка подписана B, и "
"подсказки A показывают B). PC: клавиши и кнопки мыши стандартной раскладки клавиатуры "
"(E, Shift, пробел, левый клик...) и мышь для камеры. Игра читает подсказки при запуске, "
"так что они меняются после перезапуска. Подсказки записаны в файлах игры, поэтому у "
"кнопки, переназначенной на вкладке управления, на экране остаётся прежняя подсказка.",
[UI_MENU_PROMPTS_NINTENDO] = "Nintendo", [UI_MENU_PROMPTS_XBOX] = "Xbox", [UI_MENU_PROMPTS_PC] = "PC",
"подсказки A показывают B). PlayStation: символы геймпада PlayStation (○ × △ □, L1, R1, "
"L2, R2, Options и Share) на кнопке, которую нажимает раскладка выше. PC: клавиши и "
"кнопки мыши стандартной раскладки клавиатуры (E, Shift, пробел, левый клик...) и мышь "
"для камеры. Игра читает подсказки при запуске, так что они меняются после перезапуска. "
"Подсказки записаны в файлах игры, поэтому у кнопки, переназначенной на вкладке "
"управления, на экране остаётся прежняя подсказка.",
[UI_MENU_PROMPTS_NINTENDO] = "Nintendo", [UI_MENU_PROMPTS_XBOX] = "Xbox",
[UI_MENU_PROMPTS_PLAYSTATION] = "PlayStation", [UI_MENU_PROMPTS_PC] = "PC",
[UI_MENU_PROMPTS_MISSING] = "нет файлов подсказок: запустите установку снова",
[UI_MENU_PROMPTS_FAILED] = "файлы подсказок повреждены: запустите установку снова",
[UI_MENU_PROMPTS_RESTART] = "подсказки сменятся после перезапуска",
@@ -1685,13 +1691,15 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
[UI_MENU_PROMPTS_DESC] = "Os botões de qual controle os ícones do jogo mostram. Nintendo: os do próprio jogo. "
"Xbox: LB, RB, LT, RT, Menu, Exibir e uma cruz direcional, e A, B, X e Y com a letra do "
"botão que o layout acima aperta (com Nintendo (A à direita) o botão da direita tem a "
"letra B, então os ícones de A mostram B). PC: as teclas e os botões do mouse do layout "
"padrão do teclado (E, Shift, Espaço, clique esquerdo...) e o mouse para a câmera. O jogo "
"lê os ícones ao iniciar, então eles mudam depois de reiniciar. Eles fazem parte dos "
"arquivos do jogo, então um botão remapeado em Controles continua com o ícone antigo na "
"tela.",
"letra B, então os ícones de A mostram B). PlayStation: os símbolos de um controle "
"PlayStation (○ × △ □, L1, R1, L2, R2, Options e Share), no botão que o layout acima "
"aperta. PC: as teclas e os botões do mouse do layout padrão do teclado (E, Shift, "
"Espaço, clique esquerdo...) e o mouse para a câmera. O jogo lê os ícones ao iniciar, "
"então eles mudam depois de reiniciar. Eles fazem parte dos arquivos do jogo, então um "
"botão remapeado em Controles continua com o ícone antigo na tela.",
[UI_MENU_PROMPTS_NINTENDO] = "Nintendo",
[UI_MENU_PROMPTS_XBOX] = "Xbox",
[UI_MENU_PROMPTS_PLAYSTATION] = "PlayStation",
[UI_MENU_PROMPTS_PC] = "PC",
[UI_MENU_MOUSE_MODE] = "Câmera com o mouse",
[UI_MENU_MOUSE_MODE_DESC] = "Direta: a câmera gira o quanto o mouse se move, como num jogo de PC, sem zona morta nem curva do analógico (jogos 1.4.3 e 1.2.1; o 1.1.0 usa a emulação do analógico). Emulação do analógico: o mouse age como o analógico direito.",
@@ -2436,10 +2444,12 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_MENU_PROMPTS] = "按键提示",
[UI_MENU_PROMPTS_DESC] = "游戏的按键提示显示哪种手柄的按键。Nintendo:游戏原有的提示。Xbox:LB、RB、LT、RT、Menu、View 和十字键,以及上方布局所按下的按键上标注的 "
"A、B、X、Y(使用 Nintendo(A 在右)时右侧按键标为 B,因此 A 的提示显示 "
"B)。PC:键盘默认布局的按键和鼠标按键(E、Shift、空格、左键……),镜头用鼠标。"
"B)。PlayStation:PlayStation 手柄上的符号(○ × △ □、L1、R1、L2、R2、Options 和 Share),"
"显示在上方布局所按下的按键上。PC:键盘默认布局的按键和鼠标按键(E、Shift、空格、左键……),镜头用鼠标。"
"游戏在启动时读取按键提示,因此重启后才会改变。提示属于游戏文件,在“操作”中重新映射的按键在屏幕上仍显示原来的提示。",
[UI_MENU_PROMPTS_NINTENDO] = "Nintendo",
[UI_MENU_PROMPTS_XBOX] = "Xbox",
[UI_MENU_PROMPTS_PLAYSTATION] = "PlayStation",
[UI_MENU_PROMPTS_PC] = "PC",
[UI_MENU_MOUSE_MODE] = "鼠标视角",
[UI_MENU_MOUSE_MODE_DESC] = "直接:镜头按鼠标移动的距离转动,与电脑游戏相同,没有摇杆死区和响应曲线(游戏 1.4.3 和 1.2.1;1.1.0 使用摇杆模拟)。摇杆模拟:鼠标相当于右摇杆。",
+2 -1
View File
@@ -133,7 +133,8 @@ typedef enum {
UI_MENU_RUMBLE_TRIGGERS, UI_MENU_RUMBLE_TRIGGERS_DESC,
UI_MENU_PAD_LAYOUT, UI_MENU_PAD_LAYOUT_DESC, UI_MENU_PAD_LAYOUT_AUTO, UI_MENU_PAD_LAYOUT_NINTENDO,
UI_MENU_PAD_LAYOUT_XBOX, UI_MENU_PAD_LAYOUT_IN_USE,
UI_MENU_PROMPTS, UI_MENU_PROMPTS_DESC, UI_MENU_PROMPTS_NINTENDO, UI_MENU_PROMPTS_XBOX, UI_MENU_PROMPTS_PC,
UI_MENU_PROMPTS, UI_MENU_PROMPTS_DESC, UI_MENU_PROMPTS_NINTENDO, UI_MENU_PROMPTS_XBOX, UI_MENU_PROMPTS_PLAYSTATION,
UI_MENU_PROMPTS_PC,
// the notes under the prompts: their files are missing or damaged, they change after restart, or why they are off
UI_MENU_PROMPTS_MISSING, UI_MENU_PROMPTS_FAILED, UI_MENU_PROMPTS_RESTART, UI_MENU_PROMPTS_OFF_SHAPE,
UI_MENU_OUTPUT_RES_NO_LAYOUT, UI_MENU_OUTPUT_RES_PREPARING, UI_MENU_SHAPE_PREPARE, UI_MENU_SHAPE_PREPARE_DESC,
+18
View File
@@ -866,6 +866,24 @@ class ShapesTest(unittest.TestCase):
'pad_layout = nintendo\nprompts = xbox',
'pad_layout = xbox_prompts', 'prompts = nintendo')],
[None, 'pc', 'xbox-label', 'xbox', 'xbox', None])
self.assertEqual([screens.prompts_style(t) for t in ('prompts = playstation', 'prompts = PS',
'pad_layout = nintendo\nprompts = playstation',
'pad_layout = xbox\nprompts = playstation')],
['playstation-xbox', 'playstation-xbox', 'playstation', 'playstation-xbox'])
def test_playstation_shapes_replace_every_older_shaped_folder(self):
screens.displays = lambda: [(2560, 1080)]
(self.dest / 'totk.ini').write_text('pad_layout = auto\nprompts = playstation\n')
for old in ('romfs-patches-playstation-1280x800', 'romfs-patches-playstation-xbox-3440x1440-hud21x9',
'romfs-patches-xbox-label-2560x1080', 'romfs-patches-playstation-xbox'):
(self.dest / old).mkdir()
(self.dest / 'romfs-patches-playstation-xbox' / 'manifest.tsv').write_text('#\n')
record = steps.Shapes().run(self.ctx)
self.assertEqual(record['folders'], ['romfs-patches-2560x1080', 'romfs-patches-playstation-xbox-2560x1080'])
self.assertEqual(sorted(p.name for p in self.dest.iterdir() if p.is_dir()),
['romfs-patches-2560x1080', 'romfs-patches-playstation-xbox',
'romfs-patches-playstation-xbox-2560x1080'])
self.assertEqual(self.calls[-1][self.calls[-1].index('--prompts') + 1], 'playstation-xbox')
def test_wanted_from_displays_and_ini(self):
(self.dest / 'totk.ini').write_text('[display]\noutput_res = 3000x2000\n[input]\nprompts = pc\n')
+107 -6
View File
@@ -38,7 +38,9 @@ spec.loader.exec_module(icons)
POSITION = {'nintendo': {'A': 'east', 'B': 'south', 'X': 'north', 'Y': 'west'},
'xbox': {'A': 'south', 'B': 'east', 'X': 'west', 'Y': 'north'}}
XBOX_LABEL = {'south': 'A', 'east': 'B', 'west': 'X', 'north': 'Y'}
STYLE_LAYOUT = {'xbox': 'nintendo', 'xbox-label': 'xbox'}
PS_SHAPE = {'nintendo': {'A': '○', 'B': '×', 'X': '△', 'Y': '□'}, # A east, B south, X north, Y west
'xbox': {'A': '×', 'B': '○', 'X': '□', 'Y': '△'}} # A south, B east, X west, Y north
STYLE_LAYOUT = {'xbox': 'nintendo', 'xbox-label': 'xbox', 'playstation': 'nintendo', 'playstation-xbox': 'xbox'}
FACE = {'A': 0xE040, 'B': 0xE041, 'X': 0xE042, 'Y': 0xE043}
# The glyphs drawn as Xbox icons, with their advance: LB RB LT RT, Menu and View, the d-pad.
DRAWN = {0xE044: 820, 0xE045: 820, 0xE046: 760, 0xE047: 760, 0xE04B: 640, 0xE04C: 640, 0xE049: 640,
@@ -359,6 +361,9 @@ LETTERS_2 = {ord('T'): (560, polygon((230, 0), (330, 0), (330, 600), (520, 600),
# its own size.
LETTERS_2.update({ord(ch): (560, lambda pen, i=i: [rect(pen, 60, 0, 300 + 10 * i, 700), rect(pen, 120, 100, 240, 600, True)])
for i, ch in enumerate('ACDEFGHIMQSW1234')})
# The PlayStation shapes the diamond needs in the text font (make_romfs_patches.py --prompts playstation checks them).
LETTERS_2.update({cp: (560, lambda pen, i=i: rect(pen, 60, 0, 300 + 10 * i, 700))
for i, cp in enumerate((0x25CB, 0x00D7, 0x25B3, 0x25A1))})
PC_PANES = {'A': 'E', 'B': '↑', 'X': '▬', 'Y': 'L'} # the diamond's letters with the default keys
@@ -453,7 +458,7 @@ class PromptsTest(unittest.TestCase):
cls.romfs = {v: Romfs(cls.base / v / 'romfs', v) for v in VERSIONS}
cls.outs = {}
for v, romfs in cls.romfs.items():
for style in ('plain', 'xbox', 'xbox-label', 'pc'):
for style in ('plain', 'xbox', 'xbox-label', 'playstation', 'playstation-xbox', 'pc'):
out = cls.base / v / style
proc = romfs.run(out, *(() if style == 'plain' else ('--prompts', style)))
assert proc.returncode == 0, proc.stderr
@@ -504,7 +509,8 @@ class PromptsTest(unittest.TestCase):
self.assertEqual(sarc_files(romfs.read(out, path))['LayoutMsg/Other_00.msbt'], msbt({'T_A_00': 'A'}))
def test_xbox_label_diamond_moves_letters_bars_and_hold_flashes(self):
for romfs, _, out, _ in self.each(('xbox-label',)):
# playstation-xbox plays the face buttons where an Xbox pad has them, so its diamond moves the same way
for romfs, _, out, _ in self.each(('xbox-label', 'playstation-xbox')):
before = sarc_files(romfs.contents[romfs.common])['blyt/DoCommand_00.bflyt']
after = sarc_files(romfs.read(out, romfs.common))['blyt/DoCommand_00.bflyt']
old, new = pane_positions(before), pane_positions(after)
@@ -517,6 +523,12 @@ class PromptsTest(unittest.TestCase):
self.assertEqual(new['N_LoopA_03'], tuple(a + b - c for a, b, c in
zip(old['N_LoopA_03'], old['P_CaptureB_01'], old['P_CaptureA_01'])))
def test_nintendo_layout_diamonds_keep_the_switch_positions(self):
for romfs, _, out, _ in self.each(('xbox', 'playstation')):
before = sarc_files(romfs.contents[romfs.common])['blyt/DoCommand_00.bflyt']
after = sarc_files(romfs.read(out, romfs.common))['blyt/DoCommand_00.bflyt']
self.assertEqual(pane_positions(after), pane_positions(before))
def test_other_buttons_are_drawn_as_xbox_icons(self):
for romfs, style, out, _ in self.each():
with self.subTest(version=romfs.version, style=style):
@@ -563,8 +575,97 @@ class PromptsTest(unittest.TestCase):
if member not in ('timg/__Combined.bntx', 'blyt/DoCommand_00.bflyt') and not member.startswith('anim/'):
self.assertEqual(after[member], before[member], member)
def test_face_buttons_are_playstation_shapes(self):
for romfs, style, out, _ in self.each(('playstation', 'playstation-xbox')):
with self.subTest(version=romfs.version, style=style):
layout = STYLE_LAYOUT[style]
shape = PS_SHAPE[layout]
advances = icons.font_advances(sarc_files(romfs.contents[DEFAULT_FONT])['scft/External.bfotf'])
ps = icons.playstation_icons(icons.text_glyphs(romfs.text_fonts), advances, layout)
before, after = sarc_files(romfs.contents[romfs.common]), sarc_files(romfs.read(out, romfs.common))
old, new = bntx_images(before['timg/__Combined.bntx']), bntx_images(after['timg/__Combined.bntx'])
panes = pane_texts(after['blyt/DoCommand_00.bflyt'])
messages = {path: message_texts(sarc_files(romfs.read(out, path))['LayoutMsg/DoCommand_00.msbt'])
for path in romfs.mals}
original = font(sarc_files(romfs.contents[DEFAULT_FONT])['scft/External.bfotf'])
for path in (DEFAULT_FONT, REGIONAL_FONT):
drawn = font(sarc_files(romfs.read(out, path))['scft/External.bfotf'])
for b, cp in FACE.items():
outline, advance = glyph(drawn, cp)
self.assertNotEqual(outline, glyph(original, cp)[0], f'{path}: glyph of {b}')
self.assertEqual(advance, advances[cp], f'{path}: advance of {b}')
size = VERSIONS[romfs.version]['size']
for b in FACE:
fmt, width, image = new[f'Nt_KeyTex{b}_00']
self.assertEqual((fmt, width, len(image)), (R8_UNORM, size, len(old[f'Nt_KeyTex{b}_00'][2])),
f'action prompt image of {b}')
pixels = bytes(image[icons.gob_offset(x, y, (size + 63) // 64, 16)]
for y in range(size) for x in range(size))
self.assertEqual(pixels, icons.rasterize(ps[FACE[b]][1], size), f'action prompt image of {b}')
self.assertEqual(panes[f'T_{b}_00'], shape[b], f'diamond letter of {b}')
for path, texts in messages.items():
self.assertEqual(texts[f'T_{b}_00'], shape[b], f'{path}: diamond message of {b}')
# Text that only looks like a letter pane, and every other message, stays.
self.assertEqual((panes['T_Name_00'], pane_texts(after['blyt/Title_00.bflyt'])), ('A', {'N_Title_00': 'Z'}))
for path, texts in messages.items():
self.assertEqual((texts['T_Name_00'], texts['Greeting']), ('A', 'Hello'))
self.assertEqual(sarc_files(romfs.read(out, path))['LayoutMsg/Other_00.msbt'], msbt({'T_A_00': 'A'}))
def test_other_buttons_are_drawn_as_playstation_icons(self):
for romfs, style, out, _ in self.each(('playstation', 'playstation-xbox')):
with self.subTest(version=romfs.version, style=style):
layout = STYLE_LAYOUT[style]
advances = icons.font_advances(sarc_files(romfs.contents[DEFAULT_FONT])['scft/External.bfotf'])
ps = icons.playstation_icons(icons.text_glyphs(romfs.text_fonts), advances, layout)
original = font(sarc_files(romfs.contents[DEFAULT_FONT])['scft/External.bfotf'])
default = sarc_files(romfs.read(out, DEFAULT_FONT))
drawn = font(default['scft/External.bfotf'])
for cp in range(0xE040, 0xE069):
outline, advance = glyph(drawn, cp)
if cp in ps:
rec = RecordingPen()
ps[cp][1](rec)
self.assertNotEqual(outline, glyph(original, cp)[0], f'U+{cp:04X} drawn')
self.assertEqual(advance, advances[cp], f'U+{cp:04X} advance')
self.assertEqual(sum(op == 'moveTo' for op, _ in outline),
sum(op == 'moveTo' for op, _ in rec.value), f'U+{cp:04X} contours')
elif cp not in FACE.values():
self.assertEqual((outline, advance), glyph(original, cp), f'U+{cp:04X} kept')
# A circle, square and triangle are outlines with a counter; the cross is a filled X.
moves = sorted(sum(op == 'moveTo' for op, _ in glyph(drawn, cp)[0]) for cp in FACE.values())
self.assertEqual(moves, [1, 2, 2, 2])
# The text fonts and the archives' other members stay byte for byte; both archives hold the same font.
before = sarc_files(romfs.contents[DEFAULT_FONT])
self.assertEqual({k: v for k, v in default.items() if k != 'scft/External.bfotf'},
{k: v for k, v in before.items() if k != 'scft/External.bfotf'})
regional = sarc_files(romfs.read(out, REGIONAL_FONT))
self.assertEqual(regional['fnt/rest.bin'], sarc_files(romfs.contents[REGIONAL_FONT])['fnt/rest.bin'])
self.assertEqual(unbfotf(regional['scft/External.bfotf']), unbfotf(default['scft/External.bfotf']))
self.assertEqual(struct.unpack_from('<I', regional['scft/External.bfotf'])[0] ^ MAGIC, 0x77777777)
def test_playstation_button_guide_images_show_the_same_icons(self):
for romfs, style, out, _ in self.each(('playstation', 'playstation-xbox')):
with self.subTest(version=romfs.version, style=style):
size = VERSIONS[romfs.version]['size']
layout = STYLE_LAYOUT[style]
advances = icons.font_advances(sarc_files(romfs.contents[DEFAULT_FONT])['scft/External.bfotf'])
ps = icons.playstation_icons(icons.text_glyphs(romfs.text_fonts), advances, layout)
before = sarc_files(romfs.contents[romfs.common])
after = sarc_files(romfs.read(out, romfs.common))
self.assertEqual(len(after['timg/__Combined.bntx']), len(before['timg/__Combined.bntx']))
old, new = bntx_images(before['timg/__Combined.bntx']), bntx_images(after['timg/__Combined.bntx'])
for name, cp in icons.PS_HUD_TEXTURES.items():
fmt, width, image = new[name]
pixels = bytes(image[icons.gob_offset(x, y, (size + 63) // 64, 16)] for y in range(size) for x in range(size))
self.assertEqual(pixels, icons.rasterize(ps[cp][1], size), name)
self.assertEqual({pixels[0], pixels[-1], max(pixels)}, {0, 255}, name) # a margin around a white key
self.assertEqual(new['Nt_KeyTexLSt_00'], old['Nt_KeyTexLSt_00'])
for member in before: # the 60 fps patch and the prompts touch only these
if member not in ('timg/__Combined.bntx', 'blyt/DoCommand_00.bflyt') and not member.startswith('anim/'):
self.assertEqual(after[member], before[member], member)
def test_resource_size_table_grows_with_the_fonts(self):
for romfs, style, out, summary in self.each(('xbox', 'xbox-label', 'pc')):
for romfs, style, out, summary in self.each(('xbox', 'xbox-label', 'playstation', 'playstation-xbox', 'pc')):
with self.subTest(version=romfs.version, style=style):
table = restbl_sizes(romfs.read(out, romfs.restbl))
original = restbl_sizes(romfs.contents[romfs.restbl])
@@ -580,12 +681,12 @@ class PromptsTest(unittest.TestCase):
self.assertEqual(set(table), set(original))
def test_manifest_lists_what_changed_with_both_hashes(self):
for romfs, style, out, _ in self.each(('plain', 'xbox', 'xbox-label', 'pc')):
for romfs, style, out, _ in self.each(('plain', 'xbox', 'xbox-label', 'playstation', 'playstation-xbox', 'pc')):
with self.subTest(version=romfs.version, style=style):
expect = {romfs.common}
if style != 'plain':
expect |= {DEFAULT_FONT, REGIONAL_FONT, romfs.restbl}
expect |= set(romfs.mals) if style in ('xbox', 'pc') else set()
expect |= set(romfs.mals) if style in ('xbox', 'playstation', 'playstation-xbox', 'pc') else set()
lines = manifest(out)
self.assertEqual(set(lines), expect)
for path, (size, sha, original) in lines.items():
+132 -52
View File
@@ -1,6 +1,6 @@
# Adapted from MacNativeGames games/totk/scripts/make_button_icons.py @ 933b6a0 (MIT, Copyright (c) 2026
# MacNativeGames contributors).
"""Xbox and keyboard-and-mouse button icons for the game's prompts, drawn on the player's machine for
"""Xbox, PlayStation and keyboard-and-mouse button icons for the game's prompts, drawn on the player's machine for
tools/make_romfs_patches.py --prompts.
The outlines are our own shapes with letters cut out of them in the game's own text fonts: nothing of the game is in
the repository.
@@ -10,17 +10,18 @@ Font/Font*.Nin_NX_NVN.bfarc.zs: private-use code points from U+E040 (A, B, X, Y,
Minus, the sticks). A .bfotf is an OpenType (CFF) font after an 8-byte header; from offset 4 on, every byte is XORed
with a 4-byte key, which the size in the header's second word gives away (bfotf_decode). redraw_font draws the shoulder
buttons, the triggers, Plus, Minus and the d-pad as an Xbox controller names them (LB RB, LT RT, Menu and View, a
cross), or every button as the key or mouse button the keyboard presses it with (pc_icons), can swap the glyphs of
the face buttons (A with B, X with Y), and has fontTools write the font again. The archive then grows by a kilobyte or
two, more than the game's resource size table allows it: grow_restbl raises those entries (without it the game stops at
start, MacNativeGames found).
cross), the face buttons as the PlayStation shapes (○ × △ □) with L1 R1 L2 R2, Options and Share, or every button as
the key or mouse button the keyboard presses it with (pc_icons), can swap the glyphs of the face buttons (A with B, X
with Y), and has fontTools write the font again. The archive then grows by a kilobyte or two, more than the game's
resource size table allows it: grow_restbl raises those entries (without it the game stops at start, MacNativeGames
found).
The button guide in play (bottom right) draws its buttons, L and ZL among them, from images of the common layout
archive instead (timg/__Combined.bntx, Nt_KeyTexL_00 and Nt_KeyTexZL_00): bntx_redraw paints the same icons into them,
the size unchanged. The Xbox prompts redraw L and ZL, the keyboard and mouse ones every image (PC_HUD_TEXTURES: A, B, X,
Y, L, ZL and the stick's two) with the keys of pc_binds. The font's glyphs use pc_binds(text=True): a text prompt shows
Y as T, the button guide the left mouse button. Prompts drawn as fixed images (some tutorial animations) keep the
Switch icons.
the size unchanged. The Xbox prompts redraw L and ZL, the PlayStation prompts the face buttons and L and ZL, the
keyboard and mouse ones every image (PC_HUD_TEXTURES: A, B, X, Y, L, ZL and the stick's two) with the keys of
pc_binds. The font's glyphs use pc_binds(text=True): a text prompt shows Y as T, the button guide the left mouse button.
Prompts drawn as fixed images (some tutorial animations) keep the Switch icons.
Needs fontTools (tools/requirements-installer.txt, tools/requirements-py314.txt).
"""
@@ -134,57 +135,136 @@ def polygon(pen, points):
pen.closePath()
def bumper(g, label, advance=820):
"""A shoulder button: a rounded key with its label cut out."""
def draw(pen):
rounded(pen, 40, Y0 + 70, advance - 40, Y1 - 70, 70, 150); g.hole(pen, label, advance / 2, CY, 230, advance - 200)
return advance, draw
def trigger(g, label, advance=760):
"""A trigger: a taller key with its label cut out."""
def draw(pen):
rounded(pen, 60, Y0, advance - 60, Y1, 60, 230); g.hole(pen, label, advance / 2, CY - 20, 230, advance - 220)
return advance, draw
def menu_key(advance=640): # three bars, as on the Menu button
def draw(pen):
circle(pen, advance / 2, CY, R); reverse = ReverseContourPen(pen)
for dy in (-115, 0, 115):
rounded(reverse, advance / 2 - 150, CY + dy - 38, advance / 2 + 150, CY + dy + 38, 38)
return advance, draw
def view_key(advance=640): # two overlapping windows, as on the View button
def draw(pen):
circle(pen, advance / 2, CY, R); reverse = ReverseContourPen(pen); s = 150
rounded(reverse, advance / 2 - s - 15, CY + 15, advance / 2 - 15, CY + s + 15, 16)
rounded(reverse, advance / 2 + 15, CY - s - 15, advance / 2 + s + 15, CY - 15, 16)
return advance, draw
def dpad_key(*lit, advance=640): # a cross with an arrow cut into each direction the prompt means
def draw(pen):
cx, length, arm = advance / 2, R, R * 0.40
polygon(pen, [(cx + length, CY - arm), (cx + length, CY + arm), (cx + arm, CY + arm), (cx + arm, CY + length),
(cx - arm, CY + length), (cx - arm, CY + arm), (cx - length, CY + arm), (cx - length, CY - arm),
(cx - arm, CY - arm), (cx - arm, CY - length), (cx + arm, CY - length), (cx + arm, CY - arm)])
m, t, h = (length + arm) / 2, arm * 0.72, arm * 0.80 # arm centre, half base and height of the arrow
heads = {'up': [(cx - t, CY + m - h / 2), (cx, CY + m + h / 2), (cx + t, CY + m - h / 2)],
'down': [(cx + t, CY - m + h / 2), (cx, CY - m - h / 2), (cx - t, CY - m + h / 2)],
'left': [(cx - m + h / 2, CY - t), (cx - m - h / 2, CY), (cx - m + h / 2, CY + t)],
'right': [(cx + m - h / 2, CY + t), (cx + m + h / 2, CY), (cx + m - h / 2, CY - t)]}
for d in lit:
polygon(pen, heads[d]) # already clockwise: a hole
return advance, draw
def xbox_icons(g):
"""Code point -> (advance, draw(pen)) for the buttons an Xbox controller names differently from a Switch: L R = LB
RB, ZL ZR = LT RT, Plus and Minus = Menu and View, the d-pad as a cross. g: Glyphs for the letters. The face
buttons keep the game's own glyphs (redraw_font swaps them for the Nintendo layout)."""
def bumper(label, advance=820):
def draw(pen):
rounded(pen, 40, Y0 + 70, advance - 40, Y1 - 70, 70, 150); g.hole(pen, label, advance / 2, CY, 230, advance - 200)
return advance, draw
def trigger(label, advance=760):
def draw(pen):
rounded(pen, 60, Y0, advance - 60, Y1, 60, 230); g.hole(pen, label, advance / 2, CY - 20, 230, advance - 220)
return advance, draw
def menu(advance=640): # three bars, as on the Menu button
def draw(pen):
circle(pen, advance / 2, CY, R); reverse = ReverseContourPen(pen)
for dy in (-115, 0, 115):
rounded(reverse, advance / 2 - 150, CY + dy - 38, advance / 2 + 150, CY + dy + 38, 38)
return advance, draw
def view(advance=640): # two overlapping windows, as on the View button
def draw(pen):
circle(pen, advance / 2, CY, R); reverse = ReverseContourPen(pen); s = 150
rounded(reverse, advance / 2 - s - 15, CY + 15, advance / 2 - 15, CY + s + 15, 16)
rounded(reverse, advance / 2 + 15, CY - s - 15, advance / 2 + s + 15, CY - 15, 16)
return advance, draw
def dpad(*lit, advance=640): # a cross with an arrow cut into each direction the prompt means
def draw(pen):
cx, length, arm = advance / 2, R, R * 0.40
polygon(pen, [(cx + length, CY - arm), (cx + length, CY + arm), (cx + arm, CY + arm), (cx + arm, CY + length),
(cx - arm, CY + length), (cx - arm, CY + arm), (cx - length, CY + arm), (cx - length, CY - arm),
(cx - arm, CY - arm), (cx - arm, CY - length), (cx + arm, CY - length), (cx + arm, CY - arm)])
m, t, h = (length + arm) / 2, arm * 0.72, arm * 0.80 # arm centre, half base and height of the arrow
heads = {'up': [(cx - t, CY + m - h / 2), (cx, CY + m + h / 2), (cx + t, CY + m - h / 2)],
'down': [(cx + t, CY - m + h / 2), (cx, CY - m - h / 2), (cx - t, CY - m + h / 2)],
'left': [(cx - m + h / 2, CY - t), (cx - m - h / 2, CY), (cx - m + h / 2, CY + t)],
'right': [(cx + m - h / 2, CY + t), (cx + m + h / 2, CY), (cx + m - h / 2, CY - t)]}
for d in lit:
polygon(pen, heads[d]) # already clockwise: a hole
return advance, draw
return {
0xE044: bumper('LB'), 0xE045: bumper('RB'), 0xE046: trigger('LT'), 0xE047: trigger('RT'),
0xE04B: menu(), 0xE04C: view(),
0xE049: dpad('up', 'down', 'left', 'right'), 0xE060: dpad('up'), 0xE061: dpad('down'),
0xE062: dpad('left'), 0xE063: dpad('right'), 0xE064: dpad('up', 'down'), 0xE065: dpad('left', 'right'),
0xE044: bumper(g, 'LB'), 0xE045: bumper(g, 'RB'), 0xE046: trigger(g, 'LT'), 0xE047: trigger(g, 'RT'),
0xE04B: menu_key(), 0xE04C: view_key(),
0xE049: dpad_key('up', 'down', 'left', 'right'), 0xE060: dpad_key('up'), 0xE061: dpad_key('down'),
0xE062: dpad_key('left'), 0xE063: dpad_key('right'), 0xE064: dpad_key('up', 'down'),
0xE065: dpad_key('left', 'right'),
}
# ---- PlayStation prompts (--prompts playstation, playstation-xbox): the shapes on a PlayStation pad, in the same
# filled-shape style. The game's text fonts have ○ U+25CB, × U+00D7, △ U+25B3 and □ U+25A1, so the diamond's letters
# become those characters (make_romfs_patches.py pane_letters). The face buttons are the shapes; the shoulders and
# triggers carry L1/R1/L2/R2; Plus and Minus show Options (three bars) and Share (a box with an arrow).
PS_FACE = {
'nintendo': {'A': '○', 'B': '×', 'X': '△', 'Y': '□'}, # A east, B south, X north, Y west
'xbox': {'A': '×', 'B': '○', 'X': '□', 'Y': '△'}, # A south, B east, X west, Y north
}
PS_HUD_TEXTURES = {'Nt_KeyTexA_00': 0xE040, 'Nt_KeyTexB_00': 0xE041, 'Nt_KeyTexX_00': 0xE042,
'Nt_KeyTexY_00': 0xE043, 'Nt_KeyTexL_00': 0xE044, 'Nt_KeyTexZL_00': 0xE046}
def ps_shape(shape, advance):
"""The filled outline of a PlayStation face button (○ × △ □) in the font's 1000-unit em, centred on the glyph's
advance. The ring, square and triangle are outlines about a tenth of their size wide, as on the controller; the
cross is a thick X."""
cx, cy = advance / 2, CY
if shape == '○':
def draw(pen):
circle(pen, cx, cy, R)
circle(ReverseContourPen(pen), cx, cy, R * 0.81)
elif shape == '×':
def draw(pen):
l, w = 270.0, 55.0
polygon(pen, [(cx - l, cy - l + w), (cx - l + w, cy - l), (cx, cy - w), (cx + l - w, cy - l),
(cx + l, cy - l + w), (cx + w, cy), (cx + l, cy + l - w), (cx + l - w, cy + l),
(cx, cy + w), (cx - l + w, cy + l), (cx - l, cy + l - w), (cx - w, cy)])
elif shape == '△':
def draw(pen):
polygon(pen, [(cx - 280, cy - 270), (cx + 280, cy - 270), (cx, cy + 270)])
polygon(ReverseContourPen(pen), [(cx - 215, cy - 205), (cx + 215, cy - 205), (cx, cy + 205)])
elif shape == '□':
def draw(pen):
polygon(pen, [(cx - 270, cy - 270), (cx + 270, cy - 270), (cx + 270, cy + 270), (cx - 270, cy + 270)])
polygon(ReverseContourPen(pen), [(cx - 216, cy - 216), (cx + 216, cy - 216), (cx + 216, cy + 216),
(cx - 216, cy + 216)])
else:
raise ValueError(f'no PlayStation shape {shape!r}')
return draw
def share_key(advance=640): # a box with an arrow, as on the Share button
def draw(pen):
cx = advance / 2
circle(pen, cx, CY, R)
reverse = ReverseContourPen(pen)
rounded(reverse, cx - 150, CY - 150, cx + 60, CY + 40, 20)
polygon(reverse, [(cx - 15, CY + 10), (cx + 15, CY + 10), (cx + 15, CY + 140), (cx - 15, CY + 140)])
polygon(reverse, [(cx, CY + 205), (cx + 70, CY + 120), (cx - 70, CY + 120)])
return advance, draw
def playstation_icons(g, adv, layout='nintendo'):
"""Code point -> (advance, draw(pen)) for the PlayStation prompts: the face buttons as ○ × △ □ on the button the
pad layout presses, L1 R1 L2 R2, Plus and Minus as Options and Share, and the d-pad cross. g: Glyphs for the
labels; adv: the game's advance of each glyph (font_advances), which each drawing keeps."""
face = PS_FACE[layout]
icons = {cp: (adv[cp], ps_shape(face[b], adv[cp]))
for b, cp in (('A', 0xE040), ('B', 0xE041), ('X', 0xE042), ('Y', 0xE043))}
icons.update({
0xE044: bumper(g, 'L1', adv[0xE044]), 0xE045: bumper(g, 'R1', adv[0xE045]),
0xE046: trigger(g, 'L2', adv[0xE046]), 0xE047: trigger(g, 'R2', adv[0xE047]),
0xE04B: menu_key(adv[0xE04B]), 0xE04C: share_key(adv[0xE04C]),
0xE049: dpad_key('up', 'down', 'left', 'right', advance=adv[0xE049]),
})
for cp, lit in ((0xE060, ('up',)), (0xE061, ('down',)), (0xE062, ('left',)), (0xE063, ('right',)),
(0xE064, ('up', 'down')), (0xE065, ('left', 'right'))):
icons[cp] = dpad_key(*lit, advance=adv[cp])
return icons
# ---- keyboard and mouse prompts (--prompts pc): every button the keyboard drives, drawn as the key or mouse button
# bound to it, in the same filled-shape style. Each glyph keeps the advance of the game's own (a wider glyph runs into
# the text of a right-aligned guide).
+33 -13
View File
@@ -41,8 +41,16 @@ from the game's own files on the player's machine, nothing added (tools/button_i
every pad not labelled the Nintendo way), so the face buttons keep their letters. The action prompt's diamond is
laid out as an Xbox pad's (bflyt_xbox_diamond): A at the bottom, B on the right, X on the left, Y at the top, the
button the prompt names lit in its place with its bar.
--xbox-prompts is the older name of --prompts xbox. With --aspect, romfs-patches-xbox-<w>x<h> or
romfs-patches-xbox-label-<w>x<h>: the same prompts with that shape's UI layout.
--prompts playstation | playstation-xbox: the same overlay with PlayStation button icons in the game's prompts, for
prompts = playstation (romfs-patches-playstation for pad_layout = nintendo, romfs-patches-playstation-xbox for xbox and
auto). The face buttons become the circle, cross, triangle and square shapes (button_icons.PS_FACE: with nintendo A is
the circle and B the cross, as the buttons sit; with xbox and auto A is the cross and B the circle), the shoulders and
triggers L1 R1 L2 R2, Plus and Minus Options and Share, and the d-pad keeps its cross. The game's text fonts get the
four shapes, so the diamond's letters become those characters; playstation-xbox lays the diamond out as xbox-label
does, since the face buttons sit where an Xbox pad's do. Drawn from the game's own files like the Xbox prompts
(tools/button_icons.py).
--xbox-prompts is the older name of --prompts xbox. With --aspect, romfs-patches-<style>-<w>x<h>: the same prompts with
that shape's UI layout.
--prompts pc: keyboard and mouse prompts, for prompts = pc (romfs-patches-pc, or romfs-patches-pc-<w>x<h> with
--aspect): every button of the button font is drawn as the key or mouse button the keyboard defaults put on it
(button_icons.pc_icons; --binds <totk.ini> takes the first key of its bind_ lines instead), and so are the button
@@ -79,10 +87,11 @@ ap.add_argument('--aspect', help='<w>x<h> of a game resolution of another shape
ap.add_argument('--hud', choices=('full', '21:9', '16:9'), default='full',
help='with --aspect on a wider screen: the HUD stays within the middle 21:9 or 16:9 (default full: the '
'screen\'s corners); the default --out gets a -hud21x9 or -hud16x9 suffix')
ap.add_argument('--prompts', choices=('xbox', 'xbox-label', 'pc'),
help='Xbox button icons in the prompts: xbox for pad_layout = nintendo (A shown as B, X as Y), '
'xbox-label for pad_layout = xbox or auto (the face buttons keep their letters), '
'pc for the keyboard and mouse')
ap.add_argument('--prompts', choices=('xbox', 'xbox-label', 'playstation', 'playstation-xbox', 'pc'),
help='Xbox or PlayStation button icons in the prompts: xbox for pad_layout = nintendo (A shown as B, '
'X as Y), xbox-label for pad_layout = xbox or auto (the face buttons keep their letters), '
'playstation for the PlayStation shapes on the Nintendo layout and playstation-xbox for xbox and '
'auto, pc for the keyboard and mouse')
ap.add_argument('--binds', type=Path, help='--prompts pc: a totk.ini whose bind_ lines the key icons follow')
ap.add_argument('--xbox-prompts', dest='prompts', action='store_const', const='xbox', help='the same as --prompts xbox')
ap.add_argument('--reuse', type=Path,
@@ -186,7 +195,8 @@ def bntx_swap(data, base, pairs):
def bflyt_letters(data, base, end, swap):
"""Swap the text of the one-letter text panes T_<letter>_<n> (A, B, X or Y) in the BFLYT at data[base:end] by
swap (letter -> letter); the names of the panes changed. Same length (one UTF-16 letter and its terminator)."""
swap (text -> text, one UTF-16 code unit: a letter or a PlayStation shape); the names of the panes changed. Same
length (one character and its terminator)."""
assert data[base:base + 4] == b'FLYT'
pos, changed = base + struct.unpack_from('<H', data, base + 6)[0], []
while pos + 8 <= end:
@@ -293,8 +303,9 @@ def bflyt_xbox_diamond(data, base, end):
def msbt_letters(data, swap):
"""Swap the one-letter messages labelled T_<letter>_<n> (A, B, X or Y) in the UTF-16 MSBT data (a bytearray) by
swap; the labels changed. The game sets a layout's text panes from the messages of the same name in
Mals/<language>/LayoutMsg/<layout>.msbt, over the text stored in the layout."""
swap (text -> text, one UTF-16 code unit: a letter or a PlayStation shape); the labels changed. The game sets a
layout's text panes from the messages of the same name in Mals/<language>/LayoutMsg/<layout>.msbt, over the text
stored in the layout."""
assert data[:8] == b'MsgStdBn' and data[0x0c] == 1, 'not a UTF-16 MSBT'
sections, pos = {}, 0x20
for _ in range(struct.unpack_from('<H', data, 0x0e)[0]):
@@ -360,7 +371,9 @@ RESTBL = max((p for p in files if p.startswith('System/Resource/ResourceSizeTabl
key=lambda p: int((re.search(r'\.(\d+)\.', p) or [0, 0])[1]), default=None)
by_position = args.prompts == 'xbox' # the face buttons' prompts swapped to the labels (pad_layout = nintendo)
pc = args.prompts == 'pc'
letter_panes = by_position or pc # the one-letter panes around the action prompt change
ps = args.prompts in ('playstation', 'playstation-xbox')
ps_layout = 'nintendo' if args.prompts == 'playstation' else 'xbox'
letter_panes = by_position or pc or ps # the one-letter panes around the action prompt change
if args.prompts:
assert FONTS, 'no Font/Font*.Nin_NX_NVN.bfarc.zs in the RomFS'
assert MALS or not letter_panes, 'no Mals/<language>.Product.<version>.sarc.zs in the RomFS'
@@ -427,14 +440,20 @@ if args.prompts:
missing = [name for name in icons.TEXT_FONTS if name not in text]
assert not missing, f'no {", ".join(missing)} in {icons.TEXT_ARCHIVE}'
glyphs = icons.text_glyphs(archives[icons.TEXT_ARCHIVE][slice(*text[name])] for name in icons.TEXT_FONTS)
advances = icons.font_advances(archives[icons.TEXT_ARCHIVE][slice(*text[icons.FONT])])
if pc:
ini = args.binds.read_text(encoding='utf-8', errors='replace') if args.binds else None
binds = icons.pc_binds(ini)
advances = icons.font_advances(archives[icons.TEXT_ARCHIVE][slice(*text[icons.FONT])])
drawn = icons.pc_icons(glyphs, advances, binds)
# The text prompts show Y as T (button_icons.PC_TEXT_KEYS); the button guide's images keep the left click
font_drawn = icons.pc_icons(glyphs, advances, icons.pc_binds(ini, text=True))
pane_letters = {letter: icons.pc_letter(binds[letter]) for letter in 'ABXY'}
elif ps:
drawn = icons.playstation_icons(glyphs, advances, ps_layout)
for shape in set(icons.PS_FACE[ps_layout].values()):
glyphs.outline(shape) # the diamond's text needs the shape in the game's text fonts
font_drawn = drawn
pane_letters = icons.PS_FACE[ps_layout]
else:
drawn = font_drawn = icons.xbox_icons(glyphs)
pane_letters = KEY_LETTERS
@@ -443,7 +462,7 @@ if args.prompts:
if by_position:
bntx_swap(blarc, bntx, KEY_TEXTURES)
diamond = []
if args.prompts == 'xbox-label':
if args.prompts in ('xbox-label', 'playstation-xbox'):
diamond = bflyt_xbox_diamond(blarc, *members['blyt/DoCommand_00.bflyt'])
if letter_panes:
for member, (lo, hi) in members.items():
@@ -452,7 +471,8 @@ if args.prompts:
if changed:
letters[member] = changed
assert 'blyt/DoCommand_00.bflyt' in letters, 'no letter panes in blyt/DoCommand_00.bflyt'
hud = icons.bntx_redraw(blarc, bntx, icons.PC_HUD_TEXTURES if pc else icons.HUD_TEXTURES, drawn)
hud = icons.bntx_redraw(blarc, bntx, icons.PC_HUD_TEXTURES if pc else icons.PS_HUD_TEXTURES if ps else icons.HUD_TEXTURES,
drawn)
outputs[ARCHIVE] = bytes(blarc)
fonts = {} # each distinct font is drawn once (1.4.3's four archives hold the same one)
for path, bfarc in archives.items():
+2 -1
View File
@@ -93,7 +93,8 @@ def main():
else:
print(f'package_build: {f} not in {build}, skipped')
n = copy_tree(build / 'romfs-patches', out / 'romfs-patches')
for name in ('romfs-patches-xbox', 'romfs-patches-xbox-label'): # prompts = xbox (make_romfs_patches.py --prompts)
for name in ('romfs-patches-xbox', 'romfs-patches-xbox-label', 'romfs-patches-playstation',
'romfs-patches-playstation-xbox'): # prompts = xbox or playstation (make_romfs_patches.py --prompts)
if (build / name).is_dir():
n += copy_tree(build / name, out / name)
n += copy_tree(exefs, out / 'exefs')
+5 -4
View File
@@ -406,10 +406,11 @@
# 0.1.9's xbox_prompts is read as nintendo with prompts = xbox.
# pad_layout = auto
# The buttons the game's prompts show: nintendo (the game's own), xbox (LB RB LT RT, Menu, View and a d-pad cross,
# and A B X Y as labelled on the button pad_layout presses: with nintendo, A shows as B and X as Y). Read at start
# (docs/controls.md, "Xbox button prompts"). pc: the key or mouse button the keyboard defaults press each button with
# (E, Shift, Space, left click, Q, R, right click, F, Tab, M, 1 to 4, W A S D, Ctrl, C) and the mouse for the right
# stick, whatever pad_layout (docs/controls.md, "PC button prompts").
# and A B X Y as labelled on the button pad_layout presses: with nintendo, A shows as B and X as Y), playstation
# (○ × △ □, L1 R1 L2 R2, Options and Share, on the button pad_layout presses: with nintendo, A shows as ○), or pc
# (the key or mouse button the keyboard defaults press each button with: E, Shift, Space, left click, Q, R, right
# click, F, Tab, M, 1 to 4, W A S D, Ctrl, C, and the mouse for the right stick, whatever pad_layout). Read at start
# (docs/controls.md, "Xbox and PlayStation button prompts", "PC button prompts").
# prompts = nintendo
# Gamepad stick dead zone in percent of full deflection (0 to 50). Raise it for a stick that drifts: inside the circle
# the stick reads centred, and the rest of its travel is scaled to start there.