Keep saves safe in Import Saves and Quit, draw no traced game art, and recompile the game for a new processor.

Import Saves: the saves folder picked in the dialog imports what waits in it (it had made the folder's README the
save); the save backed up is the one the game would load, in runtime/fs_host.c save_recover's order, so an interrupted
commit's only copy is kept, and the rest of the commit journal moves into the backup instead of being deleted; the
imported save goes into place before the old one is deleted, which comes back if that fails; another NX2navi install's
finished commit counts as its save. Tests cover each.

Quit waits while the game writes a save, as Restart does: the game runs on under the menu, and closing the window
finishes only a commit that has begun. The VSync row says "in use: Immediate" when VSync On falls back to tearing, and
its default follows the device profile (cfg_default). Without the game's textures the menu's divider is a plain line
and diamond of its own, not a tracing of the game's ornament.

make_game.py: the compile key holds the processor's features (cpu_tag), so a game folder moved to a PC without AVX2
compiles again instead of crashing; the main thread gets 16 MiB of stack with GNU ld too; any error waits for the
RomFS image, so its .part file is not cut short. The launcher tests use a neutral title id; tools/menu_preview.cpp
has cfg_default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-08 03:57:02 -05:00
parent 8daedbd806
commit f57a327a86
11 changed files with 166 additions and 93 deletions

View File

@@ -749,13 +749,17 @@ static const char *present_name(const char *mode) {
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.
// "in use: ..." under the VSync row when the swapchain does other than the row says: VSync when it is off and the driver
// cannot present without waiting, Immediate when it is on and the driver has neither mailbox nor relaxed FIFO
// (gfx_present.c pick_present_mode), so the game tears; 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;
if (!*got) return nullptr;
bool off = !strcmp(cfg_value("NX2NAVI_VK_PRESENT"), "immediate"), tears = !strcmp(got, "immediate");
if (off == tears) return nullptr;
static char note[96];
snprintf(note, sizeof note, menu_text(UI_MENU_PRESENT_IN_USE), menu_text(UI_MENU_PRESENT_VSYNC));
snprintf(note, sizeof note, menu_text(UI_MENU_PRESENT_IN_USE),
menu_text(tears ? UI_MENU_PRESENT_IMMEDIATE : UI_MENU_PRESENT_VSYNC));
return note;
}
@@ -1004,8 +1008,9 @@ static const char *prompts_note(bool *restart) {
// 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.
// (cheats_rebuild_allow). The Quit button's confirmation is the same box (g_confirm_quit), and it waits too: the game
// runs on while the menu is open, and closing the window finishes only a Commit that has begun (gfx_window_closed,
// fs_save_flush), so a save between writing its files and committing them would be dropped.
static bool restart_rebuild, g_confirm_quit;
static void restart_confirm(float scale) {
g_modal = false;
@@ -1019,10 +1024,11 @@ static void restart_confirm(float scale) {
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;
bool saving = 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));
menu_text(!saving ? UI_MENU_SAVE_FAILED : g_confirm_quit ? UI_MENU_QUIT_SAVING
: UI_MENU_RESTART_SAVING));
ImGui::Spacing();
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();

View File

@@ -2,8 +2,8 @@
// 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)).
// menu's cursor (a 3 px white frame with a soft white-blue glow); without the textures the divider is a plain line with
// a diamond in its middle and a dot at each end, a shape of its own, not the game's ornament.
#include <float.h>
#include <math.h>
#include <stdlib.h>
@@ -63,34 +63,6 @@ void ornament_line(ImDrawList *dl, ImVec2 a, ImVec2 b, float inset, float s, ImU
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.
@@ -416,31 +388,12 @@ void skin_filigree(ImDrawList *dl, float x0, float x1, float y, float s, float a
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);
}
// the middle: a diamond outline with a small filled one inside, and a short stroke on each side of it
float d = 9.0f * k * 1.08f, inner = 3.2f * k * 1.08f, t = 1.6f * k;
dl->AddQuad(ImVec2(cx, y - d), ImVec2(cx + d, y), ImVec2(cx, y + d), ImVec2(cx - d, y), orn, t);
dl->AddQuadFilled(ImVec2(cx, y - inner), ImVec2(cx + inner, y), ImVec2(cx, y + inner), ImVec2(cx - inner, y), orn);
dl->AddLine(ImVec2(cx - orn_w * 0.5f, y), ImVec2(cx - d - 3 * k, y), orn, t);
dl->AddLine(ImVec2(cx + d + 3 * k, y), ImVec2(cx + orn_w * 0.5f, y), orn, t);
}
void skin_panel(ImDrawList *dl, ImVec2 a, ImVec2 b, float s, float alpha) {

View File

@@ -322,11 +322,13 @@ bool opt_toggle(const char *key, UiTextId label, UiTextId desc, bool inverted) {
}
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;
// the default as the player's profile has it (cfg_default: the Steam Deck's fifo), which is also what "on" writes
// when it is an on value, so turning the switch off and on again puts the profile's own value back
const char *d = cfg_default(key);
bool on = strcmp(cfg_value(key), off_value) != 0, def = d && strcmp(d, 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);
apply(key, on ? off_value : def && *d ? d : on_value);
return true;
}