blake502 / balatro-mobile-maker

Create a mobile Balatro app from your Steam version of Balatro
329 stars 25 forks source link

Cannot transfer Steam save data #6

Closed ramenmaruru closed 1 month ago

ramenmaruru commented 1 month ago

i already tried copying and pasting my save data from C:/Users/%UserName%/AppData/Roaming/Balatro to sdcard/Android/data/com.unofficial.balatro/ but the game doesnt detect it, and android doesn't let me modify data/data/com.unofficial.balatro/files

blake502 commented 1 month ago

I'm looking into this, but it's quite tricky. Some notes for other developers: Love2D will save in one of two locations on Android. See here. /data/data/com.unofficial.balatro/files/save/ or /sdcard/Android/data/com.unofficial.balatro/files/save/ The "Accessible Saves" patch uses the latter instead of the former. Since the AndroidManifest.xml has the debug flag, you should be able to use ADB to "run as" com.unofficial.balatro and modify the contents of either location.

Even with this knowledge, I have been unable to successfully load a save from my Steam copy of Balatro. I haven't investigated this suspicion yet-- but I suspect that Balatro stores the platform in the save, and refuses to load a save from another platform. If that's the case, a simple patch could sort that out.

atmanli commented 1 month ago

Just as a side note, maybe this is useful information for you: I am able to transfer my save from Steam to RGB30 (Portmaster).

Also in regards to this:

Love2D will save in one of two locations on Android. See here. /data/data/com.unofficial.balatro/files/save/` or /sdcard/Android/data/com.unofficial.balatro/files/save/

Both folders are empty for me although I have a profile and a save in Balatro. So the game must store the save file/folder somewhere else

blake502 commented 1 month ago

Both folders are empty for me although I have a profile and a save in Balatro. So the game must store the save file/folder somewhere else

It doesn't, that's the correct location. You cannot view the contents of those folders by typical means. They will appear empty, but that is the location. Android updates have continually made it more difficult to view (let alone modify) those locations.

blake502 commented 1 month ago

You can view the contents using ADB:

adb shell
run-as com.unofficial.balatro
cd /sdcard/Android/data/com.unofficial.balatro/files/save/game
ls -a
cd 1
ls -a

image

TheCatRiX commented 1 month ago

That's how I transfer my saves. Added android:debuggable="true" in AndroidManifest.xml and didn't apply "Accessible Saves" patch. Launched game at least once to create save data directory. Commands for PowerShell:

adb push $env:AppData/Balatro/1/. /data/local/tmp/1
adb shell run-as com.unofficial.balatro cp -r /data/local/tmp/1 files/save/game
adb shell rm -r /data/local/tmp/1
blake502 commented 1 month ago

Thanks for this @TheCatRiX !! I'll do some testing and get some documentation written up for this-- I'll be sure to credit you!

blake502 commented 1 month ago

With the latest release (beta-0.5) you can now automatically transfer saves one your build your APK. Thanks again @TheCatRiX !!

TheCatRiX commented 1 month ago

If user has not launched the game yet, destination directory will not exist and cp command will not be executed successfully.

TheCatRiX commented 1 month ago

I also want to note that only the first save slot is transferred. It may be worth adding the transfer of the second and third slots, if there are any. And yet, we can offer the user to install the apk via adb: adb install balatro.apk

blake502 commented 1 month ago

Both valid points. I'll make those changes. Since you seem to be more knowledgeable about adb, does this look right to you? That should transfer the entire folder?

adb push $env:AppData/Balatro/. /data/local/tmp/balatro/game
adb shell run-as com.unofficial.balatro cp -r /data/local/tmp/balatro files/save
adb shell rm -r /data/local/tmp/balatro
TheCatRiX commented 1 month ago

Second command should be adb shell run-as com.unofficial.balatro cp -r /data/local/tmp/balatro/game files/save But it will also copy settings.jkr and steam_autocloud.vdf that I don't think we want to be copied. And also this still won't work if game hasn't been launched yet: изображение We need to ask user launch game at least once before copying saves (not so automatic...) or create this directory if it is not exist.

blake502 commented 1 month ago

Okay great, looks like this should do the trick

adb push %AppData%/Balatro/. /data/local/tmp/balatro/save/game
adb shell run-as com.unofficial.balatro mkdir files
adb shell run-as com.unofficial.balatro cp -r /data/local/tmp/balatro/save files
adb shell rm -r /data/local/tmp/balatro

I tested it and it seems to work fine-- Even if the app has not already been launched. Including settings.jkr should be fine... But I might eat my words on that later haha. Oh well, I can modify it later to only copy the folders if we run in to trouble. And while I don't love including steam_autocloud.vdf, it also shouldn't cause any trouble.

Edit: Scratch that... doing some more testing, but I think I'm on to something here haha

blake502 commented 1 month ago

Okay, final answer haha:

adb push %AppData%/Balatro/. /data/local/tmp/balatro/files/save/game
adb shell run-as com.unofficial.balatro cp -r /data/local/tmp/balatro/files .
adb shell rm -r /data/local/tmp/balatro
TheCatRiX commented 1 month ago

Nice, it works

blake502 commented 1 month ago

I also added in adb shell am force-stop com.unofficial.balatro in case it's already running when they try to transfer saves. Going to do a clean-up pass, then I'll get the next release out ASAP.

Aaantoni commented 1 month ago

I got this error while attempting save transfer:

adb: error: failed to get feature set: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.

I've enabled USB debugging prior to attempting this and clicked Allow on my phone when prompted. I have an Oppo Reno5


edit: running the tool again downloads platform-tools again and asks if I want to overwrite the existing adb.exe file with the one from the archive - but there's no way of confirming or declining.

blake502 commented 1 month ago

You need to deleted this directory: %userprofile%\.android\

See here: https://github.com/blake502/balatro-apk-maker/issues/17#issuecomment-2052150424

blake502 commented 1 month ago

In reference to your edit-- I'm also cleaning up those kinds of bugs with this next revision. Should be done shortly.

blake502 commented 1 month ago

Okay beta-0.5.1 is live. This should sort out everything.