XorTroll / uLaunch

:rocket: The themeable Nintendo Switch HOME menu Nintendo forgot to make
https://xortroll.github.io/uLaunch/
GNU General Public License v2.0
618 stars 55 forks source link

[SUGGESTION] Extended LayeredFS support for game mods #39

Closed lordelan closed 4 months ago

lordelan commented 5 years ago

The goal is to have separate mods for the same game available on the home screen. Think of Breath of the Wild. There's a Linkle mod and a Zelda mod for example. For some reason sometimes you might wanna play the vanilla game (without LayeredFS active), sometimes the Linkle Mod and sometimes the princess Zelda mod.

To achieve this, instead of putting those mods in sd:\atmosphere\titles[titleID of BotW]\ we could put them like this:

sd:\ulaunch\titles[titleID of BotW]\mods\linkle\ sd:\ulaunch\titles[titleID of BotW]\mods\princess_zelda\

Then two more things have to be done:

  1. Make it possible to "clone" a title in ulaunch or to create separate shortcuts to titles to have Breath of the Wild three times on your homescreen
  2. Put an option in the title menu (pressing + on the game in ulaunch) to pick either one of the mods in sd:\ulaunch\titles\ to be applied to that shortcut (to turn one into Linkle mod and the other into Zelda mod) or to deactivate LayeredFS for this specific title (to have the third of the three BotW icons on the home screen boot into vanilla BotW without any mods)
XorTroll commented 5 years ago

I'm.. not really sure I can do something to help on this. Atmosphere's extensions allow me to replace a title's exefs (instead of messing around copying stuff to /titles), but won't allow romfs.

lordelan commented 5 years ago

I don't know if you can detect when a title is closed by a user to start an event just then, but if yes, this could be the way to go:

  1. mod is placed at sd:\ulaunch\titles[titleID][mod name] (or inside the AMS titles folder with a placeholder name)
  2. when shortcut in ulaunch is launched, that has a LayeredFS mod adjusted to it (like Linkle mod for BotW) you automatically do some folder moving/renaming in the background to fit atmosphères LFS requirements, then launch the game (so mod is applied)
  3. ulaunch detects that title has been closed by user => mod files in sd:\atmosphere\titles[titleID]\ are being moved/renamed back

Only thing that has to been taken care of is the case that the Switch freezes or is forced to shut down while title is running so that "closing title event" didn't happen properly.

XorTroll commented 5 years ago

Well, "moving" pretty big folders/files sounds more like a dirty practice IMO, but it's the only solution I can think of

lordelan commented 5 years ago

You're probably right, moving takes too long and is too risky (in case of crashes or memory issues). Renaming on the other hand is almost instant speed so maybe there's a clever way to handle it just by that.

One possible way could be: User puts it like this: sd:\atmosphere\titles\00050000101C9500_linkle sd:\atmosphere\titles\00050000101C9500_zelda

Launching the vanilla icon does nothing obviously. Launching the Linkle clone/shortcut/howeveryouwannacallit looks for that titleID folder in sd:\atmosphere\titles\ that has a "_" after the titleID and removes the "_linkle". Launching the Princess Zelda clone/shortcut does the same for "_zelda"

If you place a small ulaunch.ini in each of those folders containing the string that is the mod name, you can even handle crashes. I mean sd:\atmosphere\titles\00050000101C9500linkle\ulaunch.ini containing only the word "linkle". That has the benefit (e.g. in case of a crash) that if a user launches the vanilla Breath of the Wild, where LayeredFS should be disabled, if there's a folder named only this: sd:\atmosphere\titles\00050000101C9500 You can then look if there's a ulaunch.ini in it. If yes, the Switch crashed while a mod has been used so you could read the content of that file, rename the folder back to 00050000101C9500 + "" + [content of ulaunch.ini] before the game is launched so it launches in "vanilla mode". By checking for a ulaunch.ini this way before any title is started you won't even need an event handling when the user closes a title as written above. It's just solved everytime the user launches any of the game versions (either vanilla or a mod).

I'm aware that this increases loading times before the game is actually launched though (if a ulaunch.ini and renaming magic has to be done before each launching) but maybe it's done fast enough.