mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-19 04:15:57 +00:00
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-<w>x<h>-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 <noreply@anthropic.com>
This commit is contained in:
1 parent
f85058070e
commit
757ee0b2bf
11 files changed
+240
-81
No files matched your search
@@ -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.
|
||||
|
||||
@@ -117,6 +117,10 @@ of them.
|
||||
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").
|
||||
`--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`
|
||||
(`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
|
||||
|
||||
+47
-22
@@ -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-<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
|
||||
sizes for every prompts style, 64 folders. The key holds the shapes and the style, so a run of the setup after a
|
||||
sizes for every prompts style, 64 folders. The key holds the shapes, prompts style and selected HUD width, so a run after a
|
||||
monitor or settings change (or its rebuild mode) writes only these again; the game's settings menu can also start
|
||||
the generator for the shape in use (runtime/ui/menu.cpp row_output_res)."""
|
||||
|
||||
@@ -1222,7 +1239,8 @@ class Shapes(Step):
|
||||
sizes, style = self.wanted(ctx)
|
||||
# The pc prompts' shaped folders are drawn from the same bindings as romfs-patches-pc, so they follow its key
|
||||
prompts = ctx.keys.get('pc_prompts', '') if style == 'pc' else ''
|
||||
return fingerprint('shapes-2', ctx.keys.get('prepare', ''), prompts, style or 'nintendo', *sizes)
|
||||
return fingerprint('shapes-3', ctx.keys.get('prepare', ''), prompts, style or 'nintendo',
|
||||
hud_width(ctx.dest), *sizes)
|
||||
|
||||
def current(self, ctx, record):
|
||||
return all((ctx.dest / name / 'manifest.tsv').is_file() for name in record.get('folders', []))
|
||||
@@ -1237,31 +1255,38 @@ class Shapes(Step):
|
||||
version = version_tag(game_version(ctx))
|
||||
plain = dest / f'romfs-patches-{style}' if style else None
|
||||
folders, failed = [], None
|
||||
hud = hud_width(dest)
|
||||
for i, size in enumerate(sizes):
|
||||
rep.progress('shapes', 'layouts', i, len(sizes), 'shapes', force=True)
|
||||
out = dest / f'romfs-patches-{size}'
|
||||
code, log = run_tool(ctx, 'shapes', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version, '--romfs', dest / 'romfs', '--out', out, '--aspect', size])
|
||||
if code:
|
||||
raise InstallError('prepare.romfs_patches_failed', code=code, log=str(log))
|
||||
folders.append(out.name)
|
||||
# Only the Common archive differs from romfs-patches-<style>: --reuse links the fonts, messages and size
|
||||
# table from there. Optional like that folder: the game keeps the Switch prompts with this layout.
|
||||
if not plain or not (plain / 'manifest.tsv').is_file():
|
||||
continue
|
||||
out = dest / f'romfs-patches-{style}-{size}'
|
||||
code, log = run_tool(ctx, f'shapes-{style}', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version, '--romfs', dest / 'romfs', '--out', out, '--prompts', style,
|
||||
'--aspect', size, '--reuse', plain, *(pc_binds(dest) if style == 'pc' else ())])
|
||||
if code:
|
||||
remove(out)
|
||||
failed = failed or (code, log)
|
||||
else:
|
||||
cap = shape_hud(size, hud)
|
||||
# Keep the full layout as a fallback, plus only the cap this player selected for this shape.
|
||||
for variant in (None, cap) if cap else (None,):
|
||||
suffix = '-hud' + variant.replace(':', 'x') if variant else ''
|
||||
hud_args = ['--hud', variant] if variant else []
|
||||
out = dest / f'romfs-patches-{size}{suffix}'
|
||||
code, log = run_tool(ctx, 'shapes', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version, '--romfs', dest / 'romfs', '--out', out, '--aspect', size,
|
||||
*hud_args])
|
||||
if code:
|
||||
raise InstallError('prepare.romfs_patches_failed', code=code, log=str(log))
|
||||
folders.append(out.name)
|
||||
# Reuse the selected prompts' fonts/messages/table; PC layouts retain the player's bindings.
|
||||
if not plain or not (plain / 'manifest.tsv').is_file():
|
||||
continue
|
||||
out = dest / f'romfs-patches-{style}-{size}{suffix}'
|
||||
code, log = run_tool(ctx, f'shapes-{style}', layout.tools / 'make_romfs_patches.py',
|
||||
['--version', version, '--romfs', dest / 'romfs', '--out', out, '--prompts', style,
|
||||
'--aspect', size, *hud_args, '--reuse', plain,
|
||||
*(pc_binds(dest) if style == 'pc' else ())])
|
||||
if code:
|
||||
remove(out)
|
||||
failed = failed or (code, log)
|
||||
else:
|
||||
folders.append(out.name)
|
||||
rep.progress('shapes', 'layouts', len(sizes), len(sizes), 'shapes', force=True)
|
||||
if failed:
|
||||
rep.warning('warn.xbox_prompts_failed', code=failed[0], log=str(failed[1]))
|
||||
return {'folders': folders, 'sizes': sizes, 'style': style}
|
||||
return {'folders': folders, 'sizes': sizes, 'style': style, 'hud': hud}
|
||||
|
||||
|
||||
# ---- 7. NVIDIA DLSS
|
||||
|
||||
+3
-1
@@ -51,7 +51,7 @@ static const char *const known[] = {
|
||||
"GAMEPLAY_WEAPON_WHEEL",
|
||||
"GPL", "GPL_DRAW_BUILD", "GPU", "GPU_INDEX", "GPU_NAME", "GRASS_RANGE",
|
||||
"GYRO_BIAS_PAD", "GYRO_BIAS_X", "GYRO_BIAS_Y", "GYRO_BIAS_Z", "GYRO_CALIBRATION", "HDR", "HDR_GAME_NITS", "HDR_HUE",
|
||||
"HDR_PEAK_NITS", "HDR_UI_NITS", "HIGHFPS_FIX", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "KSPIN_US", "LANG", "LIB_PREBUILD",
|
||||
"HDR_PEAK_NITS", "HDR_UI_NITS", "HIGHFPS_FIX", "HUD_WIDTH", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "KSPIN_US", "LANG", "LIB_PREBUILD",
|
||||
"LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LOCALE", "LOD_GUARD", "LOD_STEADY", "LSTICK_DEADZONE", "MAP_CLICK", "MEMORY", "MEMX", "MENU_LANG", "MENU_TEST", "MENU_FONT_FONTCONFIG",
|
||||
"MEM_RESERVE_MIB", "MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_NO_CODE", "MODS_ORDER", "MODS_REBUILD", "MODS_WITHOUT_CODE", "MOTION", "MOUSE_AIM_SCALE", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_ASPECT", "MOVIE_HOST", "MOVIE_PACE",
|
||||
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
|
||||
@@ -78,6 +78,7 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"CLIMB_FIX", "frame rate"},
|
||||
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
||||
{"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
||||
{"HUD_WIDTH", "display"},
|
||||
{"SHARPNESS", "display"}, {"DYNAMIC_RES", "display"}, {"ASPECT", "display"}, {"MOVIE_ASPECT", "display"}, {"FOV", "display"}, {"ANISO", "display"},
|
||||
{"LOD_STEADY", "display"}, {"COLOR_PRESET", "display"},
|
||||
{"COLOR_BRIGHTNESS", "display"}, {"COLOR_CONTRAST", "display"}, {"COLOR_SATURATION", "display"},
|
||||
@@ -136,6 +137,7 @@ static const CfgMeta metas[] = {
|
||||
{"VK_PRESENT", "mailbox", "mailbox|fifo|immediate", LIVE}, {"GPU_INDEX", "", NULL, RESTART},
|
||||
{"PERF_OVERLAY", "off", "off|fps|full", LIVE},
|
||||
{"OUTPUT_RES", "1920x1080", NULL, RESTART}, {"RENDER_SCALE", "game", "game|50|67|75|100|125|150|200", RESTART},
|
||||
{"HUD_WIDTH", "full", "full|21:9|16:9", RESTART},
|
||||
{"DYNAMIC_RES", "1", "0|1", LIVE}, // resolution.c res_dynres_live
|
||||
{"UPSCALER", "fsr", "fsr|bilinear", LIVE}, {"SHARPNESS", "80", "0..100", LIVE},
|
||||
{"DLAA", "0", "0|1", RESTART}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance|ultra_performance", LIVE},
|
||||
|
||||
+57
-20
@@ -970,23 +970,44 @@ static void overlay_drop(size_t a, size_t b) {
|
||||
noverlay -= b - a;
|
||||
}
|
||||
|
||||
// The folder <prefix>-<w>x<h> the game resolution w x h takes in base: that exact size when it has a manifest (an
|
||||
// The HUD cap for the canonical shape. An inapplicable cap is full, as in installer/steps.py shape_hud. The generator
|
||||
// takes that same shape, so a resolution alias near the one-percent boundary cannot ask for an invalid variant.
|
||||
static const char *hud_suffix(unsigned w, unsigned h) {
|
||||
unsigned shape[2] = {w, h};
|
||||
cfg_shape_size(w, h, shape);
|
||||
const char *value = cfg_value("TOTK_HUD_WIDTH");
|
||||
double cap = !strcmp(value, "21:9") ? 21.0 / 9 : !strcmp(value, "16:9") ? 16.0 / 9 : 0;
|
||||
return cap && shape[1] && cap < (double)shape[0] / shape[1] * 0.99
|
||||
? (cap > 2 ? "-hud21x9" : "-hud16x9") : "";
|
||||
}
|
||||
|
||||
// The folder <prefix>-<w>x<h><suffix> the game resolution w x h takes in base: that exact size when it has a manifest (an
|
||||
// install by a setup that wrote every size, or make_romfs_patches.py --aspect <w>x<h> in a source build), else the
|
||||
// size of its shape (cfg.c cfg_shape_size), the one folder per shape installer/steps.py Shapes writes. name gets the
|
||||
// folder found, or the shape's one when neither has a manifest (for the log). 1 when found.
|
||||
static int shaped_name(const char *base, const char *prefix, unsigned w, unsigned h, char *name, size_t cap) {
|
||||
static int shaped_name(const char *base, const char *prefix, unsigned w, unsigned h, const char *suffix,
|
||||
char *name, size_t cap) {
|
||||
char path[2400];
|
||||
unsigned s[2] = {w, h};
|
||||
for (int pass = 0; pass < 2; pass++) {
|
||||
if (pass && !cfg_shape_size(w, h, s)) break;
|
||||
if (pass && s[0] == w && s[1] == h) break;
|
||||
snprintf(name, cap, "%s-%ux%u", prefix, s[0], s[1]);
|
||||
if (snprintf(name, cap, "%s-%ux%u%s", prefix, s[0], s[1], suffix) >= (int)cap) return 0;
|
||||
if (snprintf(path, sizeof path, "%s/%s/manifest.tsv", base, name) < (int)sizeof path && plat_file_exists(path))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Prefer the selected HUD at both exact and canonical sizes. Boot may fall back to the full HUD, but preparation
|
||||
// and the menu's missing-layout note use strict lookup so a full layout cannot hide a missing capped variant.
|
||||
static int selected_shape(const char *base, const char *prefix, unsigned w, unsigned h, char *name, size_t cap,
|
||||
int fallback) {
|
||||
const char *suffix = hud_suffix(w, h);
|
||||
if (shaped_name(base, prefix, w, h, suffix, name, cap)) return 1;
|
||||
return fallback && *suffix && shaped_name(base, prefix, w, h, "", name, cap);
|
||||
}
|
||||
|
||||
static void overlay_init(void) {
|
||||
// TOTK_ROMFS_PATCHES unset: romfs-patches next to romfs-index.bin if it has a manifest (tools/make_romfs_patches.py).
|
||||
// A game resolution that is not 16:9 takes romfs-patches-<w>x<h> instead when it is there (shaped_name: the exact
|
||||
@@ -1012,10 +1033,15 @@ static void overlay_init(void) {
|
||||
cfg_shape_size(out[0], out[1], shape);
|
||||
if (!patches && res_wants_wide_overlay(out)) {
|
||||
char name[128];
|
||||
if (shaped_name(index_dir, "romfs-patches", out[0], out[1], name, sizeof name) &&
|
||||
if (selected_shape(index_dir, "romfs-patches", out[0], out[1], name, sizeof name, 1) &&
|
||||
snprintf(def, sizeof def, "%s/%s", index_dir, name) < (int)sizeof def) {
|
||||
patches = def, wide = 1;
|
||||
rt_log("RomFS overlay: the UI layout for %ux%u from %s", out[0], out[1], name);
|
||||
const char *suffix = hud_suffix(out[0], out[1]);
|
||||
if (*suffix && !ends_with(name, suffix))
|
||||
rt_log("RomFS overlay: the selected HUD layout is missing; using the full HUD. Prepare it in the "
|
||||
"Screen tab, rerun setup, or run tools/make_romfs_patches.py --aspect %ux%u --hud %s",
|
||||
shape[0], shape[1], cfg_value("TOTK_HUD_WIDTH"));
|
||||
} else {
|
||||
rt_log("RomFS overlay: no %s for this game resolution, the UI keeps its 16:9 layout (run the setup again, "
|
||||
"or tools/make_romfs_patches.py --aspect %ux%u)", name, shape[0], shape[1]);
|
||||
@@ -1027,7 +1053,8 @@ static void overlay_init(void) {
|
||||
char *dir = prompts_folders[i].dir;
|
||||
prompts_folders[i].name = name;
|
||||
if (wide) {
|
||||
prompts_folders[i].ready = shaped_name(index_dir, name, out[0], out[1], dir, sizeof prompts_folders[i].dir);
|
||||
prompts_folders[i].ready = selected_shape(index_dir, name, out[0], out[1], dir,
|
||||
sizeof prompts_folders[i].dir, 1);
|
||||
continue;
|
||||
}
|
||||
snprintf(dir, sizeof prompts_folders[i].dir, "%s", name);
|
||||
@@ -1041,6 +1068,10 @@ static void overlay_init(void) {
|
||||
const char *wanted_dir = prompts_wanted; // the folder its files come from
|
||||
for (int i = 0; i < 3; 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))
|
||||
rt_log("RomFS overlay: the %s prompts have no selected HUD layout; their full HUD loads instead. Prepare "
|
||||
"the layout in the Screen tab or rerun setup", style);
|
||||
prompts_off = !prompts_wanted ? ROMFS_PROMPTS_OK
|
||||
: patches && !wide ? ROMFS_PROMPTS_PATCHES
|
||||
: !romfs_prompts_ready(prompts_wanted) ? (wide ? ROMFS_PROMPTS_SHAPE : ROMFS_PROMPTS_MISSING)
|
||||
@@ -1128,19 +1159,19 @@ static void index_folder(char *dir, size_t cap) {
|
||||
}
|
||||
|
||||
// 1 when the folder overlay_init takes for <prefix> at w x h (shaped_name) has a manifest next to romfs-index.bin.
|
||||
static int shaped_folder_ready(const char *prefix, unsigned w, unsigned h) {
|
||||
static int shaped_folder_ready(const char *prefix, unsigned w, unsigned h, int fallback) {
|
||||
char dir[2100], name[128];
|
||||
index_folder(dir, sizeof dir);
|
||||
return shaped_name(dir, prefix, w, h, name, sizeof name);
|
||||
return selected_shape(dir, prefix, w, h, name, sizeof name, fallback);
|
||||
}
|
||||
|
||||
// 1 when the game resolution w x h has the UI layout of its shape: romfs-patches-<w>x<h> of that size or of its shape,
|
||||
// the folder overlay_init looks for.
|
||||
int romfs_shaped_ready(unsigned w, unsigned h) { return shaped_folder_ready("romfs-patches", w, h); }
|
||||
int romfs_shaped_ready(unsigned w, unsigned h) { return shaped_folder_ready("romfs-patches", w, h, 1); }
|
||||
|
||||
// 1 when it has a prompts' folder (input_prompts_folder) with that layout too: <folder>-<w>x<h>, which overlay_init
|
||||
// loads in its place with those prompts.
|
||||
int romfs_shaped_prompts_ready(const char *folder, unsigned w, unsigned h) { return shaped_folder_ready(folder, w, h); }
|
||||
int romfs_shaped_prompts_ready(const char *folder, unsigned w, unsigned h) { return shaped_folder_ready(folder, w, h, 1); }
|
||||
|
||||
// ---- the layout for a new screen, from the settings menu (ui/menu.cpp row_output_res)
|
||||
// The setup writes the shaped folders for the displays connected when it ran (installer/steps.py Shapes). After a
|
||||
@@ -1175,9 +1206,9 @@ static int prepare_tools(char *python, size_t pcap, char *script, size_t scap, c
|
||||
|
||||
int romfs_shape_missing(unsigned w, unsigned h, const char *prompts_folder) {
|
||||
unsigned out[2] = {w, h};
|
||||
if (!res_wants_wide_overlay(out)) return 0;
|
||||
return !shaped_folder_ready("romfs-patches", w, h) ||
|
||||
(prompts_folder && romfs_prompts_ready(prompts_folder) && !shaped_folder_ready(prompts_folder, w, h));
|
||||
if (cfg_get("TOTK_ROMFS_PATCHES") || !res_wants_wide_overlay(out)) return 0;
|
||||
return !shaped_folder_ready("romfs-patches", w, h, 0) ||
|
||||
(prompts_folder && !shaped_folder_ready(prompts_folder, w, h, 0));
|
||||
}
|
||||
|
||||
int romfs_shape_can_prepare(void) {
|
||||
@@ -1221,27 +1252,33 @@ int romfs_shape_prepare(unsigned w, unsigned h, const char *prompts_folder) {
|
||||
snprintf(size, sizeof size, "%ux%u", s[0], s[1]);
|
||||
snprintf(version, sizeof version, "v%d", rt_game_version);
|
||||
snprintf(romfs, sizeof romfs, "%s/romfs", dir);
|
||||
const char *suffix = hud_suffix(w, h), *hud = *suffix ? cfg_value("TOTK_HUD_WIDTH") : "full";
|
||||
int started = 0, failed = 0;
|
||||
if (!shaped_name(dir, "romfs-patches", w, h, name, sizeof name)) {
|
||||
snprintf(folder, sizeof folder, "romfs-patches-%s", size);
|
||||
if (!selected_shape(dir, "romfs-patches", w, h, name, sizeof name, 0)) {
|
||||
snprintf(folder, sizeof folder, "romfs-patches-%s%s", size, suffix);
|
||||
snprintf(out, sizeof out, "%s/%s", dir, folder);
|
||||
const char *argv[] = {python, script, "--version", version, "--romfs", romfs, "--out", out, "--aspect", size,
|
||||
NULL};
|
||||
"--hud", hud, NULL};
|
||||
if (shape_spawn(argv, dir, folder)) started++;
|
||||
else failed++;
|
||||
}
|
||||
snprintf(reuse, sizeof reuse, "%s/%s/manifest.tsv", dir, prompts_folder ? prompts_folder : "");
|
||||
if (prompts_folder && plat_file_exists(reuse) && !shaped_name(dir, prompts_folder, w, h, name, sizeof name)) {
|
||||
if (prompts_folder && !selected_shape(dir, prompts_folder, w, h, name, sizeof name, 0)) {
|
||||
const char *style = prompts_folder + strlen("romfs-patches-");
|
||||
snprintf(reuse, sizeof reuse, "%s/%s/manifest.tsv", dir, prompts_folder);
|
||||
int can_reuse = plat_file_exists(reuse);
|
||||
snprintf(reuse, sizeof reuse, "%s/%s", dir, prompts_folder);
|
||||
snprintf(folder, sizeof folder, "%s-%s", prompts_folder, size);
|
||||
snprintf(folder, sizeof folder, "%s-%s%s", prompts_folder, size, suffix);
|
||||
snprintf(out, sizeof out, "%s/%s", dir, folder);
|
||||
// The keyboard and mouse prompts are drawn from totk.ini's bind_ lines, as the setup's PcPrompts and Shapes
|
||||
// steps draw them (installer/steps.py pc_binds); a file without such lines gives the keyboard defaults.
|
||||
snprintf(binds, sizeof binds, "%s/totk.ini", dir);
|
||||
int pc = !strcmp(style, "pc") && plat_file_exists(binds);
|
||||
const char *argv[] = {python, script, "--version", version, "--romfs", romfs, "--out", out, "--prompts", style,
|
||||
"--aspect", size, "--reuse", reuse, pc ? "--binds" : NULL, binds, NULL};
|
||||
const char *argv[24] = {python, script, "--version", version, "--romfs", romfs, "--out", out, "--prompts", style,
|
||||
"--aspect", size, "--hud", hud};
|
||||
int argc = 14;
|
||||
if (can_reuse) argv[argc++] = "--reuse", argv[argc++] = reuse;
|
||||
if (pc) argv[argc++] = "--binds", argv[argc++] = binds;
|
||||
argv[argc] = NULL;
|
||||
if (shape_spawn(argv, dir, folder)) started++;
|
||||
else failed++;
|
||||
}
|
||||
|
||||
+24
-8
@@ -525,16 +525,18 @@ static void row_output_res(void) {
|
||||
// checks run again only when a setting or the started generation changes.
|
||||
static unsigned seen = ~0u;
|
||||
static int missing, started; // started: 0 not asked, 1 running, -1 failed to start
|
||||
static char asked[16];
|
||||
static char asked[128];
|
||||
char request[128];
|
||||
const char *now = cfg_value("TOTK_OUTPUT_RES");
|
||||
const char *layout = cfg_value("TOTK_PAD_LAYOUT");
|
||||
const char *want = input_prompts_folder(input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout), layout);
|
||||
snprintf(request, sizeof request, "%s|%s|%s", now, cfg_value("TOTK_HUD_WIDTH"), want ? want : "");
|
||||
if (seen != cfg_version()) {
|
||||
seen = cfg_version();
|
||||
unsigned w = 0, h = 0;
|
||||
const char *layout = cfg_value("TOTK_PAD_LAYOUT");
|
||||
const char *want = input_prompts_folder(input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout), layout);
|
||||
missing = sscanf(now, "%ux%u", &w, &h) == 2 && romfs_shape_missing(w, h, want);
|
||||
}
|
||||
int here = started && !strcmp(asked, now); // the generation started for the value shown
|
||||
int here = started && !strcmp(asked, request); // resolution, selected HUD width and button prompts
|
||||
const char *note = !missing ? nullptr
|
||||
: here ? menu_text(started > 0 ? UI_MENU_OUTPUT_RES_PREPARING : UI_MENU_SHAPE_PREPARE_FAILED)
|
||||
: menu_text(UI_MENU_OUTPUT_RES_NO_LAYOUT);
|
||||
@@ -542,11 +544,24 @@ static void row_output_res(void) {
|
||||
if (!missing || here || !romfs_shape_can_prepare()) return;
|
||||
if (!opt_button("##shape_prepare", UI_MENU_SHAPE_PREPARE, UI_MENU_SHAPE_PREPARE_DESC)) return;
|
||||
unsigned w = 0, h = 0;
|
||||
const char *layout = cfg_value("TOTK_PAD_LAYOUT");
|
||||
sscanf(now, "%ux%u", &w, &h);
|
||||
snprintf(asked, sizeof asked, "%s", now);
|
||||
started = romfs_shape_prepare(w, h, input_prompts_folder(input_prompts_pick(cfg_get("TOTK_PROMPTS"), layout), layout))
|
||||
? 1 : -1;
|
||||
snprintf(asked, sizeof asked, "%s", request);
|
||||
started = romfs_shape_prepare(w, h, want) ? 1 : -1;
|
||||
}
|
||||
|
||||
// The HUD's width on a screen wider than 16:9 (hud_width, romfs.c hud_suffix): the choices that narrow the HUD at the
|
||||
// game resolution in the settings. 21:9 is offered on the 32:9 sizes (wider than 2.5), 16:9 on any size more than 1%
|
||||
// wider than 16:9. The row is hidden on a screen that is not wider
|
||||
// than that, where the setting does nothing (a value left in totk.ini stays as it is).
|
||||
static void row_hud_width(void) {
|
||||
int w = 0, h = 0;
|
||||
if (sscanf(cfg_value("TOTK_OUTPUT_RES"), "%dx%d", &w, &h) != 2 || h <= 0) return;
|
||||
double aspect = (double)w / h;
|
||||
if (aspect <= 16.0 / 9 * 1.01) return;
|
||||
const char *vals[3] = {"full", "21:9", "16:9"}, *names[3] = {menu_text(UI_MENU_HUD_WIDTH_FULL), "21:9", "16:9"};
|
||||
int n = aspect > 2.5 ? 3 : 2;
|
||||
if (n == 2) vals[1] = vals[2], names[1] = names[2];
|
||||
opt_choice_list("TOTK_HUD_WIDTH", UI_MENU_HUD_WIDTH, vals, names, n, UI_MENU_HUD_WIDTH_DESC);
|
||||
}
|
||||
|
||||
static void row_render_scale(void) {
|
||||
@@ -705,6 +720,7 @@ static void tab_screen(float scale) {
|
||||
opt_choice("TOTK_PERF_OVERLAY", UI_MENU_PERF_OVERLAY, perf, 3, UI_MENU_PERF_OVERLAY_DESC);
|
||||
opt_group(UI_MENU_GRAPHICS);
|
||||
row_output_res();
|
||||
row_hud_width();
|
||||
row_render_scale();
|
||||
opt_toggle("TOTK_DYNAMIC_RES", UI_MENU_DYNAMIC_RES, UI_MENU_DYNAMIC_RES_DESC);
|
||||
row_shadow_res();
|
||||
|
||||
@@ -67,6 +67,11 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
"more video memory and GPU time. A wider size (21:9) widens the camera's view and moves "
|
||||
"the HUD to the screen's corners; a taller one (16:10, 3:2) moves it to the top "
|
||||
"and bottom edges.",
|
||||
[UI_MENU_HUD_WIDTH] = "HUD width",
|
||||
[UI_MENU_HUD_WIDTH_DESC] = "On a screen wider than 16:9, how far apart the HUD's left and right sides are. Full puts "
|
||||
"them at the screen's edges; 21:9 or 16:9 keeps the HUD within the middle of the screen "
|
||||
"of that shape. Needs the setup's HUD layouts for the game resolution.",
|
||||
[UI_MENU_HUD_WIDTH_FULL] = "Full screen",
|
||||
[UI_MENU_RENDER_SCALE] = "3D render scale",
|
||||
[UI_MENU_RENDER_SCALE_DESC] = "Size of the 3D scene relative to the game resolution; the game's FSR scales it to "
|
||||
"that size. Above 100 % smooths jagged edges (supersampling) at a high GPU cost.",
|
||||
@@ -638,6 +643,11 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
"видеопамяти и времени GPU. Более широкий размер (21:9) расширяет обзор камеры и "
|
||||
"переносит интерфейс в углы экрана, более высокий (16:10, 3:2) переносит его к "
|
||||
"верхнему и нижнему краям.",
|
||||
[UI_MENU_HUD_WIDTH] = "Ширина интерфейса",
|
||||
[UI_MENU_HUD_WIDTH_DESC] = "На экране шире 16:9: как далеко друг от друга левая и правая части интерфейса. "
|
||||
"«Весь экран» ставит их у краёв экрана; 21:9 или 16:9 держит интерфейс в середине "
|
||||
"экрана такой формы. Нужны раскладки интерфейса из установки для этого разрешения игры.",
|
||||
[UI_MENU_HUD_WIDTH_FULL] = "Весь экран",
|
||||
[UI_MENU_RENDER_SCALE] = "Масштаб 3D-отрисовки",
|
||||
[UI_MENU_RENDER_SCALE_DESC] = "Размер 3D-сцены относительно разрешения игры; FSR игры доводит её до этого размера. "
|
||||
"Выше 100 % сглаживает лесенки на краях (суперсэмплинг) ценой большой нагрузки на GPU.",
|
||||
@@ -1250,6 +1260,11 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
"precisa de mais memória de vídeo e tempo de GPU. Um tamanho mais largo (21:9) amplia a "
|
||||
"visão da câmera e leva o HUD para os cantos da tela; um mais alto (16:10, 3:2) "
|
||||
"leva-o para as bordas de cima e de baixo.",
|
||||
[UI_MENU_HUD_WIDTH] = "Largura do HUD",
|
||||
[UI_MENU_HUD_WIDTH_DESC] = "Em uma tela mais larga que 16:9: a distância entre os lados esquerdo e direito do HUD. "
|
||||
"Tela cheia os coloca nas bordas da tela; 21:9 ou 16:9 mantém o HUD no meio da tela "
|
||||
"desse formato. Precisa dos layouts de HUD da instalação para a resolução do jogo.",
|
||||
[UI_MENU_HUD_WIDTH_FULL] = "Tela cheia",
|
||||
[UI_MENU_RENDER_SCALE] = "Escala da renderização 3D",
|
||||
[UI_MENU_RENDER_SCALE_DESC] = "Tamanho da cena 3D em relação à resolução do jogo; o FSR do jogo a amplia até esse "
|
||||
"tamanho. Acima de 100 % suaviza bordas serrilhadas (supersampling) com alto custo de "
|
||||
@@ -1872,6 +1887,11 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
"高于 1920 x 1080 会占用更多显存和 GPU 时间。"
|
||||
"更宽的尺寸(21:9)会扩大视野,并把界面移到屏幕四角;"
|
||||
"更高的尺寸(16:10、3:2)则移到上下边缘。",
|
||||
[UI_MENU_HUD_WIDTH] = "界面宽度",
|
||||
[UI_MENU_HUD_WIDTH_DESC] = "在比 16:9 更宽的屏幕上,界面左右两侧相距多远。"
|
||||
"“整个屏幕”把它们放在屏幕边缘;21:9 或 16:9 则把界面保持在屏幕中间该比例的区域内。"
|
||||
"需要安装程序为该游戏分辨率准备的界面布局。",
|
||||
[UI_MENU_HUD_WIDTH_FULL] = "整个屏幕",
|
||||
[UI_MENU_RENDER_SCALE] = "3D 渲染比例",
|
||||
[UI_MENU_RENDER_SCALE_DESC] = "3D 场景相对于游戏分辨率的尺寸;"
|
||||
"游戏的 FSR 会将其缩放到该尺寸。"
|
||||
|
||||
@@ -34,6 +34,7 @@ typedef enum {
|
||||
UI_PERF_LINE_FPS,
|
||||
UI_MENU_GRAPHICS, // group heading over the resolution rows
|
||||
UI_MENU_OUTPUT_RES, UI_MENU_OUTPUT_RES_DESC,
|
||||
UI_MENU_HUD_WIDTH, UI_MENU_HUD_WIDTH_DESC, UI_MENU_HUD_WIDTH_FULL,
|
||||
UI_MENU_RENDER_SCALE, UI_MENU_RENDER_SCALE_DESC, UI_MENU_RENDER_SCALE_GAME,
|
||||
UI_MENU_DYNAMIC_RES, UI_MENU_DYNAMIC_RES_DESC,
|
||||
UI_MENU_UPSCALER, UI_MENU_UPSCALER_DESC, UI_MENU_UPSCALER_FSR, UI_MENU_UPSCALER_BILINEAR,
|
||||
|
||||
@@ -16,6 +16,9 @@ for that shape (tools/ultrawide_layout.py): menus keep their 16:9 proportions in
|
||||
cover the screen and the HUD moves to the screen's corners (wider) or its top and bottom edges (narrower). totk.exe
|
||||
loads that overlay from romfs-patches-<w>x<h> when the game resolution is that size (runtime/romfs.c overlay_init);
|
||||
the camera's side of it is the patch set aspect (recomp/patches-v121.txt, patches-v143.txt).
|
||||
--hud 21:9 | 16:9 (with --aspect, a screen wider than that; default full) keeps the HUD within the middle 21:9 or 16:9 of
|
||||
the screen instead of its corners (totk.ini hud_width). The folder is romfs-patches-<w>x<h>-hud21x9 or -hud16x9, which
|
||||
runtime/romfs.c overlay_init loads in place of romfs-patches-<w>x<h> when hud_width asks for it.
|
||||
|
||||
--prompts xbox | xbox-label: the same overlay with Xbox button icons in the game's prompts, for prompts = xbox
|
||||
(runtime/romfs.c overlay_init loads romfs-patches-xbox or romfs-patches-xbox-label in place of romfs-patches). Drawn
|
||||
@@ -53,7 +56,8 @@ contents match the new one is hard-linked (copied where links fail) instead of c
|
||||
lists them. The output is byte for byte the same as without it.
|
||||
|
||||
Input: build/extracted/<version>/romfs (romfs.bin and index.json, verified by tools/extract.py). Output:
|
||||
build/<version>/romfs-patches/<path> by default (romfs-patches-<style> with --prompts), and <out>/manifest.tsv (path, size, SHA-256 of the overlay, SHA-256 of the original). Run with .venv-py314.
|
||||
build/<version>/romfs-patches/<path> by default (romfs-patches-<style> with --prompts, -<w>x<h> with --aspect,
|
||||
and -hud<a>x<b> with --hud), and <out>/manifest.tsv (path, size, SHA-256 of the overlay, SHA-256 of the original). Run with .venv-py314.
|
||||
"""
|
||||
import argparse
|
||||
import compression.zstd as zstd
|
||||
@@ -70,8 +74,11 @@ ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
ap.add_argument('--version', choices=('v110', 'v121', 'v143'), default='v121')
|
||||
ap.add_argument('--romfs', type=Path, help='default build/extracted/<version>/romfs')
|
||||
ap.add_argument('--out', type=Path,
|
||||
help='default build/<version>/romfs-patches (romfs-patches-<style> with --prompts)')
|
||||
help='default build/<version>/romfs-patches[-<style>][-<w>x<h>][-hud<a>x<b>]')
|
||||
ap.add_argument('--aspect', help='<w>x<h> of a game resolution of another shape than 16:9: also lay the UI out for it')
|
||||
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), '
|
||||
@@ -82,7 +89,24 @@ ap.add_argument('--reuse', type=Path,
|
||||
help='an overlay folder made before: its files with the same contents are linked, not compressed again')
|
||||
args = ap.parse_args()
|
||||
args.romfs = args.romfs or root / 'build/extracted' / args.version / 'romfs'
|
||||
args.out = args.out or root / 'build' / args.version / (f'romfs-patches-{args.prompts}' if args.prompts else 'romfs-patches')
|
||||
width = height = None
|
||||
if args.aspect:
|
||||
match = re.fullmatch(r'([1-9][0-9]*)x([1-9][0-9]*)', args.aspect.lower())
|
||||
if not match: ap.error('--aspect must be positive integer dimensions <w>x<h>')
|
||||
width, height = map(int, match.groups())
|
||||
if width * 9 == height * 16: ap.error('--aspect must have another shape than 16:9')
|
||||
args.aspect = f'{width}x{height}'
|
||||
HUD_CAP = {'full': None, '21:9': 21 / 9, '16:9': 16 / 9}[args.hud]
|
||||
if HUD_CAP is not None:
|
||||
if not args.aspect: ap.error('--hud needs --aspect')
|
||||
if HUD_CAP >= width / height * 0.99:
|
||||
ap.error(f'--hud {args.hud} is not narrower than a {width}x{height} screen (that is --hud full)')
|
||||
if not args.out:
|
||||
# Match runtime/romfs.c overlay_init, preserving the default 16:9 overlay.
|
||||
name = f'romfs-patches-{args.prompts}' if args.prompts else 'romfs-patches'
|
||||
if args.aspect: name += '-' + args.aspect
|
||||
if args.hud != 'full': name += '-hud' + args.hud.replace(':', 'x')
|
||||
args.out = root / 'build' / args.version / name
|
||||
index = json.loads((args.romfs / 'index.json').read_text())
|
||||
assert index['status'] == 'pass'
|
||||
files = {f['path']: f for f in index['files']}
|
||||
@@ -381,11 +405,10 @@ for member, panes in MEMBERS.items():
|
||||
patched[member] = changed
|
||||
layout = []
|
||||
if args.aspect:
|
||||
width, height = (int(v) for v in args.aspect.lower().split('x'))
|
||||
spec = importlib.util.spec_from_file_location('ultrawide_layout', Path(__file__).with_name('ultrawide_layout.py'))
|
||||
ultrawide = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(ultrawide)
|
||||
layout = ultrawide.apply(blarc, members, width, height)
|
||||
layout = ultrawide.apply(blarc, members, width, height, HUD_CAP)
|
||||
diff = [i for i in range(len(original)) if original[i] != blarc[i]]
|
||||
touched = [members[m] for m in (*MEMBERS, *layout)]
|
||||
assert diff and all(any(lo <= i < hi for lo, hi in touched) for i in diff), diff
|
||||
@@ -496,5 +519,5 @@ for path, contents in outputs.items():
|
||||
(args.out / 'manifest.tsv').write_text('# path\tsize\tsha256\toriginal_sha256 (tools/make_romfs_patches.py)\n'
|
||||
+ ''.join(line + '\n' for line in lines))
|
||||
print(json.dumps(dict(status='pass', path=ARCHIVE, members=patched, changed_bytes=len(diff),
|
||||
ultrawide_layout=dict(aspect=args.aspect, members=len(layout)) if args.aspect else None,
|
||||
ultrawide_layout=dict(aspect=args.aspect, hud=args.hud, members=len(layout)) if args.aspect else None,
|
||||
prompts=prompts, reused=reused)))
|
||||
+47
-23
@@ -12,6 +12,7 @@ found for 1.0.0 .. 1.2.1 (GPL; only those values are taken, no code; THIRD_PARTY
|
||||
implementation, checked against 1.2.1's Common.Product.110 and 1.4.3's Common.Product.140: every pane is found by name
|
||||
and every pane field and animation key holds the value the edit expects before it is written.
|
||||
"""
|
||||
import math
|
||||
import struct
|
||||
|
||||
# BFLYT pane sections (pan1, pic1, txt1, ...): name at +12 (24 bytes), translate x / y at +44 / +48, scale x / y at +68 / +72.
|
||||
@@ -48,10 +49,24 @@ MARKER_ROOT = {
|
||||
# animations only key alpha, visibility and N_Loop_00's y. (pane, x, y) as shipped.
|
||||
BALLOON_PART = (('C_CaptureBase_00', 226.0, 20.0), ('N_InOut_00', 30.0, -10.0))
|
||||
|
||||
def edits(k, hud_corner):
|
||||
def hud_extent(k, hud_aspect):
|
||||
"""(w_hud, right_hud) for the HUD: how far its edge moves out in a 1920-wide layout's own units (960 * (1 / kc - 1))
|
||||
and in the grid units of a root pane already scaled by k (960 * k * (1 / kc - 1)), where kc = (16/9) / C and C is
|
||||
the HUD's aspect: hud_aspect, never wider than the screen's 16/9 / k. None (or a cap that is not narrower than the
|
||||
screen) puts the HUD at the screen's edges: the same w and 960 * (1 - k) the screen itself uses. C = 16/9 gives
|
||||
(0, 0), the HUD in the middle 16:9 as shipped."""
|
||||
screen = (16 / 9) / k
|
||||
if hud_aspect is None or hud_aspect >= screen * 0.99: return 960 * (1 / k - 1), 960 * (1 - k)
|
||||
inner = 1 / ((16 / 9) / hud_aspect) - 1 # 1 / kc - 1
|
||||
return 960 * inner, 960 * k * inner
|
||||
|
||||
def edits(k, hud_aspect):
|
||||
"""(layout, pane, field, value) for the aspect: k = 16/9 over the aspect (the root's scale), w = how far a 1920-wide
|
||||
layout's edge moves out in its own units (960 * (1 / k - 1)). OFF moves a pane out of sight."""
|
||||
layout's edge moves out in its own units (960 * (1 / k - 1)). OFF moves a pane out of sight. hud_aspect: the
|
||||
widest aspect the HUD spreads over (None = the screen's, see hud_extent); w_hud and right_hud replace w and the
|
||||
root's x for the HUD panes below, everything else belongs to the screen and keeps w and k."""
|
||||
w, OFF = 960 * (1 / k - 1), 10000.0
|
||||
w_hud, right_hud = hud_extent(k, hud_aspect)
|
||||
wide = 1 / k
|
||||
out = [
|
||||
('AppAlbum_00', 'N_FadeInOut_00', 'scale_x', k), ('AppAlbum_00', 'N_Open_01', 'scale_x', wide),
|
||||
@@ -78,7 +93,8 @@ def edits(k, hud_corner):
|
||||
('PaCommonBtnTitle_00', 'B_Hit_00', 'x', OFF), ('PaCommonBtnTitle_00', 'N_Cursor_00', 'x', OFF),
|
||||
('PaLargeDungeonMap_00', 'P_BG_00', 'scale_x', wide), ('PaMessageBtn_00', 'B_Hit_00', 'x', OFF),
|
||||
('PaRecipeCardList_00', 'P_BG_00', 'scale_x', wide),
|
||||
('SaveLoadIcon_00', 'RootPane', 'x', -960 * (1 - k)),
|
||||
# The saving indicator follows the same selected HUD area as the other corner indicators.
|
||||
('SaveLoadIcon_00', 'RootPane', 'x', -right_hud),
|
||||
('ShopMenu_00', 'N_BG_00', 'scale_x', wide), ('StaffRoll_00', 'N_BG_00', 'scale_x', wide),
|
||||
*[e for pane, x, _ in BALLOON_PART for e in (('PaBalloonMessage_00', pane, 'scale_x', k),
|
||||
('PaBalloonMessage_00', pane, 'x', x * k))],
|
||||
@@ -97,18 +113,17 @@ def edits(k, hud_corner):
|
||||
('SystemActionGuide_00', 'N_SystemBG_00', 'scale_x', wide),
|
||||
('SystemActionGuide_00', 'P_DecoL_01', 'scale_x', k), ('SystemActionGuide_00', 'P_DecoL_01', 'x', -(675 + w) * k),
|
||||
('SystemActionGuide_00', 'P_DecoL_02', 'scale_x', k), ('SystemActionGuide_00', 'P_DecoL_02', 'x', (675 + w) * k)]
|
||||
if hud_corner: # the HUD in the screen's corners instead of the middle 16:9
|
||||
right = 960 * (1 - k)
|
||||
out += [(name, 'RootPane', 'x', right) for name in ('EnvironmentInfo_00', 'EventSkip_00', 'InstantTipsAppMenu_00',
|
||||
if hud_aspect is None or hud_aspect > 16 / 9: # the HUD out to its area's edges; at 16:9 it stays as shipped
|
||||
out += [(name, 'RootPane', 'x', right_hud) for name in ('EnvironmentInfo_00', 'EventSkip_00', 'InstantTipsAppMenu_00',
|
||||
'InstantTipsWithPict_00', 'InstantTips_00', 'NumDisplaySecond_00',
|
||||
'NumDisplay_00', 'PickUpWin_00')]
|
||||
out += [('Location_00', 'N_Small_00', 'x', -(388 + w)),
|
||||
('PlayerStatus3D_00', 'N_ExtraStaminaTarget_01', 'x', -(745 + w)),
|
||||
('PlayerStatus_00', 'N_DevilDemoTargetC_00', 'x', -(284 + w)),
|
||||
('PlayerStatus_00', 'N_DevilDemoTargetLT_00', 'x', -(576 + w)),
|
||||
('PlayerStatus_00', 'N_HeartGaugeTargetLT_00', 'x', -(576 + w)),
|
||||
('PlayerStatus_00', 'N_HeartPos_00', 'x', -w),
|
||||
('PlayerStatus_00', 'Pa_CompanionLife_00', 'x', -(840 + w))]
|
||||
out += [('Location_00', 'N_Small_00', 'x', -(388 + w_hud)),
|
||||
('PlayerStatus3D_00', 'N_ExtraStaminaTarget_01', 'x', -(745 + w_hud)),
|
||||
('PlayerStatus_00', 'N_DevilDemoTargetC_00', 'x', -(284 + w_hud)),
|
||||
('PlayerStatus_00', 'N_DevilDemoTargetLT_00', 'x', -(576 + w_hud)),
|
||||
('PlayerStatus_00', 'N_HeartGaugeTargetLT_00', 'x', -(576 + w_hud)),
|
||||
('PlayerStatus_00', 'N_HeartPos_00', 'x', -w_hud),
|
||||
('PlayerStatus_00', 'Pa_CompanionLife_00', 'x', -(840 + w_hud))]
|
||||
return out
|
||||
|
||||
SYSTEM_MENUS = ('SystemLoadList_00', 'SystemOption_00', 'SystemSaveLoad_00')
|
||||
@@ -217,12 +232,13 @@ def tall_anim(blarc, members, k, changed):
|
||||
if len(curves) != 1 or values != [1.08, 1.28]: raise SystemExit(f'PaMapIconDragonTears_00_Zoom P_Geoglyph_00: keys {values}')
|
||||
for key in curves[0]: put(key + 4, get(key + 4) / k)
|
||||
|
||||
def anim_edits(k, hud_corner):
|
||||
"""(animation, byte offset, value the game ships, new value): floats inside BFLAN key tables."""
|
||||
w = 960 * (1 / k - 1)
|
||||
def anim_edits(k, hud_aspect):
|
||||
"""(animation, byte offset, value the game ships, new value): floats inside BFLAN key tables. hud_aspect as in
|
||||
edits."""
|
||||
w_hud, _ = hud_extent(k, hud_aspect)
|
||||
out = [('PaMapIconDragonTears_00_Zoom', 288, 1.08, 1.08 / k), ('PaMapIconDragonTears_00_Zoom', 300, 1.28, 1.28 / k)]
|
||||
if hud_corner: # the minimap's slide-in keys end at x 765, the right edge of a 16:9 layout
|
||||
out += [('AppMap_00_MiniMap', o, 765.0, 765 + w) for o in (872, 880, 1628, 1636, 3264, 3272, 3468, 3476)]
|
||||
if hud_aspect is None or hud_aspect > 16 / 9: # the minimap's slide-in keys end at x 765, the right edge of a 16:9 layout
|
||||
out += [('AppMap_00_MiniMap', o, 765.0, 765 + w_hud) for o in (872, 880, 1628, 1636, 3264, 3272, 3468, 3476)]
|
||||
return out
|
||||
|
||||
def panes(blarc, lo, hi):
|
||||
@@ -243,10 +259,18 @@ def find_pane(found, layout, name):
|
||||
if name not in found: raise SystemExit(f'{layout}: no pane {name}')
|
||||
return found[name]
|
||||
|
||||
def apply(blarc, members, width, height, hud_corner=True):
|
||||
def apply(blarc, members, width, height, hud_aspect=None):
|
||||
"""Edits blarc (bytearray) in place for a width x height canvas of another shape than 16:9. Returns the members it
|
||||
changed. hud_corner (wider canvases): the HUD goes to the screen's corners; a narrower one always has it at the
|
||||
top and bottom edges."""
|
||||
changed. hud_aspect (wider canvases): the widest aspect the HUD spreads over, centred on the screen (21:9 =
|
||||
21 / 9, 16:9 = 16 / 9); None, or one not narrower than the screen, puts it in the screen's corners. A taller canvas
|
||||
always has the HUD at the top and bottom edges."""
|
||||
if not all(isinstance(v, (int, float)) and math.isfinite(v) and v > 0 for v in (width, height)):
|
||||
raise ValueError('canvas dimensions must be positive and finite')
|
||||
if hud_aspect is not None:
|
||||
if not math.isfinite(hud_aspect) or hud_aspect < 16 / 9:
|
||||
raise ValueError('HUD aspect must be finite and at least 16:9')
|
||||
# Runtime treats caps within one percent of the canvas as full width.
|
||||
if hud_aspect >= width / height * 0.99: hud_aspect = None
|
||||
wide = width / height > 16 / 9
|
||||
k = (16 / 9) / (width / height) if wide else (width / height) / (16 / 9)
|
||||
assert k < 1, 'only for canvases of another shape than 16:9'
|
||||
@@ -276,7 +300,7 @@ def apply(blarc, members, width, height, hud_corner=True):
|
||||
struct.pack_into('<f', blarc, at, k)
|
||||
# Every edit's value at k = 1 is the value the game ships (a scale of 1, the 16:9 position): checked before writing,
|
||||
# so a version with other numbers stops here instead of getting wrong positions. OFF moves a pane away: not checked.
|
||||
table = zip(edits(k, hud_corner), edits(1.0, hud_corner)) if wide else zip(tall_edits(k), tall_edits(1.0))
|
||||
table = zip(edits(k, hud_aspect), edits(1.0, hud_aspect)) if wide else zip(tall_edits(k), tall_edits(1.0))
|
||||
for (layout, pane, field, value), (_, _, _, shipped) in table:
|
||||
at = pane_offset(layout, pane) + FIELD[field]
|
||||
have = struct.unpack_from('<f', blarc, at)[0]
|
||||
@@ -285,7 +309,7 @@ def apply(blarc, members, width, height, hud_corner=True):
|
||||
if not wide:
|
||||
tall_anim(blarc, members, k, changed)
|
||||
return sorted(changed)
|
||||
for anim, offset, shipped, value in anim_edits(k, hud_corner):
|
||||
for anim, offset, shipped, value in anim_edits(k, hud_aspect):
|
||||
member = f'anim/{anim}.bflan'
|
||||
if member not in members: raise SystemExit(f'{anim}: no animation {member} in the archive')
|
||||
lo, hi = members[member]
|
||||
|
||||
@@ -200,6 +200,12 @@
|
||||
# laptop, 2560x1080 on a 21:9 monitor), so the picture fills the screen without black bars, with prompts = xbox or pc
|
||||
# too (on an install by an older setup, which built the Xbox prompts for 16:9 only, prompts = xbox keeps 1920x1080).
|
||||
# output_res = 1920x1080
|
||||
# HUD width on a game resolution wider than 16:9: full, the default, puts the HUD at the screen's left and right edges;
|
||||
# 21:9 keeps it within the middle 21:9 of the screen and 16:9 within the middle 16:9 (the game's own HUD), so the
|
||||
# corners of a 32:9 screen stay clear. A cap not narrower than the screen is the same as full, and a 16:9 or taller
|
||||
# screen ignores it. The installer prepares these layouts for the sizes in the list above (romfs-patches-<w>x<h>-hud21x9
|
||||
# and -hud16x9); without the folder the HUD stays at the edges. Read at start.
|
||||
# hud_width = full
|
||||
# 3D render scale: the scene's size relative to the game resolution, game (5/6, the game's own 1600x900 at 1080p) or
|
||||
# a percentage (25 to 400); above 100 supersamples the scene (anti-aliasing). The scene stays within 8192 pixels a side
|
||||
# and within a texture heap under 2 GiB (8192x2304 at most on a 5120x1440 output); the log says when it is smaller.
|
||||
|
||||
Reference in new issue
Block a user