feat(saves): save profiles on the title menu, each player with their own saves #1753
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1753
Loading…
Reference in a new issue
No description provided.
Delete branch "scampsgt/Longshot:feat/save-profiles"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: feat · Risk: medium · Tested on: Windows 11, RTX 4070 Laptop (NVIDIA 617) · Needs: Linux, any GPU
TL;DR
Several people in one house share one Longshot install, so they overwrite each other's saves or rename folders by hand (#1742). This PR adds Choose Profile to the title menu, under Options. It opens a list of three named profiles, like the N64's three files, and each profile has its own autosaves, manual saves and options. I played it on Windows with a pad, the keyboard and the mouse: naming, switching, Copy and Erase all work, and the saves players already have show up as Profile 1, unchanged.
Breakdown
main, and on a v3.0.0 build with the same change. The game-free suite passes on Linux, apart from checks that also fail onmainhere (no clang++, tmp permissions).Why
On the N64 each player had their own file. Here everyone shares one save, so a second player has to back up and rename the save folder to keep their own adventure. #1742 asks for exactly this: "multiple savegame profiles or easier switching so we have it like the original game had".
What changed
Each profile is its own console user, uid
{N, 0x5a3c9e1f0b7d2468}, andhost/nn_fs.calready names save folders by uid. So Profile 1 is the user every build has had, and Profile N saves tosave\5a3c9e1f0b7d2468000000000000000N. The title layout already has a fourth button,Pa_Button_03, that the game never shows. It is shown through the UI library's own visibility update, so the game aligns it and its own navigation reaches it. The renderer's overlay draws the line's words and the profile list.host/nn_applet.c:TryOpenPreselectedUser,GetUserId,GetUserExistenceandListAllUsersanswer with the chosen profile's uid (profile_uid, derived fromuser_uid). The first call waits until a profile is chosen.host/oot_files.c: the chosen profile (hos_file_wait,HOS_FILE,files.ini'slast=), the title line's input gate (hos_profile_input: A on the line, and everything while the list is open, go to the list), and the row's position and mouse handed to the overlay.host/oot_menu.ctitle_show_fourth/title_row_tick: showsPa_Button_03(wrapper flags +0xa8 bit 0, thenf_8154c890, the library's visibility update) and places the row. While the list is open,mouse_tick_lockedhands the pointer to the list instead of moving the title's focus.host/nn_hid.c:hos_pad_poll(the pads read now) and thehos_profile_inputcall afterhos_title_input.gpu/vk/vk_menu.cppnamespace files: the profile list (names, last saved, Playing now, Copy, Erase toerased-files, an N64-style letter grid) with keys, pads (the game's bindings) and the mouse.profiles_tickrestarts the game for another profile with the menu's Restart now (WM_APP + 9). Alsodraw_title_row, andmenu_record/menu_record_imagedraw both.gpu/vk/vk_replay.cpppresent_image: stores the picture's rect (files_picture_rect) so the row and list sit on the game's picture in a letterboxed window.gpu/vk/vk_api.h:MkwVkHostgainsuser_dir,pad_poll,file_chosen,title_row,profile_list_asked,profile_list_closed,current_file,profile_buttonsandprofile_pointer;MKWVK_API_VERSION36.host/rx_backend.cfills them.host/display.ccallshos_file_defaultafterrx_start(window and headless).gpu/vk/vk_main.cppstarts as the last profile.HOS_FILErow ingpu/vk/switches.def. Docs: README, "Where the files go".input_background_test.c,present_geometry_trace_test.cpp,test_present_aspect.py,windows_display_startup_test.c).test_fps_overlay_order.pynow also checks the order with the row and the list.Measurements
Nothing to measure: a title-menu feature with no work in play (the title hook returns at once on other screens, and the overlay draws nothing while neither the row nor the list shows).
Flags and settings
One new diagnostic switch, for test runs.
HOS_FILETesting
Tested: Windows 11, RTX 4070 Laptop, NVIDIA 617.
This branch built on current
main(this PR @1e68fe4, the Builder runningnx2/make_game.pyfrom this tree): the title shows Choose Profile. I opened the list with the pad and clicked Profile 2 with the mouse.files.inigotlast=2, the game restarted by itself, and the new run mountedsave\5a3c9e1f0b7d24680000000000000002and showed Choose Profile again.Earlier, the full flow on a v3.0.0 build with the same change:
files.ini. Choosing it restarts the game, which mounts...0002, and the title shows New Game and Options with no Continue (no save yet). Choosing Profile 1 again brings back the original saves.erased-files.Game-free:
python -I -B tests/run_all.pyon Linux (WSL, gcc, no clang++). Every check this change touched passes:test_env_on,test_switch_table,test_fps_overlay_order,test_menu_text_field,test_options_budget_once,test_input_background,test_present_aspect,test_present_geometry_trace,test_windows_display_startup. The other failures here also fail onmainin this environment (clang++ missing, tmp permissions). The changed host files compile with llvm-mingw clang (-fsyntax-only -Wall -Wextra, no new warnings).Not tested:
CreateDirectoryA,MoveFileExA,PostMessageA), so it may need the POSIX side.Must be tested:
save\5a3c9e1f0b7d24680000000000000002and Profile 1's saves untouched (Test Farm: @Beanstalk windows, Choose Profile on the title: name and switch to Profile 2, then save).Risks
What could break: the title screen (the fourth line's visibility and focus), the account HLEs (a wrong uid means the wrong save folder: Profile 1 is uid 1, as before), input on the title while the row or list has it, and the Linux build (Win32 calls in the list).
Turning it off: revert the commit. Never opening Choose Profile keeps Profile 1, the existing saves.
Compatibility: saves are unchanged: Profile 1 is the existing folder, and new profiles add folders beside it plus
save\files.ini.MKWVK_API_VERSIONgoes to 36, so the host and renderer must come from the same build (the builder builds both).longshot_options.iniis unchanged. Going back to a build without this PR plays Profile 1's saves, and the other profiles' folders are kept and ignored.Issues
See #1742
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.MKWVK_API_VERSIONbumped (gpu/vk/vk_api.h'sMkwVkHostorMkwVkRendererchanged).tests/that reads changed source updated in this PR, not weakened.The title menu gets a fourth line, Choose Profile, under Options (the layout's Pa_Button_03, which the game never shows, shown through the UI library's own visibility update). It opens a list drawn as the title's lines: three profiles with names, Copy and Erase, a letter grid to name one, keys, pads and the mouse. Each profile is its own console user, uid {N, 0x5a3c9e1f0b7d2468}, so profile 1 is the saves players already have and every autosave, manual save and in-game option of another profile lives in its own save folder. Choosing another profile restarts the game as it (the menu's Restart now). files.ini in the save folder keeps the names and the last profile. HOS_FILE=1..3 picks one for test runs. MKWVK_API_VERSION 36. See #1742. Assisted-by: Claude Code Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Dypn3L2qNTumSW4aRfXF8YTested in game: Windows 11, RTX 4070 Laptop, NVIDIA 617, on a v3.0.0 build with this change (before the clean rebase onto main): title screen, Choose Profile with pad, keys and mouse; named Profile 2, switched to it (game restarted, mounted ...0002, no Continue), switched back to Profile 1 with its saves intact; Copy and Erase checked. A run of this branch's own main build is still to come.
Possibly related, for context:
Ran this branch built on current main (@
1e68fe4) on Windows 11, RTX 4070 Laptop: Choose Profile shows on the title; the list opened with the pad, a mouse click on Profile 2 restarted the game into save\5a3c9e1f0b7d24680000000000000002 with files.ini last=2. Description updated; Linux is still untested.WIP: feat(saves): save profiles on the title menu, each player with their own savesto feat(saves): save profiles on the title menu, each player with their own savesView command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.