Redraw the in-game menu with the game's own interface textures, and bring in the launcher's save import and faster builds.

In-game menu: the settings window, its tabs, rows, buttons and cursor, the performance overlay and the Preparing
shaders box are drawn with the game's interface textures where the RomFS holds them (runtime/ui/menu_skin.cpp,
perf_panel.cpp; plain shapes until they are decoded). Restart joins Continue and Quit, each behind a confirmation;
VSync is an on/off switch; DLSS is listed only on NVIDIA GPUs; the menu sounds are quieter; Picture shape is gone and
the setting descriptions are shorter; edge cases of input, layout and fonts are fixed. tools/menu_preview.py draws the
menu without the game.

Launcher: Import Saves takes a save from the game folder's saves/ folder or one the player picks; downloads fall back
to Windows' own certificate check when Python's refuses a server; updates are faster; the title bar is drawn in the
window and Navi is every icon. tools/make_game.py builds with CLANG64's clang where the launcher installed it, packs
the RomFS beside the lift and the compile, takes a prebuilt runtime, and compiles the game's resources without cmd.exe,
so a user folder with a space in its name builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-08 03:57:01 -05:00
parent 5b28da3a06
commit 8daedbd806
42 changed files with 4138 additions and 972 deletions

View File

@@ -50,7 +50,7 @@ static const char *const known[] = {
"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",
"MV_SURVEY",
"ONE_PER_CORE", "OPERATION_MODE", "OUTPUT_RES", "PAD_LAYOUT", "PACE_HZ", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_RES_FIXED", "PATCH_SCENE", "PATCH_WIDE_ASPECT", "PATCH_WIDE_HUD", "PATCH_WIDE_MOVIE", "PATCH_WIDE_OUT", "PATCH_WIDE_SCENE", "PCSS", "PCSS_K", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT",
"PREWARM_WAIT_MS", "PREWARM_XLATE", "PROBE_MOVIE", "PROBE_MOVIE_SHOT", "PROFILE", "PROFILE_CHAINS", "PROFILE_DIR", "PROFILE_FRAMES",
"PREWARM_FULL", "PREWARM_WAIT_MS", "PREWARM_XLATE", "PROBE_MOVIE", "PROBE_MOVIE_SHOT", "PROFILE", "PROFILE_CHAINS", "PROFILE_DIR", "PROFILE_FRAMES",
"PROFILE_MAIN", "PROFILE_RENDER", "PROMPTS", "PUSH_SKIP", "PUSH_STAGE", "RDOC", "RDOC_DIR", "RDOC_DLL", "REALTIME", "REC_END", "REEXEC",
"RENDER_SCALE", "REPLAY_ASYNC", "RTSS",
"REPLAY_CHECK", "RESOLVE_CHECK", "RESTART_WAIT", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES",

View File

@@ -137,11 +137,16 @@ static float volume(void) {
static _Atomic uint64_t last_start_ns;
// The least time between a cursor tick and the sound before it. Moving down a list or changing a value asks for a tick
// at every step, about 20 a second while a direction is held, and the focus moving with a press or a tab change is part
// of that sound: at most five ticks a second are heard.
#define CURSOR_GAP_NS 180000000ull
#define CURSOR_GAIN 0.6f // the tick under the sounds of a decision
void menu_sound_play(MenuSound id) {
if ((unsigned)id >= MENU_SOUND_COUNT || volume() <= 0) return;
// A cursor tick right after another sound (the focus moving with a tab change or a press) is the same action.
uint64_t now = plat_now_ns();
if (id == MENU_SOUND_CURSOR && now - atomic_load(&last_start_ns) < 40000000ull) return;
if (id == MENU_SOUND_CURSOR && now - atomic_load(&last_start_ns) < CURSOR_GAP_NS) return;
atomic_store(&last_start_ns, now);
if (atomic_load_explicit(&loaded, memory_order_acquire) != 2) load_all();
if (atomic_load_explicit(&loaded, memory_order_acquire) != 2 || !sounds[id].pcm) return;
@@ -151,9 +156,11 @@ void menu_sound_play(MenuSound id) {
if (atomic_load_explicit(&voices[i].pos, memory_order_acquire) < 0) { pick = i; break; }
if (voices[i].started < oldest) oldest = voices[i].started, pick = i;
}
// A sound that replaces itself (holding a direction) restarts instead of stacking up.
// A sound that replaces itself restarts instead of stacking up, and a decision replaces the tick of the same press
// (a row changes its value in the frame the press is seen).
for (int i = 0; i < VOICES; i++)
if (atomic_load_explicit(&voices[i].pos, memory_order_acquire) >= 0 && atomic_load(&voices[i].sound) == (int)id &&
if (atomic_load_explicit(&voices[i].pos, memory_order_acquire) >= 0 &&
(atomic_load(&voices[i].sound) == (int)id || atomic_load(&voices[i].sound) == MENU_SOUND_CURSOR) &&
atomic_load(&voices[i].pos) < 2400) { // started under 50 ms ago
pick = i;
break;
@@ -170,13 +177,15 @@ void menu_sound_mix(float *out, uint32_t frames, int channels, int rate) {
for (int v = 0; v < VOICES; v++) {
int pos = atomic_load_explicit(&voices[v].pos, memory_order_acquire);
if (pos < 0) continue;
const Sound *s = &sounds[atomic_load_explicit(&voices[v].sound, memory_order_relaxed)];
int which = atomic_load_explicit(&voices[v].sound, memory_order_relaxed);
const Sound *s = &sounds[which];
if (g < 0) g = volume();
float vg = which == MENU_SOUND_CURSOR ? g * CURSOR_GAIN : g;
uint32_t n = s->frames - (uint32_t)pos < frames ? s->frames - (uint32_t)pos : frames;
const float *src = s->pcm + (size_t)pos * 2;
for (uint32_t i = 0; i < n; i++) {
out[(size_t)i * channels] += src[2 * i] * g;
out[(size_t)i * channels + 1] += src[2 * i + 1] * g;
out[(size_t)i * channels] += src[2 * i] * vg;
out[(size_t)i * channels + 1] += src[2 * i + 1] * vg;
}
int next = pos + (int)n;
// Only advance if the menu thread did not restart the voice meanwhile.

View File

@@ -192,13 +192,14 @@ static void capture_window(void) {
if (!ImGui::IsPopupOpen("##bind_capture")) ImGui::OpenPopup("##bind_capture");
uint64_t now = plat_now_ns();
bool pad_cell = g_cap.cell == 2;
// the timeout first: a press polled after it would compare with a held state long gone and bind what is held now
if (!g_cap.done && now - g_cap.start > CAPTURE_SECONDS * 1000000000ull) g_cap.done = now;
if (!g_cap.done) {
int id = 0, got = input_capture(g_cap.reset, &id);
g_cap.reset = false;
if (got == INPUT_CAPTURE_KEY && !pad_cell) change(g_cap.action, g_cap.cell, id);
if (got == INPUT_CAPTURE_PAD && pad_cell) change(g_cap.action, g_cap.cell, id);
if (got != INPUT_CAPTURE_NONE && !(got == INPUT_CAPTURE_KEY && pad_cell)) g_cap.done = now;
if (now - g_cap.start > CAPTURE_SECONDS * 1000000000ull) g_cap.done = now;
}
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
if (ImGui::BeginPopupModal("##bind_capture", nullptr,
@@ -222,6 +223,8 @@ static void capture_window(void) {
bool binds_modal(void) { return g_cap.action >= 0; }
void binds_cancel(void) { g_cap.action = -1; }
static bool g_reset_asked; // the reset row was chosen this frame (acted on after the page)
void binds_rows(float scale) {

View File

@@ -8,3 +8,6 @@ void binds_rows(float scale);
void binds_after_page(void);
// A cell waits for a press (or its press is still reaching the menu): B, Esc, L / R and the tab keys stay on the page.
bool binds_modal(void);
// The menu opened or closed (menu.cpp): a cell still waiting for a press stops waiting, unchanged. Its window is closed
// with the menu's popups.
void binds_cancel(void);

View File

@@ -32,10 +32,12 @@ static int g_font_bad;
#include "menu_sound.h"
#include "menu_assets.h"
#include "ui/menu_art.h"
#include "ui/menu_skin.h"
#pragma clang diagnostic pop
#include "ui/amiibo_page.h"
#include "ui/binds_page.h"
#include "ui/option_rows.h"
#include "ui/perf_panel.h"
extern "C" {
#include "amiibo.h"
@@ -86,13 +88,20 @@ static std::atomic<int> g_reset; // opened or closed since the last laid-out
// (F1, Esc), the polling thread (combo) and the present path (Continue, B) race.
static PlatMutex open_lock = PLAT_MUTEX_INIT;
// want 0 or 1 sets the state; -1 flips it. Returns the new state.
static PlatMutex ev_lock = PLAT_MUTEX_INIT; // the event queue below
static int ev_n;
// want 0 or 1 sets the state; -1 flips it. Returns the new state. The window events queued before the change go with it:
// keys pressed just before a close would otherwise reach the menu when it next opens.
static int change_open(int want) {
plat_mutex_lock(&open_lock);
int open = want < 0 ? !g_open.load() : want;
if (g_open.load() != open) {
g_open.store(open);
g_reset.store(1);
plat_mutex_lock(&ev_lock);
ev_n = 0;
plat_mutex_unlock(&ev_lock);
input_menu(open);
menu_sound_play(open ? MENU_SOUND_OPEN : MENU_SOUND_CLOSE);
rt_log("menu: %s", open ? "open" : "closed");
@@ -104,9 +113,9 @@ static int change_open(int want) {
static void set_open(int open) { change_open(open); }
static int g_failed_flag();
// The boot screen is up (menu_boot_set): the menu does not open, as it would not be drawn while its keys queued up and
// changed settings once the game ran.
static std::atomic<int> g_booting{0};
// Until the game's first frame (menu_overlay_frame), boot screen included: the menu does not open, as it would not be
// drawn while its keys queued up and changed settings once the game ran.
static std::atomic<int> g_booting{1};
extern "C" int menu_is_open(void) { return g_open.load(std::memory_order_relaxed); }
extern "C" void menu_toggle(void) {
if (!g_failed_flag() && !g_booting.load(std::memory_order_acquire)) change_open(-1);
@@ -115,13 +124,17 @@ extern "C" void menu_toggle(void) {
// ---- events from the window adapter, queued while the menu is open; the present path hands them to ImGui
enum { EV_KEY, EV_POS, EV_BUTTON, EV_WHEEL, EV_FOCUS, EV_MAX = 256 };
struct Ev { int type, a, b; float x, y; };
static PlatMutex ev_lock = PLAT_MUTEX_INIT;
static Ev ev_q[EV_MAX];
static int ev_n;
static void push(Ev e) {
if (!menu_is_open()) return;
plat_mutex_lock(&ev_lock);
// checked again under the lock: change_open empties the queue after the state changes, so an event of the closed
// menu cannot slip in behind that
if (!menu_is_open()) {
plat_mutex_unlock(&ev_lock);
return;
}
if (e.type == EV_POS && ev_n && ev_q[ev_n - 1].type == EV_POS) ev_q[ev_n - 1] = e; // only the newest position
else if (ev_n < EV_MAX) ev_q[ev_n++] = e;
plat_mutex_unlock(&ev_lock);
@@ -143,7 +156,12 @@ static void drain_events(ImGuiIO &io) {
for (int i = 0; i < n; i++) {
const Ev &e = q[i];
switch (e.type) {
case EV_KEY: io.AddKeyEvent((ImGuiKey)e.a, e.b != 0); break;
case EV_KEY:
io.AddKeyEvent((ImGuiKey)e.a, e.b != 0);
// ImGui takes the modifier state (io.KeyShift, io.KeyCtrl: Shift+Tab, Ctrl+Up) from these keys only
if (e.a == ImGuiKey_LeftShift) io.AddKeyEvent(ImGuiMod_Shift, e.b != 0);
if (e.a == ImGuiKey_LeftCtrl) io.AddKeyEvent(ImGuiMod_Ctrl, e.b != 0);
break;
case EV_POS: io.AddMousePosEvent(e.x, e.y); break;
case EV_BUTTON: io.AddMouseButtonEvent(e.a, e.b != 0); break;
case EV_WHEEL: io.AddMouseWheelEvent(e.x, e.y); break;
@@ -204,51 +222,17 @@ static ImGuiStyle g_base_style; // the menu's style at 1080 lines
static uint64_t g_last_ns;
static uint64_t g_cost_ns, g_cost_frames; // CPU time of layout and recording while open, logged per 600 frames
// Sizes are tuned for 1080 lines and follow the window's height. Under 720 lines at 100% display scale they stay at the
// 720 size; that floor grows with the window's DPI, so a small window on a 150% or 200% display (sizes are physical
// pixels) still gets text as large as the display scale asks for.
static float menu_scale(uint32_t h) {
float least = 720.0f * (float)gfx_window_dpi() / 96.0f;
return ((float)h >= least ? (float)h : least) / 1080.0f;
// Sizes are tuned for 1080 lines and follow the window's height, or its width in a window narrower than 1.47:1, where
// the menu's 1400 pixels at 1080 lines would no longer fit 88 % of the width (layout_menu). Under 720 lines at 100%
// display scale they stay at the 720 size; that floor grows with the window's DPI, so a small window on a 150% or 200%
// display (sizes are physical pixels) still gets text as large as the display scale asks for.
static float menu_scale(uint32_t w, uint32_t h) {
float least = 720.0f * (float)gfx_window_dpi() / 96.0f, lines = fminf((float)h, (float)w * 0.68f);
return (lines >= least ? lines : least) / 1080.0f;
}
// The game's menu colours: a dark umber panel, warm browns for frames and what is selected, gold for the ornaments,
// accents and the cursor, parchment text. kGreen and kOcarina keep their names for the selected and active controls.
static const ImVec4 kGold(0.93f, 0.76f, 0.38f, 1), kGreen(0.36f, 0.26f, 0.13f, 1), kNavy(0.075f, 0.058f, 0.042f, 0.95f),
kOcarina(0.62f, 0.47f, 0.22f, 1);
static void style_init(ImGuiStyle &s) {
ImGui::StyleColorsDark(&s);
s.WindowRounding = 10; s.FrameRounding = 6; s.GrabRounding = 6; s.TabRounding = 6; s.ChildRounding = 8;
s.WindowPadding = ImVec2(40, 30); s.FramePadding = ImVec2(14, 8); s.ItemSpacing = ImVec2(14, 12);
s.WindowBorderSize = 2; s.ScrollbarSize = 16;
ImVec4 *c = s.Colors;
c[ImGuiCol_WindowBg] = kNavy;
c[ImGuiCol_Border] = ImVec4(kGold.x, kGold.y, kGold.z, 0.55f);
c[ImGuiCol_ChildBg] = ImVec4(0, 0, 0, 0);
c[ImGuiCol_PopupBg] = kNavy;
c[ImGuiCol_Text] = ImVec4(0.96f, 0.92f, 0.82f, 1);
c[ImGuiCol_TextDisabled] = ImVec4(0.62f, 0.56f, 0.46f, 1);
c[ImGuiCol_FrameBg] = ImVec4(0.15f, 0.115f, 0.08f, 1);
c[ImGuiCol_FrameBgHovered] = ImVec4(0.24f, 0.18f, 0.10f, 1);
c[ImGuiCol_FrameBgActive] = kGreen;
c[ImGuiCol_SliderGrab] = kOcarina;
c[ImGuiCol_SliderGrabActive] = kGold;
c[ImGuiCol_CheckMark] = kGold;
c[ImGuiCol_Button] = ImVec4(0.19f, 0.145f, 0.09f, 1);
c[ImGuiCol_ButtonHovered] = kGreen;
c[ImGuiCol_ButtonActive] = kOcarina;
c[ImGuiCol_Header] = ImVec4(0.24f, 0.18f, 0.10f, 1);
c[ImGuiCol_HeaderHovered] = kGreen;
c[ImGuiCol_HeaderActive] = kOcarina;
c[ImGuiCol_Tab] = ImVec4(0.13f, 0.10f, 0.07f, 1);
c[ImGuiCol_TabHovered] = kGreen;
c[ImGuiCol_TabSelected] = ImVec4(0.42f, 0.31f, 0.15f, 1);
c[ImGuiCol_TabSelectedOverline] = kGold;
c[ImGuiCol_NavCursor] = kGold;
c[ImGuiCol_Separator] = ImVec4(kGold.x, kGold.y, kGold.z, 0.30f);
c[ImGuiCol_ScrollbarGrab] = ImVec4(0.36f, 0.28f, 0.16f, 1);
c[ImGuiCol_ScrollbarBg] = ImVec4(0, 0, 0, 0.2f);
}
// The gold of the title and its Triforce (the rest of the menu's colours: ui/menu_skin.cpp skin_style).
static const ImVec4 kGold(0.93f, 0.76f, 0.38f, 1);
// The Triforce, its top at (x, y), h high, drawn with the title.
static void triforce(ImDrawList *dl, float x, float y, float h, ImU32 col) {
@@ -266,7 +250,9 @@ static void make_context(void) {
io.LogFilename = nullptr;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard | ImGuiConfigFlags_NavEnableGamepad;
io.BackendPlatformName = "nx2navi_menu";
style_init(g_base_style);
// no window switcher on Ctrl+Tab (the menu is one window; the switcher would list its inner windows by their ids)
GImGui->ConfigNavWindowingKeyNext = GImGui->ConfigNavWindowingKeyPrev = 0;
skin_style(g_base_style);
ImGui::GetStyle() = g_base_style;
g_ctx_ok = 1;
}
@@ -398,11 +384,12 @@ static int fonts_up(float scale) {
fa->AddFontFromMemoryTTF((void *)roboto_ttf, (int)sizeof roboto_ttf, 26.0f * scale, &fc, kRanges);
}
uint8_t *data[N] = {};
ImVector<ImWchar> ranges[N];
uint64_t sizes[N] = {};
ImVector<ImWchar> ranges[N], title_ranges[N];
int merged = 0;
for (int i = 0; i < N; i++) {
char path[512];
uint64_t size = 0;
uint64_t &size = sizes[i];
if (!plat_font_path(kCjk[i].lang, path, sizeof path) || !(data[i] = plat_file_read(path, &size))) continue;
if (!font_usable(data[i], size)) {
rt_log("menu: system font %s left out: the font parser cannot read it (%llu bytes)", path,
@@ -435,7 +422,23 @@ static int fonts_up(float scale) {
rc.MergeMode = true;
rc.FontDataOwnedByAtlas = false;
fa->AddFontFromMemoryTTF((void *)roboto_ttf, (int)sizeof roboto_ttf, 30.0f * scale, &rc, kRanges);
// what the title face shows in the CJK languages: the menu's title and tabs (Simplified Chinese menu text) and
// the boot screen's title (the game's language)
static const UiTextId titles[] = {UI_MENU_TITLE, UI_MENU_TAB_SCREEN, UI_MENU_TAB_GAME, UI_MENU_TAB_SOUND,
UI_MENU_TAB_CONTROLS, UI_BOOT_TITLE};
for (int i = 0; i < N; i++) {
if (!data[i]) continue;
ImFontGlyphRangesBuilder b;
for (UiTextId id : titles) b.AddText(ui_text_in(kCjk[i].lang, id));
b.BuildRanges(&title_ranges[i]);
ImFontConfig mc;
mc.MergeMode = true;
mc.FontDataOwnedByAtlas = false;
fa->AddFontFromMemoryTTF(data[i], (int)sizes[i], 31.0f * scale, &mc, title_ranges[i].Data);
}
}
skin_atlas_add(fa); // the boxes' grain tile (ui/menu_skin.cpp), drawn into the atlas once it is built
skin_atlas_fill(fa); // builds the atlas, which the upload below then takes as it is
vk_queue_lock(); // the upload submits on the queue and waits for it
int ok = ImGui_ImplVulkan_CreateFontsTexture();
// ClarimoUDPE's line (ascent to descent, which is all Dear ImGui spaces lines by) leaves wrapped lines touching: the
@@ -450,19 +453,25 @@ static int fonts_up(float scale) {
return ok;
}
// The font atlas follows the window's scale: rebuilt at once when it is more than 12% off (text would blur or shrink
// visibly), else once the scale has held for half a second, so dragging a window's edge does not rebuild it, and read the
// system's fonts again, every frame. Until then io.FontGlobalScale stretches the atlas there is. False: fonts_up failed.
static bool fonts_follow(float scale) {
static float last;
static uint64_t since;
uint64_t now = plat_now_ns();
if (scale != last) last = scale, since = now;
// The atlas for scale. While the scale keeps changing (the window being resized), the atlas is made again only once it
// has held for a quarter of a second, and the old one is drawn scaled meanwhile (io.FontGlobalScale): each atlas reads
// the system fonts from disk and waits for the queue to upload. 0 when no atlas could be made.
static float g_scale_seen;
static uint64_t g_scale_seen_ns;
static int fonts_for(float scale, uint64_t now) {
ImGuiIO &io = ImGui::GetIO();
if (g_font_scale != scale && (!g_font_scale || fabsf(g_font_scale / scale - 1) > 0.12f || now - since > 500000000ull))
if (!fonts_up(scale)) return false;
io.FontGlobalScale = scale / g_font_scale;
return true;
if (g_font_scale == scale) {
io.FontGlobalScale = 1;
return 1;
}
if (scale != g_scale_seen) g_scale_seen = scale, g_scale_seen_ns = now;
if (g_font_scale > 0 && now - g_scale_seen_ns < 250000000ull) {
io.FontGlobalScale = scale / g_font_scale;
return 1;
}
io.FontGlobalScale = 1;
return fonts_up(scale);
}
extern "C" void menu_vk_release(void) {
@@ -740,21 +749,33 @@ static const char *present_name(const char *mode) {
return nullptr;
}
// "in use: VSync" under the Presentation value when the swapchain got another mode than the setting (a driver without
// mailbox gets fifo); NULL when they agree or before the first swapchain.
static const char *present_note(void) {
const char *got = gfx_window_present_mode(), *name = present_name(got);
if (!*got || !strcmp(got, cfg_value("NX2NAVI_VK_PRESENT")) || !name) return nullptr;
// "in use: VSync" under the VSync row when it is off and the driver cannot present without waiting; NULL otherwise, and
// before the first swapchain.
static const char *vsync_note(void) {
const char *got = gfx_window_present_mode();
if (!*got || strcmp(cfg_value("NX2NAVI_VK_PRESENT"), "immediate") || !strcmp(got, "immediate")) return nullptr;
static char note[96];
snprintf(note, sizeof note, menu_text(UI_MENU_PRESENT_IN_USE), name);
snprintf(note, sizeof note, menu_text(UI_MENU_PRESENT_IN_USE), menu_text(UI_MENU_PRESENT_VSYNC));
return note;
}
// ---- the tabs
// The PCI vendor of the GPU the game renders on (menu_overlay_frame reads it from the device it is given; 0 before the
// first frame). DLSS runs on NVIDIA GPUs only, so the rows below leave it out elsewhere (AMD, Intel).
static std::atomic<uint32_t> g_gpu_vendor;
static VkPhysicalDevice g_gpu_vendor_of;
static bool dlss_offered(void) {
uint32_t v = g_gpu_vendor.load(std::memory_order_relaxed);
return v == 0 || v == 0x10de; // unknown (no frame yet): as before, offered
}
// One upscaling choice over three settings: NX2NAVI_UPSCALER (how the picture is fitted to the window), NX2NAVI_DLAA
// (DLSS on) and NX2NAVI_DLSS (its mode, the render scale: widescreen.c wide_present). A DLSS mode fits the picture with
// bilinear, DLSS having made it; the model is NVIDIA's own for the mode (vk_dlaa.c evaluate, dlss_preset at its default).
// (DLSS or FSR 3.1 on) with NX2NAVI_TAA (which of them) and NX2NAVI_DLSS (the mode, the render scale: widescreen.c
// wide_present). A temporal mode fits the picture with bilinear, the upscaler having made it; DLSS's model is NVIDIA's own
// for the mode (vk_dlaa.c evaluate, dlss_preset at its default). The list: bilinear, FSR 1, the DLSS modes where DLSS
// runs (dlss_offered), the FSR 3.1 modes; a DLSS mode still set where DLSS does not run stays listed last until another
// choice replaces it, so the row shows what is set.
static void row_upscaling(void) {
static const char *const modes[] = {"dlaa", "quality", "balanced", "performance", "ultra_performance"};
static const UiTextId mode_names[] = {UI_MENU_DLSS_DLAA, UI_MENU_DLSS_QUALITY, UI_MENU_DLSS_BALANCED,
@@ -762,28 +783,51 @@ static void row_upscaling(void) {
// FSR 3.1's modes take the same render scales as DLSS's (Native AA is FSR's name for DLAA's full size)
static const UiTextId fsr_names[] = {UI_MENU_FSR3_NATIVE, UI_MENU_DLSS_QUALITY, UI_MENU_DLSS_BALANCED,
UI_MENU_DLSS_PERFORMANCE, UI_MENU_DLSS_ULTRA};
static char dl[10][96];
const char *names[12] = {menu_text(UI_MENU_UPSCALER_BILINEAR), menu_text(UI_MENU_UPSCALER_FSR)};
for (int i = 0; i < 5; i++) {
snprintf(dl[i], sizeof dl[i], i ? "DLSS %s" : "NVIDIA %s", menu_text(mode_names[i]));
snprintf(dl[5 + i], sizeof dl[5 + i], "AMD FSR 3.1 %s", menu_text(fsr_names[i]));
names[2 + i] = dl[i], names[7 + i] = dl[5 + i];
}
int cur = strcmp(cfg_value("NX2NAVI_UPSCALER"), "fsr") ? 0 : 1;
enum { BILINEAR, FSR1, DLSS, FSR3 };
struct Entry { int kind, mode; };
static char text[10][96];
Entry list[12];
const char *names[12];
int n = 0;
auto add = [&](int kind, int mode) {
list[n] = {kind, mode};
if (kind == BILINEAR) names[n] = menu_text(UI_MENU_UPSCALER_BILINEAR);
else if (kind == FSR1) names[n] = menu_text(UI_MENU_UPSCALER_FSR);
else {
char *t = text[(kind == FSR3 ? 5 : 0) + mode];
if (kind == DLSS) snprintf(t, sizeof text[0], mode ? "DLSS %s" : "NVIDIA %s", menu_text(mode_names[mode]));
else snprintf(t, sizeof text[0], "AMD FSR 3.1 %s", menu_text(fsr_names[mode]));
names[n] = t;
}
n++;
};
// what is set now
Entry now = {strcmp(cfg_value("NX2NAVI_UPSCALER"), "fsr") ? BILINEAR : FSR1, 0};
if (cfg_bool("NX2NAVI_DLAA")) {
int base = strcmp(cfg_value("NX2NAVI_TAA"), "fsr3") ? 2 : 7;
cur = base;
now = {strcmp(cfg_value("NX2NAVI_TAA"), "fsr3") ? DLSS : FSR3, 0};
for (int i = 0; i < 5; i++)
if (!strcmp(cfg_value("NX2NAVI_DLSS"), modes[i])) cur = base + i;
if (!strcmp(cfg_value("NX2NAVI_DLSS"), modes[i])) now.mode = i;
}
int nv = opt_choice_index("NX2NAVI_UPSCALER", UI_MENU_UPSCALING, names, 12, cur, 1, UI_MENU_UPSCALING_DESC,
cur >= 2 ? menu_text(UI_MENU_UPSCALING_DLSS_NOTE) : nullptr);
if (nv < 0) return;
opt_apply("NX2NAVI_UPSCALER", nv == 1 ? "fsr" : "bilinear");
opt_apply("NX2NAVI_DLAA", nv >= 2 ? "1" : "0");
if (nv < 2) opt_apply("NX2NAVI_FRAMEGEN", "off"); // it needs DLSS's or FSR 3.1's motion vectors (row_framegen)
if (nv >= 2) opt_apply("NX2NAVI_DLSS", modes[(nv - 2) % 5]);
if (nv >= 2) opt_apply("NX2NAVI_TAA", nv >= 7 ? "fsr3" : "dlss");
const bool dlss = dlss_offered();
add(BILINEAR, 0);
add(FSR1, 0);
for (int i = 0; dlss && i < 5; i++) add(DLSS, i);
for (int i = 0; i < 5; i++) add(FSR3, i);
if (!dlss && now.kind == DLSS) add(DLSS, now.mode);
int cur = 0;
for (int i = 0; i < n; i++)
if (list[i].kind == now.kind && list[i].mode == now.mode) cur = i;
bool temporal = now.kind >= DLSS;
int nv = opt_choice_index("NX2NAVI_UPSCALER", UI_MENU_UPSCALING, names, n, cur, 1,
dlss ? UI_MENU_UPSCALING_DESC : UI_MENU_UPSCALING_DESC_FSR,
temporal ? menu_text(dlss ? UI_MENU_UPSCALING_DLSS_NOTE : UI_MENU_UPSCALING_FSR_NOTE) : nullptr);
if (nv < 0 || nv >= n) return;
const Entry e = list[nv];
opt_apply("NX2NAVI_UPSCALER", e.kind == FSR1 ? "fsr" : "bilinear");
opt_apply("NX2NAVI_DLAA", e.kind >= DLSS ? "1" : "0");
if (e.kind < DLSS) opt_apply("NX2NAVI_FRAMEGEN", "off"); // it needs DLSS's or FSR 3.1's motion vectors (row_framegen)
if (e.kind >= DLSS) opt_apply("NX2NAVI_DLSS", modes[e.mode]);
if (e.kind >= DLSS) opt_apply("NX2NAVI_TAA", e.kind == FSR3 ? "fsr3" : "dlss");
}
// "in use: off" under the HDR value when the game started with HDR on but the swapchain is not HDR10 (the display or
@@ -813,7 +857,8 @@ static void row_hdr(void) {
// Frame generation (vk_fg.cpp), after a restart; it needs a temporal upscaler's motion vectors
static void row_framegen(void) {
// the generated frames are made from DLSS's or FSR 3.1's motion vectors: without one of them it would do nothing
if (!cfg_bool("NX2NAVI_DLAA")) opt_disable_next(UI_MENU_FRAMEGEN_NEEDS);
const bool dlss = dlss_offered();
if (!cfg_bool("NX2NAVI_DLAA")) opt_disable_next(dlss ? UI_MENU_FRAMEGEN_NEEDS : UI_MENU_FRAMEGEN_NEEDS_FSR);
static const char *const values[] = {"off", "fsr3", "dlss"};
const char *names[] = {menu_text(UI_MENU_FRAMEGEN_OFF), "AMD FSR 3.1", "NVIDIA DLSS"};
const char *v = cfg_value("NX2NAVI_FRAMEGEN");
@@ -821,9 +866,10 @@ static void row_framegen(void) {
// NVIDIA DLSS (vk_dlssg.c) is listed only while it is set: Streamline now starts and takes the swapchain, but presents
// no generated frames yet (one presented per frame, status OK)
int n = cur == 2 ? 3 : 2;
int nv = opt_choice_index("NX2NAVI_FRAMEGEN", UI_MENU_FRAMEGEN, names, n, cur, 0, UI_MENU_FRAMEGEN_DESC,
menu_text(UI_MENU_FRAMEGEN_NOTE));
if (nv >= 0) opt_apply("NX2NAVI_FRAMEGEN", values[nv]);
int nv = opt_choice_index("NX2NAVI_FRAMEGEN", UI_MENU_FRAMEGEN, names, n, cur, 0,
dlss ? UI_MENU_FRAMEGEN_DESC : UI_MENU_FRAMEGEN_DESC_FSR,
menu_text(dlss ? UI_MENU_FRAMEGEN_NOTE : UI_MENU_FRAMEGEN_NOTE_FSR));
if (nv >= 0 && nv < n) opt_apply("NX2NAVI_FRAMEGEN", values[nv]);
}
// The picture's height (widescreen.c picture_height): the game's 1440 or more.
@@ -837,8 +883,9 @@ static void tab_screen(float scale) {
opt_begin("##screen", scale);
opt_toggle("NX2NAVI_FULLSCREEN", UI_MENU_FULLSCREEN, UI_MENU_FULLSCREEN_DESC);
row_window_size();
static const UiTextId present[] = {UI_MENU_PRESENT_MAILBOX, UI_MENU_PRESENT_VSYNC, UI_MENU_PRESENT_IMMEDIATE};
opt_choice("NX2NAVI_VK_PRESENT", UI_MENU_PRESENT, present, 3, UI_MENU_PRESENT_DESC, present_note());
// On is the default mode, mailbox with its fallbacks (gfx_present.c pick_present_mode): plain fifo would drop the
// game to 30 at every slow frame on a 60 Hz display. A fifo already saved also reads as on.
opt_toggle_value("NX2NAVI_VK_PRESENT", UI_MENU_PRESENT_VSYNC, UI_MENU_PRESENT_DESC, "mailbox", "immediate", vsync_note());
row_gpu();
static const UiTextId perf[] = {UI_MENU_PERF_OFF, UI_MENU_PERF_FPS, UI_MENU_PERF_FULL};
opt_choice("NX2NAVI_PERF_OVERLAY", UI_MENU_PERF_OVERLAY, perf, 3, UI_MENU_PERF_OVERLAY_DESC);
@@ -859,8 +906,6 @@ static void tab_screen(float scale) {
int dl = cfg_bool("NX2NAVI_DLAA"), fsr3 = dl && !strcmp(cfg_value("NX2NAVI_TAA"), "fsr3");
if (!fsr3 && (strcmp(cfg_value("NX2NAVI_UPSCALER"), "fsr") || dl)) opt_disable_next(UI_MENU_SHARPNESS_NEEDS_FSR);
opt_slider("NX2NAVI_SHARPNESS", UI_MENU_SHARPNESS, 0, 100, UI_MENU_SHARPNESS_DESC, 5, "%.0f %%");
static const UiTextId aspect[] = {UI_MENU_ASPECT_FIT, UI_MENU_ASPECT_STRETCH};
opt_choice("NX2NAVI_ASPECT", UI_MENU_ASPECT, aspect, 2, UI_MENU_ASPECT_DESC);
opt_end();
}
@@ -955,34 +1000,44 @@ static const char *prompts_note(bool *restart) {
}
}
// The confirmation of "Restart now", over the menu; Cancel has the cursor first. Restart writes nx2navi.ini, then closes
// the game as Quit does and starts it again (gfx_window_request_restart). It waits while the game writes a save, and
// the game stays when nx2navi.ini cannot be written, as the new prompts would not come back. From the Cheats tab
// (restart_rebuild) Restart also lets the next start rebuild for cheats whose last rebuild failed (cheats_rebuild_allow).
static bool restart_rebuild;
static void restart_confirm(void) {
// The confirmation of the menu's Restart button, over the menu; Cancel has the cursor first. Restart writes nx2navi.ini,
// then closes the game as Quit does and starts it again (gfx_window_request_restart). It waits while the game writes a
// save, and the game stays when nx2navi.ini cannot be written, as the changed settings would not come back. From the
// Cheats tab (restart_rebuild) Restart also lets the next start rebuild for cheats whose last rebuild failed
// (cheats_rebuild_allow). The Quit button's confirmation is the same box (g_confirm_quit): closing the window already
// finishes a save in progress (gfx_window_closed), so it does not wait.
static bool restart_rebuild, g_confirm_quit;
static void restart_confirm(float scale) {
g_modal = false;
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
if (!ImGui::BeginPopupModal("##restart_confirm", nullptr,
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize))
return;
ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 0);
const bool open = ImGui::BeginPopupModal("##confirm", nullptr,
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize);
ImGui::PopStyleVar();
if (!open) return;
g_modal = true;
ImGui::TextUnformatted(menu_text(UI_MENU_RESTART_CONFIRM));
bool saving = fs_save_busy() != 0;
if (saving || !cfg_last_save_ok())
const ImVec2 box = ImGui::GetWindowPos(), box_size = ImGui::GetWindowSize();
skin_panel(ImGui::GetWindowDrawList(), box, ImVec2(box.x + box_size.x, box.y + box_size.y), scale);
ImGui::TextUnformatted(menu_text(g_confirm_quit ? UI_MENU_QUIT_CONFIRM : UI_MENU_RESTART_CONFIRM));
bool saving = !g_confirm_quit && fs_save_busy() != 0;
if (saving || (!g_confirm_quit && !cfg_last_save_ok()))
ImGui::TextColored(ImVec4(0.95f, 0.45f, 0.35f, 1), "%s",
menu_text(saving ? UI_MENU_RESTART_SAVING : UI_MENU_SAVE_FAILED));
ImGui::Spacing();
const char *yes = menu_text(UI_MENU_RESTART_YES), *no = menu_text(UI_MENU_RESET_NO);
const char *yes = menu_text(g_confirm_quit ? UI_MENU_QUIT : UI_MENU_RESTART_YES), *no = menu_text(UI_MENU_RESET_NO);
const ImGuiStyle &st = ImGui::GetStyle();
float bw = fmaxf(ImGui::CalcTextSize(yes).x, ImGui::CalcTextSize(no).x) + st.FramePadding.x * 4;
bool close = ImGui::Button(no, ImVec2(bw, 0));
bool close = skin_widget_button(no, ImVec2(bw, 0), scale);
if (ImGui::IsWindowAppearing()) ImGui::SetItemDefaultFocus();
ImGui::SameLine();
ImGui::SameLine(0, st.ItemSpacing.x + skin_cursor_reach(scale));
ImGui::BeginDisabled(saving);
if (ImGui::Button(yes, ImVec2(bw, 0)) && cfg_save()) {
if (restart_rebuild) cheats_rebuild_allow();
gfx_window_request_restart();
if (skin_widget_button(yes, ImVec2(bw, 0), scale)) {
if (g_confirm_quit) {
gfx_window_request_close();
} else if (cfg_save()) {
if (restart_rebuild) cheats_rebuild_allow();
gfx_window_request_restart();
}
}
ImGui::EndDisabled();
if (ImGui::IsKeyPressed(ImGuiKey_Escape, false) || ImGui::IsKeyPressed(ImGuiKey_GamepadFaceRight, false))
@@ -990,7 +1045,6 @@ static void restart_confirm(void) {
if (close) {
ImGui::CloseCurrentPopup();
restart_rebuild = false;
opt_focus_key("##restart"); // back on the row it came from
}
ImGui::EndPopup();
}
@@ -1031,18 +1085,26 @@ static void go_to(int tab, const char *key) {
}
// The game's interface sounds (menu_sound.c) for what the frame did: a press or click on an item, the cursor on another
// item, another tab by a click (L and R play theirs where they are read). The first frame after opening only records.
// item, another tab by a click (L, R, Q and E play theirs where they are read: g_tab_sounded). The first frame after
// opening only records: the open sound has played, and the cursor going to the first row is part of it. g_sound_fresh
// marks that frame, as the frame count alone does not when nothing was laid out while the menu was closed.
static bool g_sound_fresh;
static int g_tab_sounded = -1; // the tab L / R / Q / E asked for, its sound played
static void menu_sounds_frame(void) {
ImGuiContext &g = *GImGui;
static int last_frame = -2, last_tab = -1;
static ImGuiID last_nav;
bool fresh = g.FrameCount != last_frame + 1;
bool fresh = g_sound_fresh || g.FrameCount != last_frame + 1;
g_sound_fresh = false;
last_frame = g.FrameCount;
if (!fresh) {
if (g.ActiveId && g.ActiveIdIsJustActivated) menu_sound_play(MENU_SOUND_DECIDE);
else if (g.NavId && g.NavId != last_nav) menu_sound_play(MENU_SOUND_CURSOR);
if (g_tab != last_tab && last_tab >= 0) menu_sound_play(g_tab > last_tab ? MENU_SOUND_TAB_RIGHT : MENU_SOUND_TAB_LEFT);
if (g_tab != last_tab && last_tab >= 0 && g_tab != g_tab_sounded)
menu_sound_play(g_tab > last_tab ? MENU_SOUND_TAB_RIGHT : MENU_SOUND_TAB_LEFT);
}
if (g_tab != last_tab) g_tab_sounded = -1;
last_nav = g.NavId, last_tab = g_tab;
}
@@ -1058,7 +1120,6 @@ static void layout_menu(uint32_t w, uint32_t h, float scale) {
ImGuiWindowFlags_NoSavedSettings);
if (framed) ImGui::PopStyleVar();
const ImVec2 win_p = ImGui::GetWindowPos(), win_s = ImGui::GetWindowSize();
const float inset = 7 * scale;
// The game's ornamented frame (ui/menu_art.cpp; nothing without the RomFS's), in gold. Its lines lie inside the
// texture (about 4 % of the width, 7 % of the height in), so the frame is drawn that far outside the window and its
// lines run along the window's edge, clear of the title and the rows; unclipped, it may reach past the window.
@@ -1085,19 +1146,24 @@ static void layout_menu(uint32_t w, uint32_t h, float scale) {
ImGui::SameLine();
ImGui::TextUnformatted(menu_text(UI_MENU_TITLE));
}
const float title_end = ImGui::GetItemRectMax().x;
if (g_title_font) ImGui::PopFont();
// the port version and the game update, right-aligned on the title line: what a bug report needs first
// the port version and the game update, right-aligned on the title line: what a bug report needs first; left out
// where it would run into the title (a narrow window, a long title)
char game[16], version[96];
snprintf(game, sizeof game, "%d.%d.%d", rt_game_version / 100, rt_game_version / 10 % 10, rt_game_version % 10);
snprintf(version, sizeof version, "NX2navi %s - game %s", rt_port_version, game);
ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetStyle().WindowPadding.x - ImGui::CalcTextSize(version).x);
ImGui::TextDisabled("%s", version);
float version_x = win_s.x - ImGui::GetStyle().WindowPadding.x - ImGui::CalcTextSize(version).x;
if (win_p.x + version_x >= title_end + ImGui::GetStyle().ItemSpacing.x * 2) {
ImGui::SameLine(version_x);
ImGui::TextDisabled("%s", version);
}
int step = g_modal || binds_modal() ? 0
: ImGui::IsKeyPressed(ImGuiKey_GamepadR1, false) || ImGui::IsKeyPressed(ImGuiKey_E, false) ? 1
: ImGui::IsKeyPressed(ImGuiKey_GamepadL1, false) || ImGui::IsKeyPressed(ImGuiKey_Q, false) ? -1
: 0;
if (step) g_tab_request = (g_tab + step + TAB_COUNT) % TAB_COUNT;
if (step) g_tab_request = g_tab_sounded = (g_tab + step + TAB_COUNT) % TAB_COUNT;
if (step) menu_sound_play(step > 0 ? MENU_SOUND_TAB_RIGHT : MENU_SOUND_TAB_LEFT);
if (g_tab_request >= 0) g_focus_page = g_tab_request; // the new page's first row takes the cursor
@@ -1107,9 +1173,8 @@ static void layout_menu(uint32_t w, uint32_t h, float scale) {
for (int k = 0; k < TAB_COUNT; k++) {
char label[128];
snprintf(label, sizeof label, " %s ###tab%d", menu_text(kTabNames[k]), k); // the id stays per language
if (g_title_font) ImGui::PushFont(g_title_font); // the tab labels in the title face
bool shown = ImGui::BeginTabItem(label, nullptr, g_tab_request == k ? ImGuiTabItemFlags_SetSelected : 0);
if (g_title_font) ImGui::PopFont();
// the tab labels in the title face, on the rows' button (ui/menu_skin.cpp)
bool shown = skin_tab_item(label, menu_text(kTabNames[k]), g_tab_request == k ? ImGuiTabItemFlags_SetSelected : 0, scale, g_title_font);
if (!shown) continue;
g_tab = k;
if (g_focus_page == k) {
@@ -1146,15 +1211,20 @@ static void layout_menu(uint32_t w, uint32_t h, float scale) {
ImGui::SetCursorPosY(y + st.FramePadding.y);
ImGui::TextColored(ImVec4(0.95f, 0.45f, 0.35f, 1), "%s", menu_text(UI_MENU_SAVE_FAILED));
}
const char *cont = menu_text(UI_MENU_CONTINUE), *quit = menu_text(UI_MENU_QUIT);
float bw = fmaxf(ImGui::CalcTextSize(cont).x, ImGui::CalcTextSize(quit).x) + st.FramePadding.x * 4;
ImGui::SetCursorPos(ImVec2(ImGui::GetWindowWidth() - st.WindowPadding.x - bw * 2 - st.ItemSpacing.x, y));
if (ImGui::Button(cont, ImVec2(bw, 0))) set_open(0);
ImGui::SameLine();
if (ImGui::Button(quit, ImVec2(bw, 0))) gfx_window_request_close();
const char *cont = menu_text(UI_MENU_CONTINUE), *restart = menu_text(UI_MENU_RESTART_YES), *quit = menu_text(UI_MENU_QUIT);
float bw = fmaxf(fmaxf(ImGui::CalcTextSize(cont).x, ImGui::CalcTextSize(restart).x), ImGui::CalcTextSize(quit).x) + st.FramePadding.x * 4;
// the save menu's brown buttons, with the game's cursor on the selected one (ui/menu_skin.cpp)
float gap = st.ItemSpacing.x + skin_cursor_reach(scale);
// right-aligned; in a window too narrow for all three, from the left edge
ImGui::SetCursorPos(ImVec2(fmaxf(st.WindowPadding.x, ImGui::GetWindowWidth() - st.WindowPadding.x - bw * 3 - gap * 2), y));
if (skin_widget_button(cont, ImVec2(bw, 0), scale)) set_open(0);
ImGui::SameLine(0, gap);
if (skin_widget_button(restart, ImVec2(bw, 0), scale)) g_confirm_quit = false, ImGui::OpenPopup("##confirm");
ImGui::SameLine(0, gap);
if (skin_widget_button(quit, ImVec2(bw, 0), scale)) g_confirm_quit = true, ImGui::OpenPopup("##confirm");
restart_confirm(scale);
menu_sounds_frame();
bool was_modal = g_modal || binds_modal();
if (g_tab != TAB_CONTROLS) g_modal = false;
if (!was_modal && (ImGui::IsKeyPressed(ImGuiKey_Escape, false) || ImGui::IsKeyPressed(ImGuiKey_GamepadFaceRight, false)))
set_open(0);
ImGui::End();
@@ -1240,54 +1310,13 @@ static void perf_tick(uint64_t now, const MenuTarget *t) {
g_perf_last_ns = now;
}
// The panel keeps its width while the numbers change: every column is as wide as the widest text it can show, measured
// on samples of 8s (Roboto's digits share one width), and the numbers are right-aligned in it.
struct PerfCol { UiTextId fmt; float sample; };
static float perf_text_w(UiTextId fmt, float v) {
char b[64];
snprintf(b, sizeof b, menu_text(fmt), v);
return ImGui::CalcTextSize(b).x;
}
// A fixed column as wide as the widest of the formats (with their samples) and labels given.
static void perf_column(const char *id, const PerfCol *cols, int n, const UiTextId *labels = nullptr, int nl = 0) {
float w = ImGui::CalcTextSize(menu_text(UI_MENU_OV_NONE)).x;
for (int i = 0; i < n; i++) w = fmaxf(w, perf_text_w(cols[i].fmt, cols[i].sample));
for (int i = 0; i < nl; i++) w = fmaxf(w, ImGui::CalcTextSize(menu_text(labels[i])).x);
ImGui::TableSetupColumn(id, ImGuiTableColumnFlags_WidthFixed, w);
}
static void perf_right(const char *s, bool dim) {
float pad = ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(s).x;
if (pad > 0) ImGui::SetCursorPosX(ImGui::GetCursorPosX() + pad);
if (dim) ImGui::TextDisabled("%s", s);
else ImGui::TextUnformatted(s);
}
// One cell of the full panel's table: fmt (a catalog format, one number) with v, or "-" when the machine gives none.
static void perf_cell(UiTextId fmt, float v) {
ImGui::TableNextColumn();
if (v < 0) return perf_right(menu_text(UI_MENU_OV_NONE), true);
char b[64];
snprintf(b, sizeof b, menu_text(fmt), v);
perf_right(b, false);
}
static void perf_label(UiTextId label, const ImVec4 &c) {
ImGui::TableNextColumn();
ImGui::TextColored(c, "%s", menu_text(label));
}
static float perf_gb(float mb) { return mb < 0 ? -1 : mb / 1024; }
// The picture lines: the window, the game image the present shows and the 3D scene it holds (resolution.c), how the
// present scales the image to the window (gfx_present.c, the last present), the frame limit and the presentation mode
// in use.
static void perf_picture(const MenuTarget *t, const ImVec4 &c) {
// in use; formatted into the panel's picture lines.
static void perf_picture(const MenuTarget *t, PerfPanel *p) {
unsigned out[2], scene[2];
res_sizes(out, scene);
char v[6][64];
char (*v)[64] = p->picture;
snprintf(v[0], sizeof v[0], menu_text(UI_MENU_OV_FMT_SIZE), t->width, t->height);
snprintf(v[1], sizeof v[1], menu_text(UI_MENU_OV_FMT_SIZE), (unsigned)t->image_w, (unsigned)t->image_h);
snprintf(v[2], sizeof v[2], menu_text(UI_MENU_OV_FMT_SCENE), scene[0], scene[1], scene[0] * 100.0 / out[0]);
@@ -1309,42 +1338,16 @@ static void perf_picture(const MenuTarget *t, const ImVec4 &c) {
if (hz > 0) snprintf(v[4], sizeof v[4], menu_text(UI_MENU_OV_FPS), hz);
const char *pm = present_name(gfx_window_present_mode());
snprintf(v[5], sizeof v[5], "%s", pm ? pm : menu_text(UI_MENU_OV_NONE));
static const UiTextId labels[6] = {UI_MENU_OV_WINDOW, UI_MENU_OV_OUTPUT, UI_MENU_OV_SCENE,
UI_MENU_OV_SCALING, UI_MENU_OV_LIMIT, UI_MENU_OV_PRESENT};
// The 3D scene's size is known only where resolution.c sets it (the builds with its patch sets); Ocarina sizes its own scene
// dynamically and res_sizes would report a fixed 1600x900, so the line is left out
bool scene_known = res_adjustable() != 0;
if (!ImGui::BeginTable("##perfp", 2, ImGuiTableFlags_SizingFixedFit)) return;
float vw = 0;
for (auto &s : v) vw = fmaxf(vw, ImGui::CalcTextSize(s).x);
ImGui::TableSetupColumn("##p0", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("##p1", ImGuiTableColumnFlags_WidthFixed, vw);
for (int i = 0; i < 6; i++) {
if (i == 2 && !scene_known) continue;
perf_label(labels[i], c);
ImGui::TableNextColumn();
perf_right(v[i], false);
}
ImGui::EndTable();
// The 3D scene's size is known only where resolution.c sets it (the builds with its patch sets); Ocarina sizes its
// own scene dynamically and res_sizes would report a fixed 1600x900, so the line is left out
p->scene_known = res_adjustable() != 0;
}
// The full panel (ui/perf_panel.cpp draws it in the menu's look): the numbers of this frame.
static void perf_full_draw(const MenuTarget *t, float scale) {
float w = (float)t->width;
PerfStats s;
perfmon_snapshot(&s);
ImGui::SetNextWindowPos(ImVec2(w - 12 * scale, 12 * scale), ImGuiCond_Always, ImVec2(1, 0));
ImGui::SetNextWindowBgAlpha(0.6f);
ImGui::Begin("##perf", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoNav |
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoSavedSettings);
// under the menu while it is open (the settings stay readable), else over everything
if (g_open.load(std::memory_order_relaxed)) ImGui::BringWindowToDisplayBack(ImGui::GetCurrentWindow());
else ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow());
ImGui::SetWindowFontScale(0.72f);
const ImVec4 gpu_c(0.55f, 0.83f, 0.31f, 1), cpu_c(0.18f, 0.59f, 0.80f, 1), ram_c(0.80f, 0.45f, 0.70f, 1),
fps_c(0.95f, 0.95f, 0.95f, 1), wait_c(0.93f, 0.76f, 0.33f, 1), pic_c(0.62f, 0.70f, 0.95f, 1);
// the port version and the game update first, so a screenshot in a bug report carries both; formatted once per
// menu language
static PerfPanel p;
perfmon_snapshot(&p.s);
// the port version and the game update, formatted once per menu language
static char ver[96];
static const char *ver_fmt;
if (ver_fmt != menu_text(UI_MENU_VERSION)) {
@@ -1353,82 +1356,11 @@ static void perf_full_draw(const MenuTarget *t, float scale) {
snprintf(game, sizeof game, "%d.%d.%d", rt_game_version / 100, rt_game_version / 10 % 10, rt_game_version % 10);
snprintf(ver, sizeof ver, ver_fmt, rt_port_version, game);
}
ImGui::TextDisabled("%s", ver);
if (ImGui::BeginTable("##perft", 4, ImGuiTableFlags_SizingFixedFit)) {
static const UiTextId labels[] = {UI_MENU_OV_GPU, UI_MENU_OV_VRAM, UI_MENU_OV_CPU, UI_MENU_OV_RAM,
UI_MENU_OV_FPS_LABEL, UI_MENU_OV_FRAME_LABEL};
static const PerfCol c1[] = {{UI_MENU_OV_FMT_PCT, 100}, {UI_MENU_OV_FMT_GB, 888.8f}, {UI_MENU_OV_FMT_FPS, 888},
{UI_MENU_OV_FRAME_MS, 888.8f}};
static const PerfCol c2[] = {{UI_MENU_OV_FMT_TEMP, 188}, {UI_MENU_OV_FMT_GB_OF, 888.8f}, {UI_MENU_OV_LOW1, 888},
{UI_MENU_OV_MAX_MS, 8888.8f}};
static const PerfCol c3[] = {{UI_MENU_OV_FMT_POWER, 888}, {UI_MENU_OV_FMT_MHZ, 8888}, {UI_MENU_OV_GAME_PCT, 100},
{UI_MENU_OV_GAME_GB, 888.8f}, {UI_MENU_OV_LOW01, 888}};
perf_column("##c0", nullptr, 0, labels, 6);
perf_column("##c1", c1, 4);
perf_column("##c2", c2, 4);
perf_column("##c3", c3, 5);
perf_label(UI_MENU_OV_GPU, gpu_c);
perf_cell(UI_MENU_OV_FMT_PCT, s.gpu_pct);
perf_cell(UI_MENU_OV_FMT_TEMP, s.gpu_temp_c);
perf_cell(UI_MENU_OV_FMT_POWER, s.gpu_power_w);
perf_label(UI_MENU_OV_VRAM, gpu_c);
perf_cell(UI_MENU_OV_FMT_GB, perf_gb(s.vram_used_mb));
perf_cell(UI_MENU_OV_FMT_GB_OF, perf_gb(s.vram_total_mb));
perf_cell(UI_MENU_OV_FMT_MHZ, s.gpu_clock_mhz);
perf_label(UI_MENU_OV_CPU, cpu_c);
perf_cell(UI_MENU_OV_FMT_PCT, s.cpu_total_pct);
perf_cell(UI_MENU_OV_FMT_TEMP, s.cpu_temp_c);
perf_cell(UI_MENU_OV_GAME_PCT, s.cpu_game_pct);
perf_label(UI_MENU_OV_RAM, ram_c);
perf_cell(UI_MENU_OV_FMT_GB, perf_gb(s.ram_used_mb));
perf_cell(UI_MENU_OV_FMT_GB_OF, perf_gb(s.ram_total_mb));
perf_cell(UI_MENU_OV_GAME_GB, perf_gb(s.ram_game_mb));
ImGui::TableNextRow(ImGuiTableRowFlags_None, 6 * scale); // a gap between the machine and the frames
// the frames: the rate over the last second with the lows over the last ten seconds, then the frame times
perf_label(UI_MENU_OV_FPS_LABEL, fps_c);
perf_cell(UI_MENU_OV_FMT_FPS, s.fps);
perf_cell(UI_MENU_OV_LOW1, s.low1_fps);
perf_cell(UI_MENU_OV_LOW01, s.low01_fps);
if (gfx_output_fps() > 0) { // frame generation: what the display gets, generated frames included
perf_label(UI_MENU_OV_FG_LABEL, fps_c);
perf_cell(UI_MENU_OV_FMT_FPS, (float)gfx_output_fps());
ImGui::TableNextColumn();
ImGui::TableNextColumn();
}
perf_label(UI_MENU_OV_FRAME_LABEL, fps_c);
perf_cell(UI_MENU_OV_FRAME_MS, s.frame_ms_avg);
perf_cell(UI_MENU_OV_MAX_MS, s.frame_ms_max);
ImGui::TableNextColumn();
ImGui::EndTable();
}
float top = s.frame_ms_max > 50 ? s.frame_ms_max : 50;
// as wide as the panel the tables size; the plot does not count toward that width, so the panel can still shrink
ImGuiWindow *win = ImGui::GetCurrentWindow();
float max_x = win->DC.CursorMaxPos.x;
ImGui::PlotLines("##ft", s.frame_ms, PERF_HISTORY, 0, nullptr, 0, top, ImVec2(-FLT_MIN, 48 * scale));
win->DC.CursorMaxPos.x = max_x;
// per frame, averaged over the last half second; the labels' column stretches, so the numbers end at the panel's
// right edge, and the table still asks for no more than its widest label and number
if (ImGui::BeginTable("##perfw", 2, ImGuiTableFlags_SizingFixedFit)) {
static const PerfCol c1[] = {{UI_MENU_OV_FMT_MS, 888.88f}, {UI_MENU_OV_PER_FRAME, 888.8f}};
ImGui::TableSetupColumn("##w0", ImGuiTableColumnFlags_WidthStretch);
perf_column("##w1", c1, 2);
perf_label(UI_MENU_OV_REPLAY, wait_c);
perf_cell(UI_MENU_OV_FMT_MS, s.replay_ms);
perf_label(UI_MENU_OV_GPU_TIME, wait_c);
perf_cell(UI_MENU_OV_FMT_MS, s.gpu_ms);
perf_label(UI_MENU_OV_PIPE_WAIT, wait_c);
perf_cell(UI_MENU_OV_FMT_MS, s.pipe_wait_ms);
perf_label(UI_MENU_OV_SHADER_WAIT, wait_c);
perf_cell(UI_MENU_OV_FMT_MS, s.xlate_ms);
perf_label(UI_MENU_OV_TEX_UPLOADS, wait_c);
perf_cell(UI_MENU_OV_PER_FRAME, s.tex_uploads);
ImGui::EndTable();
}
perf_picture(t, pic_c);
if (s.gpu_name[0]) ImGui::TextDisabled("%s", s.gpu_name);
if (s.cpu_name[0]) ImGui::TextDisabled("%s", s.cpu_name);
ImGui::End();
p.version = ver;
perf_picture(t, &p);
p.fg_fps = gfx_output_fps() > 0 ? (float)gfx_output_fps() : 0;
p.under_menu = g_open.load(std::memory_order_relaxed) != 0;
perf_panel_draw(&p, (float)t->width, scale);
}
static void perf_draw(const MenuTarget *t, float scale) {
@@ -1438,14 +1370,21 @@ static void perf_draw(const MenuTarget *t, float scale) {
// with the menu open: under its window, over the dimming layout_menu drew before
ImDrawList *dl = g_open.load(std::memory_order_relaxed) ? ImGui::GetBackgroundDrawList() : ImGui::GetForegroundDrawList();
ImVec2 sz = ImGui::CalcTextSize(g_perf_text);
float pad = 6 * scale;
ImVec2 p(w - 12 * scale - sz.x - pad * 2, 12 * scale); // the top right corner: the game's HUD leaves it empty
dl->AddRectFilled(p, ImVec2(p.x + sz.x + pad * 2, p.y + sz.y + pad * 2), IM_COL32(0, 0, 0, 150), 4 * scale);
dl->AddText(ImVec2(p.x + pad, p.y + pad), IM_COL32(255, 255, 255, 235), g_perf_text);
float padx = 14 * scale, pady = 9 * scale;
ImVec2 p(w - 12 * scale - sz.x - padx * 2, 12 * scale); // the top right corner: the game's HUD leaves it empty
// a small panel in the menu's look (ui/menu_skin.cpp), its frame scaled to the line
skin_panel(dl, p, ImVec2(p.x + sz.x + padx * 2, p.y + sz.y + pady * 2), scale * 0.6f, 0.9f);
dl->AddText(ImVec2(p.x + padx, p.y + pady), SKIN_TEXT, g_perf_text);
}
extern "C" int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const char **shot) {
*shot = NULL;
if (t->phys && t->phys != g_gpu_vendor_of) { // the GPU's vendor for the rows that depend on it (dlss_offered)
VkPhysicalDeviceProperties props;
vkGetPhysicalDeviceProperties(t->phys, &props);
g_gpu_vendor.store(props.vendorID, std::memory_order_relaxed);
g_gpu_vendor_of = t->phys;
}
menu_art_start(); // the game's interface textures decode on a worker from the first present on
cheats_frame(frame); // the data cheats and the buttons of the cheats that need them held
if (!g_test.parsed) test_parse();
@@ -1453,7 +1392,13 @@ extern "C" int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const cha
if (g_perf_save.exchange(0)) cfg_save();
perf_tick(plat_now_ns(), t);
amiibo_tick();
if (g_booting.load(std::memory_order_relaxed)) g_booting.store(0, std::memory_order_release); // the game runs
bool open = g_open.load(std::memory_order_relaxed);
// the frame the menu is first laid out after opening: also when its g_reset went to an earlier frame of the overlay
// alone (the menu opened between the two loads), the pad's buttons held now must not count as presses
static bool was_open;
bool opened = open && !was_open;
was_open = open;
if (!open) {
if (g_save_pending) g_save_pending = opt_save_tick(1); // closed: the last change goes to nx2navi.ini now
if (g_test.at && !g_test.opened && frame >= g_test.at) {
@@ -1472,8 +1417,8 @@ extern "C" int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const cha
}
uint64_t t0 = plat_now_ns();
if (!g_ctx_ok) make_context();
float scale = menu_scale(t->height);
if (!vk_up(t) || !fonts_follow(scale)) {
float scale = menu_scale(t->width, t->height);
if (!vk_up(t) || !fonts_for(scale, t0)) {
rt_log("menu: Dear ImGui Vulkan back end set-up failed; the menu stays closed");
g_failed.store(1);
set_open(0);
@@ -1492,8 +1437,11 @@ extern "C" int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const cha
// ran without its focus row and with the opening key still down.
open = g_open.load(std::memory_order_acquire);
if (reset) {
io.ClearEventsQueue(); // events handed over before the close and not yet taken (ImGui spreads them over frames)
io.ClearInputKeys();
io.ClearInputMouse();
binds_cancel(); // a cell waiting for a press when the menu closed: no press binds on the next opening
g_sound_fresh = true;
g_last_ns = 0;
g_focus_page = g_tab_request >= 0 ? g_tab_request : g_tab; // opening: the first row has the cursor
if (GImGui->OpenPopupStack.Size) ImGui::ClosePopupToLevel(0, false); // a confirmation left open on closing
@@ -1506,7 +1454,7 @@ extern "C" int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const cha
if (!open) { // the overlay alone: no input reaches ImGui
} else if (g_test.page < 0) {
drain_events(io);
pad_events(io, reset);
pad_events(io, reset || opened);
} else { // the test hook's pages: the user's input in a background test window must not change settings
plat_mutex_lock(&ev_lock);
ev_n = 0;
@@ -1544,20 +1492,20 @@ extern "C" void menu_boot_set(int phase, long long done, long long total) {
g_boot_done.store(done, std::memory_order_relaxed);
g_boot_total.store(total, std::memory_order_relaxed);
g_boot_phase.store(phase, std::memory_order_release);
g_booting.store(phase >= 0, std::memory_order_release);
}
// A panel in the middle of the screen in the menu's colours: the title, the step with its count and a bar, and why it
// happens. The input queue is left alone: keys pressed now reach the menu once the game runs.
// A box in the middle of the screen in the menu's look (ui/menu_skin.cpp skin_boot_panel): the title, the step with its
// count and a bar, and why it happens. The input queue is left alone: keys pressed now reach the menu once the game runs.
extern "C" int menu_boot_frame(const MenuTarget *t) {
if (g_failed_flag() || g_boot_phase.load(std::memory_order_acquire) < 0) return 0; // -1: done, a black frame
if (!g_ctx_ok) make_context();
float scale = menu_scale(t->height);
if (!vk_up(t) || !fonts_follow(scale)) {
float scale = menu_scale(t->width, t->height);
if (!vk_up(t) || !fonts_for(scale, plat_now_ns())) {
rt_log("menu: Dear ImGui Vulkan back end set-up failed; no boot screen, and the menu stays closed");
g_failed.store(1);
return 0;
}
menu_art_start(); // the box takes the game's textures as soon as they are decoded, plain shapes until then
if (g_style_scale != scale) {
ImGui::GetStyle() = g_base_style;
ImGui::GetStyle().ScaleAllSizes(scale);
@@ -1582,41 +1530,16 @@ extern "C" int menu_boot_frame(const MenuTarget *t) {
snprintf(step, sizeof step, "%s", ui_text(UI_BOOT_STARTING));
const char *title = ui_text(UI_BOOT_TITLE), *hint = ui_text(UI_BOOT_HINT);
ImDrawList *dl = ImGui::GetForegroundDrawList();
float w = (float)t->width, h = (float)t->height, pad = 34 * scale, gap = 16 * scale;
// the box in the menu's look (ui/menu_skin.cpp): a filled bar while there is a count, else a sweeping segment
ImFont *body = ImGui::GetFont();
float body_px = ImGui::GetFontSize();
ImFont *head = g_title_font ? g_title_font : body;
float head_px = g_title_font ? g_title_font->FontSize * ImGui::GetIO().FontGlobalScale : body_px * 1.2f;
ImVec2 ts = head->CalcTextSizeA(head_px, FLT_MAX, 0, title), ss = body->CalcTextSizeA(body_px, FLT_MAX, 0, step),
hs = body->CalcTextSizeA(body_px * 0.8f, FLT_MAX, 0, hint);
float bar_h = 10 * scale;
float pw = fmaxf(fmaxf(ts.x, hs.x), 560 * scale) + pad * 2;
float ph = pad + ts.y + gap * 1.5f + ss.y + gap * 0.6f + bar_h + gap * 1.4f + hs.y + pad;
ImVec2 a((w - pw) / 2, (h - ph) / 2), b(a.x + pw, a.y + ph);
ImU32 gold = ImGui::GetColorU32(kGold), panel = ImGui::GetColorU32(kNavy);
ImU32 text = IM_COL32(236, 224, 196, 255), dim = IM_COL32(236, 224, 196, 150);
dl->AddRectFilled(a, b, panel, 10 * scale);
dl->AddRect(a, b, IM_COL32(237, 194, 97, 140), 10 * scale, 0, 1.5f * scale);
float y = a.y + pad;
dl->AddText(head, head_px, ImVec2((w - ts.x) / 2, y), gold, title);
y += ts.y + gap * 1.5f;
dl->AddText(body, body_px, ImVec2(a.x + pad, y), text, step);
y += ss.y + gap * 0.6f;
ImVec2 ba(a.x + pad, y), bb(b.x - pad, y + bar_h);
dl->AddRectFilled(ba, bb, IM_COL32(255, 255, 255, 28), bar_h / 2);
if ((phase == 1 || phase == 2) && total > 0) {
float f = (float)done / (float)total;
f = f < 0 ? 0 : f > 1 ? 1 : f;
if (f > 0) dl->AddRectFilled(ba, ImVec2(ba.x + (bb.x - ba.x) * f, bb.y), gold, bar_h / 2);
} else { // no count yet: a short segment sweeps along the bar
float span = (bb.x - ba.x) * 0.2f, run = (bb.x - ba.x) - span;
float s = (float)fmod((now - g_boot_t0) / 1e9 * 0.8, 2.0);
float x = ba.x + run * (s < 1 ? s : 2 - s);
dl->AddRectFilled(ImVec2(x, ba.y), ImVec2(x + span, bb.y), gold, bar_h / 2);
}
y += bar_h + gap * 1.4f;
dl->AddText(body, body_px * 0.8f, ImVec2((w - hs.x) / 2, y), dim, hint);
float head_px = g_title_font ? g_title_font->FontSize * io.FontGlobalScale : body_px * 1.2f; // as GetFontSize scales
float frac = -1;
if ((phase == 1 || phase == 2) && total > 0) frac = done <= 0 ? 0 : done >= total ? 1 : (float)done / (float)total;
float s = (float)fmod((now - g_boot_t0) / 1e9 * 0.8, 2.0);
skin_boot_panel(ImGui::GetForegroundDrawList(), head, head_px, body, body_px, title, step, hint, frac, s < 1 ? s : 2 - s,
(float)t->width, (float)t->height, scale);
ImGui::Render();
return ImGui::GetDrawData()->TotalVtxCount > 0;
}

View File

@@ -24,7 +24,7 @@ extern "C" {
// ---- state, any thread
int menu_is_open(void);
void menu_toggle(void); // F1 / Esc on the keyboard, Minus+Plus on the pad
void menu_toggle(void); // F1 / Esc on the keyboard, Minus+Plus on the pad; not before the game's first frame
void menu_perf_cycle(void); // F10: the performance overlay off, fps, full
// ---- events from the window adapter, used only while the menu is open. key: an ImGuiKey; coordinates in pixels of the

View File

@@ -1,8 +1,8 @@
// The settings menu's art from the game's own interface textures (menu_assets.c reads them from the user's RomFS):
// the cursor's glow and line, the frame's corner ornaments and the control guide's bar. A worker decodes them into
// RGBA once at start (the archive unpacks to about 240 MB and takes a moment); the window thread uploads each to the GPU
// the first time the menu asks for it, and registers it with Dear ImGui's Vulkan back end. Without the files the menu
// draws its plain shapes.
// the frame's corner ornaments, the control guide's bar, and the layers of the buttons, cursor, panels and divider that
// ui/menu_skin.cpp puts together. A worker decodes them into RGBA once at start (the archive unpacks to about 240 MB and
// takes a moment); the window thread uploads each to the GPU with its smaller levels the first time the menu asks for
// it, and registers it with Dear ImGui's Vulkan back end. Without the files the menu draws its plain shapes.
#include <atomic>
#include <math.h>
#include <stdlib.h>
@@ -18,12 +18,20 @@ extern "C" {
}
#include "menu_assets.h"
#include "ui/menu_art.h"
#include "ui/menu_skin.h"
#define COMMON_BNTX "UI/Layout2Archive/Common.Product.100.Nin_Ounce_NVN2.bntx.zs"
// in the order of MenuArt (tools/menu_preview.py reads this list too)
static const char *const kNames[MENU_ART_COUNT] = {
"CmnBtnCursorGlow_00", "CmnBtnCursorLine_00", "LocationDeco_00", "CtrlGuideBG_00", "MessageWindowCommonBase_00",
"LocationDeco_00", "CtrlGuideBG_00", "MessageWindowCommonBase_00",
"BtnThinBase_01", "BtnThinBase_00", "BtnThinBase_05", "BtnThinBase_04", "BtnThinBase_02",
"OptionBtnThinCursorGlow_00", "OptionBtnThinCursorLine_00", "SystemCaptionBg_00",
"OptionSeparateMark_00", "SystemLine_03", "MenuHeaderSelect_00",
};
// Levels uploaded for each art: the buttons draw it at about half size and smaller, where a line one or two texels wide
// would break up if sampled from the full image alone.
enum { MAX_LEVELS = 6 };
static struct Art {
uint8_t *rgba;
@@ -44,7 +52,7 @@ static void decode_all(void *) {
if (!bntx) rt_log("menu: %s could not be read from the RomFS", COMMON_BNTX);
for (int i = 0; bntx && i < MENU_ART_COUNT; i++) {
Art &a = g_art[i];
if (menu_asset_texture(bntx, n, kNames[i], &a.rgba, &a.w, &a.h)) got++;
if (menu_asset_texture(bntx, n, kNames[i], &a.rgba, &a.w, &a.h)) got++, skin_art_prepare(i, a.rgba, a.w, a.h);
else rt_log("menu: interface texture %s not decoded (archive of %llu bytes)", kNames[i], (unsigned long long)n);
}
free(bntx);
@@ -66,26 +74,52 @@ static int upload(Art &a) {
si.magFilter = si.minFilter = VK_FILTER_LINEAR;
si.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
si.addressModeU = si.addressModeV = si.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
si.maxLod = 1;
si.maxLod = MAX_LEVELS;
if (vkCreateSampler(c->device, &si, nullptr, &g_sampler) != VK_SUCCESS) return 0;
}
uint32_t lw[MAX_LEVELS] = {a.w}, lh[MAX_LEVELS] = {a.h}, levels = 1;
VkDeviceSize bytes = (VkDeviceSize)a.w * a.h * 4;
while (levels < MAX_LEVELS && (lw[levels - 1] > 1 || lh[levels - 1] > 1)) {
lw[levels] = lw[levels - 1] > 1 ? lw[levels - 1] / 2 : 1;
lh[levels] = lh[levels - 1] > 1 ? lh[levels - 1] / 2 : 1;
bytes += (VkDeviceSize)lw[levels] * lh[levels] * 4;
levels++;
}
VkImageCreateInfo ii = {VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO};
ii.imageType = VK_IMAGE_TYPE_2D;
ii.format = VK_FORMAT_R8G8B8A8_UNORM;
ii.extent = {a.w, a.h, 1};
ii.mipLevels = ii.arrayLayers = 1;
ii.mipLevels = levels;
ii.arrayLayers = 1;
ii.samples = VK_SAMPLE_COUNT_1_BIT;
ii.tiling = VK_IMAGE_TILING_OPTIMAL;
ii.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
VmaAllocationCreateInfo ai = {};
ai.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE;
if (vmaCreateImage(c->vma, &ii, &ai, &a.img, &a.alloc, nullptr) != VK_SUCCESS) return 0;
VkDeviceSize bytes = (VkDeviceSize)a.w * a.h * 4;
VkBuffer sb;
VmaAllocation sa;
void *map = vk_staging(bytes, &sb, &sa);
uint8_t *map = (uint8_t *)vk_staging(bytes, &sb, &sa);
if (!map) return 0;
memcpy(map, a.rgba, (size_t)bytes);
// the levels one after the other in a plain allocation, each halved from the one before (the staging memory may be
// slow to read back)
uint8_t *chain = (uint8_t *)malloc((size_t)bytes);
if (!chain) {
vmaDestroyBuffer(c->vma, sb, sa);
return 0;
}
memcpy(chain, a.rgba, (size_t)a.w * a.h * 4);
VkBufferImageCopy regions[MAX_LEVELS] = {};
VkDeviceSize at = 0;
for (uint32_t l = 0; l < levels; l++) {
regions[l].bufferOffset = at;
regions[l].imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, l, 0, 1};
regions[l].imageExtent = {lw[l], lh[l], 1};
if (l) skin_art_halve(chain + regions[l - 1].bufferOffset, lw[l - 1], lh[l - 1], chain + at, lw[l], lh[l]);
at += (VkDeviceSize)lw[l] * lh[l] * 4;
}
memcpy(map, chain, (size_t)bytes);
free(chain);
VkCommandBuffer cb = vk_upload_begin();
VkImageMemoryBarrier2 b = {VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2};
b.srcStageMask = VK_PIPELINE_STAGE_2_NONE;
@@ -95,15 +129,12 @@ static int upload(Art &a) {
b.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
b.image = a.img;
b.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
b.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, levels, 0, 1};
VkDependencyInfo di = {VK_STRUCTURE_TYPE_DEPENDENCY_INFO};
di.imageMemoryBarrierCount = 1;
di.pImageMemoryBarriers = &b;
vkCmdPipelineBarrier2(cb, &di);
VkBufferImageCopy r = {};
r.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
r.imageExtent = {a.w, a.h, 1};
vkCmdCopyBufferToImage(cb, sb, a.img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &r);
vkCmdCopyBufferToImage(cb, sb, a.img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, levels, regions);
b.srcStageMask = VK_PIPELINE_STAGE_2_COPY_BIT;
b.srcAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT;
b.dstStageMask = VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT;
@@ -118,7 +149,7 @@ static int upload(Art &a) {
vi.image = a.img;
vi.viewType = VK_IMAGE_VIEW_TYPE_2D;
vi.format = VK_FORMAT_R8G8B8A8_UNORM;
vi.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
vi.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, levels, 0, 1};
if (vkCreateImageView(c->device, &vi, nullptr, &a.view) != VK_SUCCESS) return 0;
a.ds = ImGui_ImplVulkan_AddTexture(g_sampler, a.view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
return a.ds != VK_NULL_HANDLE; // the pixels stay (a few MB): the back end may start again on another format
@@ -147,37 +178,3 @@ extern "C" void menu_art_release(void) {
}
if (g_sampler) vkDestroySampler(c->device, g_sampler, nullptr), g_sampler = VK_NULL_HANDLE;
}
extern "C" int menu_art_draw(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, ImU32 tint) {
ImTextureID t;
if (!menu_art(id, &t, nullptr, nullptr)) return 0;
dl->AddImage(t, a, b, ImVec2(0, 0), ImVec2(1, 1), tint);
return 1;
}
// Nine pieces: the corners at `corner` pixels on screen from the texture's outer `frac` of each side, the edges
// stretched between them, the middle left out (frames) or stretched (fill).
extern "C" int menu_art_draw9_turned(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, float corner, float frac, ImU32 tint, int fill,
int turned);
extern "C" int menu_art_draw9(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, float corner, float frac, ImU32 tint, int fill) {
return menu_art_draw9_turned(dl, id, a, b, corner, frac, tint, fill, 0);
}
// The same, the texture turned half a turn when turned: its top-left corner piece at the bottom right.
extern "C" int menu_art_draw9_turned(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, float corner, float frac, ImU32 tint, int fill,
int turned) {
ImTextureID t;
if (!menu_art(id, &t, nullptr, nullptr)) return 0;
float c = corner, maxc = fminf((b.x - a.x) / 2, (b.y - a.y) / 2);
if (c > maxc) c = maxc;
const float xs[4] = {a.x, a.x + c, b.x - c, b.x}, ys[4] = {a.y, a.y + c, b.y - c, b.y};
float us[4] = {0, frac, 1 - frac, 1}, vs[4] = {0, frac, 1 - frac, 1};
if (turned)
for (int k = 0; k < 4; k++) us[k] = 1 - us[k], vs[k] = 1 - vs[k];
for (int j = 0; j < 3; j++)
for (int i = 0; i < 3; i++) {
if (i == 1 && j == 1 && !fill) continue;
dl->AddImage(t, ImVec2(xs[i], ys[j]), ImVec2(xs[i + 1], ys[j + 1]), ImVec2(us[i], vs[j]), ImVec2(us[i + 1], vs[j + 1]), tint);
}
return 1;
}

View File

@@ -3,11 +3,21 @@
#include "imgui.h"
typedef enum {
MENU_ART_CURSOR_GLOW, // the glow of the game's button cursor (white mask; tinted by the caller)
MENU_ART_CURSOR_LINE, // its outline
MENU_ART_FRAME_DECO, // a frame with ornamented corners
MENU_ART_GUIDE_BAR, // the control guide's bar
MENU_ART_WINDOW_BASE, // a rounded window base
// the layers of the save menu's Load and Cancel button, in drawing order; white masks except for the grain
MENU_ART_BTN_RIM, // a soft line along the button's edge, reaching outside it
MENU_ART_BTN_FILL, // the button's shape
MENU_ART_BTN_GRAIN, // the mottling: light at the edge, dark and speckled in the middle
MENU_ART_BTN_EDGE, // the light edge
MENU_ART_BTN_LINE, // the inset line, a diamond and a curl at alternate corners
MENU_ART_CURSOR_GLOW, // the options cursor's soft glow
MENU_ART_CURSOR_LINE, // the options cursor's white frame (skin_art_prepare cuts it out of the texture)
MENU_ART_PANEL_FILL, // a dark brown panel
MENU_ART_DIVIDER, // the options menu's divider ornament
MENU_ART_DIVIDER_LINE, // the line beside the ornament, ending in a dot
MENU_ART_TAB_SELECT, // the plate of the selected category in the game's menu header
MENU_ART_COUNT
} MenuArt;

545
runtime/ui/menu_skin.cpp Normal file
View File

@@ -0,0 +1,545 @@
// The look of the game's own menus (ui/menu_skin.h). With the game's textures (ui/menu_art.cpp) each piece is those
// textures tinted and laid over each other in nine slices; until they are decoded, or without them, it is plain shapes
// whose colours and proportions are sampled from the game: the save menu's Load and Cancel buttons (brown fill, light
// edge, an inset line about a twentieth of the height in with a diamond and a curl at alternate corners), the options
// menu's cursor (a 3 px white frame with a soft white-blue glow) and its divider ornament (traced: two pointed lens
// ends, S-waves into spiral hooks and a diamond knot under the middle, in a 120 x 38 box with its centre at (60, 21)).
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <initializer_list>
#include "imgui.h"
#include "imgui_internal.h" // NavCursorVisible
#include "ui/menu_art.h"
#include "ui/menu_skin.h"
namespace {
// The mottled grain of the game's brown boxes: a tile in the font atlas (skin_atlas_add, skin_atlas_fill), white with
// the grain in alpha, drawn over a box darkened in some places and lightened in others.
const int kGrainW = 160, kGrainH = 48;
int g_grain_rect = -1;
ImVec2 g_grain_uv0, g_grain_uv1;
bool g_grain_ok;
ImU32 rgba(int r, int g, int b, float a) { return IM_COL32(r, g, b, (int)(a * 255.0f + 0.5f)); }
ImU32 mix(const int c0[3], const int c1[3], float t, float a) {
return rgba((int)(c0[0] + (c1[0] - c0[0]) * t), (int)(c0[1] + (c1[1] - c0[1]) * t), (int)(c0[2] + (c1[2] - c0[2]) * t),
a);
}
// A spiral of `turns` turns around c, from radius r at angle a0 (radians, clockwise on screen) in to 35 % of it.
void curl(ImDrawList *dl, ImVec2 c, float r, float a0, float turns, ImU32 col, float thick) {
const int n = 28;
for (int i = 0; i <= n; i++) {
float t = (float)i / n, a = a0 + t * turns * 6.2831853f, rad = r * (1.0f - 0.65f * t);
dl->PathLineTo(ImVec2(c.x + cosf(a) * rad, c.y + sinf(a) * rad));
}
dl->PathStroke(col, 0, thick);
}
void diamond(ImDrawList *dl, ImVec2 c, float d, ImU32 col) {
dl->AddQuadFilled(ImVec2(c.x, c.y - d), ImVec2(c.x + d, c.y), ImVec2(c.x, c.y + d), ImVec2(c.x - d, c.y), col);
}
// The inset line of the button and panel frames, `inset` inside [a, b]: a diamond at the top-left and bottom-right
// corners, a curl at the top-right and bottom-left ones, the four lines running between them with a small gap.
void ornament_line(ImDrawList *dl, ImVec2 a, ImVec2 b, float inset, float s, ImU32 col) {
const float l = a.x + inset, t = a.y + inset, r = b.x - inset, bt = b.y - inset;
// the ornaments grow with the box as on the game's buttons (a curl about a tenth of the height across), within limits
const float span = fminf(r - l, bt - t);
float rad = fminf(fmaxf(span * 0.13f, 3.5f * s), 7.0f * s), d = rad * 0.6f, gap = 2.4f * s, thick = 1.4f * s;
// top: from the diamond into the curl, whose outer turn starts at the top of its circle
dl->AddLine(ImVec2(l + d + gap, t), ImVec2(r - rad, t), col, thick);
curl(dl, ImVec2(r - rad, t + rad), rad, -1.5707963f, 1.3f, col, thick);
dl->AddLine(ImVec2(r, t + 2 * rad + gap), ImVec2(r, bt - d - gap), col, thick); // right: under the curl
dl->AddLine(ImVec2(r - d - gap, bt), ImVec2(l + rad, bt), col, thick); // bottom: into the other curl
curl(dl, ImVec2(l + rad, bt - rad), rad, 1.5707963f, 1.3f, col, thick);
dl->AddLine(ImVec2(l, bt - 2 * rad - gap), ImVec2(l, t + d + gap), col, thick); // left: over the curl
diamond(dl, ImVec2(l, t), d, col);
diamond(dl, ImVec2(r, bt), d, col);
}
// The divider ornament's paths: F_M x y, F_L x y, F_C x1 y1 x2 y2 x y, ending with F_END.
enum { F_M = -1000, F_L = -1001, F_C = -1002, F_Z = -1003, F_END = -1004 };
static const float kFiligree0[] = {
F_M, 20, 17.4, F_C, 20.4, 17.3, 21.6, 16.8, 22.2, 16.9, F_C, 22.8, 17, 23.5, 17.7, 23.5, 18.2, F_C, 23.5, 18.7,
23.1, 19.4, 22.4, 19.8, F_C, 21.6, 20.2, 20.3, 20.4, 19, 20.4, F_C, 17.7, 20.4, 15.9, 20.2, 14.5, 19.9, F_C,
13.1, 19.6, 10.6, 19.4, 10.5, 18.6, F_C, 10.4, 17.9, 12.6, 16.3, 14, 15.4, F_C, 15.4, 14.5, 17.2, 13.6, 19, 13.2,
F_C, 20.8, 12.8, 23.2, 12.8, 25, 13.1, F_C, 26.8, 13.4, 28.1, 13.9, 29.5, 14.8, F_C, 30.9, 15.7, 32.2, 17.4,
33.5, 18.6, F_C, 34.8, 19.8, 36, 21.2, 37.5, 22, F_C, 39, 22.8, 40.8, 23.4, 42.5, 23.6, F_C, 44.2, 23.8, 46,
23.5, 47.5, 23.1, F_C, 49, 22.7, 50.4, 21.9, 51.2, 21.2, F_C, 52, 20.5, 52.5, 19.5, 52.4, 18.8, F_C, 52.3, 18.1,
51.5, 17.3, 50.6, 16.9, F_C, 49.7, 16.5, 48.2, 16.2, 47, 16.3, F_C, 45.8, 16.4, 44.2, 17.1, 43.6, 17.2, F_END};
static const float kFiligree1[] = {
F_M, 100, 17.4, F_C, 99.6, 17.3, 98.4, 16.8, 97.8, 16.9, F_C, 97.2, 17, 96.5, 17.7, 96.5, 18.2, F_C, 96.5, 18.7,
96.8, 19.4, 97.6, 19.8, F_C, 98.3, 20.2, 99.7, 20.4, 101, 20.4, F_C, 102.3, 20.4, 104.1, 20.2, 105.5, 19.9, F_C,
106.9, 19.6, 109.4, 19.4, 109.5, 18.6, F_C, 109.6, 17.9, 107.4, 16.3, 106, 15.4, F_C, 104.6, 14.5, 102.8, 13.6,
101, 13.2, F_C, 99.2, 12.8, 96.8, 12.8, 95, 13.1, F_C, 93.2, 13.4, 91.9, 13.9, 90.5, 14.8, F_C, 89.1, 15.7, 87.8,
17.4, 86.5, 18.6, F_C, 85.2, 19.8, 84, 21.2, 82.5, 22, F_C, 81, 22.8, 79.2, 23.4, 77.5, 23.6, F_C, 75.8, 23.8,
74, 23.5, 72.5, 23.1, F_C, 71, 22.7, 69.6, 21.9, 68.8, 21.2, F_C, 68, 20.5, 67.5, 19.5, 67.6, 18.8, F_C, 67.7,
18.1, 68.5, 17.3, 69.4, 16.9, F_C, 70.3, 16.5, 71.8, 16.2, 73, 16.3, F_C, 74.2, 16.4, 75.8, 17.1, 76.4, 17.2,
F_END};
static const float kFiligree2[] = {
F_M, 40.6, 17.6, F_C, 40.7, 17, 40.7, 14.9, 41.2, 14, F_C, 41.7, 13.1, 42.6, 12.4, 43.8, 12, F_C, 45, 11.6, 46.7,
11.4, 48.2, 11.5, F_C, 49.7, 11.6, 51.3, 11.8, 52.6, 12.3, F_C, 53.9, 12.8, 55, 13.6, 56, 14.6, F_C, 57, 15.6,
58.2, 17.6, 58.6, 18.2, F_L, 64.6, 26, F_L, 60, 31.6, F_END};
static const float kFiligree3[] = {
F_M, 79.4, 17.6, F_C, 79.3, 17, 79.3, 14.9, 78.8, 14, F_C, 78.3, 13.1, 77.4, 12.4, 76.2, 12, F_C, 75, 11.6, 73.3,
11.4, 71.8, 11.5, F_C, 70.3, 11.6, 68.7, 11.8, 67.4, 12.3, F_C, 66.1, 12.8, 65, 13.6, 64, 14.6, F_C, 63, 15.6,
61.8, 17.6, 61.4, 18.2, F_L, 55.4, 26, F_L, 60, 31.6, F_END};
const float *const kFiligree[] = {kFiligree0, kFiligree1, kFiligree2, kFiligree3};
// The settings menu's colours: a dark umber panel, warm browns for frames and what is selected, gold for the ornaments,
// accents and the cursor, parchment text. kGreen and kOcarina keep their names for the selected and active controls.
const ImVec4 kGold(0.93f, 0.76f, 0.38f, 1), kGreen(0.36f, 0.26f, 0.13f, 1), kNavy(0.075f, 0.058f, 0.042f, 0.95f),
kOcarina(0.62f, 0.47f, 0.22f, 1);
// Where the art's boxes lie in its textures, in texels (measured from the textures). The button's layers are 489 x 133
// with the button's box from (20, 19) to (469, 114); the cursor's are 640 x 173 and its box, the button it surrounds,
// runs from (49, 48) to (591, 125); the panel's box runs from (53, 53) to (1147, 374) in 1200 x 427.
const float kBtnW = 489, kBtnH = 133, kBtnL = 20, kBtnT = 19, kBtnBoxH = 95, kBtnCut = 60;
const float kCurW = 640, kCurH = 173, kCurX = 49, kCurY = 48, kCurCut = 70, kCurScale = 0.72f;
const float kPanelW = 1200, kPanelH = 427, kPanelM = 53;
const float kTabL = 25, kTabT = 0, kTabR = 336, kTabB = 151; // the selected tab's plate in its 360 x 173 texture
bool have_art(std::initializer_list<MenuArt> ids) {
ImTextureID t;
for (MenuArt id : ids)
if (!menu_art(id, &t, nullptr, nullptr)) return false;
return true;
}
enum { MAX_COPIES = 15 };
struct Piece { float p0, p1, t0, t1; };
// One axis of a slice: screen [a, b] from texels [x0, x1] of a texture `size` long, the outer `cut` texels c pixels
// long. The middle is stretched, or with tile repeated at k pixels per texel: an odd number of copies, every other one
// mirrored, so each copy meets the next on the same texels and the last meets the far corner. Mottled art stretched
// across a wide box would turn into streaks.
int axis(Piece *out, float a, float b, float x0, float x1, float size, float cut, float c, float k, bool tile) {
const float m0 = a + c, m1 = b - c, t0 = (x0 + cut) / size, t1 = (x1 - cut) / size, unit = (x1 - x0 - 2 * cut) * k;
int copies = 1, n = 0;
if (tile && unit > 0) copies = 2 * (int)floorf(((m1 - m0) / unit - 1) * 0.5f + 0.5f) + 1;
copies = copies < 1 ? 1 : copies > MAX_COPIES ? MAX_COPIES : copies;
out[n++] = {a, m0, x0 / size, t0};
for (int i = 0; i < copies; i++) {
float w = (m1 - m0) / copies;
out[n++] = {m0 + i * w, m0 + (i + 1) * w, i & 1 ? t1 : t0, i & 1 ? t0 : t1};
}
out[n++] = {m1, b, t1, x1 / size};
return n;
}
// The texels (x0, y0)-(x1, y1) of an art over [a, b] in nine slices: the outer `cut` texels on each side at k screen
// pixels per texel, so corners keep their shape, the rest stretched or tiled. A box smaller than its two corners shrinks
// them.
void slice(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, float x0, float y0, float x1, float y1, float cut, float k, ImU32 tint,
bool tile_x = false, bool tile_y = false) {
ImTextureID t;
float tw, th;
if (!menu_art(id, &t, &tw, &th)) return;
Piece xs[MAX_COPIES + 2], ys[MAX_COPIES + 2];
int nx = axis(xs, a.x, b.x, x0, x1, tw, cut, fminf(cut * k, (b.x - a.x) * 0.5f), k, tile_x);
int ny = axis(ys, a.y, b.y, y0, y1, th, cut, fminf(cut * k, (b.y - a.y) * 0.5f), k, tile_y);
for (int j = 0; j < ny; j++)
for (int i = 0; i < nx; i++)
dl->AddImage(t, ImVec2(xs[i].p0, ys[j].p0), ImVec2(xs[i].p1, ys[j].p1), ImVec2(xs[i].t0, ys[j].t0), ImVec2(xs[i].t1, ys[j].t1), tint);
}
// A button layer over the box [a, b]: the whole texture, reaching past the box by its margins.
void btn_layer(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, float k, ImU32 tint, bool tile_x = false) {
const float mx = kBtnL * k, my = kBtnT * k;
slice(dl, id, ImVec2(a.x - mx, a.y - my), ImVec2(b.x + mx, b.y + my), 0, 0, kBtnW, kBtnH, kBtnCut, k, tint, tile_x);
}
// A cursor layer around the box [a, b], at a fixed size so its frame keeps its width on any box.
void cursor_layer(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, float s, ImU32 tint) {
const float k = kCurScale * s, mx = kCurX * k, my = kCurY * k;
slice(dl, id, ImVec2(a.x - mx, a.y - my), ImVec2(b.x + mx, b.y + my), 0, 0, kCurW, kCurH, kCurCut, k, tint);
}
} // namespace
// The cursor line's texture is not the line: its alpha climbs from 0 at the outer edge to full about 28 texels in, and
// is full inside. The white frame is a band of that ramp, about 3.5 texels wide just outside the box it surrounds
// (alpha 102 lies about six texels out from the cursor's box), so the frame follows the texture's own corners.
void skin_art_prepare(int art, uint8_t *rgba, uint32_t w, uint32_t h) {
if (art != MENU_ART_CURSOR_LINE) return;
const int mid = 102, full = 16, soft = 8; // in alpha steps; the ramp climbs about 8.7 of them per texel
for (size_t i = 0, n = (size_t)w * h; i < n; i++) {
int d = abs((int)rgba[i * 4 + 3] - mid) - full;
rgba[i * 4 + 3] = d <= 0 ? 255 : d >= soft ? 0 : (uint8_t)(255 - d * 255 / soft);
}
}
// A box filter over the 2 x 2 texels each destination texel covers (an odd last row or column repeats). Colour is
// weighted by alpha, so what is transparent does not bleed into the edges of the coloured art.
void skin_art_halve(const uint8_t *src, uint32_t w, uint32_t h, uint8_t *dst, uint32_t dw, uint32_t dh) {
for (uint32_t y = 0; y < dh; y++)
for (uint32_t x = 0; x < dw; x++) {
const uint32_t xs[2] = {x * 2 < w ? x * 2 : w - 1, x * 2 + 1 < w ? x * 2 + 1 : w - 1},
ys[2] = {y * 2 < h ? y * 2 : h - 1, y * 2 + 1 < h ? y * 2 + 1 : h - 1};
uint32_t rgb[3] = {0, 0, 0}, plain[3] = {0, 0, 0}, al = 0;
for (int j = 0; j < 2; j++)
for (int i = 0; i < 2; i++) {
const uint8_t *p = src + ((size_t)ys[j] * w + xs[i]) * 4;
for (int c = 0; c < 3; c++) rgb[c] += p[c] * (uint32_t)p[3], plain[c] += p[c];
al += p[3];
}
uint8_t *d = dst + ((size_t)y * dw + x) * 4;
for (int c = 0; c < 3; c++) d[c] = (uint8_t)(al ? (rgb[c] + al / 2) / al : (plain[c] + 2) / 4);
d[3] = (uint8_t)((al + 2) / 4);
}
}
extern "C" int menu_art_draw(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, ImU32 tint) {
ImTextureID t;
if (!menu_art(id, &t, nullptr, nullptr)) return 0;
dl->AddImage(t, a, b, ImVec2(0, 0), ImVec2(1, 1), tint);
return 1;
}
extern "C" int menu_art_draw9(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, float corner, float frac, ImU32 tint, int fill) {
return menu_art_draw9_turned(dl, id, a, b, corner, frac, tint, fill, 0);
}
// Nine pieces: the corners at `corner` pixels on screen from the texture's outer `frac` of each side, the edges
// stretched between them, the middle left out (frames) or stretched (fill); the texture turned half a turn when turned,
// its top-left corner piece at the bottom right.
extern "C" int menu_art_draw9_turned(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, float corner, float frac, ImU32 tint, int fill,
int turned) {
ImTextureID t;
if (!menu_art(id, &t, nullptr, nullptr)) return 0;
float c = corner, maxc = fminf((b.x - a.x) / 2, (b.y - a.y) / 2);
if (c > maxc) c = maxc;
const float xs[4] = {a.x, a.x + c, b.x - c, b.x}, ys[4] = {a.y, a.y + c, b.y - c, b.y};
float us[4] = {0, frac, 1 - frac, 1}, vs[4] = {0, frac, 1 - frac, 1};
if (turned)
for (int k = 0; k < 4; k++) us[k] = 1 - us[k], vs[k] = 1 - vs[k];
for (int j = 0; j < 3; j++)
for (int i = 0; i < 3; i++) {
if (i == 1 && j == 1 && !fill) continue;
dl->AddImage(t, ImVec2(xs[i], ys[j]), ImVec2(xs[i + 1], ys[j + 1]), ImVec2(us[i], vs[j]), ImVec2(us[i + 1], vs[j + 1]), tint);
}
return 1;
}
void skin_style(ImGuiStyle &s) {
ImGui::StyleColorsDark(&s);
s.WindowRounding = 10; s.FrameRounding = 6; s.GrabRounding = 6; s.TabRounding = 6; s.ChildRounding = 8;
s.WindowPadding = ImVec2(40, 30); s.FramePadding = ImVec2(14, 8); s.ItemSpacing = ImVec2(14, 12);
s.WindowBorderSize = 2; s.ScrollbarSize = 16;
ImVec4 *c = s.Colors;
c[ImGuiCol_WindowBg] = kNavy;
c[ImGuiCol_Border] = ImVec4(kGold.x, kGold.y, kGold.z, 0.55f);
c[ImGuiCol_ChildBg] = ImVec4(0, 0, 0, 0);
c[ImGuiCol_PopupBg] = kNavy;
c[ImGuiCol_Text] = ImVec4(0.96f, 0.92f, 0.82f, 1);
c[ImGuiCol_TextDisabled] = ImVec4(0.62f, 0.56f, 0.46f, 1);
c[ImGuiCol_FrameBg] = ImVec4(0.15f, 0.115f, 0.08f, 1);
c[ImGuiCol_FrameBgHovered] = ImVec4(0.24f, 0.18f, 0.10f, 1);
c[ImGuiCol_FrameBgActive] = kGreen;
c[ImGuiCol_SliderGrab] = kOcarina;
c[ImGuiCol_SliderGrabActive] = kGold;
c[ImGuiCol_CheckMark] = kGold;
c[ImGuiCol_Button] = ImVec4(0.19f, 0.145f, 0.09f, 1);
c[ImGuiCol_ButtonHovered] = kGreen;
c[ImGuiCol_ButtonActive] = kOcarina;
c[ImGuiCol_Header] = ImVec4(0.24f, 0.18f, 0.10f, 1);
c[ImGuiCol_HeaderHovered] = kGreen;
c[ImGuiCol_HeaderActive] = kOcarina;
c[ImGuiCol_Tab] = ImVec4(0.13f, 0.10f, 0.07f, 1);
c[ImGuiCol_TabHovered] = kGreen;
c[ImGuiCol_TabSelected] = ImVec4(0.42f, 0.31f, 0.15f, 1);
c[ImGuiCol_TabSelectedOverline] = kGold;
c[ImGuiCol_NavCursor] = kGold;
c[ImGuiCol_Separator] = ImVec4(kGold.x, kGold.y, kGold.z, 0.30f);
c[ImGuiCol_ScrollbarGrab] = ImVec4(0.36f, 0.28f, 0.16f, 1);
c[ImGuiCol_ScrollbarBg] = ImVec4(0, 0, 0, 0.2f);
}
// The grain over [a, b]: the tile repeated at four pixels per texel (its noise wraps, so the copies join unseen), so the
// blotches keep their size on any box; darkening where the tile is dense, lightening where its mirror image is.
static void grain(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float strength) {
if (!g_grain_ok) return;
ImTextureID tex = ImGui::GetIO().Fonts->TexID;
const float pw = kGrainW * 4.0f * s, ph = kGrainH * 4.0f * s;
const ImVec2 du(g_grain_uv1.x - g_grain_uv0.x, g_grain_uv1.y - g_grain_uv0.y);
const ImU32 dark = rgba(20, 12, 4, 0.30f * strength), light = rgba(255, 236, 196, 0.12f * strength);
for (float y = a.y; y < b.y; y += ph)
for (float x = a.x; x < b.x; x += pw) {
float x1 = fminf(x + pw, b.x), y1 = fminf(y + ph, b.y);
ImVec2 u0 = g_grain_uv0, u1(g_grain_uv0.x + du.x * (x1 - x) / pw, g_grain_uv0.y + du.y * (y1 - y) / ph);
dl->AddImage(tex, ImVec2(x, y), ImVec2(x1, y1), u0, u1, dark);
// the mirror image: the tile read from its far corner, over the same piece
ImVec2 m0(g_grain_uv1.x, g_grain_uv1.y), m1(g_grain_uv1.x - du.x * (x1 - x) / pw, g_grain_uv1.y - du.y * (y1 - y) / ph);
dl->AddImage(tex, ImVec2(x, y), ImVec2(x1, y1), m0, m1, light);
}
}
void skin_atlas_add(ImFontAtlas *fa) { g_grain_rect = fa->AddCustomRectRegular(kGrainW, kGrainH), g_grain_ok = false; }
void skin_atlas_fill(ImFontAtlas *fa) {
unsigned char *px;
int w, h;
fa->GetTexDataAsRGBA32(&px, &w, &h);
const ImFontAtlasCustomRect *r = g_grain_rect >= 0 ? fa->GetCustomRectByIndex(g_grain_rect) : nullptr;
if (!px || !r || !r->IsPacked()) return;
// value noise of three octaves on a lattice that wraps, with a little fine speckle: blotches and grain
auto lattice = [](int x, int y, int seed) {
unsigned v = (unsigned)(x * 374761393 + y * 668265263 + seed * 2246822519u);
v = (v ^ (v >> 13)) * 1274126177u;
return ((v ^ (v >> 16)) & 0xffff) / 65535.0f;
};
auto smooth = [&](float x, float y, int cell, int seed) {
float gx = x / cell, gy = y / cell;
int x0 = (int)floorf(gx), y0 = (int)floorf(gy);
float fx = gx - x0, fy = gy - y0;
fx = fx * fx * (3 - 2 * fx), fy = fy * fy * (3 - 2 * fy);
int wx = kGrainW / cell, wy = kGrainH / cell;
auto at = [&](int i, int j) { return lattice(((i % wx) + wx) % wx, ((j % wy) + wy) % wy, seed); };
float top = at(x0, y0) + (at(x0 + 1, y0) - at(x0, y0)) * fx;
float bot = at(x0, y0 + 1) + (at(x0 + 1, y0 + 1) - at(x0, y0 + 1)) * fx;
return top + (bot - top) * fy;
};
for (int y = 0; y < kGrainH; y++)
for (int x = 0; x < kGrainW; x++) {
float n = 0.55f * smooth((float)x, (float)y, 16, 1) + 0.30f * smooth((float)x, (float)y, 8, 2) +
0.15f * smooth((float)x, (float)y, 4, 3);
n = n * 0.85f + 0.15f * lattice(x, y, 9);
float v = fminf(1.0f, fmaxf(0.0f, (n - 0.35f) * 1.8f));
unsigned char *d = px + 4 * ((size_t)(r->Y + y) * w + r->X + x);
d[0] = d[1] = d[2] = 255, d[3] = (unsigned char)(v * 255.0f + 0.5f);
}
fa->CalcCustomRectUV(r, &g_grain_uv0, &g_grain_uv1);
g_grain_ok = true;
}
// The button from the game's layers; false while they are not there. plate: the selected tab's plate under the lines.
static bool button_art(ImDrawList *dl, ImVec2 a, ImVec2 b, float lift, bool dim, bool plate) {
if (!have_art({MENU_ART_BTN_RIM, MENU_ART_BTN_FILL, MENU_ART_BTN_GRAIN, MENU_ART_BTN_EDGE, MENU_ART_BTN_LINE})) return false;
static const int fill0[3] = {100, 76, 42}, fill1[3] = {128, 99, 58}, grain0[3] = {150, 118, 76}, grain1[3] = {178, 144, 96};
static const int grey_fill[3] = {76, 67, 56}, grey_grain[3] = {128, 116, 100};
const float t = (b.y - a.y) / kBtnBoxH;
btn_layer(dl, MENU_ART_BTN_RIM, a, b, t, rgba(20, 14, 8, 0.85f));
btn_layer(dl, MENU_ART_BTN_FILL, a, b, t, dim ? mix(grey_fill, grey_fill, 0, 1) : mix(fill0, fill1, lift, 1));
btn_layer(dl, MENU_ART_BTN_GRAIN, a, b, t, dim ? mix(grey_grain, grey_grain, 0, 0.26f) : mix(grain0, grain1, lift, 0.32f), true);
if (plate) slice(dl, MENU_ART_TAB_SELECT, a, b, kTabL, kTabT, kTabR, kTabB, 30, t, rgba(232, 186, 104, 0.55f));
btn_layer(dl, MENU_ART_BTN_EDGE, a, b, t, dim ? rgba(98, 88, 74, 1) : rgba(140, 116, 74, 1));
btn_layer(dl, MENU_ART_BTN_LINE, a, b, t, dim ? rgba(112, 102, 88, 1) : rgba(150 + (int)(24 * lift), 124 + (int)(20 * lift), 80 + (int)(12 * lift), 1));
return true;
}
void skin_button(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float lift, bool dim) {
static const int top0[3] = {98, 75, 41}, top1[3] = {122, 95, 55}, bot0[3] = {84, 63, 32}, bot1[3] = {106, 81, 44};
static const int grey_top[3] = {66, 58, 48}, grey_bot[3] = {56, 49, 40};
lift = lift < 0 ? 0 : lift > 1 ? 1 : lift;
if (button_art(dl, a, b, lift, dim, false)) return;
const float k = 1.0f * s;
dl->AddRectFilled(a, b, rgba(28, 22, 14, 0.92f)); // the dark rim between the button and what is behind it
ImVec2 ia(a.x + k, a.y + k), ib(b.x - k, b.y - k);
ImU32 top = dim ? mix(grey_top, grey_top, 0, 1) : mix(top0, top1, lift, 1);
ImU32 bot = dim ? mix(grey_bot, grey_bot, 0, 1) : mix(bot0, bot1, lift, 1);
dl->AddRectFilledMultiColor(ia, ib, top, top, bot, bot);
grain(dl, ia, ib, s, dim ? 0.5f : 1.0f);
dl->AddRect(ia, ib, dim ? rgba(98, 88, 74, 1) : rgba(126, 104, 68, 1), 0, 0, 1.4f * s); // the light edge
float h = b.y - a.y, inset = fmaxf(4.0f * s, h * 0.1f);
ornament_line(dl, a, b, inset, s, dim ? rgba(104, 94, 80, 1) : rgba(134 + (int)(18 * lift), 111 + (int)(14 * lift),
70 + (int)(8 * lift), 1));
}
float skin_cursor_reach(float s) { return 3.0f * s + 2.5f * s + 12.0f * s; }
// one slow breath every 1.6 s, as the game's cursor pulses
static float breath(void) { return 0.5f - 0.5f * cosf((float)ImGui::GetTime() * 6.2831853f / 1.6f); }
void skin_cursor_glow(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float alpha) {
if (have_art({MENU_ART_CURSOR_GLOW})) {
cursor_layer(dl, MENU_ART_CURSOR_GLOW, a, b, s, rgba(164, 194, 240, alpha * (0.78f + 0.22f * breath())));
return;
}
// filled rounded boxes stacked from the outside in, each faint, so the glow brightens towards the frame; the box
// drawn over them hides their middle
const float ring = 3.0f * s + 1.25f * s, br = breath();
const int n = 12;
for (int i = n; i >= 1; i--) {
float o = ring + i * 0.95f * s;
dl->AddRectFilled(ImVec2(a.x - o, a.y - o), ImVec2(b.x + o, b.y + o), rgba(160, 190, 236, alpha * (0.055f + 0.03f * br)),
2.0f * s + i * 0.9f * s);
}
}
void skin_cursor_frame(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float alpha) {
if (have_art({MENU_ART_CURSOR_LINE})) {
cursor_layer(dl, MENU_ART_CURSOR_LINE, a, b, s, rgba(240, 242, 245, alpha));
return;
}
const float gap = 3.0f * s, thick = 2.5f * s, ring = gap + thick * 0.5f;
// a little glow in the gap between the box and the frame, then the white frame
dl->AddRect(ImVec2(a.x - gap * 0.5f, a.y - gap * 0.5f), ImVec2(b.x + gap * 0.5f, b.y + gap * 0.5f),
rgba(190, 210, 240, alpha * (0.30f + 0.15f * breath())), gap * 0.4f, 0, gap);
dl->AddRect(ImVec2(a.x - ring, a.y - ring), ImVec2(b.x + ring, b.y + ring), rgba(236, 238, 241, alpha), 2.0f * s, 0, thick);
}
float skin_filigree_height(float s) { return 26.0f * s; }
// The divider from the game's art: the ornament (its ink runs from (28, 24) to (200, 65) in 228 x 80) and on each side
// the line texture, turned round for the left one: its stroke from x = 38 to 217 stretched, then the dot up to x = 232
// at its own proportions, the whole on the row y = 23 of 240 x 43.
static bool filigree_art(ImDrawList *dl, float x0, float x1, float y, float s, float alpha) {
ImTextureID mark, stroke;
float mw, mh, lw, lh;
if (!menu_art(MENU_ART_DIVIDER, &mark, &mw, &mh) || !menu_art(MENU_ART_DIVIDER_LINE, &stroke, &lw, &lh)) return false;
const ImU32 orn = rgba(196, 164, 112, alpha), line = rgba(150, 126, 90, alpha);
const float orn_w = fminf(84.0f * s, (x1 - x0) * 0.5f), k = orn_w / 172.0f, cx = (x0 + x1) * 0.5f;
dl->AddImage(mark, ImVec2(cx - 114 * k, y - 44.5f * k), ImVec2(cx - 114 * k + mw * k, y - 44.5f * k + mh * k), ImVec2(0, 0), ImVec2(1, 1), orn);
const float lk = 0.42f * s, top = y - 9 * lk, bot = y + 9 * lk, v0 = 14 / lh, v1 = 32 / lh, dot = (232 - 217) * lk;
const float from = cx + orn_w * 0.5f + 5 * s, to = x1 - 4 * s;
if (to - dot <= from) return true;
const float u0 = 38 / lw, u1 = 217 / lw, u2 = 232 / lw, mirror = 2 * cx;
dl->AddImage(stroke, ImVec2(from, top), ImVec2(to - dot, bot), ImVec2(u0, v0), ImVec2(u1, v1), line);
dl->AddImage(stroke, ImVec2(to - dot, top), ImVec2(to, bot), ImVec2(u1, v0), ImVec2(u2, v1), line);
dl->AddImage(stroke, ImVec2(mirror - (to - dot), top), ImVec2(mirror - from, bot), ImVec2(u1, v0), ImVec2(u0, v1), line);
dl->AddImage(stroke, ImVec2(mirror - to, top), ImVec2(mirror - (to - dot), bot), ImVec2(u2, v0), ImVec2(u1, v1), line);
return true;
}
void skin_filigree(ImDrawList *dl, float x0, float x1, float y, float s, float alpha) {
if (filigree_art(dl, x0, x1, y, s, alpha)) return;
const ImU32 line = rgba(96, 80, 56, alpha), dot = rgba(110, 92, 64, alpha), orn = rgba(138, 114, 76, alpha);
float orn_w = fminf(78.0f * s, (x1 - x0) * 0.5f), k = orn_w / 108.0f, cx = (x0 + x1) * 0.5f;
float dot_r = 1.5f * s, gap = 5.0f * s;
dl->AddCircleFilled(ImVec2(x0 + 4 * s + dot_r, y), dot_r, dot);
dl->AddCircleFilled(ImVec2(x1 - 4 * s - dot_r, y), dot_r, dot);
dl->AddLine(ImVec2(x0 + 4 * s + 2 * dot_r + gap, y), ImVec2(cx - orn_w * 0.5f - gap, y), line, 1.0f * s);
dl->AddLine(ImVec2(cx + orn_w * 0.5f + gap, y), ImVec2(x1 - 4 * s - 2 * dot_r - gap, y), line, 1.0f * s);
auto at = [&](float px, float py) { return ImVec2(cx + (px - 60.0f) * k, y + (py - 21.0f) * k); };
for (const float *p : kFiligree) {
ImVec2 cur(0, 0);
bool open = false;
for (int i = 0; p[i] != F_END;) {
if (p[i] == F_M) {
if (open) dl->PathStroke(orn, 0, 2.2f * k);
cur = at(p[i + 1], p[i + 2]);
dl->PathLineTo(cur);
open = true;
i += 3;
} else if (p[i] == F_L) {
cur = at(p[i + 1], p[i + 2]);
dl->PathLineTo(cur);
i += 3;
} else if (p[i] == F_C) {
cur = at(p[i + 5], p[i + 6]);
dl->PathBezierCubicCurveTo(at(p[i + 1], p[i + 2]), at(p[i + 3], p[i + 4]), cur, 8);
i += 7;
} else { // F_Z: back to the path's start (no path here uses it)
i += 1;
}
}
if (open) dl->PathStroke(orn, 0, 2.2f * k);
}
}
void skin_panel(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float alpha) {
if (have_art({MENU_ART_PANEL_FILL, MENU_ART_BTN_EDGE, MENU_ART_BTN_LINE})) {
// the panel's own texture inside its box, with the button's edge and inset line at a size that suits a large box
const float k = 0.62f * s;
slice(dl, MENU_ART_PANEL_FILL, a, b, kPanelM, kPanelM, kPanelW - kPanelM, kPanelH - kPanelM, 40, k, rgba(255, 255, 255, alpha), true, true);
btn_layer(dl, MENU_ART_BTN_EDGE, a, b, k, rgba(126, 104, 68, 1));
btn_layer(dl, MENU_ART_BTN_LINE, a, b, k, rgba(150, 124, 80, 1));
return;
}
dl->AddRectFilled(a, b, rgba(20, 15, 10, 0.85f * alpha));
ImVec2 ia(a.x + 1.0f * s, a.y + 1.0f * s), ib(b.x - 1.0f * s, b.y - 1.0f * s);
dl->AddRectFilledMultiColor(ia, ib, rgba(44, 35, 25, alpha), rgba(44, 35, 25, alpha), rgba(33, 26, 19, alpha),
rgba(33, 26, 19, alpha));
grain(dl, ia, ib, s, 0.6f * alpha);
dl->AddRect(ia, ib, rgba(110, 90, 58, 1), 0, 0, 1.4f * s);
ornament_line(dl, a, b, 7.0f * s, s, rgba(122, 101, 66, 1));
}
bool skin_widget_button(const char *label, ImVec2 size, float s) {
ImVec2 ts = ImGui::CalcTextSize(label, nullptr, true);
const ImGuiStyle &st = ImGui::GetStyle();
ImVec2 sz(size.x > 0 ? size.x : ts.x + st.FramePadding.x * 2, size.y > 0 ? size.y : ts.y + st.FramePadding.y * 2);
ImVec2 a = ImGui::GetCursorScreenPos(), b(a.x + sz.x, a.y + sz.y);
ImGui::PushStyleColor(ImGuiCol_NavCursor, ImVec4(0, 0, 0, 0)); // the cursor below shows the selection
bool pressed = ImGui::InvisibleButton(label, sz, ImGuiButtonFlags_EnableNav);
ImGui::PopStyleColor();
bool hov = ImGui::IsItemHovered(), foc = ImGui::IsItemFocused() && ImGui::GetCurrentContext()->NavCursorVisible;
bool held = ImGui::IsItemActive();
ImDrawList *dl = ImGui::GetWindowDrawList();
if (foc || hov) skin_cursor_glow(dl, a, b, s, foc ? 1.0f : 0.55f); // under the button
skin_button(dl, a, b, s, held ? 0.4f : foc ? 1.0f : hov ? 0.7f : 0.15f, false);
const char *end = ImGui::FindRenderedTextEnd(label);
dl->AddText(ImVec2(floorf((a.x + b.x - ts.x) * 0.5f), floorf((a.y + b.y - ts.y) * 0.5f)), SKIN_TEXT, label, end);
if (foc || hov) skin_cursor_frame(dl, a, b, s, foc ? 1.0f : 0.55f);
return pressed;
}
bool skin_tab_item(const char *id, const char *text, int flags, float s, ImFont *font) {
// Dear ImGui keeps the bar's behaviour (selecting, sizing, the D-pad) and lays out the tab with everything it would
// draw made invisible; the button and the text go over its rectangle here.
static const ImGuiCol hide[] = {ImGuiCol_Tab, ImGuiCol_TabHovered, ImGuiCol_TabSelected, ImGuiCol_TabSelectedOverline, ImGuiCol_TabDimmed,
ImGuiCol_TabDimmedSelected, ImGuiCol_TabDimmedSelectedOverline, ImGuiCol_Text, ImGuiCol_NavCursor};
for (ImGuiCol c : hide) ImGui::PushStyleColor(c, ImVec4(0, 0, 0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(12.0f * s, ImGui::GetStyle().ItemInnerSpacing.y));
if (font) ImGui::PushFont(font);
const bool shown = ImGui::BeginTabItem(id, nullptr, flags);
ImGui::PopStyleVar();
ImGui::PopStyleColor((int)(sizeof hide / sizeof *hide));
ImVec2 a = ImGui::GetItemRectMin(), b = ImGui::GetItemRectMax();
if (b.x > a.x && b.y > a.y) {
b.y -= 4.0f * s; // clear of the line under the tabs
const bool hov = ImGui::IsItemHovered(), foc = ImGui::IsItemFocused() && ImGui::GetCurrentContext()->NavCursorVisible;
ImDrawList *dl = ImGui::GetWindowDrawList();
if (foc) skin_cursor_glow(dl, a, b, s, 1.0f);
const float lift = shown ? 1.0f : hov ? 0.6f : 0.0f;
if (!button_art(dl, a, b, lift, false, shown)) skin_button(dl, a, b, s, lift, false);
const ImVec2 ts = ImGui::CalcTextSize(text, nullptr, true);
dl->AddText(ImVec2(floorf((a.x + b.x - ts.x) * 0.5f), floorf((a.y + b.y - ts.y) * 0.5f)), shown ? SKIN_GOLD : SKIN_TEXT, text);
if (foc) skin_cursor_frame(dl, a, b, s, 1.0f);
}
if (font) ImGui::PopFont();
return shown;
}
void skin_boot_panel(ImDrawList *dl, ImFont *head, float head_px, ImFont *body, float body_px, const char *title,
const char *step, const char *hint, float frac, float sweep, float w, float h, float s) {
const float pad = 38 * s, gap = 16 * s, bar_h = 12 * s, fh = skin_filigree_height(s);
ImVec2 ts = head->CalcTextSizeA(head_px, FLT_MAX, 0, title), ss = body->CalcTextSizeA(body_px, FLT_MAX, 0, step),
hs = body->CalcTextSizeA(body_px * 0.8f, FLT_MAX, 0, hint);
float pw = fminf(fmaxf(fmaxf(fmaxf(ts.x, hs.x), ss.x), 560 * s) + pad * 2, w - 24 * s);
float ph = pad + ts.y + fh + gap * 0.4f + ss.y + gap * 0.7f + bar_h + gap * 1.4f + hs.y + pad;
ImVec2 a(floorf((w - pw) / 2), floorf((h - ph) / 2)), b(a.x + pw, a.y + ph);
skin_panel(dl, a, b, s);
float y = a.y + pad;
dl->AddText(head, head_px, ImVec2(floorf((w - ts.x) / 2), y), SKIN_GOLD, title);
y += ts.y;
skin_filigree(dl, a.x + pad, b.x - pad, y + fh * 0.5f, s);
y += fh + gap * 0.4f;
dl->AddText(body, body_px, ImVec2(a.x + pad, y), SKIN_TEXT, step);
y += ss.y + gap * 0.7f;
// the bar: a sunken track with the frames' brown edge, filled in gold from the left
ImVec2 ba(a.x + pad, y), bb(b.x - pad, y + bar_h);
dl->AddRectFilled(ba, bb, rgba(12, 9, 6, 0.85f), 2 * s);
float x0 = ba.x + 2 * s, x1 = bb.x - 2 * s, top = ba.y + 2 * s, bot = bb.y - 2 * s;
auto fill = [&](float from, float to) {
if (to - from < 1) return;
dl->AddRectFilledMultiColor(ImVec2(from, top), ImVec2(to, bot), rgba(246, 214, 128, 1), rgba(246, 214, 128, 1),
rgba(196, 148, 66, 1), rgba(196, 148, 66, 1));
dl->AddLine(ImVec2(from, top + 0.5f * s), ImVec2(to, top + 0.5f * s), rgba(255, 240, 196, 0.6f), 1.0f * s);
};
if (frac >= 0) {
fill(x0, x0 + (x1 - x0) * fminf(frac, 1.0f));
} else {
float span = (x1 - x0) * 0.2f, run = (x1 - x0) - span, at = sweep < 0 ? 0 : sweep > 1 ? 1 : sweep;
fill(x0 + run * at, x0 + run * at + span);
}
dl->AddRect(ba, bb, rgba(110, 90, 58, 1), 2 * s, 0, 1.3f * s);
y += bar_h + gap * 1.4f;
dl->AddText(body, body_px * 0.8f, ImVec2(floorf((w - hs.x) / 2), y), rgba(214, 198, 166, 0.85f), hint);
}

60
runtime/ui/menu_skin.h Normal file
View File

@@ -0,0 +1,60 @@
// The look of the game's own menus (ui/menu_skin.cpp): the save menu's brown button with its inset line and corner
// ornaments, the options menu's white selection cursor and its filigree divider, and a dark panel framed like the
// buttons. Each is drawn from the game's textures when they are there (ui/menu_art.cpp), else from plain shapes in the
// same colours. Sizes are in pixels at 1080 lines; s scales them (menu.cpp menu_scale).
#pragma once
#include <stdint.h>
#include "imgui.h"
// What the art needs after it is decoded: the cursor's frame is cut out of its texture here (art: a MenuArt).
void skin_art_prepare(int art, uint8_t *rgba, uint32_t w, uint32_t h);
// One level of an art at half the size of the last: dst is dw x dh (each half of the source's, at least 1).
void skin_art_halve(const uint8_t *src, uint32_t w, uint32_t h, uint8_t *dst, uint32_t dw, uint32_t dh);
// The settings menu's Dear ImGui style at 1080 lines: the colours of the game's menus (a dark umber panel, warm browns
// for frames and what is selected, gold ornaments and accents, parchment text) and the sizes of its frames.
void skin_style(ImGuiStyle &s);
// The boxes' mottled grain lives in the font atlas: skin_atlas_add before the atlas is built (it reserves the tile),
// skin_atlas_fill after it is built and before it is uploaded (it draws the tile). Without them the boxes are plain.
void skin_atlas_add(ImFontAtlas *fa);
void skin_atlas_fill(ImFontAtlas *fa);
// The brown button over [a, b]: a dark rim, a light edge, the fill, and an inset line that stops short of a diamond at
// the top-left and bottom-right corners and of a curl at the other two. lift 0..1 brightens the fill (hovered or
// selected); dim mutes it (a row the environment fixes).
void skin_button(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float lift, bool dim);
// How far skin_cursor reaches outside the box it surrounds: a box needs that much room on every side.
float skin_cursor_reach(float s);
// The selection cursor around the box [a, b], in two parts: a soft white-blue glow, drawn before the box (the box hides
// its middle, so it shows only around it), and a white frame a little outside the box, drawn after it. Both breathe
// slowly; alpha 0..1 (a hovered row's cursor is fainter than the selected one's).
void skin_cursor_glow(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float alpha);
void skin_cursor_frame(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float alpha);
// The divider: a thin line with a dot at each end and the ornament in its middle, centred on y between x0 and x1.
void skin_filigree(ImDrawList *dl, float x0, float x1, float y, float s, float alpha = 1);
float skin_filigree_height(float s);
// A dark panel over [a, b] with the button's edge, inset line and corner ornaments (the description pane, the
// performance overlay). alpha scales its fill.
void skin_panel(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float alpha = 1);
// The boot screen's box (menu.cpp menu_boot_frame) centred in a w x h frame: the panel, the title in gold over the
// divider, the step's line, a bar filled to frac (0..1; a negative frac: a short segment sweeping at position sweep
// 0..1, no count yet) and the hint under it.
void skin_boot_panel(ImDrawList *dl, ImFont *head, float head_px, ImFont *body, float body_px, const char *title,
const char *step, const char *hint, float frac, float sweep, float w, float h, float s);
// A button widget drawn as skin_button with its label centred and skin_cursor round it while selected or hovered (the
// save menu's Load and Cancel). True when pressed (click, A, Enter). size: as for ImGui::Button.
bool skin_widget_button(const char *label, ImVec2 size, float s);
// One tab of the bar: ImGui::BeginTabItem drawn as the rows' button, with the game's plate behind the selected tab's
// lines and its text in gold. id: BeginTabItem's label (it sizes the tab); text: what is shown. font: the label's font,
// NULL for the current one. True when selected: call ImGui::EndTabItem then.
bool skin_tab_item(const char *id, const char *text, int flags, float s, ImFont *font);
// The colours the boxes are drawn in, for text on them.
#define SKIN_TEXT IM_COL32(244, 236, 214, 255) // labels on a button
#define SKIN_TEXT_DIM IM_COL32(206, 188, 150, 255) // notes on a button
#define SKIN_GOLD IM_COL32(236, 196, 104, 255) // headings and accents

View File

@@ -40,8 +40,12 @@ static ImGuiKey key_of(WPARAM vk) {
}
}
// The mouse buttons pressed on the open menu and not yet released, one bit each. While any is held the window has the
// mouse capture, so the release reaches the menu where the pointer went outside the window (else ImGui would hold the
// button down and miss the next click). The game itself only clips the cursor (input_win.c), it takes no capture.
static unsigned g_held;
extern "C" int menu_window_msg(HWND h, UINT m, WPARAM w, LPARAM l, LRESULT *res) {
(void)h;
switch (m) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
@@ -71,9 +75,17 @@ extern "C" int menu_window_msg(HWND h, UINT m, WPARAM w, LPARAM l, LRESULT *res)
case WM_LBUTTONDOWN: case WM_LBUTTONUP:
case WM_RBUTTONDOWN: case WM_RBUTTONUP:
case WM_MBUTTONDOWN: case WM_MBUTTONUP: {
if (!menu_is_open()) return 0;
int b = m == WM_LBUTTONDOWN || m == WM_LBUTTONUP ? 0 : m == WM_RBUTTONDOWN || m == WM_RBUTTONUP ? 1 : 2;
int down = m == WM_LBUTTONDOWN || m == WM_RBUTTONDOWN || m == WM_MBUTTONDOWN;
if (!down && (g_held & 1u << b)) { // also when the menu closed meanwhile: the capture goes either way
g_held &= ~(1u << b);
if (!g_held && GetCapture() == h) ReleaseCapture();
}
if (!menu_is_open()) return 0;
if (down) {
if (!g_held) SetCapture(h);
g_held |= 1u << b;
}
menu_event_mouse_pos((float)GET_X_LPARAM(l), (float)GET_Y_LPARAM(l));
menu_event_mouse_button(b, down);
return 0;
@@ -81,6 +93,13 @@ extern "C" int menu_window_msg(HWND h, UINT m, WPARAM w, LPARAM l, LRESULT *res)
case WM_MOUSEWHEEL:
if (menu_is_open()) menu_event_wheel(0, (float)GET_WHEEL_DELTA_WPARAM(w) / WHEEL_DELTA);
return 0;
case WM_CAPTURECHANGED: // another window took the capture (ReleaseCapture above finds g_held empty)
if ((HWND)l != h && g_held) {
for (int b = 0; b < 3; b++)
if (g_held & 1u << b) menu_event_mouse_button(b, 0);
g_held = 0;
}
return 0;
case WM_SETFOCUS:
case WM_KILLFOCUS:
menu_event_focus(m == WM_SETFOCUS);

View File

@@ -12,20 +12,18 @@
#include "imgui.h"
#include "imgui_internal.h" // SetKeyOwner, SetFocusID, NavCursorVisible
#include "ui/menu_skin.h"
#include "ui/option_rows.h"
extern "C" {
#include "cfg.h"
#include "platform/platform.h"
#include "ui_text.h"
#include "ui/menu_art.h"
#include "menu_sound.h"
// host.h pulls in cpu.h, which is C only: the one function needed from it, as declared there.
void rt_log(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
}
static const ImU32 kGold = IM_COL32(236, 194, 84, 255);
static const ImU32 kDim = IM_COL32(150, 150, 140, 255);
static const ImU32 kGrey = IM_COL32(110, 110, 102, 255);
static float g_scale = 1;
@@ -36,9 +34,18 @@ static float g_bottom; // opt_reserve_bottom: kept free under
static bool g_disable_next; // opt_disable_next: the next row is greyed out with g_disable_note
static const char *g_disable_note;
// The description pane: this frame's hovered and selected rows, the page's first row, and the last one shown.
// The rows' cursor, drawn once all rows are (opt_end), its glow in the layer under the rows and its frame in the one
// over them: the selected row's box, else the hovered one's (alpha: fainter for a hovered row, and for one the
// environment fixes).
static struct { bool on; ImVec2 a, b; float alpha; } g_cursor;
// Room left on each side of a row for its cursor, which is drawn outside the row's box.
static float row_margin(void) { return ceilf(skin_cursor_reach(g_scale) * 0.85f); }
// The description pane: this frame's hovered and selected rows, the page's first row, and the last one shown (of the
// page g_page: another page starts from its first row's, however it was opened).
struct Desc { char text[UI_DESC_BYTES]; };
static Desc g_hover, g_focus, g_first, g_shown;
static ImGuiID g_page;
// disabled: the note of a row opt_disable_next greyed out, else NULL.
static void desc_set(Desc &d, const char *desc, const char *key, const CfgMeta *m, const char *disabled) {
@@ -72,14 +79,30 @@ void opt_begin(const char *id, float scale) {
g_focus_req = false;
if (g_take_first) ImGui::NavMoveRequestCancel(); // this frame's move goes to the first row instead
g_hover.text[0] = g_focus.text[0] = g_first.text[0] = 0;
if (ImGuiID page = ImGui::GetID(id); page != g_page) g_page = page, g_shown.text[0] = 0;
ImVec2 avail = ImGui::GetContentRegionAvail();
avail.y -= g_bottom;
ImGui::PushID(id);
ImGui::BeginChild("##rows", ImVec2(avail.x * 0.58f, avail.y), ImGuiChildFlags_NavFlattened);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(ImGui::GetStyle().ItemSpacing.x, 5 * scale));
// the rows sit far enough apart that the selected row's cursor frame clears its neighbours' boxes
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(ImGui::GetStyle().ItemSpacing.x, 9 * scale));
ImGui::Dummy(ImVec2(0, row_margin())); // and the first row's cursor stays inside the pane
g_cursor.on = false;
// three layers: the cursor's glow under the rows, the rows, the cursor's frame over them (opt_end draws the cursor)
ImGui::GetWindowDrawList()->ChannelsSplit(3);
ImGui::GetWindowDrawList()->ChannelsSetCurrent(1);
}
void opt_end(void) {
ImGui::Dummy(ImVec2(0, row_margin())); // the last row's cursor stays inside the pane
ImDrawList *dl = ImGui::GetWindowDrawList();
if (g_cursor.on) {
dl->ChannelsSetCurrent(0);
skin_cursor_glow(dl, g_cursor.a, g_cursor.b, g_scale, g_cursor.alpha);
dl->ChannelsSetCurrent(2);
skin_cursor_frame(dl, g_cursor.a, g_cursor.b, g_scale, g_cursor.alpha);
}
dl->ChannelsMerge();
ImGui::PopStyleVar();
ImGui::EndChild();
// the hovered row (mouse) wins, else the selected one (controller), else the last shown, else the first row
@@ -90,10 +113,10 @@ void opt_end(void) {
ImVec2 p = ImGui::GetCursorScreenPos(), avail = ImGui::GetContentRegionAvail();
avail.y -= g_bottom;
float gap = 24 * g_scale;
ImGui::GetWindowDrawList()->AddLine(ImVec2(p.x + gap * 0.5f, p.y), ImVec2(p.x + gap * 0.5f, p.y + avail.y),
IM_COL32(236, 194, 84, 110), 1.0f);
// the description on a dark panel framed like the rows' buttons
skin_panel(ImGui::GetWindowDrawList(), ImVec2(p.x + gap * 0.5f, p.y), ImVec2(p.x + avail.x, p.y + avail.y), g_scale);
ImGui::SetCursorScreenPos(ImVec2(p.x + gap, p.y));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(14 * g_scale, 6 * g_scale));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(22 * g_scale, 20 * g_scale));
ImGui::BeginChild("##desc", ImVec2(0, avail.y), ImGuiChildFlags_AlwaysUseWindowPadding, ImGuiWindowFlags_NoNav);
ImGui::PopStyleVar();
ImGui::PushTextWrapPos(0);
@@ -120,10 +143,15 @@ static int row_text(const char *key, const char *label, const char *desc, const
g_disable_next = false;
bool off = disabled || cfg_from_env(key) != 0;
ImGui::PushID(key);
// the row's box, inset from the pane's sides by the room its cursor needs
const float margin = row_margin();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + margin);
ImVec2 p = ImGui::GetCursorScreenPos();
// h whole pixels: ImGui truncates cursor positions, which rounds a fractional height the other way above the window's
// top (negative y), so the page grew a pixel per row scrolled out and a row scrolled to the bottom was cut off
float fs = ImGui::GetFontSize(), w = ImGui::GetContentRegionAvail().x, h = floorf(fs * 2.2f);
// at least a pixel wide: InvisibleButton asserts on a zero size (a narrow window), and ImGui reads a negative one as
// "up to that far before the right edge", away from the box drawn
float fs = ImGui::GetFontSize(), w = fmaxf(ImGui::GetContentRegionAvail().x - margin, 1.0f), h = floorf(fs * 2.2f);
ImGui::PushStyleColor(ImGuiCol_NavCursor, ImVec4(0, 0, 0, 0)); // the row's own border shows the selection
bool clicked = ImGui::InvisibleButton("##row", ImVec2(w, h), ImGuiButtonFlags_EnableNav);
ImGui::PopStyleColor();
@@ -138,6 +166,8 @@ static int row_text(const char *key, const char *label, const char *desc, const
}
bool hov = ImGui::IsItemHovered(), foc = ImGui::IsItemFocused() && ImGui::GetCurrentContext()->NavCursorVisible;
int step = clicked && !off ? 2 : 0;
// a click of the mouse, not A / Enter / Space: only a click picks an arrow by where the pointer is
const bool by_mouse = clicked && hov && ImGui::IsMouseReleased(ImGuiMouseButton_Left);
g_held = false;
if (foc && !off) {
// the left stick arrives as the D-pad (menu.cpp pad_events)
@@ -164,32 +194,31 @@ static int row_text(const char *key, const char *label, const char *desc, const
ImDrawList *dl = ImGui::GetWindowDrawList();
ImFont *font = ImGui::GetFont();
float r = 9 * g_scale, pad = 16 * g_scale, small = fs * 0.72f;
dl->AddRectFilled(p, ImVec2(p.x + w, p.y + h), hov || foc ? IM_COL32(255, 230, 170, 18) : IM_COL32(0, 0, 0, 46), r);
// the selected row in the game's own cursor (glow, then its line; ui/menu_art.cpp), else a gold border
bool art = false;
if (hov || foc) { // a halo around the row (the glow's middle left out, so the label stays readable), then the line
float gx = h * 0.22f, gy = h * 0.16f;
art = menu_art_draw9(dl, MENU_ART_CURSOR_GLOW, ImVec2(p.x - gx, p.y - gy), ImVec2(p.x + w + gx, p.y + h + gy), h * 0.5f, 0.3f,
off ? IM_COL32(236, 194, 84, 50) : IM_COL32(244, 200, 96, 120), 0) &&
menu_art_draw9(dl, MENU_ART_CURSOR_LINE, ImVec2(p.x - gx * 0.3f, p.y - gy * 0.3f),
ImVec2(p.x + w + gx * 0.3f, p.y + h + gy * 0.3f), h * 0.12f, 0.1f,
off ? IM_COL32(255, 236, 190, 80) : IM_COL32(255, 236, 180, 150), 0); // edges only: the art is a filled bar
float pad = 20 * g_scale, small = fs * 0.72f;
// the save menu's brown button, brighter while selected or hovered; the white cursor goes round it in opt_end
skin_button(dl, p, ImVec2(p.x + w, p.y + h), g_scale, foc ? 1.0f : hov ? 0.6f : 0.0f, off);
if (foc || (hov && !g_cursor.on)) {
g_cursor.on = true, g_cursor.a = p, g_cursor.b = ImVec2(p.x + w, p.y + h);
g_cursor.alpha = (foc ? 1.0f : 0.55f) * (off ? 0.5f : 1.0f);
}
if (!art)
dl->AddRect(p, ImVec2(p.x + w, p.y + h),
hov || foc ? (off ? IM_COL32(236, 194, 84, 120) : kGold) : IM_COL32(255, 236, 200, off ? 16 : 34), r, 0,
hov || foc ? 2.0f : 1.0f);
float ty = p.y + fs * 0.25f, ny = p.y + fs * 1.3f; // the label line and the note line under it
float right = p.x + w - pad; // the value's right edge
float value_left = right;
// The value and its note take at most 60 % of the row: a longer value (a graphics card's full name) is drawn smaller,
// down to 75 % of the font size, then clipped, so the label keeps room and nothing reaches past the box.
const float cap = fmaxf((w - pad * 2) * 0.6f, 0.0f);
float vfs = fs, tv = v.value[0] ? font->CalcTextSizeA(fs, FLT_MAX, 0, v.value).x : 0;
if (tv > cap) {
vfs = fmaxf(fs * cap / tv, fs * 0.75f);
tv = fminf(font->CalcTextSizeA(vfs, FLT_MAX, 0, v.value).x, cap);
}
if (v.arrows && v.value[0]) { // < value >, drawn (the font has no arrow glyphs); a click on one steps
float aw = fs * 0.42f, gap = fs * 0.55f, cy = ty + fs * 0.52f;
float rx = right - aw, lx = rx - gap - ImGui::CalcTextSize(v.value).x - gap - aw;
ImU32 ac = off ? kGrey : hov || foc ? kGold : IM_COL32(170, 170, 160, 255);
float rx = right - aw, lx = rx - gap - tv - gap - aw;
ImU32 ac = off ? kGrey : hov || foc ? SKIN_TEXT : SKIN_TEXT_DIM;
dl->AddTriangleFilled(ImVec2(lx, cy), ImVec2(lx + aw, cy - aw * 0.75f), ImVec2(lx + aw, cy + aw * 0.75f), ac);
dl->AddTriangleFilled(ImVec2(rx + aw, cy), ImVec2(rx, cy - aw * 0.75f), ImVec2(rx, cy + aw * 0.75f), ac);
if (clicked && !off) {
if (by_mouse && !off) {
float mx = ImGui::GetIO().MousePos.x;
if (mx >= lx - gap && mx <= lx + aw + gap) step = -1;
else if (mx >= rx - gap && mx <= rx + aw + gap) step = 1;
@@ -200,36 +229,45 @@ static int row_text(const char *key, const char *label, const char *desc, const
if (movable) { // up and down arrows left of the value; a click on one moves the row
// a fixed value column (On / Off differ in width) keeps the arrows of the rows in one line
float aw = fs * 0.42f, gap = fs * 0.55f;
float cx = right - fmaxf(ImGui::CalcTextSize(v.value).x, fs * 2.8f) - gap * 2 - aw;
float cx = right - fmaxf(tv, fs * 2.8f) - gap * 2 - aw;
float uy = ty + fs * 0.12f, dy = ty + fs * 0.92f;
ImU32 ac = off ? kGrey : hov || foc ? kGold : IM_COL32(170, 170, 160, 255);
ImU32 ac = off ? kGrey : hov || foc ? SKIN_TEXT : SKIN_TEXT_DIM;
dl->AddTriangleFilled(ImVec2(cx, uy + aw * 0.7f), ImVec2(cx + aw, uy + aw * 0.7f), ImVec2(cx + aw * 0.5f, uy), ac);
dl->AddTriangleFilled(ImVec2(cx, dy - aw * 0.7f), ImVec2(cx + aw, dy - aw * 0.7f), ImVec2(cx + aw * 0.5f, dy), ac);
if (clicked && !off) {
if (by_mouse && !off) {
ImVec2 mp = ImGui::GetIO().MousePos;
if (mp.x >= cx - gap * 0.5f && mp.x <= cx + aw + gap * 0.5f) step = mp.y < ty + fs * 0.52f ? 3 : 4;
}
value_left = cx - gap;
}
if (v.value[0]) {
float vx = right - ImGui::CalcTextSize(v.value).x;
dl->AddText(ImVec2(vx, ty), off ? kGrey : v.is_default ? IM_COL32(205, 205, 195, 255) : IM_COL32(255, 255, 255, 255),
v.value);
float vx = right - tv;
ImVec4 vclip(vx, p.y, right, p.y + h);
dl->AddText(font, vfs, ImVec2(vx, ty + (fs - vfs) * 0.5f),
off ? kGrey : v.is_default ? IM_COL32(232, 222, 198, 255) : IM_COL32(255, 255, 255, 255), v.value, NULL,
0, &vclip);
if (!v.arrows && !movable) value_left = vx;
}
if (v.note || v.is_default) { // under the value, right-aligned with it
float note_right = p.x + w - pad; // where the label's own note stops: short of the value's note, when there is one
if (v.note || v.is_default) { // under the value, right-aligned with it; its start shows when it is too long
const char *t = v.note ? v.note : menu_text(UI_MENU_DEFAULT_MARK);
float tw = font->CalcTextSizeA(small, FLT_MAX, 0, t).x;
dl->AddText(font, small, ImVec2(right - tw, ny), v.note ? IM_COL32(220, 170, 100, 255) : kDim, t);
float tw = fminf(font->CalcTextSizeA(small, FLT_MAX, 0, t).x, cap);
ImVec4 nclip(right - tw, p.y, right, p.y + h);
dl->AddText(font, small, ImVec2(right - tw, ny), v.note ? IM_COL32(250, 206, 130, 255) : SKIN_TEXT_DIM, t, NULL, 0,
&nclip);
if (tw > 0) note_right = right - tw - fs * 0.6f;
}
// the label and its note, clipped before the value
ImVec4 clip(p.x, p.y, value_left - fs * 0.6f, p.y + h);
dl->AddText(font, fs, ImVec2(p.x + pad, ty), off ? kGrey : IM_COL32(240, 236, 224, 255), label, NULL, 0, &clip);
dl->AddText(font, fs, ImVec2(p.x + pad, ty), off ? kGrey : SKIN_TEXT, label, NULL, 0, &clip);
const char *note = disabled ? disabled
: off ? menu_text(UI_MENU_SET_BY_ENV)
: m && !m->live ? menu_text(UI_MENU_AFTER_RESTART)
: NULL;
if (note) dl->AddText(font, small, ImVec2(p.x + pad, ny), off ? IM_COL32(200, 150, 90, 255) : kDim, note);
ImVec4 note_clip(p.x, p.y, note_right, p.y + h);
if (note)
dl->AddText(font, small, ImVec2(p.x + pad, ny), off ? IM_COL32(200, 150, 90, 255) : SKIN_TEXT_DIM, note, NULL, 0,
&note_clip);
ImGui::PopID();
return off ? 0 : step;
}
@@ -283,6 +321,15 @@ bool opt_toggle(const char *key, UiTextId label, UiTextId desc, bool inverted) {
return true;
}
bool opt_toggle_value(const char *key, UiTextId label, UiTextId desc, const char *on_value, const char *off_value, const char *note) {
const CfgMeta *m = cfg_meta(key);
bool on = strcmp(cfg_value(key), off_value) != 0, def = m && strcmp(m->def, off_value) != 0;
RowView v = {menu_text(on ? UI_MENU_ON : UI_MENU_OFF), on == def, false, note};
if (!row(key, label, desc, v)) return false; // any step flips it
apply(key, on ? off_value : on_value);
return true;
}
bool opt_button(const char *id, UiTextId label, UiTextId desc, const char *value) {
RowView v = {value ? value : "", false, false, NULL};
return row(id, label, desc, v) == 2; // A or a click; left and right do nothing
@@ -294,32 +341,44 @@ bool opt_toggle_text(const char *id, const char *label, const char *desc, bool o
return row_text(id, label, desc, v, false) != 0; // any step flips it
}
void opt_group_text(const char *title) {
ImGui::Dummy(ImVec2(0, 6 * g_scale));
ImGui::PushTextWrapPos(0);
ImGui::TextColored(ImVec4(0.93f, 0.76f, 0.33f, 1), "%s", title);
ImGui::PopTextWrapPos();
// A group heading: the game's divider ornament across the pane, then the title in the accent colour.
static void group_divider(void) {
float fh = skin_filigree_height(g_scale);
ImVec2 p = ImGui::GetCursorScreenPos();
float m = row_margin();
skin_filigree(ImGui::GetWindowDrawList(), p.x + m, p.x + ImGui::GetContentRegionAvail().x - m, p.y + fh * 0.5f, g_scale);
ImGui::Dummy(ImVec2(0, fh));
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + m);
}
void opt_text_str(const char *text, bool warn) {
ImGui::PushTextWrapPos(0);
if (warn) ImGui::TextColored(ImVec4(0.95f, 0.66f, 0.40f, 1), "%s", text);
// Text across the rows' column, inset from its sides as the rows' boxes are and wrapped before their right edge. The
// cursor already stands at the inset when indented is true (after group_divider).
static void column_text(const char *text, const ImVec4 *col, bool indented) {
const float m = row_margin();
if (!indented) ImGui::SetCursorPosX(ImGui::GetCursorPosX() + m);
ImGui::PushTextWrapPos(ImGui::GetCursorPosX() + fmaxf(ImGui::GetContentRegionAvail().x - m, 1.0f));
if (col) ImGui::TextColored(*col, "%s", text);
else ImGui::TextUnformatted(text);
ImGui::PopTextWrapPos();
}
void opt_group(UiTextId title) {
ImGui::Dummy(ImVec2(0, 6 * g_scale));
ImGui::TextColored(ImVec4(0.93f, 0.76f, 0.33f, 1), "%s", menu_text(title));
static const ImVec4 kWarn(0.95f, 0.66f, 0.40f, 1);
void opt_group_text(const char *title) {
group_divider();
const ImVec4 gold = ImGui::ColorConvertU32ToFloat4(SKIN_GOLD);
column_text(title, &gold, true);
}
void opt_text(UiTextId text, bool warn) {
ImGui::PushTextWrapPos(0);
if (warn) ImGui::TextColored(ImVec4(0.95f, 0.66f, 0.40f, 1), "%s", menu_text(text));
else ImGui::TextUnformatted(menu_text(text));
ImGui::PopTextWrapPos();
void opt_text_str(const char *text, bool warn) { column_text(text, warn ? &kWarn : nullptr, false); }
void opt_group(UiTextId title) {
group_divider();
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(SKIN_GOLD), "%s", menu_text(title));
}
void opt_text(UiTextId text, bool warn) { column_text(menu_text(text), warn ? &kWarn : nullptr, false); }
bool opt_choice_list(const char *key, UiTextId label, const char *const *values, const char *const *names, int n,
UiTextId desc, int cur, const char *note) {
const char *d = cfg_default(key);
@@ -428,20 +487,22 @@ static void fit_text(ImDrawList *dl, float x0, float x1, float y, float h, ImU32
// The label column and the three cells of a binding row of width w.
static void bind_columns(float x, float w, float cx[3], float *cw) {
float lw = floorf(w * 0.34f), gap = floorf(8 * g_scale);
*cw = floorf((w - lw - gap * 3) / 3);
*cw = fmaxf(floorf((w - lw - gap * 3) / 3), 1.0f); // a pixel at least: InvisibleButton asserts on a zero width
for (int c = 0; c < 3; c++) cx[c] = x + lw + gap + c * (*cw + gap);
}
void opt_bind_header(UiTextId c0, UiTextId c1, UiTextId c2) {
// over the cells of the binding rows: the same inset (opt_bind_row) and the same columns
const float margin = row_margin();
ImVec2 p = ImGui::GetCursorScreenPos();
float w = ImGui::GetContentRegionAvail().x, cx[3], cw, fs = ImGui::GetFontSize() * 0.8f;
bind_columns(p.x, w, cx, &cw);
float w = fmaxf(ImGui::GetContentRegionAvail().x - margin * 2, 1.0f), cx[3], cw, fs = ImGui::GetFontSize() * 0.8f;
bind_columns(p.x + margin, w, cx, &cw);
const UiTextId cols[3] = {c0, c1, c2};
ImFont *font = ImGui::GetFont();
for (int c = 0; c < 3; c++) {
const char *t = menu_text(cols[c]);
float tw = font->CalcTextSizeA(fs, FLT_MAX, 0, t).x;
ImGui::GetWindowDrawList()->AddText(font, fs, ImVec2(cx[c] + (cw - tw) * 0.5f, p.y), kDim, t);
ImGui::GetWindowDrawList()->AddText(font, fs, ImVec2(cx[c] + (cw - tw) * 0.5f, p.y), SKIN_TEXT_DIM, t);
}
ImGui::Dummy(ImVec2(w, fs * 1.2f));
}
@@ -449,11 +510,13 @@ void opt_bind_header(UiTextId c0, UiTextId c1, UiTextId c2) {
int opt_bind_row(const char *key, const char *label, UiTextId desc, const char *const cells[3], const bool enabled[3],
const char *note) {
ImGui::PushID(key);
const float margin = row_margin(); // room for the cursor, as the option rows leave
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + margin);
ImVec2 p = ImGui::GetCursorScreenPos();
float fs = ImGui::GetFontSize(), w = ImGui::GetContentRegionAvail().x, h = floorf(fs * 1.9f), cx[3], cw;
float fs = ImGui::GetFontSize(), w = ImGui::GetContentRegionAvail().x - margin, h = floorf(fs * 1.9f), cx[3], cw;
bind_columns(p.x, w, cx, &cw);
ImDrawList *dl = ImGui::GetWindowDrawList();
float r = 8 * g_scale, pad = 6 * g_scale;
float pad = 6 * g_scale;
fit_text(dl, p.x + 16 * g_scale, cx[0] - fs * 0.3f, p.y, h, IM_COL32(240, 236, 224, 255), label, false);
int result = -1;
bool row_foc = false, row_hov = false;
@@ -461,7 +524,7 @@ int opt_bind_row(const char *key, const char *label, UiTextId desc, const char *
ImVec2 a(cx[c], p.y), b(cx[c] + cw, p.y + h);
const char *t = cells[c] && cells[c][0] ? cells[c] : "-";
if (!enabled[c]) { // not a nav item: the cursor skips it
dl->AddRect(a, b, IM_COL32(255, 255, 255, 14), r);
skin_button(dl, a, b, g_scale, 0, true);
fit_text(dl, a.x + pad, b.x - pad, a.y, h, kGrey, t, true);
continue;
}
@@ -488,9 +551,9 @@ int opt_bind_row(const char *key, const char *label, UiTextId desc, const char *
if (foc && (ImGui::IsKeyPressed(ImGuiKey_Delete, false) || ImGui::IsKeyPressed(ImGuiKey_Backspace, false) ||
ImGui::IsKeyPressed(ImGuiKey_GamepadFaceUp, false)))
result = 10 + c;
dl->AddRectFilled(a, b, hov || foc ? IM_COL32(255, 255, 255, 22) : IM_COL32(0, 0, 0, 40), r);
dl->AddRect(a, b, hov || foc ? kGold : IM_COL32(255, 255, 255, 38), r, 0, hov || foc ? 2.0f : 1.0f);
fit_text(dl, a.x + pad, b.x - pad, a.y, h, IM_COL32(255, 255, 255, 255), t, true);
skin_button(dl, a, b, g_scale, foc ? 1.0f : hov ? 0.6f : 0.0f, false); // a small brown button per cell
if (foc || (hov && !g_cursor.on)) g_cursor.on = true, g_cursor.a = a, g_cursor.b = b, g_cursor.alpha = foc ? 1.0f : 0.55f;
fit_text(dl, a.x + pad, b.x - pad, a.y, h, SKIN_TEXT, t, true);
ImGui::PopID();
}
char k[64];

View File

@@ -36,6 +36,10 @@ void opt_text(UiTextId text, bool warn = false);
// The return value of every row: true when it changed the setting this frame.
// inverted: the row shows "on" while the key is 0 (a setting whose key names the opposite).
bool opt_toggle(const char *key, UiTextId label, UiTextId desc, bool inverted = false);
// An on/off row over a key with named values: off while the key holds off_value and on for any other, so a value the
// row does not write itself still reads as on. Flipping it writes on_value or off_value. note: as for opt_choice.
bool opt_toggle_value(const char *key, UiTextId label, UiTextId desc, const char *on_value, const char *off_value,
const char *note = nullptr);
// One name per value of the key's cfg_meta values list, in its order. When the key has no fixed default (an empty
// def), names[0] is the automatic choice (the key unset) and names[1..] follow the values. note: a short line under
// the value in place of the "default" mark (NULL: none).

221
runtime/ui/perf_panel.cpp Normal file
View File

@@ -0,0 +1,221 @@
// The full performance overlay's panel (ui/perf_panel.h) in the settings menu's look: the menu's framed dark panel
// (ui/menu_skin.cpp), the numbers in tables with gold labels and parchment values, the game's divider between the
// machine, the frames, the per-frame waits and the picture, and the frame times as a gold line.
#include <float.h>
#include <math.h>
#include <stdio.h>
#include "imgui.h"
#include "imgui_internal.h" // the window's draw cursor (the plot does not widen the panel)
#include "ui/menu_skin.h"
#include "ui/perf_panel.h"
extern "C" {
#include "ui_text.h"
}
namespace {
const ImVec4 kLabel(236 / 255.0f, 196 / 255.0f, 104 / 255.0f, 1); // SKIN_GOLD
const ImVec4 kValue(244 / 255.0f, 236 / 255.0f, 214 / 255.0f, 1); // SKIN_TEXT
const ImVec4 kDimText(170 / 255.0f, 152 / 255.0f, 120 / 255.0f, 1);
struct PerfCol { UiTextId fmt; float sample; };
float text_w(UiTextId fmt, float v) {
char b[64];
snprintf(b, sizeof b, menu_text(fmt), v);
return ImGui::CalcTextSize(b).x;
}
// The panel keeps its width while the numbers change: every column is as wide as the widest text it can show, measured
// on samples of 8s (the menu fonts' digits share one width), and the numbers are right-aligned in it.
// A fixed column as wide as the widest of the formats (with their samples) and labels given.
void column(const char *id, const PerfCol *cols, int n, const UiTextId *labels = nullptr, int nl = 0) {
float w = ImGui::CalcTextSize(menu_text(UI_MENU_OV_NONE)).x;
for (int i = 0; i < n; i++) w = fmaxf(w, text_w(cols[i].fmt, cols[i].sample));
for (int i = 0; i < nl; i++) w = fmaxf(w, ImGui::CalcTextSize(menu_text(labels[i])).x);
ImGui::TableSetupColumn(id, ImGuiTableColumnFlags_WidthFixed, w);
}
void right(const char *s, bool dim) {
float pad = ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(s).x;
if (pad > 0) ImGui::SetCursorPosX(ImGui::GetCursorPosX() + pad);
ImGui::TextColored(dim ? kDimText : kValue, "%s", s);
}
// One cell: fmt (a catalog format, one number) with v, or "-" when the machine gives none.
void cell(UiTextId fmt, float v) {
ImGui::TableNextColumn();
if (v < 0) return right(menu_text(UI_MENU_OV_NONE), true);
char b[64];
snprintf(b, sizeof b, menu_text(fmt), v);
right(b, false);
}
void label(UiTextId id) {
ImGui::TableNextColumn();
ImGui::TextColored(kLabel, "%s", menu_text(id));
}
float gb(float mb) { return mb < 0 ? -1 : mb / 1024; }
// The game's divider across the panel between two sections, smaller than the menu's.
void divider(float scale) {
float s = scale * 0.72f, h = skin_filigree_height(s);
ImVec2 p = ImGui::GetCursorScreenPos();
ImGuiWindow *win = ImGui::GetCurrentWindow();
float x1 = win->WorkRect.Max.x > p.x + 40 * s ? win->WorkRect.Max.x : p.x + 200 * s;
skin_filigree(ImGui::GetWindowDrawList(), p.x - 4 * s, x1 + 4 * s, p.y + h * 0.5f, s);
ImGui::Dummy(ImVec2(0, h));
}
void machine_and_frames(const PerfPanel *p, float scale) {
const PerfStats &s = p->s;
if (!ImGui::BeginTable("##perft", 4, ImGuiTableFlags_SizingFixedFit)) return;
static const UiTextId labels[] = {UI_MENU_OV_GPU, UI_MENU_OV_VRAM, UI_MENU_OV_CPU, UI_MENU_OV_RAM,
UI_MENU_OV_FPS_LABEL, UI_MENU_OV_FRAME_LABEL};
static const PerfCol c1[] = {{UI_MENU_OV_FMT_PCT, 100}, {UI_MENU_OV_FMT_GB, 888.8f}, {UI_MENU_OV_FMT_FPS, 888},
{UI_MENU_OV_FRAME_MS, 888.8f}};
static const PerfCol c2[] = {{UI_MENU_OV_FMT_TEMP, 188}, {UI_MENU_OV_FMT_GB_OF, 888.8f}, {UI_MENU_OV_LOW1, 888},
{UI_MENU_OV_MAX_MS, 8888.8f}};
static const PerfCol c3[] = {{UI_MENU_OV_FMT_POWER, 888}, {UI_MENU_OV_FMT_MHZ, 8888}, {UI_MENU_OV_GAME_PCT, 100},
{UI_MENU_OV_GAME_GB, 888.8f}, {UI_MENU_OV_LOW01, 888}};
column("##c0", nullptr, 0, labels, 6);
column("##c1", c1, 4);
column("##c2", c2, 4);
column("##c3", c3, 5);
label(UI_MENU_OV_GPU);
cell(UI_MENU_OV_FMT_PCT, s.gpu_pct);
cell(UI_MENU_OV_FMT_TEMP, s.gpu_temp_c);
cell(UI_MENU_OV_FMT_POWER, s.gpu_power_w);
label(UI_MENU_OV_VRAM);
cell(UI_MENU_OV_FMT_GB, gb(s.vram_used_mb));
cell(UI_MENU_OV_FMT_GB_OF, gb(s.vram_total_mb));
cell(UI_MENU_OV_FMT_MHZ, s.gpu_clock_mhz);
label(UI_MENU_OV_CPU);
cell(UI_MENU_OV_FMT_PCT, s.cpu_total_pct);
cell(UI_MENU_OV_FMT_TEMP, s.cpu_temp_c);
cell(UI_MENU_OV_GAME_PCT, s.cpu_game_pct);
label(UI_MENU_OV_RAM);
cell(UI_MENU_OV_FMT_GB, gb(s.ram_used_mb));
cell(UI_MENU_OV_FMT_GB_OF, gb(s.ram_total_mb));
cell(UI_MENU_OV_GAME_GB, gb(s.ram_game_mb));
ImGui::EndTable();
divider(scale);
if (!ImGui::BeginTable("##perff", 4, ImGuiTableFlags_SizingFixedFit)) return;
column("##f0", nullptr, 0, labels, 6);
column("##f1", c1, 4);
column("##f2", c2, 4);
column("##f3", c3, 5);
// the frames: the rate over the last second with the lows over the last ten seconds, then the frame times
label(UI_MENU_OV_FPS_LABEL);
cell(UI_MENU_OV_FMT_FPS, s.fps);
cell(UI_MENU_OV_LOW1, s.low1_fps);
cell(UI_MENU_OV_LOW01, s.low01_fps);
if (p->fg_fps > 0) { // frame generation: what the display gets, generated frames included
label(UI_MENU_OV_FG_LABEL);
cell(UI_MENU_OV_FMT_FPS, p->fg_fps);
ImGui::TableNextColumn();
ImGui::TableNextColumn();
}
label(UI_MENU_OV_FRAME_LABEL);
cell(UI_MENU_OV_FRAME_MS, s.frame_ms_avg);
cell(UI_MENU_OV_MAX_MS, s.frame_ms_max);
ImGui::TableNextColumn();
ImGui::EndTable();
}
// The frame times of the last PERF_HISTORY frames as a gold line over a dark band, as wide as the tables made the panel
// (the plot does not count toward that width, so the panel can still shrink).
void frame_plot(const PerfStats &s, float scale) {
float top = s.frame_ms_max > 50 ? s.frame_ms_max : 50;
ImGuiWindow *win = ImGui::GetCurrentWindow();
float max_x = win->DC.CursorMaxPos.x;
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0, 0, 0, 0.32f));
ImGui::PushStyleColor(ImGuiCol_PlotLines, kLabel);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0);
ImGui::PlotLines("##ft", s.frame_ms, PERF_HISTORY, 0, nullptr, 0, top, ImVec2(-FLT_MIN, 48 * scale));
ImGui::PopStyleVar();
ImGui::PopStyleColor(2);
win->DC.CursorMaxPos.x = max_x;
}
// Per frame, averaged over the last half second; the labels' column stretches, so the numbers end at the panel's right
// edge, and the table still asks for no more than its widest label and number.
void waits(const PerfStats &s) {
if (!ImGui::BeginTable("##perfw", 2, ImGuiTableFlags_SizingFixedFit)) return;
static const PerfCol c1[] = {{UI_MENU_OV_FMT_MS, 888.88f}, {UI_MENU_OV_PER_FRAME, 888.8f}};
ImGui::TableSetupColumn("##w0", ImGuiTableColumnFlags_WidthStretch);
column("##w1", c1, 2);
label(UI_MENU_OV_REPLAY);
cell(UI_MENU_OV_FMT_MS, s.replay_ms);
label(UI_MENU_OV_GPU_TIME);
cell(UI_MENU_OV_FMT_MS, s.gpu_ms);
label(UI_MENU_OV_PIPE_WAIT);
cell(UI_MENU_OV_FMT_MS, s.pipe_wait_ms);
label(UI_MENU_OV_SHADER_WAIT);
cell(UI_MENU_OV_FMT_MS, s.xlate_ms);
label(UI_MENU_OV_TEX_UPLOADS);
cell(UI_MENU_OV_PER_FRAME, s.tex_uploads);
ImGui::EndTable();
}
void picture(const PerfPanel *p) {
static const UiTextId labels[6] = {UI_MENU_OV_WINDOW, UI_MENU_OV_OUTPUT, UI_MENU_OV_SCENE,
UI_MENU_OV_SCALING, UI_MENU_OV_LIMIT, UI_MENU_OV_PRESENT};
if (!ImGui::BeginTable("##perfp", 2, ImGuiTableFlags_SizingFixedFit)) return;
float vw = 0;
for (const auto &v : p->picture) vw = fmaxf(vw, ImGui::CalcTextSize(v).x);
ImGui::TableSetupColumn("##p0", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("##p1", ImGuiTableColumnFlags_WidthFixed, vw);
for (int i = 0; i < 6; i++) {
if (i == 2 && !p->scene_known) continue;
label(labels[i]);
ImGui::TableNextColumn();
right(p->picture[i], false);
}
ImGui::EndTable();
}
} // namespace
void perf_panel_draw(const PerfPanel *p, float width, float scale) {
const float m = 12 * scale;
ImGui::SetNextWindowPos(ImVec2(width - m, m), ImGuiCond_Always, ImVec2(1, 0));
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0)); // the panel below is the background
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(24 * scale, 20 * scale));
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(7 * scale, 1.5f * scale));
ImGui::Begin("##perf", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoNav |
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoSavedSettings);
ImGui::PopStyleVar(3);
ImGui::PopStyleColor();
// under the menu while it is open (the settings stay readable), else over everything
if (p->under_menu) ImGui::BringWindowToDisplayBack(ImGui::GetCurrentWindow());
else ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow());
ImDrawList *dl = ImGui::GetWindowDrawList();
dl->ChannelsSplit(2); // the panel goes under the text, drawn once the window's size is known
dl->ChannelsSetCurrent(1);
ImGui::SetWindowFontScale(0.72f);
// the port version and the game update first, so a screenshot in a bug report carries both
ImGui::TextColored(kDimText, "%s", p->version);
divider(scale);
machine_and_frames(p, scale);
ImGui::Dummy(ImVec2(0, 4 * scale));
frame_plot(p->s, scale);
ImGui::Dummy(ImVec2(0, 2 * scale));
waits(p->s);
divider(scale);
picture(p);
if (p->s.gpu_name[0] || p->s.cpu_name[0]) divider(scale);
if (p->s.gpu_name[0]) ImGui::TextColored(kDimText, "%s", p->s.gpu_name);
if (p->s.cpu_name[0]) ImGui::TextColored(kDimText, "%s", p->s.cpu_name);
dl->ChannelsSetCurrent(0);
ImVec2 a = ImGui::GetWindowPos(), sz = ImGui::GetWindowSize();
skin_panel(dl, a, ImVec2(a.x + sz.x, a.y + sz.y), scale * 0.8f, 0.94f);
dl->ChannelsMerge();
ImGui::End();
}

20
runtime/ui/perf_panel.h Normal file
View File

@@ -0,0 +1,20 @@
// The full performance overlay's panel (ui/perf_panel.cpp), drawn in the settings menu's look: what menu.cpp
// perf_full_draw gathered, laid out in tables on the menu's framed panel with the game's divider between the sections.
#pragma once
#include "imgui.h"
extern "C" {
#include "perfmon.h"
}
typedef struct {
PerfStats s; // perfmon_snapshot
const char *version; // "NX2navi <version>, game <update>"
char picture[6][64]; // window, game image, scene, scaling, frame limit, presentation (formatted)
bool scene_known; // the scene line is shown (resolution.c sets the scene's size)
float fg_fps; // frames the display gets with frame generation, 0 without it
bool under_menu; // the menu is open: the panel goes under its window
} PerfPanel;
// The panel at the top right corner of a width-pixel-wide frame.
void perf_panel_draw(const PerfPanel *p, float width, float scale);

View File

@@ -48,58 +48,44 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_SAVE_FAILED] = "could not save settings",
[UI_MENU_VERSION] = "NX2navi %s, game %s",
[UI_MENU_FULLSCREEN] = "Fullscreen", [UI_MENU_FULLSCREEN_DESC] = "Fills the screen with the game; F11 toggles it.",
[UI_MENU_WINDOW_SIZE] = "Window size", [UI_MENU_WINDOW_SIZE_DESC] = "Size of the game window when not fullscreen.",
[UI_MENU_FULLSCREEN] = "Fullscreen", [UI_MENU_FULLSCREEN_DESC] = "Play in fullscreen. F11 switches it.",
[UI_MENU_WINDOW_SIZE] = "Window size", [UI_MENU_WINDOW_SIZE_DESC] = "Window size outside fullscreen.",
[UI_MENU_WINDOW_SIZE_CUSTOM] = "Custom",
[UI_MENU_PRESENT] = "Presentation", [UI_MENU_PRESENT_DESC] = "How finished frames reach the screen.",
[UI_MENU_PRESENT_DESC] = "Stops screen tearing. Off lowers input delay slightly.",
[UI_MENU_PRESENT_MAILBOX] = "Mailbox", [UI_MENU_PRESENT_VSYNC] = "VSync", [UI_MENU_PRESENT_IMMEDIATE] = "Immediate",
[UI_MENU_PRESENT_IN_USE] = "in use: %s",
[UI_MENU_GPU] = "Graphics card", [UI_MENU_GPU_DESC] = "The Vulkan device that draws the game.",
[UI_MENU_GPU] = "Graphics card", [UI_MENU_GPU_DESC] = "The graphics card that runs the game.",
[UI_MENU_GPU_AUTO] = "Automatic",
[UI_MENU_PERF_OVERLAY] = "Performance overlay",
[UI_MENU_PERF_OVERLAY_DESC] = "Frame rate in the top right corner. Full adds frame times with a graph, CPU, GPU and "
"memory load, temperatures and the render thread's waits. F10 cycles the modes.",
[UI_MENU_PERF_OVERLAY_DESC] = "Shows frame rate and system stats. F10 switches modes.",
[UI_MENU_PERF_OFF] = "Off", [UI_MENU_PERF_FPS] = "FPS", [UI_MENU_PERF_FULL] = "Full",
// printf format of the overlay line in FPS mode: the frame rate
[UI_PERF_LINE_FPS] = "%.0f fps",
[UI_MENU_GRAPHICS] = "Picture",
[UI_MENU_OUTPUT_RES] = "Game resolution",
[UI_MENU_OUTPUT_RES_DESC] = "The size the game draws its picture and interface in. Above 1920 x 1080 the game needs "
"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_OUTPUT_RES_DESC] = "The resolution the game draws at. Higher needs a stronger GPU.",
[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.",
[UI_MENU_RENDER_SCALE_DESC] = "Size of the 3D scene. Higher is sharper but slower.",
[UI_MENU_RENDER_SCALE_GAME] = "Game (83 %)",
[UI_MENU_UPSCALER] = "Scaling to the window",
[UI_MENU_UPSCALER_DESC] = "How the game's picture is fitted to the window. Larger window: FSR keeps edges and detail "
"sharper than bilinear. Smaller window (Ocarina draws 2560 x 1440): the picture is shrunk "
"and FSR sharpens it by the strength below.",
[UI_MENU_UPSCALER_FSR] = "AMD FSR 1", [UI_MENU_UPSCALER_BILINEAR] = "Bilinear",
[UI_MENU_ASPECT] = "Picture shape",
[UI_MENU_ASPECT_DESC] = "When the window's shape differs from the game resolution's (a 16:9 picture on a 21:9 "
"screen): keep the picture's shape with black bars, or stretch it over the window.",
[UI_MENU_GAME_ASPECT] = "Widescreen",
[UI_MENU_GAME_ASPECT_DESC] = "The game draws a wider picture: more of the world at the sides, the HUD and menus in "
"the middle 16:9. Window shape follows the window (the monitor in fullscreen).",
[UI_MENU_GAME_ASPECT_DESC] = "Widens the view. HUD and menus stay 16:9.",
[UI_MENU_GAME_ASPECT_16_9] = "16:9 (the game's)", [UI_MENU_GAME_ASPECT_WINDOW] = "Window shape",
[UI_MENU_GAME_ASPECT_21_9] = "21:9", [UI_MENU_GAME_ASPECT_32_9] = "32:9",
[UI_MENU_ASPECT_FIT] = "Black bars", [UI_MENU_ASPECT_STRETCH] = "Stretch",
[UI_MENU_FOV] = "Field of view",
[UI_MENU_FOV_DESC] = "How much of the world the camera shows, in percent of the game's own. Game version 1.4.3 only.",
[UI_MENU_SHADOW_RES] = "Shadow map size",
[UI_MENU_SHADOW_RES_DESC] = "Size of the sun's shadow map. The game's own size changes with the view, down to about 400 "
"near the ground, so leaf shadows look blocky and jump; a fixed size keeps them still and "
"sharper. Above 1024 the shadows cost more GPU time and video memory; 256 is coarser than the "
"game's own and is for integrated GPUs short of memory bandwidth.",
[UI_MENU_SHADOW_RES_DESC] = "Shadow detail. Higher costs more GPU power.",
[UI_MENU_SHADOW_RES_GAME] = "Game (changes)",
[UI_MENU_ANISO] = "Texture filtering",
[UI_MENU_ANISO_DESC] = "Anisotropic filtering of surface textures: ground, roads and walls seen at a shallow angle stay sharp into the distance instead of blurring. Game: the level the game asks for, as on the Switch.",
[UI_MENU_ANISO_GAME] = "Game",
[UI_MENU_SHARPNESS] = "FSR sharpness",
[UI_MENU_SHARPNESS_DESC] = "Sharpening after FSR scaling, also when the picture is shrunk to the window; 0 turns it "
"off.",
[UI_MENU_SHARPNESS_DESC] = "How sharp FSR makes the picture. 0 turns it off.",
[UI_MENU_SHARPNESS_NEEDS_FSR] = "only with AMD FSR 1 or FSR 3.1",
[UI_MENU_COLOR] = "Colour",
[UI_MENU_COLOR_PRESET] = "Colour profile",
@@ -118,24 +104,18 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_COLOR_GAMMA_DESC] = "Below 1 brightens dark and middle tones, above 1 darkens them; 1 leaves them.",
[UI_MENU_HDR_GROUP] = "HDR",
[UI_MENU_HDR] = "HDR output",
[UI_MENU_HDR_DESC] = "Bright highlights on an HDR display. Needs HDR turned on in Windows (\"Use HDR\") or in a "
"Wayland compositor with colour management; without it the picture stays SDR. Native: the "
"game's own HDR, as on a Switch 2 on an HDR TV. Enhanced: the game's picture with its highlights "
"kept above the SDR white. Applies after a restart. The colour profile above is for SDR and is "
"not used in HDR.",
[UI_MENU_HDR_DESC] = "Brighter highlights on an HDR display. Turn on HDR in Windows first.",
[UI_MENU_HDR_PEAK] = "Peak brightness",
[UI_MENU_HDR_PEAK_DESC] = "Your display's peak in nits; the brightest highlights stop there.",
[UI_MENU_HDR_PEAK_DESC] = "Your display's peak brightness in nits.",
[UI_MENU_HDR_GAME] = "Game brightness",
[UI_MENU_HDR_GAME_DESC] = "Nits of the picture's white (paper white). 203 is the HDR reference; raise it in a "
"bright room.",
[UI_MENU_HDR_GAME_DESC] = "Brightness of white in the game, in nits.",
[UI_MENU_HDR_UI] = "HUD and menu brightness",
[UI_MENU_HDR_UI_DESC] = "Nits of the HUD's and this menu's white.",
[UI_MENU_HDR_UI_DESC] = "Brightness of the HUD and this menu, in nits.",
[UI_MENU_HDR_HUE] = "Highlight hue correction",
[UI_MENU_HDR_HUE_DESC] = "Bright colours such as fire and sparks turn towards white as in the game's own SDR picture, "
"matching the light they cast; 0 keeps them fully saturated.",
[UI_MENU_SHADOW_SCALE] = "Shadow resolution",
[UI_MENU_SHADOW_SCALE_DESC] = "Draws the sun's shadow maps this many times larger on each side than the game's 960x960: "
"sharper shadow edges and leaf shadows. Takes effect at the next start.",
[UI_MENU_SHADOW_SCALE_DESC] = "Sharper shadows. Higher costs more GPU power.",
[UI_MENU_PCSS] = "Soft shadows",
[UI_MENU_PCSS_DESC] = "Sun shadows sharp where an object meets the ground and softer the further the shadow falls "
"(PCSS). 0 keeps the game's filter. Takes effect at the next start.",
@@ -143,9 +123,7 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_CONTACT_SHADOWS_DESC] = "Small sun shadows the shadow maps miss: at feet, under stones, in grass and creases. "
"Traced on the screen after lighting. Takes effect at the next start.",
[UI_MENU_SHADOW_RANGE] = "Shadow cascade range",
[UI_MENU_SHADOW_RANGE_DESC] = "Moves the steps where shadows turn softer (the game's 20, 40, 80 and 160 m) further "
"away. Spreads the shadow map over more ground: raise Shadow resolution with it. "
"Takes effect at the next start.",
[UI_MENU_SHADOW_RANGE_DESC] = "Keeps shadows sharp further away.",
[UI_MENU_DLAA] = "NVIDIA DLSS / DLAA",
[UI_MENU_DLAA_DESC] = "NVIDIA DLSS for the 3D scene (NVIDIA RTX GPUs; " DLSS_FILE " next to " EXE_FILE "): smoother "
"edges and less shimmer. The HUD is not touched. The mode below sets the resolution it works "
@@ -173,8 +151,7 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_FXAA_DESC] = "The game's own FXAA edge smoothing. It blurs fine detail a little; with DLAA on it is not needed.",
[UI_MENU_FPS_LIMIT] = "Frame rate limit",
[UI_MENU_FPS_LIMIT_DESC] = "The most frames per second the game draws. The game keeps time by the clock, so it "
"plays at the same speed at any rate. Unlimited draws as fast as the PC can.",
[UI_MENU_FPS_LIMIT_DESC] = "The highest frame rate the game runs at.",
[UI_MENU_FPS_30] = "30 FPS", [UI_MENU_FPS_40] = "40 FPS", [UI_MENU_FPS_45] = "45 FPS",
[UI_MENU_FPS_60] = "60 FPS", [UI_MENU_FPS_90] = "90 FPS", [UI_MENU_FPS_120] = "120 FPS", [UI_MENU_FPS_144] = "144 FPS",
// the monitor's refresh rate; printf format with the rate in Hz when it is known
@@ -193,13 +170,10 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_GAME_LANG] = "Game language", [UI_MENU_GAME_LANG_DESC] = "Language of the game's text and voices.",
[UI_MENU_GAME_LANG_AUTO] = "Automatic",
[UI_MENU_OPERATION_MODE] = "Console mode",
[UI_MENU_OPERATION_MODE_DESC] = "Whether the game thinks it runs docked or handheld.",
[UI_MENU_OPERATION_MODE_DESC] = "Runs the game as docked or handheld.",
[UI_MENU_MODE_DOCKED] = "Docked", [UI_MENU_MODE_HANDHELD] = "Handheld",
[UI_MENU_ASSUME_FOCUS] = "Keep running out of focus",
[UI_MENU_ASSUME_FOCUS_DESC] = "On (the default), the game keeps running while you are in another window, and the "
"keyboard stays quiet until the window is in front again. Off, it pauses when its "
"window loses focus, as on the Switch when Home is pressed; a load interrupted that "
"way can stop for good.",
[UI_MENU_ASSUME_FOCUS_DESC] = "Keeps the game running when you switch to another window.",
[UI_MENU_MODS_BUILTIN] = "Built into the port", [UI_MENU_MODS_INSTALLED] = "Installed mods",
[UI_MENU_MODS_NONE] = "No mods yet. Unpack a mod into the mods folder, one folder per mod with its romfs folder "
@@ -232,24 +206,20 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_MODS_QUICKMENU_DESC] = "The port's fix for the black background of the weapon, shield and material menus "
"at 60 FPS.",
[UI_MENU_VOLUME] = "Volume", [UI_MENU_VOLUME_DESC] = "Master volume of the game.", [UI_MENU_MENU_SOUNDS] = "Menu sounds", [UI_MENU_MENU_SOUNDS_DESC] = "Volume of this menu's sounds, the game's own cursor, confirm and cancel sounds. 0 turns them off.",
[UI_MENU_VOLUME] = "Volume", [UI_MENU_VOLUME_DESC] = "Overall game volume.", [UI_MENU_MENU_SOUNDS] = "Menu sounds", [UI_MENU_MENU_SOUNDS_DESC] = "Volume of this menu's sounds.",
[UI_MENU_AUDIO_CHANNELS] = "Speakers",
[UI_MENU_AUDIO_CHANNELS_DESC] = "Stereo or 5.1 surround output. Automatic picks 5.1 when the Windows speaker setup "
"has six or more channels. Applies after a restart.",
[UI_MENU_AUDIO_CHANNELS_DESC] = "Stereo or 5.1 surround sound.",
[UI_MENU_CHANNELS_AUTO] = "Automatic", [UI_MENU_CHANNELS_STEREO] = "Stereo", [UI_MENU_CHANNELS_51] = "5.1 surround",
[UI_MENU_MOTION] = "Motion controls", [UI_MENU_MOTION_DESC] = "Aiming with the controller's gyroscope.",
[UI_MENU_MOTION] = "Motion controls", [UI_MENU_MOTION_DESC] = "Aim with the controller's gyro.",
[UI_MENU_RUMBLE_STRENGTH] = "Vibration strength",
[UI_MENU_RUMBLE_STRENGTH_DESC] = "How strong the controller vibrates.",
[UI_MENU_RUMBLE_STRENGTH_DESC] = "How strong the vibration is.",
[UI_MENU_RUMBLE_CURVE] = "Vibration curve",
[UI_MENU_RUMBLE_CURVE_DESC] = "Lower values make weak vibration stronger.",
[UI_MENU_RUMBLE_CURVE_DESC] = "Lower values make light vibration stronger.",
[UI_MENU_RUMBLE_TRIGGERS] = "Trigger vibration (Xbox)",
[UI_MENU_RUMBLE_TRIGGERS_DESC] = "Vibrates the triggers of an Xbox controller too.",
[UI_MENU_RUMBLE_TRIGGERS_DESC] = "Also vibrates the triggers on Xbox controllers.",
[UI_MENU_PAD_LAYOUT] = "Button layout",
[UI_MENU_PAD_LAYOUT_DESC] = "Which button is A. Nintendo: the right one, as on a Switch. Xbox: the bottom one, as "
"labelled on an Xbox controller (cross on a PlayStation controller). Automatic picks "
"Nintendo for controllers with Nintendo labels and Xbox for the others. The game's "
"prompts always show the Switch letters.",
[UI_MENU_PAD_LAYOUT_DESC] = "Sets which button acts as A.",
[UI_MENU_PAD_LAYOUT_AUTO] = "Automatic", [UI_MENU_PAD_LAYOUT_NINTENDO] = "Nintendo (A right)",
[UI_MENU_PAD_LAYOUT_XBOX] = "Xbox (A bottom)",
[UI_MENU_PAD_LAYOUT_IN_USE] = "in use: %s",
@@ -272,11 +242,12 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_RESTART_DESC] = "Closes the game and starts it again with the new prompts. Progress since your last save "
"is lost.",
[UI_MENU_RESTART_CONFIRM] = "Restart the game now? Progress since your last save is lost.",
[UI_MENU_QUIT_CONFIRM] = "Quit the game? Progress since your last save is lost.",
[UI_MENU_RESTART_YES] = "Restart",
[UI_MENU_RESTART_SAVING] = "The game is saving: Restart is possible in a moment.",
[UI_MENU_GROUP_STICKS] = "Analog sticks",
[UI_MENU_LSTICK_DEADZONE] = "Left stick dead zone", [UI_MENU_RSTICK_DEADZONE] = "Right stick dead zone",
[UI_MENU_STICK_DEADZONE_DESC] = "How far a gamepad stick moves before the game sees it. Raise it if the character or the camera moves on its own: let go of the stick, read \"stick now\" and set the dead zone a few percent above it.",
[UI_MENU_STICK_DEADZONE_DESC] = "How far a stick must move to register. Raise it if a stick drifts.",
[UI_MENU_STICK_DEADZONE_NOW] = "stick now: %.0f %%",
[UI_MENU_MOUSE_MODE] = "Mouse camera",
[UI_MENU_MOUSE_MODE_DESC] = "Direct: the camera turns by how far the mouse moves, as in a PC game, with no stick dead zone or curve (game 1.4.3; other versions use stick emulation). Stick emulation: the mouse acts as the right stick.",
@@ -287,15 +258,13 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_MOUSE_SENS] = "Mouse camera sensitivity",
[UI_MENU_MOUSE_SENS_DESC] = "How fast the mouse turns the camera.",
[UI_MENU_WALK_KEY] = "Walk key",
[UI_MENU_WALK_KEY_DESC] = "Hold it to tilt the keyboard's sticks part of the way, so the keyboard walks instead of "
"runs. The walk scale sets how far. A controller and the mouse are not affected.",
[UI_MENU_WALK_KEY_DESC] = "Hold to walk on the keyboard.",
[UI_MENU_WALK_KEY_TAKEN] = "also %s",
[UI_MENU_WALK_SCALE] = "Walk scale",
[UI_MENU_WALK_SCALE_DESC] = "The tilt the keyboard's sticks get while the walk key is held. Half is a walk, the "
"full tilt a run.",
[UI_MENU_STICK_SENS] = "Stick camera speed",
[UI_MENU_STICK_SENS_DESC] = "Multiplies the game's own right-stick camera speed, top speed included, at each of the "
"game's five camera sensitivities. The mouse keeps its own setting.",
[UI_MENU_STICK_SENS_DESC] = "Right stick camera speed.",
[UI_BINDS_HELP] = "Select a cell and press A or Enter, then the key, mouse button or controller button. Delete or "
"X clears a cell. A key in use moves here; a controller button swaps with the one it replaces.",
@@ -306,7 +275,7 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_BINDS_CANCEL_HINT] = "Esc cancels, or wait %d s",
[UI_BINDS_TAKEN] = "%s was taken from %s", [UI_BINDS_SWAPPED] = "%s swapped with %s",
[UI_BINDS_RESET] = "Reset all buttons",
[UI_BINDS_RESET_DESC] = "Back to the default keys and controller buttons. The button layout above applies again: remapped controller buttons stay where you put them until this reset.",
[UI_BINDS_RESET_DESC] = "Restores the default keys and buttons.",
[UI_BIND_A] = "A", [UI_BIND_B] = "B", [UI_BIND_X] = "X", [UI_BIND_Y] = "Y",
[UI_BIND_LCLICK] = "Left stick click", [UI_BIND_RCLICK] = "Right stick click", [UI_BIND_L] = "L",
[UI_BIND_R] = "R", [UI_BIND_ZL] = "ZL", [UI_BIND_ZR] = "ZR", [UI_BIND_PLUS] = "Plus", [UI_BIND_MINUS] = "Minus",
@@ -329,11 +298,10 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_BIND_DESC_PLUS] = "Menu: items, equipment, collection, system.", [UI_BIND_DESC_MINUS] = "Map.",
[UI_BIND_DESC_LEFT] = "Play the ocarina.", [UI_BIND_DESC_UP] = "Put the accessory on or take it off.",
[UI_BIND_DESC_RIGHT] = "Talk to Navi.", [UI_BIND_DESC_DOWN] = "Change boots.",
[UI_BIND_DESC_MOVE] = "Moves Link like the left stick. The controller's left stick always works too.",
[UI_BIND_DESC_CAMERA] = "Turns the camera like the right stick. The mouse and the controller's right stick always "
"work too.",
[UI_BIND_DESC_MOVE] = "Moves Link.",
[UI_BIND_DESC_CAMERA] = "Turns the camera.",
[UI_BIND_SHAKE] = "Shake the camera stick",
[UI_BIND_DESC_SHAKE] = "Swings the right stick left and right for the game. Holding the key keeps shaking.",
[UI_BIND_DESC_SHAKE] = "Shakes the right stick. Hold to keep shaking.",
[UI_KEY_SPACE] = "Space", [UI_KEY_TAB] = "Tab", [UI_KEY_LSHIFT] = "Left Shift", [UI_KEY_LCTRL] = "Left Ctrl",
[UI_KEY_UP] = "Up arrow", [UI_KEY_DOWN] = "Down arrow", [UI_KEY_LEFT] = "Left arrow",
[UI_KEY_RIGHT] = "Right arrow",
@@ -510,33 +478,22 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_BOOT_TITLE] = "Preparing shaders", [UI_BOOT_HINT] = "This happens once after an update or a graphics driver change.",
[UI_BOOT_STARTING] = "Starting", [UI_BOOT_SHADERS] = "Shaders: %lld of %lld", [UI_BOOT_PIPELINES] = "Pipelines: %lld of %lld",
[UI_MENU_UPSCALING] = "Upscaling",
[UI_MENU_UPSCALING_DESC] = "How the picture is made smooth and fitted to the window. Bilinear: plain scaling. AMD FSR 1: "
"sharper edges and detail when the window is larger than the picture (strength below). "
"NVIDIA DLSS (RTX GPUs; " DLSS_FILE " next to the game's .exe) renders the 3D scene at "
"its mode's share of the picture and scales it up with NVIDIA's newest model for the mode: "
"DLAA 100 %, Quality 67 %, Balanced 58 %, Performance 50 %, Ultra Performance 33 %. The "
"HUD is not touched. AMD FSR 3.1 (any GPU; amd_fidelityfx_vk.dll next to the game's .exe) "
"works the same way, with Native AA at 100 % and the same shares for its other modes. "
"Turning DLSS or FSR 3.1 on or off, or changing between them, takes effect after a "
"restart; the mode changes at once.",
[UI_MENU_UPSCALING_DESC] = "How the picture is smoothed and scaled to your window.",
[UI_MENU_UPSCALING_DLSS_NOTE] = "DLSS or FSR 3.1 on or off: after restart",
[UI_MENU_UPSCALING_DESC_FSR] = "How the picture is smoothed and scaled to your window.",
[UI_MENU_UPSCALING_FSR_NOTE] = "FSR 3.1 on or off: after restart",
[UI_MENU_FRAMEGEN] = "Frame generation",
[UI_MENU_FRAMEGEN_DESC] = "Shows a generated frame between every two the game draws, for about twice the frame rate "
"on a fast display. It needs DLSS or FSR 3.1 under Upscaling (any mode), whose motion "
"vectors it uses. AMD FSR 3.1 frame generation runs on any GPU (amd_fidelityfx_vk.dll next "
"to the game's .exe); NVIDIA DLSS frame generation needs an RTX 40 or 50 GPU and "
"NVIDIA's Streamline files next to the .exe. It pauses while this menu is open. Takes "
"effect after a restart.",
[UI_MENU_FRAMEGEN_DESC] = "Adds generated frames for smoother motion. Needs DLSS or FSR 3.1.",
[UI_MENU_FRAMEGEN_OFF] = "Off",
[UI_MENU_HDR_NOTE] = "after restart",
[UI_MENU_HDR_ENHANCED] = "Enhanced", [UI_MENU_HDR_NATIVE] = "Native (the game's)",
[UI_MENU_FRAMEGEN_NOTE] = "after restart; needs DLSS or FSR 3.1",
[UI_MENU_FRAMEGEN_NEEDS] = "choose a DLSS or FSR 3.1 mode under Upscaling first",
[UI_MENU_FRAMEGEN_NEEDS_FSR] = "choose an FSR 3.1 mode under Upscaling first",
[UI_MENU_FRAMEGEN_NOTE_FSR] = "after restart; needs FSR 3.1",
[UI_MENU_FRAMEGEN_DESC_FSR] = "Adds generated frames for smoother motion. Needs FSR 3.1.",
[UI_MENU_GAME_RES] = "Resolution",
[UI_MENU_GAME_RES_DESC] = "The height of the game's picture: 1440p is the game's own; higher draws a sharper picture "
"and its scene in proportion, at a matching cost on the graphics card. Native: the "
"window's height (the monitor's in fullscreen), from 1440 up to 4320. The width follows "
"the widescreen shape. Takes effect after a restart.",
[UI_MENU_GAME_RES_DESC] = "Height of the game's picture. Higher is sharper but costs more GPU power.",
[UI_MENU_GAME_RES_NATIVE] = "Native",
[UI_MENU_CHEATS_REBUILD] = "Rebuild the game now",
[UI_MENU_CHEATS_REBUILD_DESC] = "Some cheats change the game's code and are not built into it: they are new or "
@@ -564,59 +521,44 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_SAVE_FAILED] = "не удалось сохранить настройки",
[UI_MENU_VERSION] = "NX2navi %s, игра %s",
[UI_MENU_FULLSCREEN] = "Полный экран", [UI_MENU_FULLSCREEN_DESC] = "Игра на весь экран; F11 переключает режим.",
[UI_MENU_WINDOW_SIZE] = "Размер окна", [UI_MENU_WINDOW_SIZE_DESC] = "Размер окна игры вне полноэкранного режима.",
[UI_MENU_FULLSCREEN] = "Полный экран", [UI_MENU_FULLSCREEN_DESC] = "Игра на весь экран. F11 переключает.",
[UI_MENU_WINDOW_SIZE] = "Размер окна", [UI_MENU_WINDOW_SIZE_DESC] = "Размер окна вне полноэкранного режима.",
[UI_MENU_WINDOW_SIZE_CUSTOM] = "Другой",
[UI_MENU_PRESENT] = "Вывод кадров", [UI_MENU_PRESENT_DESC] = "Как готовые кадры попадают на экран.",
[UI_MENU_PRESENT_DESC] = "Убирает разрывы изображения. Выкл. немного снижает задержку.",
[UI_MENU_PRESENT_MAILBOX] = "Mailbox", [UI_MENU_PRESENT_VSYNC] = "Вертикальная синхронизация",
[UI_MENU_PRESENT_IMMEDIATE] = "Без ожидания",
[UI_MENU_PRESENT_IN_USE] = "сейчас: %s",
[UI_MENU_GPU] = "Видеокарта", [UI_MENU_GPU_DESC] = "Устройство Vulkan, которое рисует игру.",
[UI_MENU_GPU] = "Видеокарта", [UI_MENU_GPU_DESC] = "Видеокарта, на которой работает игра.",
[UI_MENU_GPU_AUTO] = "Автоматически",
[UI_MENU_PERF_OVERLAY] = "Индикатор производительности",
[UI_MENU_PERF_OVERLAY_DESC] = "Частота кадров в правом верхнем углу. «Полный» добавляет время кадров с графиком, "
"загрузку ЦП, GPU и памяти, температуры и ожидания потока отрисовки. F10 переключает "
"режимы.",
[UI_MENU_PERF_OVERLAY_DESC] = "Показывает частоту кадров и данные системы. F10 меняет режим.",
[UI_MENU_PERF_OFF] = "Выкл.", [UI_MENU_PERF_FPS] = "FPS", [UI_MENU_PERF_FULL] = "Полный",
[UI_PERF_LINE_FPS] = "%.0f к/с",
[UI_MENU_GRAPHICS] = "Изображение",
[UI_MENU_OUTPUT_RES] = "Разрешение игры",
[UI_MENU_OUTPUT_RES_DESC] = "Размер, в котором игра рисует картинку и интерфейс. Выше 1920 × 1080 игре нужно больше "
"видеопамяти и времени GPU. Более широкий размер (21:9) расширяет обзор камеры и "
"переносит интерфейс в углы экрана, более высокий (16:10, 3:2) переносит его к "
"верхнему и нижнему краям.",
[UI_MENU_OUTPUT_RES_DESC] = "Разрешение, в котором рисуется игра. Чем выше, тем больше нагрузка на видеокарту.",
[UI_MENU_RENDER_SCALE] = "Масштаб 3D-отрисовки",
[UI_MENU_RENDER_SCALE_DESC] = "Размер 3D-сцены относительно разрешения игры; FSR игры доводит её до этого размера. "
"Выше 100 % сглаживает лесенки на краях (суперсэмплинг) ценой большой нагрузки на GPU.",
[UI_MENU_RENDER_SCALE_DESC] = "Размер 3D-сцены. Выше — чётче, но медленнее.",
[UI_MENU_RENDER_SCALE_GAME] = "Как в игре (83 %)",
[UI_MENU_UPSCALER] = "Масштабирование под окно",
[UI_MENU_UPSCALER_DESC] = "Как картинка игры вписывается в окно. Окно больше: FSR сохраняет края и детали чётче "
"билинейного. Окно меньше (Ocarina рисует 2560 × 1440): картинка уменьшается, и FSR "
"повышает её резкость на величину ниже.",
[UI_MENU_UPSCALER_FSR] = "AMD FSR 1", [UI_MENU_UPSCALER_BILINEAR] = "Билинейное",
[UI_MENU_ASPECT] = "Форма картинки",
[UI_MENU_ASPECT_DESC] = "Когда форма окна отличается от разрешения игры (картинка 16:9 на экране 21:9): сохранить "
"форму картинки с чёрными полосами или растянуть её на всё окно.",
[UI_MENU_GAME_ASPECT] = "Широкий экран",
[UI_MENU_GAME_ASPECT_DESC] = "Игра рисует более широкую картинку: больше мира по бокам, интерфейс и меню в "
"центральной части 16:9. «По окну» берёт форму окна (монитора в полноэкранном режиме).",
[UI_MENU_GAME_ASPECT_DESC] = "Расширяет обзор. Интерфейс и меню остаются 16:9.",
[UI_MENU_GAME_ASPECT_16_9] = "16:9 (как в игре)", [UI_MENU_GAME_ASPECT_WINDOW] = "По окну",
[UI_MENU_GAME_ASPECT_21_9] = "21:9", [UI_MENU_GAME_ASPECT_32_9] = "32:9",
[UI_MENU_ASPECT_FIT] = "Чёрные полосы", [UI_MENU_ASPECT_STRETCH] = "Растянуть",
[UI_MENU_FOV] = "Поле зрения",
[UI_MENU_FOV_DESC] = "Сколько мира показывает камера, в процентах от игрового. Только для версии игры 1.4.3.",
[UI_MENU_SHADOW_RES] = "Размер карты теней",
[UI_MENU_SHADOW_RES_DESC] = "Размер карты теней от солнца. Собственный размер игры меняется вместе с видом, у земли до "
"примерно 400, поэтому тени листвы выглядят квадратными и дёргаются; постоянный размер делает "
"их ровными и чётче. Выше 1024 тени требуют больше времени GPU и видеопамяти; 256 грубее "
"собственного размера игры и предназначен для встроенных GPU с нехваткой пропускной способности памяти.",
[UI_MENU_SHADOW_RES_DESC] = "Детализация теней. Выше — больше нагрузка на видеокарту.",
[UI_MENU_SHADOW_RES_GAME] = "Как в игре (меняется)",
[UI_MENU_ANISO] = "Фильтрация текстур",
[UI_MENU_ANISO_DESC] = "Анизотропная фильтрация текстур поверхностей: земля, дороги и стены под острым углом остаются чёткими вдали, а не размываются. Игра: уровень, который запрашивает игра, как на Switch.",
[UI_MENU_ANISO_GAME] = "Игра",
[UI_MENU_SHARPNESS] = "Резкость FSR",
[UI_MENU_SHARPNESS_DESC] = "Повышение резкости после масштабирования FSR, в том числе когда картинка уменьшается "
"под окно; 0 выключает его.",
[UI_MENU_SHARPNESS_DESC] = "Насколько FSR повышает резкость. 0 отключает.",
[UI_MENU_SHARPNESS_NEEDS_FSR] = "только с AMD FSR 1",
[UI_MENU_COLOR] = "Цвет",
[UI_MENU_COLOR_PRESET] = "Цветовой профиль",
@@ -636,22 +578,18 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_COLOR_GAMMA_DESC] = "Ниже 1 осветляет тёмные и средние тона, выше 1 затемняет их; 1 — без изменений.",
[UI_MENU_HDR_GROUP] = "HDR",
[UI_MENU_HDR] = "Вывод HDR",
[UI_MENU_HDR_DESC] = "Яркие блики на HDR-дисплее. Нужен включённый HDR в Windows («Использовать HDR») или "
"Wayland-композитор с управлением цветом; без него картинка остаётся SDR. Применяется после "
"перезапуска. Цветовой профиль выше — для SDR и в HDR не используется.",
[UI_MENU_HDR_DESC] = "Более яркие блики на HDR-экране. Сначала включите HDR в Windows.",
[UI_MENU_HDR_PEAK] = "Пиковая яркость",
[UI_MENU_HDR_PEAK_DESC] = "Пик вашего дисплея в нитах; самые яркие блики останавливаются на нём.",
[UI_MENU_HDR_PEAK_DESC] = "Пиковая яркость вашего экрана в нитах.",
[UI_MENU_HDR_GAME] = "Яркость игры",
[UI_MENU_HDR_GAME_DESC] = "Ниты белого цвета картинки (paper white). 203 — эталон HDR; в светлой комнате "
"поднимите.",
[UI_MENU_HDR_GAME_DESC] = "Яркость белого в игре, в нитах.",
[UI_MENU_HDR_UI] = "Яркость интерфейса и меню",
[UI_MENU_HDR_UI_DESC] = "Ниты белого цвета интерфейса игры и этого меню.",
[UI_MENU_HDR_UI_DESC] = "Яркость интерфейса и этого меню, в нитах.",
[UI_MENU_HDR_HUE] = "Коррекция оттенка бликов",
[UI_MENU_HDR_HUE_DESC] = "Яркие цвета (огонь, искры) уходят к белому, как в SDR-картинке игры, и совпадают со светом, "
"который они дают; 0 оставляет их полностью насыщенными.",
[UI_MENU_SHADOW_SCALE] = "Разрешение теней",
[UI_MENU_SHADOW_SCALE_DESC] = "Карты теней от солнца рисуются во столько раз больше по каждой стороне, чем 960x960 "
"самой игры: края теней и тени листвы чётче. Действует после перезапуска.",
[UI_MENU_SHADOW_SCALE_DESC] = "Более чёткие тени. Выше — больше нагрузка на видеокарту.",
[UI_MENU_PCSS] = "Мягкие тени",
[UI_MENU_PCSS_DESC] = "Тени от солнца резкие там, где предмет касается земли, и мягче, чем дальше падает тень "
"(PCSS). 0 оставляет фильтр игры. Действует после перезапуска.",
@@ -659,9 +597,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_CONTACT_SHADOWS_DESC] = "Мелкие тени от солнца, которых нет на картах теней: у ног, под камнями, в траве и "
"складках. Считаются по экрану после освещения. Действует после перезапуска.",
[UI_MENU_SHADOW_RANGE] = "Дальность каскадов теней",
[UI_MENU_SHADOW_RANGE_DESC] = "Отодвигает границы, за которыми тени становятся мягче (в игре 20, 40, 80 и 160 м). "
"Карта теней растягивается на большую площадь, поэтому вместе с этим поднимайте "
"разрешение теней. Действует после перезапуска.",
[UI_MENU_SHADOW_RANGE_DESC] = "Сохраняет чёткие тени на большем расстоянии.",
[UI_MENU_DLAA] = "NVIDIA DLSS / DLAA",
[UI_MENU_DLAA_DESC] = "NVIDIA DLSS для 3D-сцены (видеокарты NVIDIA RTX; " DLSS_FILE " рядом с " EXE_FILE "): ровнее "
"края и меньше мерцания. Интерфейс не затрагивается. Режим ниже задаёт разрешение, с которым он "
@@ -689,8 +625,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_FXAA_DESC] = "Собственное сглаживание FXAA. Слегка размывает мелкие детали; с DLAA оно не нужно.",
[UI_MENU_FPS_LIMIT] = "Ограничение частоты кадров",
[UI_MENU_FPS_LIMIT_DESC] = "Наибольшее число кадров в секунду. Игра идёт по часам, поэтому её скорость не "
"зависит от частоты кадров. «Без ограничения» рисует так быстро, как может ПК.",
[UI_MENU_FPS_LIMIT_DESC] = "Максимальная частота кадров игры.",
[UI_MENU_FPS_30] = "30 FPS", [UI_MENU_FPS_40] = "40 FPS", [UI_MENU_FPS_45] = "45 FPS",
[UI_MENU_FPS_60] = "60 FPS", [UI_MENU_FPS_90] = "90 FPS", [UI_MENU_FPS_120] = "120 FPS", [UI_MENU_FPS_144] = "144 FPS",
[UI_MENU_FPS_DISPLAY] = "Как у монитора", [UI_MENU_FPS_DISPLAY_HZ] = "Как у монитора (%.0f Гц)",
@@ -707,13 +642,10 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_GAME_LANG] = "Язык игры", [UI_MENU_GAME_LANG_DESC] = "Язык текста и озвучки игры.",
[UI_MENU_GAME_LANG_AUTO] = "Автоматически",
[UI_MENU_OPERATION_MODE] = "Режим консоли",
[UI_MENU_OPERATION_MODE_DESC] = "Игра считает, что консоль в док-станции или в портативном режиме.",
[UI_MENU_OPERATION_MODE_DESC] = "Запускает игру как в док-станции или в портативном режиме.",
[UI_MENU_MODE_DOCKED] = "В док-станции", [UI_MENU_MODE_HANDHELD] = "Портативный",
[UI_MENU_ASSUME_FOCUS] = "Работать без фокуса",
[UI_MENU_ASSUME_FOCUS_DESC] = "Включено (по умолчанию): игра идёт, пока вы в другом окне, а клавиатура не "
"действует, пока окно не вернётся на передний план. Выключено: игра встаёт на паузу, "
"когда окно теряет фокус, как на Switch при нажатии Home; прерванная так загрузка "
"может остановиться насовсем.",
[UI_MENU_ASSUME_FOCUS_DESC] = "Игра продолжает работать, когда вы переключаетесь на другое окно.",
[UI_MENU_MODS_BUILTIN] = "Встроенные в порт", [UI_MENU_MODS_INSTALLED] = "Установленные моды",
[UI_MENU_MODS_NONE] = "Модов пока нет. Распакуйте мод в папку mods, каждый мод в свою папку с папкой romfs внутри, и "
@@ -744,24 +676,20 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_MODS_QUICKMENU] = "Исправление быстрого меню",
[UI_MENU_MODS_QUICKMENU_DESC] = "Исправление порта: чёрный фон меню оружия, щитов и материалов при 60 FPS.",
[UI_MENU_VOLUME] = "Громкость", [UI_MENU_VOLUME_DESC] = "Общая громкость игры.", [UI_MENU_MENU_SOUNDS] = "Звуки меню", [UI_MENU_MENU_SOUNDS_DESC] = "Громкость звуков этого меню (курсор, выбор и отмена из самой игры). 0 выключает их.",
[UI_MENU_VOLUME] = "Громкость", [UI_MENU_VOLUME_DESC] = "Общая громкость игры.", [UI_MENU_MENU_SOUNDS] = "Звуки меню", [UI_MENU_MENU_SOUNDS_DESC] = "Громкость звуков этого меню.",
[UI_MENU_AUDIO_CHANNELS] = "Динамики",
[UI_MENU_AUDIO_CHANNELS_DESC] = "Стерео или объёмный звук 5.1. Автоматически выбирается 5.1, если в Windows "
"настроено шесть каналов или больше. Применяется после перезапуска.",
[UI_MENU_AUDIO_CHANNELS_DESC] = "Стерео или объёмный звук 5.1.",
[UI_MENU_CHANNELS_AUTO] = "Автоматически", [UI_MENU_CHANNELS_STEREO] = "Стерео", [UI_MENU_CHANNELS_51] = "Объёмный 5.1",
[UI_MENU_MOTION] = "Управление движением", [UI_MENU_MOTION_DESC] = "Прицеливание гироскопом контроллера.",
[UI_MENU_RUMBLE_STRENGTH] = "Сила вибрации",
[UI_MENU_RUMBLE_STRENGTH_DESC] = "Насколько сильно вибрирует контроллер.",
[UI_MENU_RUMBLE_STRENGTH_DESC] = "Сила вибрации.",
[UI_MENU_RUMBLE_CURVE] = "Кривая вибрации",
[UI_MENU_RUMBLE_CURVE_DESC] = "Чем ниже значение, тем сильнее слабая вибрация.",
[UI_MENU_RUMBLE_CURVE_DESC] = "Чем ниже, тем сильнее слабая вибрация.",
[UI_MENU_RUMBLE_TRIGGERS] = "Вибрация триггеров (Xbox)",
[UI_MENU_RUMBLE_TRIGGERS_DESC] = "Вибрация и в триггерах контроллера Xbox.",
[UI_MENU_RUMBLE_TRIGGERS_DESC] = "Вибрация также на курках контроллера Xbox.",
[UI_MENU_PAD_LAYOUT] = "Раскладка кнопок",
[UI_MENU_PAD_LAYOUT_DESC] = "Какая кнопка работает как A. Nintendo: правая, как на Switch. Xbox: нижняя, как "
"подписано на контроллере Xbox (крест на контроллере PlayStation). Автоматически: "
"Nintendo для контроллеров с подписями Nintendo, Xbox для остальных. Подсказки игры "
"всегда показывают буквы Switch.",
[UI_MENU_PAD_LAYOUT_DESC] = "Какая кнопка работает как A.",
[UI_MENU_PAD_LAYOUT_AUTO] = "Автоматически", [UI_MENU_PAD_LAYOUT_NINTENDO] = "Nintendo (A справа)",
[UI_MENU_PAD_LAYOUT_XBOX] = "Xbox (A снизу)",
[UI_MENU_PAD_LAYOUT_IN_USE] = "сейчас: %s",
@@ -784,11 +712,12 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_RESTART_DESC] = "Закрывает игру и запускает её снова с новыми подсказками. Прогресс после последнего "
"сохранения будет потерян.",
[UI_MENU_RESTART_CONFIRM] = "Перезапустить игру сейчас? Прогресс после последнего сохранения будет потерян.",
[UI_MENU_QUIT_CONFIRM] = "Выйти из игры? Прогресс после последнего сохранения будет потерян.",
[UI_MENU_RESTART_YES] = "Перезапустить",
[UI_MENU_RESTART_SAVING] = "Игра сохраняется: перезапуск будет доступен через мгновение.",
[UI_MENU_GROUP_STICKS] = "Стики",
[UI_MENU_LSTICK_DEADZONE] = "Мёртвая зона левого стика", [UI_MENU_RSTICK_DEADZONE] = "Мёртвая зона правого стика",
[UI_MENU_STICK_DEADZONE_DESC] = "Насколько нужно отклонить стик геймпада, чтобы игра это заметила. Увеличьте, если персонаж или камера двигаются сами: отпустите стик, посмотрите «стик сейчас» и поставьте мёртвую зону на несколько процентов выше.",
[UI_MENU_STICK_DEADZONE_DESC] = "Насколько нужно сдвинуть стик, чтобы он сработал. Увеличьте при дрейфе.",
[UI_MENU_STICK_DEADZONE_NOW] = "стик сейчас: %.0f %%",
[UI_MENU_MOUSE_MODE] = "Управление мышью",
[UI_MENU_MOUSE_MODE_DESC] = "Прямое: камера поворачивается на столько, на сколько сдвинута мышь, как в играх для ПК, без мёртвой зоны и кривой стика (версия игры 1.4.3; на других версиях эмуляция стика). Эмуляция стика: мышь работает как правый стик.",
@@ -799,15 +728,13 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_MOUSE_SENS] = "Чувствительность мыши",
[UI_MENU_MOUSE_SENS_DESC] = "Как быстро мышь поворачивает камеру.",
[UI_MENU_WALK_KEY] = "Клавиша шага",
[UI_MENU_WALK_KEY_DESC] = "Удерживайте: стики клавиатуры отклоняются частично, и персонаж идёт, а не бежит. "
"Насколько — задаёт сила шага. Контроллер и мышь не затрагиваются.",
[UI_MENU_WALK_KEY_DESC] = "Удерживайте, чтобы идти шагом на клавиатуре.",
[UI_MENU_WALK_KEY_TAKEN] = "также %s",
[UI_MENU_WALK_SCALE] = "Сила шага",
[UI_MENU_WALK_SCALE_DESC] = "Отклонение стиков клавиатуры при удержании клавиши шага. Половина — шаг, полное "
"отклонение — бег.",
[UI_MENU_STICK_SENS] = "Скорость камеры (стик)",
[UI_MENU_STICK_SENS_DESC] = "Умножает скорость поворота камеры правым стиком, включая наибольшую, при каждой из пяти "
"чувствительностей камеры в игре. На мышь не влияет.",
[UI_MENU_STICK_SENS_DESC] = "Скорость камеры на правом стике.",
[UI_BINDS_HELP] = "Выберите ячейку и нажмите A или Enter, затем клавишу, кнопку мыши или кнопку контроллера. "
"Delete или X очищает ячейку. Занятая клавиша переходит сюда; кнопка контроллера меняется "
@@ -819,9 +746,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_BINDS_CANCEL_HINT] = "Esc отменяет, или подождите %d с",
[UI_BINDS_TAKEN] = "%s: убрано с «%s»", [UI_BINDS_SWAPPED] = "«%s» и «%s» поменялись местами",
[UI_BINDS_RESET] = "Сбросить все кнопки",
[UI_BINDS_RESET_DESC] = "Вернуть клавиши и кнопки контроллера по умолчанию. Снова действует раскладка кнопок выше: "
"переназначенные кнопки контроллера остаются на своих местах до "
"этого сброса.",
[UI_BINDS_RESET_DESC] = "Возвращает стандартные клавиши и кнопки.",
[UI_BIND_A] = "A", [UI_BIND_B] = "B", [UI_BIND_X] = "X", [UI_BIND_Y] = "Y",
[UI_BIND_LCLICK] = "Нажатие левого стика", [UI_BIND_RCLICK] = "Нажатие правого стика", [UI_BIND_L] = "L",
[UI_BIND_R] = "R", [UI_BIND_ZL] = "ZL", [UI_BIND_ZR] = "ZR", [UI_BIND_PLUS] = "Плюс", [UI_BIND_MINUS] = "Минус",
@@ -844,11 +769,10 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_BIND_DESC_PLUS] = "Меню: предметы, снаряжение, коллекция, система.", [UI_BIND_DESC_MINUS] = "Карта.",
[UI_BIND_DESC_LEFT] = "Играть на окарине.", [UI_BIND_DESC_UP] = "Надеть или снять аксессуар.",
[UI_BIND_DESC_RIGHT] = "Поговорить с Нави.", [UI_BIND_DESC_DOWN] = "Сменить сапоги.",
[UI_BIND_DESC_MOVE] = "Двигает Линка, как левый стик. Левый стик контроллера тоже всегда работает.",
[UI_BIND_DESC_CAMERA] = "Поворачивает камеру, как правый стик. Мышь и правый стик контроллера тоже всегда "
"работают.",
[UI_BIND_DESC_MOVE] = "Двигает Линка.",
[UI_BIND_DESC_CAMERA] = "Поворачивает камеру.",
[UI_BIND_SHAKE] = "Встряхнуть стик камеры",
[UI_BIND_DESC_SHAKE] = "Качает правый стик влево-вправо. Пока клавиша зажата, тряска продолжается.",
[UI_BIND_DESC_SHAKE] = "Трясёт правый стик. Удерживайте, чтобы продолжать.",
[UI_KEY_SPACE] = "Пробел", [UI_KEY_TAB] = "Tab", [UI_KEY_LSHIFT] = "Левый Shift", [UI_KEY_LCTRL] = "Левый Ctrl",
[UI_KEY_UP] = "Стрелка вверх", [UI_KEY_DOWN] = "Стрелка вниз", [UI_KEY_LEFT] = "Стрелка влево",
[UI_KEY_RIGHT] = "Стрелка вправо",
@@ -1082,61 +1006,44 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
[UI_MENU_SAVE_FAILED] = "não foi possível salvar as configurações",
[UI_MENU_VERSION] = "NX2navi %s, jogo %s",
[UI_MENU_FULLSCREEN] = "Tela cheia", [UI_MENU_FULLSCREEN_DESC] = "O jogo ocupa a tela inteira; F11 alterna.",
[UI_MENU_FULLSCREEN] = "Tela cheia", [UI_MENU_FULLSCREEN_DESC] = "Jogar em tela cheia. F11 alterna.",
[UI_MENU_WINDOW_SIZE] = "Tamanho da janela",
[UI_MENU_WINDOW_SIZE_DESC] = "Tamanho da janela do jogo fora da tela cheia.",
[UI_MENU_WINDOW_SIZE_DESC] = "Tamanho da janela fora da tela cheia.",
[UI_MENU_WINDOW_SIZE_CUSTOM] = "Personalizado",
[UI_MENU_PRESENT] = "Apresentação", [UI_MENU_PRESENT_DESC] = "Como os quadros prontos chegam à tela.",
[UI_MENU_PRESENT_DESC] = "Evita cortes na imagem. Desligado reduz um pouco o atraso.",
[UI_MENU_PRESENT_MAILBOX] = "Mailbox", [UI_MENU_PRESENT_VSYNC] = "VSync", [UI_MENU_PRESENT_IMMEDIATE] = "Imediato",
[UI_MENU_PRESENT_IN_USE] = "em uso: %s",
[UI_MENU_GPU] = "Placa de vídeo", [UI_MENU_GPU_DESC] = "O dispositivo Vulkan que desenha o jogo.",
[UI_MENU_GPU] = "Placa de vídeo", [UI_MENU_GPU_DESC] = "A placa de vídeo usada pelo jogo.",
[UI_MENU_GPU_AUTO] = "Automática",
[UI_MENU_PERF_OVERLAY] = "Indicador de desempenho",
[UI_MENU_PERF_OVERLAY_DESC] = "Taxa de quadros no canto superior direito. Completo adiciona os tempos de quadro com "
"gráfico, o uso de CPU, GPU e memória, as temperaturas e as esperas da thread de "
"renderização. F10 alterna os modos.",
[UI_MENU_PERF_OVERLAY_DESC] = "Mostra a taxa de quadros e dados do sistema. F10 alterna.",
[UI_MENU_PERF_OFF] = "Desligado", [UI_MENU_PERF_FPS] = "FPS", [UI_MENU_PERF_FULL] = "Completo",
[UI_PERF_LINE_FPS] = "%.0f fps",
[UI_MENU_GRAPHICS] = "Imagem",
[UI_MENU_OUTPUT_RES] = "Resolução do jogo",
[UI_MENU_OUTPUT_RES_DESC] = "O tamanho em que o jogo desenha a imagem e a interface. Acima de 1920 x 1080 o jogo "
"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_OUTPUT_RES_DESC] = "A resolução do jogo. Mais alta exige mais da placa de vídeo.",
[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 "
"GPU.",
[UI_MENU_RENDER_SCALE_DESC] = "Tamanho da cena 3D. Maior fica mais nítido, porém mais pesado.",
[UI_MENU_RENDER_SCALE_GAME] = "Jogo (83 %)",
[UI_MENU_UPSCALER] = "Escala para a janela",
[UI_MENU_UPSCALER_DESC] = "Como a imagem do jogo se ajusta à janela. Janela maior: o FSR mantém bordas e detalhes "
"mais nítidos que o bilinear. Janela menor (Ocarina desenha 2560 x 1440): a imagem é "
"reduzida e o FSR aumenta a nitidez com a intensidade abaixo.",
[UI_MENU_UPSCALER_FSR] = "AMD FSR 1", [UI_MENU_UPSCALER_BILINEAR] = "Bilinear",
[UI_MENU_ASPECT] = "Formato da imagem",
[UI_MENU_ASPECT_DESC] = "Quando o formato da janela difere do da resolução do jogo (uma imagem 16:9 numa tela "
"21:9): manter o formato da imagem com barras pretas ou esticá-la sobre a janela.",
[UI_MENU_GAME_ASPECT] = "Tela larga",
[UI_MENU_GAME_ASPECT_DESC] = "O jogo desenha uma imagem mais larga: mais do mundo nas laterais, a interface e os "
"menus no centro 16:9. Formato da janela segue a janela (o monitor em tela cheia).",
[UI_MENU_GAME_ASPECT_DESC] = "Amplia a visão. A interface e os menus continuam em 16:9.",
[UI_MENU_GAME_ASPECT_16_9] = "16:9 (o do jogo)", [UI_MENU_GAME_ASPECT_WINDOW] = "Formato da janela",
[UI_MENU_GAME_ASPECT_21_9] = "21:9", [UI_MENU_GAME_ASPECT_32_9] = "32:9",
[UI_MENU_ASPECT_FIT] = "Barras pretas", [UI_MENU_ASPECT_STRETCH] = "Esticar",
[UI_MENU_SHARPNESS] = "Nitidez do FSR",
[UI_MENU_SHARPNESS_DESC] = "Aumento de nitidez após a escala do FSR, também quando a imagem é reduzida à janela; 0 "
"desliga.",
[UI_MENU_SHARPNESS_DESC] = "Nitidez aplicada pelo FSR. 0 desliga.",
[UI_MENU_SHARPNESS_NEEDS_FSR] = "só com AMD FSR 1",
[UI_MENU_FPS_LIMIT] = "Limite de quadros",
[UI_MENU_FPS_LIMIT_DESC] = "O máximo de quadros por segundo que o jogo desenha. O jogo segue o relógio, então a "
"velocidade é a mesma em qualquer taxa. Sem limite desenha o mais rápido que o PC puder.",
[UI_MENU_FPS_LIMIT_DESC] = "A taxa de quadros máxima do jogo.",
[UI_MENU_FPS_30] = "30 FPS", [UI_MENU_FPS_40] = "40 FPS", [UI_MENU_FPS_45] = "45 FPS",
[UI_MENU_FPS_60] = "60 FPS", [UI_MENU_FPS_90] = "90 FPS", [UI_MENU_FPS_120] = "120 FPS", [UI_MENU_FPS_144] = "144 FPS",
[UI_MENU_ASSUME_FOCUS] = "Continuar rodando fora de foco",
[UI_MENU_ASSUME_FOCUS_DESC] = "Ligado (o padrão), o jogo continua rodando enquanto você está em outra janela, e o "
"teclado fica sem efeito até a janela voltar para a frente. Desligado, ele pausa quando "
"a janela perde o foco, como no Switch ao apertar Home; um carregamento interrompido "
"assim pode parar de vez.",
[UI_MENU_ASSUME_FOCUS_DESC] = "Mantém o jogo rodando quando você troca de janela.",
[UI_MENU_FPS_DISPLAY] = "Taxa do monitor", [UI_MENU_FPS_DISPLAY_HZ] = "Taxa do monitor (%.0f Hz)",
[UI_MENU_FPS_UNLIMITED] = "Sem limite",
[UI_MENU_FPS_RTSS] = "limitado pelo RivaTuner Statistics Server",
@@ -1151,32 +1058,27 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
[UI_MENU_GAME_LANG] = "Idioma do jogo", [UI_MENU_GAME_LANG_DESC] = "Idioma dos textos e das vozes do jogo.",
[UI_MENU_GAME_LANG_AUTO] = "Automático",
[UI_MENU_OPERATION_MODE] = "Modo do console",
[UI_MENU_OPERATION_MODE_DESC] = "Se o jogo acha que está no modo TV ou no modo portátil.",
[UI_MENU_OPERATION_MODE_DESC] = "Roda o jogo como na base ou no modo portátil.",
[UI_MENU_MODE_DOCKED] = "Modo TV", [UI_MENU_MODE_HANDHELD] = "Modo portátil",
[UI_MENU_VOLUME] = "Volume", [UI_MENU_VOLUME_DESC] = "Volume geral do jogo.", [UI_MENU_MENU_SOUNDS] = "Sons do menu", [UI_MENU_MENU_SOUNDS_DESC] = "Volume dos sons deste menu (cursor, confirmar e cancelar do próprio jogo). 0 desliga.",
[UI_MENU_VOLUME] = "Volume", [UI_MENU_VOLUME_DESC] = "Volume geral do jogo.", [UI_MENU_MENU_SOUNDS] = "Sons do menu", [UI_MENU_MENU_SOUNDS_DESC] = "Volume dos sons deste menu.",
[UI_MENU_MOTION] = "Controles de movimento", [UI_MENU_MOTION_DESC] = "Mirar com o giroscópio do controle.",
[UI_MENU_MOTION] = "Controles de movimento", [UI_MENU_MOTION_DESC] = "Mira com o giroscópio do controle.",
[UI_MENU_RUMBLE_STRENGTH] = "Intensidade da vibração",
[UI_MENU_RUMBLE_STRENGTH_DESC] = "Quão forte o controle vibra.",
[UI_MENU_RUMBLE_STRENGTH_DESC] = "Intensidade da vibração.",
[UI_MENU_RUMBLE_CURVE] = "Curva da vibração",
[UI_MENU_RUMBLE_CURVE_DESC] = "Valores menores deixam a vibração fraca mais forte.",
[UI_MENU_RUMBLE_CURVE_DESC] = "Valores menores reforçam a vibração fraca.",
[UI_MENU_RUMBLE_TRIGGERS] = "Vibração dos gatilhos (Xbox)",
[UI_MENU_RUMBLE_TRIGGERS_DESC] = "Também vibra os gatilhos de um controle de Xbox.",
[UI_MENU_RUMBLE_TRIGGERS_DESC] = "Também vibra os gatilhos do controle Xbox.",
[UI_MENU_PAD_LAYOUT] = "Layout dos botões",
[UI_MENU_PAD_LAYOUT_DESC] = "Qual botão é o A. Nintendo: o da direita, como no Switch. Xbox: o de baixo, como "
"indicado no controle de Xbox (cruz no controle de PlayStation). Automático escolhe "
"Nintendo para controles com os rótulos da Nintendo e Xbox para os demais. As dicas do "
"jogo sempre mostram as letras do Switch.",
[UI_MENU_PAD_LAYOUT_DESC] = "Define qual botão funciona como A.",
[UI_MENU_PAD_LAYOUT_AUTO] = "Automático", [UI_MENU_PAD_LAYOUT_NINTENDO] = "Nintendo (A à direita)",
[UI_MENU_PAD_LAYOUT_XBOX] = "Xbox (A embaixo)",
[UI_MENU_PAD_LAYOUT_IN_USE] = "em uso: %s",
[UI_MENU_GROUP_STICKS] = "Analógicos",
[UI_MENU_LSTICK_DEADZONE] = "Zona morta do analógico esquerdo",
[UI_MENU_RSTICK_DEADZONE] = "Zona morta do analógico direito",
[UI_MENU_STICK_DEADZONE_DESC] = "Quanto um analógico do controle precisa se mover antes que o jogo perceba. Aumente "
"se o personagem ou a câmera se moverem sozinhos: solte o analógico, leia \"analógico "
"agora\" e coloque a zona morta alguns por cento acima.",
[UI_MENU_STICK_DEADZONE_DESC] = "Quanto o analógico precisa mover para responder. Aumente se houver drift.",
[UI_MENU_STICK_DEADZONE_NOW] = "analógico agora: %.0f %%",
[UI_MENU_MOUSE_SENS] = "Sensibilidade da câmera no mouse",
[UI_MENU_MOUSE_SENS_DESC] = "Quão rápido o mouse gira a câmera.",
@@ -1191,8 +1093,7 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
[UI_BINDS_CANCEL_HINT] = "Esc cancela, ou aguarde %d s",
[UI_BINDS_TAKEN] = "%s saiu de %s", [UI_BINDS_SWAPPED] = "%s trocou de lugar com %s",
[UI_BINDS_RESET] = "Restaurar todos os botões",
[UI_BINDS_RESET_DESC] = "Volta às teclas e aos botões do controle padrão. O layout dos botões acima volta a valer: "
"os botões do controle remapeados ficam onde você os colocou até esta restauração.",
[UI_BINDS_RESET_DESC] = "Restaura as teclas e os botões padrão.",
[UI_BIND_A] = "A", [UI_BIND_B] = "B", [UI_BIND_X] = "X", [UI_BIND_Y] = "Y",
[UI_BIND_LCLICK] = "Clique do analógico esquerdo", [UI_BIND_RCLICK] = "Clique do analógico direito",
[UI_BIND_L] = "L", [UI_BIND_R] = "R", [UI_BIND_ZL] = "ZL", [UI_BIND_ZR] = "ZR", [UI_BIND_PLUS] = "Mais",
@@ -1216,12 +1117,10 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
[UI_BIND_DESC_PLUS] = "Menu: itens, equipamento, coleção, sistema.", [UI_BIND_DESC_MINUS] = "Mapa.",
[UI_BIND_DESC_LEFT] = "Tocar a ocarina.", [UI_BIND_DESC_UP] = "Pôr ou tirar o acessório.",
[UI_BIND_DESC_RIGHT] = "Falar com a Navi.", [UI_BIND_DESC_DOWN] = "Trocar de botas.",
[UI_BIND_DESC_MOVE] = "Move o Link como o analógico esquerdo. O analógico esquerdo do controle também sempre "
"funciona.",
[UI_BIND_DESC_CAMERA] = "Gira a câmera como o analógico direito. O mouse e o analógico direito do controle também "
"sempre funcionam.",
[UI_BIND_DESC_MOVE] = "Move o Link.",
[UI_BIND_DESC_CAMERA] = "Gira a câmera.",
[UI_BIND_SHAKE] = "Sacudir o analógico da câmera",
[UI_BIND_DESC_SHAKE] = "Balança o analógico direito para os lados. Segurar a tecla continua sacudindo.",
[UI_BIND_DESC_SHAKE] = "Balança o analógico direito. Segure para continuar.",
[UI_KEY_SPACE] = "Espaço", [UI_KEY_TAB] = "Tab", [UI_KEY_LSHIFT] = "Shift esquerdo",
[UI_KEY_LCTRL] = "Ctrl esquerdo",
[UI_KEY_UP] = "Seta para cima", [UI_KEY_DOWN] = "Seta para baixo", [UI_KEY_LEFT] = "Seta para a esquerda",
@@ -1385,11 +1284,7 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
[UI_MENU_FOV_DESC] = "Quanto do mundo a câmera mostra, em porcentagem do original do jogo. Só na versão 1.4.3 do "
"jogo.",
[UI_MENU_SHADOW_RES] = "Tamanho do mapa de sombras",
[UI_MENU_SHADOW_RES_DESC] = "Tamanho do mapa de sombras do sol. O tamanho do jogo muda com a vista, até cerca de "
"400 perto do chão, então as sombras das folhas ficam quadriculadas e pulam; um "
"tamanho fixo as deixa paradas e mais nítidas. Acima de 1024 as sombras custam mais "
"tempo de GPU e memória de vídeo; 256 é mais grosseiro que o do jogo e serve para GPUs "
"integradas com pouca largura de banda de memória.",
[UI_MENU_SHADOW_RES_DESC] = "Detalhe das sombras. Mais alto exige mais da placa de vídeo.",
[UI_MENU_SHADOW_RES_GAME] = "Do jogo (varia)",
[UI_MENU_ANISO] = "Filtragem de texturas",
[UI_MENU_ANISO_DESC] = "Filtragem anisotrópica das texturas de superfície: chão, estradas e paredes vistos em "
@@ -1418,16 +1313,13 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
"nada.",
[UI_MENU_HDR_GROUP] = "HDR",
[UI_MENU_HDR] = "Saída HDR",
[UI_MENU_HDR_DESC] = "Realces brilhantes em uma tela HDR. Precisa do HDR ligado no Windows (\"Usar HDR\") ou num "
"compositor Wayland com gerenciamento de cor; sem isso a imagem continua SDR. Vale após "
"reiniciar. O perfil de cor acima é para SDR e não é usado em HDR.",
[UI_MENU_HDR_DESC] = "Realces mais brilhantes em telas HDR. Ative o HDR no Windows antes.",
[UI_MENU_HDR_PEAK] = "Brilho máximo",
[UI_MENU_HDR_PEAK_DESC] = "O pico da sua tela em nits; os realces mais claros param aí.",
[UI_MENU_HDR_PEAK_DESC] = "Brilho máximo da sua tela em nits.",
[UI_MENU_HDR_GAME] = "Brilho do jogo",
[UI_MENU_HDR_GAME_DESC] = "Nits do branco da imagem (branco de papel). 203 é a referência de HDR; aumente num "
"ambiente claro.",
[UI_MENU_HDR_GAME_DESC] = "Brilho do branco no jogo, em nits.",
[UI_MENU_HDR_UI] = "Brilho do HUD e do menu",
[UI_MENU_HDR_UI_DESC] = "Nits do branco do HUD e deste menu.",
[UI_MENU_HDR_UI_DESC] = "Brilho da interface e deste menu, em nits.",
[UI_MENU_PROMPTS] = "Ícones de botões",
[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 "
@@ -1456,15 +1348,13 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
[UI_MENU_RESTART_DESC] = "Fecha o jogo e o abre de novo com os novos ícones. O progresso desde o último "
"salvamento é perdido.",
[UI_MENU_RESTART_CONFIRM] = "Reiniciar o jogo agora? O progresso desde o último salvamento é perdido.",
[UI_MENU_QUIT_CONFIRM] = "Sair do jogo? O progresso desde o último salvamento é perdido.",
[UI_MENU_RESTART_YES] = "Reiniciar",
[UI_MENU_RESTART_SAVING] = "O jogo está salvando: dá para reiniciar em um instante.",
[UI_MENU_STICK_SENS] = "Velocidade da câmera (analógico)",
[UI_MENU_STICK_SENS_DESC] = "Multiplica a velocidade da câmera do analógico direito do jogo, incluindo a máxima, "
"em cada uma das cinco sensibilidades de câmera do jogo. O mouse mantém a própria "
"configuração.",
[UI_MENU_STICK_SENS_DESC] = "Velocidade da câmera no analógico direito.",
[UI_MENU_WALK_KEY] = "Tecla de andar",
[UI_MENU_WALK_KEY_DESC] = "Segure para inclinar os analógicos do teclado só em parte, assim o teclado anda em vez "
"de correr. A intensidade do andar define quanto. Controle e mouse não são afetados.",
[UI_MENU_WALK_KEY_DESC] = "Segure para andar no teclado.",
[UI_MENU_WALK_KEY_TAKEN] = "também %s",
[UI_MENU_WALK_SCALE] = "Intensidade do andar",
[UI_MENU_WALK_SCALE_DESC] = "A inclinação dos analógicos do teclado enquanto a tecla de andar está segura. Metade "
@@ -1474,13 +1364,9 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
[UI_MENU_HDR_HUE_DESC] = "Cores fortes como fogo e faíscas vão para o branco como na imagem SDR do próprio jogo e "
"combinam com a luz que emitem; 0 as mantém totalmente saturadas.",
[UI_MENU_SHADOW_SCALE] = "Resolução das sombras",
[UI_MENU_SHADOW_SCALE_DESC] = "Desenha os mapas de sombra do sol essa quantidade de vezes maiores em cada lado "
"que os 960x960 do jogo: bordas de sombra e sombras de folhas mais nítidas. Vale no "
"próximo início.",
[UI_MENU_SHADOW_SCALE_DESC] = "Sombras mais nítidas. Mais alto exige mais da placa de vídeo.",
[UI_MENU_SHADOW_RANGE] = "Alcance das cascatas de sombra",
[UI_MENU_SHADOW_RANGE_DESC] = "Afasta os degraus em que as sombras ficam mais suaves (20, 40, 80 e 160 m no "
"jogo). Espalha o mapa de sombras por mais terreno: aumente a Resolução das sombras "
"junto. Vale no próximo início.",
[UI_MENU_SHADOW_RANGE_DESC] = "Mantém as sombras nítidas a distâncias maiores.",
[UI_MENU_CONTACT_SHADOWS] = "Sombras de contato",
[UI_MENU_CONTACT_SHADOWS_DESC] = "Pequenas sombras do sol que os mapas de sombra não pegam: nos pés, sob pedras, "
"na grama e em dobras. Traçadas na tela depois da iluminação. Vale no próximo "
@@ -1599,23 +1485,20 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_MENU_SAVE_FAILED] = "无法保存设置",
[UI_MENU_VERSION] = "NX2navi %s,游戏 %s",
[UI_MENU_FULLSCREEN] = "全屏",
[UI_MENU_FULLSCREEN_DESC] = "游戏铺满屏幕;按 F11 切换。",
[UI_MENU_FULLSCREEN_DESC] = "全屏运行。按 F11 切换。",
[UI_MENU_WINDOW_SIZE] = "窗口大小",
[UI_MENU_WINDOW_SIZE_DESC] = "非全屏时游戏窗口的大小。",
[UI_MENU_WINDOW_SIZE_DESC] = "非全屏时的窗口大小。",
[UI_MENU_WINDOW_SIZE_CUSTOM] = "自定义",
[UI_MENU_PRESENT] = "呈现模式",
[UI_MENU_PRESENT_DESC] = "渲染完成的帧如何显示到屏幕上。",
[UI_MENU_PRESENT_DESC] = "防止画面撕裂。关闭可略微降低延迟。",
[UI_MENU_PRESENT_MAILBOX] = "Mailbox",
[UI_MENU_PRESENT_VSYNC] = "垂直同步",
[UI_MENU_PRESENT_IMMEDIATE] = "立即",
[UI_MENU_PRESENT_IN_USE] = "使用中:%s",
[UI_MENU_GPU] = "显卡",
[UI_MENU_GPU_DESC] = "用于渲染游戏的 Vulkan 设备。",
[UI_MENU_GPU_DESC] = "运行游戏所用的显卡。",
[UI_MENU_GPU_AUTO] = "自动",
[UI_MENU_PERF_OVERLAY] = "性能浮层",
[UI_MENU_PERF_OVERLAY_DESC] = "在右上角显示帧率。“完整”还会显示带图表的帧时间、CPU、"
"GPU 和内存占用、温度,以及渲染线程的等待时间。"
"按 F10 循环切换模式。",
[UI_MENU_PERF_OVERLAY_DESC] = "显示帧率和系统信息。按 F10 切换模式。",
[UI_MENU_PERF_OFF] = "关",
[UI_MENU_PERF_FPS] = "FPS",
[UI_MENU_PERF_FULL] = "完整",
@@ -1624,35 +1507,24 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_MENU_GRAPHICS] = "画面",
[UI_MENU_OUTPUT_RES] = "游戏分辨率",
[UI_MENU_OUTPUT_RES_DESC] = "游戏绘制画面和界面的尺寸。"
"高于 1920 x 1080 会占用更多显存和 GPU 时间。"
"更宽的尺寸(21:9)会扩大视野,并把界面移到屏幕四角;"
"更高的尺寸(16:10、3:2)则移到上下边缘。",
[UI_MENU_OUTPUT_RES_DESC] = "游戏的渲染分辨率。越高越吃显卡。",
[UI_MENU_RENDER_SCALE] = "3D 渲染比例",
[UI_MENU_RENDER_SCALE_DESC] = "3D 场景相对于游戏分辨率的尺寸;"
"游戏的 FSR 会将其缩放到该尺寸。"
"高于 100% 会平滑锯齿边缘(超采样),但 GPU 开销很高。",
[UI_MENU_RENDER_SCALE_DESC] = "3D 场景的大小。越高越清晰,但更慢。",
[UI_MENU_RENDER_SCALE_GAME] = "游戏(83%)",
[UI_MENU_UPSCALER] = "放大到窗口",
[UI_MENU_UPSCALER_DESC] = "游戏画面适配窗口的方式。窗口更大时:FSR 比双线性更能保留边缘和细节。"
"窗口更小时(Ocarina 绘制 2560 × 1440):画面被缩小,FSR 按下方强度锐化。",
[UI_MENU_UPSCALER_FSR] = "AMD FSR 1",
[UI_MENU_UPSCALER_BILINEAR] = "双线性",
[UI_MENU_ASPECT] = "画面宽高比",
[UI_MENU_ASPECT_DESC] = "当窗口宽高比和游戏分辨率不同时(21:9 屏幕上显示 16:9 画面):"
"用黑边保持画面比例,或拉伸铺满窗口。",
[UI_MENU_GAME_ASPECT] = "宽屏",
[UI_MENU_GAME_ASPECT_DESC] = "游戏绘制更宽的画面:两侧显示更多场景,界面和菜单位于中间的 16:9 区域。"
"“窗口比例”跟随窗口(全屏时跟随显示器)。",
[UI_MENU_GAME_ASPECT_DESC] = "扩大视野。界面和菜单保持 16:9。",
[UI_MENU_GAME_ASPECT_16_9] = "16:9(游戏原生)", [UI_MENU_GAME_ASPECT_WINDOW] = "窗口比例",
[UI_MENU_GAME_ASPECT_21_9] = "21:9", [UI_MENU_GAME_ASPECT_32_9] = "32:9",
[UI_MENU_ASPECT_FIT] = "黑边",
[UI_MENU_ASPECT_STRETCH] = "拉伸",
[UI_MENU_FOV] = "视野",
[UI_MENU_FOV_DESC] = "镜头能看到多大范围,以游戏自身视野的百分比表示。"
"仅限游戏版本 1.4.3。",
[UI_MENU_SHARPNESS] = "FSR 锐度",
[UI_MENU_SHARPNESS_DESC] = "FSR 缩放后的锐化强度,画面缩小到窗口时同样生效;0 为关闭。",
[UI_MENU_SHARPNESS_DESC] = "FSR 的锐化强度。0 为关闭。",
[UI_MENU_SHARPNESS_NEEDS_FSR] = "仅限 AMD FSR 1",
[UI_MENU_COLOR] = "色彩",
[UI_MENU_COLOR_PRESET] = "色彩配置",
@@ -1671,8 +1543,7 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_MENU_COLOR_GAMMA] = "伽马",
[UI_MENU_COLOR_GAMMA_DESC] = "小于 1 提亮暗部与中间调,大于 1 压暗;1 表示不调整。",
[UI_MENU_FPS_LIMIT] = "帧率上限",
[UI_MENU_FPS_LIMIT_DESC] = "游戏每秒绘制的最高帧数。游戏按时钟计时,任何帧率下速度都相同。"
"不限制时以电脑能达到的最快速度绘制。",
[UI_MENU_FPS_LIMIT_DESC] = "游戏的最高帧率。",
[UI_MENU_FPS_30] = "30 FPS",
[UI_MENU_FPS_40] = "40 FPS",
[UI_MENU_FPS_45] = "45 FPS",
@@ -1697,38 +1568,31 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_MENU_GAME_LANG_DESC] = "游戏文本和语音的语言。",
[UI_MENU_GAME_LANG_AUTO] = "自动",
[UI_MENU_OPERATION_MODE] = "主机模式",
[UI_MENU_OPERATION_MODE_DESC] = "游戏认为自己处于底座模式还是掌机模式。",
[UI_MENU_OPERATION_MODE_DESC] = "以底座或掌机模式运行游戏。",
[UI_MENU_MODE_DOCKED] = "底座模式",
[UI_MENU_MODE_HANDHELD] = "掌机模式",
[UI_MENU_ASSUME_FOCUS] = "后台保持运行",
[UI_MENU_ASSUME_FOCUS_DESC] = "开启(默认)时,切到其他窗口游戏仍会继续运行,"
"但键盘要等窗口回到前台才会响应。关闭时,"
"窗口失去焦点即暂停,如同在 Switch 上按 Home 键;"
"这样被打断的读取可能会永久卡住。",
[UI_MENU_ASSUME_FOCUS_DESC] = "切换到其他窗口时游戏继续运行。",
[UI_MENU_VOLUME] = "音量",
[UI_MENU_MENU_SOUNDS] = "菜单音效", [UI_MENU_MENU_SOUNDS_DESC] = "此菜单音效(游戏自带的光标、确认和取消音效)的音量。0 为关闭。",
[UI_MENU_VOLUME_DESC] = "游戏的主音量。",
[UI_MENU_MENU_SOUNDS] = "菜单音效", [UI_MENU_MENU_SOUNDS_DESC] = "本菜单的音效音量。",
[UI_MENU_VOLUME_DESC] = "游戏总音量。",
[UI_MENU_MOTION] = "体感操作",
[UI_MENU_MOTION_DESC] = "用手柄的陀螺仪瞄准。",
[UI_MENU_MOTION_DESC] = "使用手柄陀螺仪瞄准。",
[UI_MENU_RUMBLE_STRENGTH] = "振动强度",
[UI_MENU_RUMBLE_STRENGTH_DESC] = "手柄振动的强弱。",
[UI_MENU_RUMBLE_STRENGTH_DESC] = "震动强度。",
[UI_MENU_RUMBLE_CURVE] = "振动曲线",
[UI_MENU_RUMBLE_CURVE_DESC] = "数值越低,弱振动越强。",
[UI_MENU_RUMBLE_CURVE_DESC] = "数值越低,轻微震动越强。",
[UI_MENU_RUMBLE_TRIGGERS] = "扳机振动(Xbox)",
[UI_MENU_RUMBLE_TRIGGERS_DESC] = "Xbox 手柄的扳机也会振动。",
[UI_MENU_RUMBLE_TRIGGERS_DESC] = "同时震动 Xbox 手柄的扳机。",
[UI_MENU_PAD_LAYOUT] = "按键布局",
[UI_MENU_PAD_LAYOUT_DESC] = "哪个按键是 A。Nintendo:右侧按键,与 Switch 相同。Xbox:下方按键,"
"与 Xbox 手柄上的标注一致(PlayStation 手柄上为叉键)。自动:"
"带 Nintendo 标注的手柄使用 Nintendo 布局,其他手柄使用 Xbox 布局。"
"游戏的按键提示始终显示 Switch 字母。",
[UI_MENU_PAD_LAYOUT_DESC] = "设置哪个按键作为 A 键。",
[UI_MENU_PAD_LAYOUT_AUTO] = "自动",
[UI_MENU_PAD_LAYOUT_NINTENDO] = "Nintendo(A 在右)",
[UI_MENU_PAD_LAYOUT_XBOX] = "Xbox(A 在下)",
[UI_MENU_PAD_LAYOUT_IN_USE] = "使用中:%s",
[UI_MENU_GROUP_STICKS] = "摇杆",
[UI_MENU_LSTICK_DEADZONE] = "左摇杆死区", [UI_MENU_RSTICK_DEADZONE] = "右摇杆死区",
[UI_MENU_STICK_DEADZONE_DESC] = "手柄摇杆要推动多远游戏才会响应。如果角色或视角会自己移动,"
"请调高此值:松开摇杆,查看“当前摇杆”,把死区设得比它高几个百分点。",
[UI_MENU_STICK_DEADZONE_DESC] = "摇杆需要推动多少才生效。摇杆漂移时请调高。",
[UI_MENU_STICK_DEADZONE_NOW] = "当前摇杆:%.0f %%",
[UI_MENU_MOUSE_SENS] = "鼠标视角灵敏度",
[UI_MENU_MOUSE_SENS_DESC] = "鼠标转动视角的速度。",
@@ -1748,8 +1612,7 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_BINDS_TAKEN] = "%s 已从 %s 移走",
[UI_BINDS_SWAPPED] = "%s 已与 %s 对调",
[UI_BINDS_RESET] = "重置所有按键",
[UI_BINDS_RESET_DESC] = "恢复默认的键盘和手柄按键。上方的按键布局会再次生效:"
"重映射过的手柄按键会一直保留到此次重置。",
[UI_BINDS_RESET_DESC] = "恢复默认按键。",
[UI_BIND_A] = "A",
[UI_BIND_B] = "B",
[UI_BIND_X] = "X",
@@ -1790,10 +1653,10 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_BIND_DESC_UP] = "戴上或摘下饰品。",
[UI_BIND_DESC_RIGHT] = "和娜薇说话。",
[UI_BIND_DESC_DOWN] = "更换靴子。",
[UI_BIND_DESC_MOVE] = "像左摇杆一样移动林克。手柄的左摇杆始终可用。",
[UI_BIND_DESC_CAMERA] = "像右摇杆一样转动视角。鼠标和手柄的右摇杆始终可用。",
[UI_BIND_DESC_MOVE] = "移动林克。",
[UI_BIND_DESC_CAMERA] = "转动镜头。",
[UI_BIND_SHAKE] = "晃动视角摇杆",
[UI_BIND_DESC_SHAKE] = "让右摇杆左右晃动。按住该键会一直晃动。",
[UI_BIND_DESC_SHAKE] = "晃动右摇杆。按住可持续晃动。",
[UI_KEY_SPACE] = "空格",
[UI_KEY_TAB] = "Tab",
[UI_KEY_LSHIFT] = "左 Shift",
@@ -2036,22 +1899,20 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_MENU_OV_SCALE_NONE] = "无(1:1)",
[UI_MENU_OV_SCALE_BILINEAR] = "双线性",
[UI_MENU_SHADOW_RES] = "阴影贴图尺寸",
[UI_MENU_SHADOW_RES_DESC] = "太阳阴影贴图的尺寸。游戏自身的尺寸随视角变化,靠近地面时降到约 400,因此树叶阴影显得块状并且跳动;固定尺寸能让阴影稳定、更清晰。高于 1024 时阴影会占用更多 "
"GPU 时间和显存;256 比游戏自身的尺寸更粗糙,适合显存带宽不足的集成显卡。",
[UI_MENU_SHADOW_RES_DESC] = "阴影细节。越高越吃显卡。",
[UI_MENU_SHADOW_RES_GAME] = "游戏默认(会变化)",
[UI_MENU_ANISO] = "纹理过滤",
[UI_MENU_ANISO_DESC] = "表面纹理的各向异性过滤:以小角度看到的地面、道路和墙壁在远处依然清晰,而不会模糊。游戏:使用游戏请求的级别,与 Switch 上相同。",
[UI_MENU_ANISO_GAME] = "游戏",
[UI_MENU_HDR_GROUP] = "HDR",
[UI_MENU_HDR] = "HDR 输出",
[UI_MENU_HDR_DESC] = "在 HDR 显示器上呈现明亮的高光。需要在 Windows 中开启 HDR(“使用 HDR”),或使用带色彩管理的 Wayland 合成器;否则画面保持 "
"SDR。重启后生效。上方的色彩配置用于 SDR,在 HDR 下不使用。",
[UI_MENU_HDR_DESC] = "在 HDR 显示器上呈现更亮的高光。请先在 Windows 中开启 HDR。",
[UI_MENU_HDR_PEAK] = "峰值亮度",
[UI_MENU_HDR_PEAK_DESC] = "显示器的峰值亮度(尼特);最亮的高光止于此。",
[UI_MENU_HDR_PEAK_DESC] = "显示器的峰值亮度(尼特)。",
[UI_MENU_HDR_GAME] = "游戏亮度",
[UI_MENU_HDR_GAME_DESC] = "画面白色(纸白)的尼特值。203 为 HDR 参考值;在明亮的房间里可调高。",
[UI_MENU_HDR_GAME_DESC] = "游戏中白色的亮度(尼特)。",
[UI_MENU_HDR_UI] = "HUD 和菜单亮度",
[UI_MENU_HDR_UI_DESC] = "HUD 和本菜单白色的尼特值。",
[UI_MENU_HDR_UI_DESC] = "界面和本菜单的亮度(尼特)。",
[UI_MENU_PROMPTS] = "按键提示",
[UI_MENU_PROMPTS_DESC] = "游戏的按键提示显示哪种手柄的按键。Nintendo:游戏原有的提示。Xbox:LB、RB、LT、RT、Menu、View 和十字键,以及上方布局所按下的按键上标注的 "
"A、B、X、Y(使用 Nintendo(A 在右)时右侧按键标为 B,因此 A 的提示显示 "
@@ -2075,12 +1936,13 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_MENU_RESTART] = "立即重启",
[UI_MENU_RESTART_DESC] = "关闭游戏并以新的按键提示重新启动。上次存档之后的进度将会丢失。",
[UI_MENU_RESTART_CONFIRM] = "现在重启游戏?上次存档之后的进度将会丢失。",
[UI_MENU_QUIT_CONFIRM] = "退出游戏?上次存档之后的进度将会丢失。",
[UI_MENU_RESTART_YES] = "重启",
[UI_MENU_RESTART_SAVING] = "游戏正在存档:稍后即可重启。",
[UI_MENU_STICK_SENS] = "摇杆镜头速度",
[UI_MENU_STICK_SENS_DESC] = "在游戏的五档镜头灵敏度下,按倍数调整右摇杆的镜头转动速度(包括最高速度)。鼠标使用自己的设置。",
[UI_MENU_STICK_SENS_DESC] = "右摇杆的镜头速度。",
[UI_MENU_WALK_KEY] = "步行键",
[UI_MENU_WALK_KEY_DESC] = "按住时键盘模拟的摇杆只推到一部分,使键盘操作走路而不是奔跑。推动幅度由步行幅度决定。手柄和鼠标不受影响。",
[UI_MENU_WALK_KEY_DESC] = "按住可用键盘步行。",
[UI_MENU_WALK_KEY_TAKEN] = "同时为 %s",
[UI_MENU_WALK_SCALE] = "步行幅度",
[UI_MENU_WALK_SCALE_DESC] = "按住步行键时键盘摇杆的推动幅度。一半为走路,推满为奔跑。",
@@ -2088,9 +1950,9 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
[UI_MENU_HDR_HUE] = "高光色调校正",
[UI_MENU_HDR_HUE_DESC] = "火焰、火花等明亮色彩像游戏自身的 SDR 画面一样趋向白色,与它们发出的光一致;0 保持完全饱和。",
[UI_MENU_SHADOW_SCALE] = "阴影分辨率",
[UI_MENU_SHADOW_SCALE_DESC] = "将太阳阴影贴图的每条边绘制为游戏 960x960 的若干倍:阴影边缘和树叶阴影更清晰。下次启动时生效。",
[UI_MENU_SHADOW_SCALE_DESC] = "让阴影更清晰。越高越吃显卡。",
[UI_MENU_SHADOW_RANGE] = "阴影级联范围",
[UI_MENU_SHADOW_RANGE_DESC] = "把阴影变柔和的分界(游戏中为 20、40、80 和 160 米)推得更远。阴影贴图会覆盖更大的地面,请同时提高阴影分辨率。下次启动时生效。",
[UI_MENU_SHADOW_RANGE_DESC] = "让远处的阴影保持清晰。",
[UI_MENU_CONTACT_SHADOWS] = "接触阴影",
[UI_MENU_CONTACT_SHADOWS_DESC] = "阴影贴图遗漏的细小太阳阴影:脚下、石头下、草丛和褶皱中。在光照之后于屏幕空间追踪。下次启动时生效。",
[UI_MENU_PCSS] = "柔和阴影",

View File

@@ -27,7 +27,7 @@ typedef enum {
// Screen
UI_MENU_FULLSCREEN, UI_MENU_FULLSCREEN_DESC,
UI_MENU_WINDOW_SIZE, UI_MENU_WINDOW_SIZE_DESC, UI_MENU_WINDOW_SIZE_CUSTOM,
UI_MENU_PRESENT, UI_MENU_PRESENT_DESC, UI_MENU_PRESENT_MAILBOX, UI_MENU_PRESENT_VSYNC, UI_MENU_PRESENT_IMMEDIATE,
UI_MENU_PRESENT_DESC, UI_MENU_PRESENT_MAILBOX, UI_MENU_PRESENT_VSYNC, UI_MENU_PRESENT_IMMEDIATE,
UI_MENU_PRESENT_IN_USE, // "in use: %s" under the value when the swapchain got another mode than the setting
UI_MENU_GPU, UI_MENU_GPU_DESC, UI_MENU_GPU_AUTO,
UI_MENU_PERF_OVERLAY, UI_MENU_PERF_OVERLAY_DESC, UI_MENU_PERF_OFF, UI_MENU_PERF_FPS, UI_MENU_PERF_FULL,
@@ -36,7 +36,6 @@ typedef enum {
UI_MENU_OUTPUT_RES, UI_MENU_OUTPUT_RES_DESC,
UI_MENU_RENDER_SCALE, UI_MENU_RENDER_SCALE_DESC, UI_MENU_RENDER_SCALE_GAME,
UI_MENU_UPSCALER, UI_MENU_UPSCALER_DESC, UI_MENU_UPSCALER_FSR, UI_MENU_UPSCALER_BILINEAR,
UI_MENU_ASPECT, UI_MENU_ASPECT_DESC, UI_MENU_ASPECT_FIT, UI_MENU_ASPECT_STRETCH,
UI_MENU_GAME_ASPECT, UI_MENU_GAME_ASPECT_DESC, UI_MENU_GAME_ASPECT_16_9, UI_MENU_GAME_ASPECT_WINDOW,
UI_MENU_GAME_ASPECT_21_9, UI_MENU_GAME_ASPECT_32_9,
UI_MENU_FOV, UI_MENU_FOV_DESC,
@@ -106,7 +105,7 @@ typedef enum {
UI_MENU_PROMPTS_MISSING, UI_MENU_PROMPTS_FAILED, UI_MENU_PROMPTS_RESTART, UI_MENU_PROMPTS_OFF_SHAPE,
UI_MENU_PROMPTS_OFF_MODS, UI_MENU_PROMPTS_OFF_PATCHES,
// "Restart now" under the prompts while they change after restart, and its confirmation (Cancel: UI_MENU_RESET_NO)
UI_MENU_RESTART, UI_MENU_RESTART_DESC, UI_MENU_RESTART_CONFIRM, UI_MENU_RESTART_YES, UI_MENU_RESTART_SAVING,
UI_MENU_RESTART, UI_MENU_RESTART_DESC, UI_MENU_RESTART_CONFIRM, UI_MENU_QUIT_CONFIRM, UI_MENU_RESTART_YES, UI_MENU_RESTART_SAVING,
UI_MENU_GROUP_STICKS, UI_MENU_LSTICK_DEADZONE, UI_MENU_RSTICK_DEADZONE, UI_MENU_STICK_DEADZONE_DESC,
UI_MENU_STICK_DEADZONE_NOW, UI_MENU_STICK_SENS, UI_MENU_STICK_SENS_DESC,
UI_MENU_MOUSE_MODE, UI_MENU_MOUSE_MODE_DESC, UI_MENU_MOUSE_STICK, UI_MENU_MOUSE_DIRECT,
@@ -246,6 +245,9 @@ typedef enum {
UI_MENU_UPSCALING, UI_MENU_UPSCALING_DESC, UI_MENU_UPSCALING_DLSS_NOTE, UI_MENU_FRAMEGEN, UI_MENU_FRAMEGEN_DESC,
UI_MENU_FRAMEGEN_OFF, UI_MENU_FRAMEGEN_NOTE, UI_MENU_FRAMEGEN_NEEDS, UI_MENU_HDR_NOTE, UI_MENU_HDR_ENHANCED, UI_MENU_HDR_NATIVE,
UI_MENU_GAME_RES, UI_MENU_GAME_RES_DESC, UI_MENU_GAME_RES_NATIVE,
// the same rows' texts on a GPU DLSS does not run on (not NVIDIA): the menu leaves DLSS out there
UI_MENU_UPSCALING_DESC_FSR, UI_MENU_UPSCALING_FSR_NOTE, UI_MENU_FRAMEGEN_DESC_FSR, UI_MENU_FRAMEGEN_NOTE_FSR,
UI_MENU_FRAMEGEN_NEEDS_FSR,
UI_TEXT_COUNT
} UiTextId;

View File

@@ -2032,6 +2032,7 @@ static struct {
uint32_t left; // prebuild jobs queued or running
uint32_t built, failed, promoted;
double t0; // now_ms() when the prebuild started
double until; // now_ms() after which the boot builders stop (comment at prewarm_run); 0 none
} K = {.io = PLAT_MUTEX_INIT};
static uint64_t rec_hash(const KeyRec *r) {
@@ -2637,11 +2638,12 @@ VkPipeline vk_pipeline_graphics_async(const VkPipeState *s, const VkPipeInfo **i
static int id_cmp(const void *x, const void *y) { return memcmp(x, y, 32); }
// Builds queued prebuild jobs until the low queue is empty, beside the pipe_worker pool (same bookkeeping).
// Builds queued prebuild jobs until the low queue is empty or K.until passes, beside the pipe_worker pool (same
// bookkeeping). Jobs left queued at K.until stay for the pool.
static void warm_builder(void *arg) {
(void)arg;
plat_mutex_lock(&P.lock);
while (A.low) {
while (A.low && !(K.until && now_ms() >= K.until)) {
Job *j = A.low;
if ((A.low = j->next)) A.low->prev = NULL;
else A.low_tail = NULL;
@@ -2686,6 +2688,16 @@ void vk_pipeline_prewarm_progress(VkPrewarmProgress *p) {
static void prewarm_run(void);
// The boot's share of the pipeline prebuild with the graphics pipeline library. The boot builds the recorded
// pipelines in record order, so those met first in play (the title screen, the first places) come first, for at most
// this long after the shaders are ready; the rest stay queued for the pool workers, which build them below normal
// priority while the game runs. A draw that meets one of them before it is built gets a pipeline linked from stage
// libraries at once (gpl_link), as for any new pipeline in play. After a driver update, when every pipeline is built
// from nothing, the boot thus waits this long instead of for all of them (15 minutes and more with a long play
// history). Without the library a draw would have to wait for a whole build, so the boot waits for all; so it does
// with NX2NAVI_PREWARM_FULL=1.
#define PREWARM_PIPE_MS 20000.0
void vk_pipeline_prewarm(void) {
prewarm_run();
__atomic_store_n(&pw_phase, 3, __ATOMIC_RELEASE);
@@ -2777,6 +2789,8 @@ static void prewarm_run(void) {
__atomic_store_n(&pw_pipe_done, 0, __ATOMIC_RELAXED);
__atomic_store_n(&pw_pipe_total, (int64_t)queued, __ATOMIC_RELAXED);
__atomic_store_n(&pw_phase, 2, __ATOMIC_RELEASE);
const char *full = cfg_get("NX2NAVI_PREWARM_FULL");
K.until = P.gpl && !(full && !strcmp(full, "1")) ? now_ms() + PREWARM_PIPE_MS : 0; // before the builders start
PlatThread *t[64];
int nt = 0;
for (int i = 0; i < cpus && i < 64 && queued; i++)
@@ -2793,10 +2807,16 @@ static void prewarm_run(void) {
}
__atomic_store_n(&pw_pipe_done, (int64_t)queued, __ATOMIC_RELAXED);
plat_mutex_lock(&P.lock);
while (K.left) plat_cond_wait(&done_cv, &P.lock); // jobs a pool worker took
rt_log("vk_pipeline: prewarm: %zu records in %s: %u pipelines built, %u failed, %u already built, %u dropped "
"(shader neither cached nor stored); shaders %.0f ms, pipelines %.0f ms on %d threads, total %.0f ms",
n, K.path, K.built, K.failed, known, dropped, t1 - t0, now_ms() - t1, nt, now_ms() - t0);
uint32_t later = 0;
for (Job *j = A.low; j; j = j->next) later += j->prebuild;
if (!later) // all built: wait for those a pool worker took
while (K.left) plat_cond_wait(&done_cv, &P.lock);
else // the boot's time is up: the pool builds the rest while the game runs
plat_cond_broadcast(&work_cv);
rt_log("vk_pipeline: prewarm: %zu records in %s: %u pipelines built, %u left to build in the background, %u "
"failed, %u already built, %u dropped (shader neither cached nor stored); shaders %.0f ms, pipelines %.0f "
"ms on %d threads, total %.0f ms", n, K.path, K.built, later, K.failed, known, dropped, t1 - t0,
now_ms() - t1, nt, now_ms() - t0);
free(K.file);
K.file = NULL;
plat_mutex_unlock(&P.lock);