mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-20 12:45:57 +00:00
Verify selective HUD shape preparation and fallback (#643)
This commit is contained in:
1 parent
bf6ebeafa5
commit
3a9e8ea50a
14 files changed
+606
-33
No files matched your search
+45
-1
@@ -6,6 +6,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "fs.h"
|
||||
#include "host.h"
|
||||
#include "input.h"
|
||||
#include "input_map.h"
|
||||
@@ -135,6 +136,9 @@ int probe_cfg(void) {
|
||||
CHECK(m && EQ(m->def, "1") && m->live, "meta: fps60 defaults to 1 and is live");
|
||||
m = cfg_meta("ASYNC_PREEMPT");
|
||||
CHECK(m && EQ(m->values, "0|1|2") && !m->live, "meta: async_preempt takes 0|1|2 and needs a restart");
|
||||
m = cfg_meta("HUD_WIDTH");
|
||||
CHECK(m && EQ(m->def, "full") && EQ(m->values, "full|21:9|16:9") && !m->live,
|
||||
"meta: HUD width defaults to full and changes after restart");
|
||||
m = cfg_meta("totk_vk_present");
|
||||
CHECK(m && EQ(m->key, "VK_PRESENT") && EQ(m->values, "mailbox|fifo|immediate") && m->live,
|
||||
"meta: prefix and case are accepted");
|
||||
@@ -363,12 +367,48 @@ int probe_cfg(void) {
|
||||
}
|
||||
snprintf(f, sizeof f, "%s/romfs-index.bin", dir);
|
||||
plat_setenv("TOTK_ROMFS_INDEX", f);
|
||||
plat_setenv("TOTK_HUD_WIDTH", NULL);
|
||||
static const char *const capped[] = {"romfs-patches-2560x1080-hud16x9",
|
||||
"romfs-patches-xbox-2560x1080-hud16x9",
|
||||
"romfs-patches-3840x1080-hud21x9"};
|
||||
for (size_t i = 0; i < sizeof capped / sizeof *capped; i++) {
|
||||
snprintf(f, sizeof f, "%s/%s/manifest.tsv", dir, capped[i]);
|
||||
plat_file_delete(f);
|
||||
}
|
||||
cfg_set("TOTK_HUD_WIDTH", "full");
|
||||
CHECK(romfs_shaped_ready(2560, 1080) && romfs_shaped_ready(5120, 2160) && !romfs_shaped_ready(3440, 1440),
|
||||
"shape: 5120x2160 finds 2560x1080's layout folder, 3440x1440 does not");
|
||||
CHECK(romfs_shaped_prompts_ready("romfs-patches-xbox", 5120, 2160) &&
|
||||
!romfs_shaped_prompts_ready("romfs-patches-xbox", 2560, 1080) &&
|
||||
!romfs_shaped_prompts_ready("romfs-patches-pc", 5120, 2160),
|
||||
"shape: an older install's exact-size prompts folder serves that size only");
|
||||
cfg_set("TOTK_HUD_WIDTH", "16:9");
|
||||
CHECK(romfs_shaped_ready(5120, 2160) && romfs_shape_missing(5120, 2160, NULL),
|
||||
"HUD: a full layout allows wide output but does not hide a missing selected cap");
|
||||
for (size_t i = 0; i < sizeof capped / sizeof *capped; i++) {
|
||||
snprintf(f, sizeof f, "%s/%s", dir, capped[i]);
|
||||
plat_file_mkdir_p(f);
|
||||
snprintf(f, sizeof f, "%s/%s/manifest.tsv", dir, capped[i]);
|
||||
plat_file_write(f, "#\n", 2);
|
||||
}
|
||||
CHECK(!romfs_shape_missing(5120, 2160, "romfs-patches-xbox") &&
|
||||
romfs_shape_missing(5120, 2160, "romfs-patches-pc"),
|
||||
"HUD: canonical capped layouts serve aliases, including Xbox; missing PC prompts still need preparation");
|
||||
cfg_set("TOTK_HUD_WIDTH", "21:9");
|
||||
CHECK(romfs_shape_missing(5120, 2160, NULL) && !romfs_shape_missing(5120, 1440, NULL),
|
||||
"HUD: a different cap needs a different folder; 5120x1440 uses the 3840x1080 shape");
|
||||
cfg_set("TOTK_HUD_WIDTH", "full");
|
||||
CHECK(!romfs_shaped_ready(5120, 1440), "HUD: switching to full does not reuse a capped-only layout");
|
||||
cfg_set("TOTK_HUD_WIDTH", "21:9");
|
||||
CHECK(!romfs_shape_missing(1920, 1080, NULL), "HUD: 16:9 output ignores a wider cap");
|
||||
plat_setenv("TOTK_ROMFS_PATCHES", "0");
|
||||
CHECK(!romfs_shape_missing(5120, 2160, NULL), "HUD: explicit overlay overrides do not request generated layouts");
|
||||
plat_setenv("TOTK_ROMFS_PATCHES", NULL);
|
||||
cfg_set("TOTK_HUD_WIDTH", "full");
|
||||
for (size_t i = 0; i < sizeof capped / sizeof *capped; i++) {
|
||||
snprintf(f, sizeof f, "%s/%s/manifest.tsv", dir, capped[i]);
|
||||
plat_file_delete(f);
|
||||
}
|
||||
plat_setenv("TOTK_ROMFS_INDEX", NULL);
|
||||
}
|
||||
uint8_t pd[PAD_COUNT] = {0};
|
||||
@@ -496,7 +536,11 @@ int probe_cfg(void) {
|
||||
char name[96];
|
||||
snprintf(name, sizeof name, "TOTK_%s", m->key);
|
||||
plat_setenv(name, "");
|
||||
CHECK(EQ(cfg_value(name), m->def), "cfg_value returns the table default");
|
||||
// cfg_get may supply a display or device-profile default (notably OUTPUT_RES on an ultrawide monitor).
|
||||
// The metadata default is used only when those leave the setting unset.
|
||||
const char *effective = cfg_get(name);
|
||||
CHECK(EQ(cfg_value(name), effective && *effective ? effective : m->def),
|
||||
"cfg_value uses the effective default, falling back to the metadata table");
|
||||
int ok = 0;
|
||||
if (!m->values) ok = 1;
|
||||
else if (strstr(m->values, "..")) {
|
||||
|
||||
+3
-3
@@ -47,12 +47,12 @@ enum { ROMFS_PROMPTS_OK, ROMFS_PROMPTS_MISSING, ROMFS_PROMPTS_FAILED, ROMFS_PROM
|
||||
ROMFS_PROMPTS_PATCHES };
|
||||
const char *romfs_prompts(void);
|
||||
int romfs_prompts_ready(const char *folder);
|
||||
// 1 when the game resolution w x h is of another shape whose folders are missing: the UI layout, or that of
|
||||
// prompts_folder (a prompts' folder that is there at 16:9; NULL for the game's own prompts). romfs.c shaped_name.
|
||||
// 1 when w x h is of another shape whose selected HUD layout or prompts_folder's selected variant is missing.
|
||||
// NULL prompts_folder means the game's own prompts; a full-layout fallback does not satisfy a requested HUD cap.
|
||||
int romfs_shape_missing(unsigned w, unsigned h, const char *prompts_folder);
|
||||
// 1 when build-cache/rebuild.txt names the setup's Python and tools/make_romfs_patches.py and both exist, with romfs/.
|
||||
int romfs_shape_can_prepare(void);
|
||||
// Starts the generator for w x h's shape (its layout, and prompts_folder's when that is there at 16:9 and lacks it) as
|
||||
// Starts the generator for w x h's shape and selected HUD width (including prompts_folder's variant when needed) as
|
||||
// child processes the game does not wait for; the next start loads the result. 1 when every one started.
|
||||
int romfs_shape_prepare(unsigned w, unsigned h, const char *prompts_folder);
|
||||
int romfs_prompts_off(const char *folder);
|
||||
|
||||
+10
-4
@@ -1223,8 +1223,8 @@ int romfs_shape_can_prepare(void) {
|
||||
// The folders a generator was started for in this process. The menu thread alone calls romfs_shape_prepare, so no
|
||||
// lock. The game picks its overlay at start, so a folder is not started twice before the next start, even when its
|
||||
// generator has ended: a second click, or the same size chosen again, starts no second generator writing into it.
|
||||
static char shape_started[8][160];
|
||||
static int shape_started_n;
|
||||
static char (*shape_started)[160];
|
||||
static int shape_started_n, shape_started_cap;
|
||||
|
||||
static int shape_was_started(const char *folder) {
|
||||
for (int i = 0; i < shape_started_n; i++)
|
||||
@@ -1237,9 +1237,15 @@ static int shape_was_started(const char *folder) {
|
||||
// thread one CreateProcess.
|
||||
static int shape_spawn(const char *const *argv, const char *dir, const char *folder) {
|
||||
if (shape_was_started(folder)) return 1;
|
||||
if (shape_started_n == shape_started_cap) {
|
||||
int cap = shape_started_cap ? shape_started_cap * 2 : 8;
|
||||
void *grown = realloc(shape_started, (size_t)cap * sizeof *shape_started);
|
||||
if (!grown) return 0; // never start a writer whose folder cannot be remembered for deduplication
|
||||
shape_started = grown;
|
||||
shape_started_cap = cap;
|
||||
}
|
||||
if (!plat_spawn(argv, dir)) return 0;
|
||||
if (shape_started_n < (int)(sizeof shape_started / sizeof *shape_started))
|
||||
snprintf(shape_started[shape_started_n++], sizeof *shape_started, "%s", folder);
|
||||
snprintf(shape_started[shape_started_n++], sizeof *shape_started, "%s", folder);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -549,17 +549,17 @@ static void row_output_res(void) {
|
||||
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).
|
||||
// Offer only caps narrower than the canonical layout, using the same tolerance as romfs.c hud_suffix and Shapes.
|
||||
// This also keeps a selected 21:9 cap visible after changing to a slightly wider-than-21:9 game resolution.
|
||||
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;
|
||||
unsigned w = 0, h = 0, shape[2];
|
||||
if (sscanf(cfg_value("TOTK_OUTPUT_RES"), "%ux%u", &w, &h) != 2 || !h) return;
|
||||
shape[0] = w, shape[1] = h;
|
||||
cfg_shape_size(w, h, shape);
|
||||
double aspect = (double)shape[0] / shape[1];
|
||||
if (16.0 / 9 >= aspect * 0.99) 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;
|
||||
int n = 21.0 / 9 < aspect * 0.99 ? 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);
|
||||
}
|
||||
|
||||
+4
-4
@@ -70,7 +70,7 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[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.",
|
||||
"of that shape. Prepare a missing layout in this tab or rerun setup, then restart.",
|
||||
[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 "
|
||||
@@ -646,7 +646,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[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 игры доводит её до этого размера. "
|
||||
@@ -1263,7 +1263,7 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[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.",
|
||||
"desse formato. Prepare o layout ausente nesta aba ou execute a instalação novamente e reinicie o 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 "
|
||||
@@ -1890,7 +1890,7 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[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 场景相对于游戏分辨率的尺寸;"
|
||||
|
||||
Reference in new issue
Block a user