From 757ee0b2bf36e150c350dc03c95cacd6773e4d47 Mon Sep 17 00:00:00 2001 From: ProSep <9l0mhe7e@prosep.anonaddy.me> Date: Thu, 5 Nov 2026 23:10:10 +0100 Subject: [PATCH 1/3] Add hud_width to keep the HUD narrower than a wide screen On a game resolution wider than 16:9, hud_width = 21:9 or 16:9 keeps the HUD within the middle 21:9 or 16:9 of the screen instead of its left and right edges; full, the default, is the old behaviour. tools/ultrawide_layout.py takes the HUD's aspect in place of the corner flag and moves the HUD panes out only as far as that area, and make_romfs_patches.py --hud writes the layout as romfs-patches-x-hud21x9 or -hud16x9. The runtime loads that folder when the setting asks for it (the plain shaped folder otherwise, with a log line naming the command that makes the missing one), the settings menu offers the choices that fit the game resolution, and the installer builds the folders for every size wider than 16:9 (and wider than 2.5 for 21:9). Co-Authored-By: Claude Sonnet 5.5 --- docs/architecture.md | 3 +- docs/building.md | 4 ++ installer/steps.py | 69 ++++++++++++++++++++++----------- runtime/cfg.c | 4 +- runtime/romfs.c | 77 +++++++++++++++++++++++++++---------- runtime/ui/menu.cpp | 32 +++++++++++---- runtime/ui_text.c | 20 ++++++++++ runtime/ui_text.h | 1 + tools/make_romfs_patches.py | 35 ++++++++++++++--- tools/ultrawide_layout.py | 70 ++++++++++++++++++++++----------- totk.ini.example | 6 +++ 11 files changed, 240 insertions(+), 81 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index c5931732..b4a18d98 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -112,7 +112,8 @@ Every guest thread is a host thread. TotK assumes Horizon's scheduler: three app `tools/ultrawide_layout.py`; the installer builds fifteen sizes: 21:9 2560x1080, 3440x1440, 3840x1600, 5120x2160, 32:9 3840x1080, 5120x1440, 16:10 1280x800, 1680x1050, 1920x1200, 2560x1600 and 3:2 1920x1280, 2160x1440, 2256x1504, 2880x1920, 3000x2000). A wider layout moves the HUD to the - screen's corners, a narrower one to its top and bottom edges. Other sizes get the camera of their shape and the 16:9 + screen's corners (`hud_width = 21:9` or `16:9` keeps it in the middle of the screen instead, from the `-hud21x9` or + `-hud16x9` variant of the folder), a narrower one to its top and bottom edges. Other sizes get the camera of their shape and the 16:9 HUD stretched over it. The `aspect` setting (`fit`, the default; `stretch`) decides what the present does when the window's shape differs from the output's: `fit` letterboxes, where a 16:9 game in a wider window used to be stretched. diff --git a/docs/building.md b/docs/building.md index 5332c22a..dac50564 100644 --- a/docs/building.md +++ b/docs/building.md @@ -117,6 +117,10 @@ of them. they write `build\\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"). + `--aspect x` 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\\romfs-patches-x-hud16x9` (`-hud21x9`), which the game loads for `hud_width = 16:9` + (`21:9`) in `totk.ini` ([totk.ini.example](../totk.ini.example)). A build from source has no layouts for other shapes than 16:9. At an `output_res` such as 5120x1440 the game then draws the largest 16:9 size inside it (2560x1440) and the present adds bars, instead of a wide camera over a diff --git a/installer/steps.py b/installer/steps.py index 3c3c1e25..3794be0e 100644 --- a/installer/steps.py +++ b/installer/steps.py @@ -1199,7 +1199,24 @@ class PcPrompts(Step): # ---- 6b. screen shapes -SHAPED_FOLDER = re.compile(r'^romfs-patches(?:-xbox|-xbox-label|-pc)?-\d+x\d+$') +SHAPED_FOLDER = re.compile(r'^romfs-patches(?:-xbox|-xbox-label|-pc)?-\d+x\d+(?:-hud(?:16|21)x9)?$') + + +def hud_width(dest): + """The selected HUD cap, with the same default as runtime/cfg.c.""" + try: + text = (dest / 'totk.ini').read_text(encoding='utf-8-sig', errors='replace') + except OSError: + text = '' + value = (screens.ini_value(text, 'hud_width') or 'full').lower() + return value if value in ('16:9', '21:9') else 'full' + + +def shape_hud(size, hud): + """The selected cap when at least 1% narrower than the shape, as make_romfs_patches.py requires.""" + w, h = (int(v) for v in size.split('x')) + cap = {'16:9': 16 / 9, '21:9': 21 / 9}.get(hud) + return hud if cap and cap < w / h * 0.99 else None class Shapes(Step): @@ -1207,7 +1224,7 @@ class Shapes(Step): in totk.ini, romfs-patches-