Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save manager backup/restore-backup 4006 #4113

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

GodAkisuke
Copy link

@GodAkisuke GodAkisuke commented Dec 13, 2022

Issue 4006 - Save savedata as backup and restore it

So i added 2 buttons in the save manager from the usesr profile menu.
One button compress the savedata folder into a zip located to a user specified path.
The other button extracts the backup and tries to replace the current savedata, with the same name and parent folder, with the backup save files.
All games i have had different savedata filenames so i assumed this could be a good approach because i got told theres no way to figure out which savedata folders and games are linked.

@CeruleanSky
Copy link
Contributor

I thought the ExtraData files were used to map folders to games, for example my save for Voice of Cards Beasts of Burden with ID 010022D016030000 and here is a hex view of the ExtraData file:

image

But I'm not familiar with the system or the codepaths, and I suppose there might be exceptions with apps and homebrew.

@GodAkisuke
Copy link
Author

I thought the ExtraData files were used to map folders to games, for example my save for Voice of Cards Beasts of Burden with ID 010022D016030000 and here is a hex view of the ExtraData file:

image

But I'm not familiar with the system or the codepaths, and I suppose there might be exceptions with apps and homebrew.

Just checked it with super smash and it seems you are right. I'll dig into this.

@AcK77
Copy link
Member

AcK77 commented Dec 13, 2022

This is not the right way to go, I suggest you to take a look at https://github.com/Ryujinx/Ryujinx/blob/master/Ryujinx.Ava/Ui/Controls/SaveManager.axaml.cs and the UserProfile code if you want to find a proper way to backup and restore savedata. You should take a look at the LibHac code too.

You removed ExtraData which could be used by some games. You store saves in a Zip at a hardcoded place instead of letting the users choose the destination. You don’t use locale fields for the new added texts.

@GodAkisuke
Copy link
Author

GodAkisuke commented Dec 13, 2022

This is not the right way to go, I suggest you to take a look at https://github.com/Ryujinx/Ryujinx/blob/master/Ryujinx.Ava/Ui/Controls/SaveManager.axaml.cs and the UserProfile code if you want to find a proper way to backup and restore savedata. You should take a look at the LibHac code too.

You removed ExtraData which could be used by some games. You store saves in a Zip at a hardcoded place instead of letting the users choose the destination. You don’t use locale fields for the new added texts.

I understand my way wasn't the right way to go but the extra files truly seem to save the TitleId.
So I could just compare the extrafiles titleId and replace the parentSaveFolder.
This seems a good way imo but I m new in Ryujinx dev.

new method for backup and restoring save data
user can choose filename now
@emmauss
Copy link
Contributor

emmauss commented Dec 14, 2022

Well, there are a lot of things that should be done differently,
UI

  1. Make the export buttons part of the content view, and not the content dialog. In this case, they should be in SaveManager.axaml
  2. You don't have to create an ICommand interface to bind a command to a button. You can bind delegates and methods to buttons straight from the viewmodel. you need to do the above first.
  3. To enhance UX, you can make the saves in the save list checkable, and then allow exporting the selected or all saves.

Export

  1. You export the whole save directory, which includes saves for all users, even though the options are only accessible when you open the saves for 1 user
  2. Switch saves have a specific way they are created an managed. Use the libhac save client to actually access and export the actual user's save directory.
  3. The output of the export should be in a format that you can reverse the export when restoring. That is, if the game already has a save, it should replace the save, if it doesn't, it should create a new save for that user. In both cases, Libhac will handle save directory creation.
    @GodAkisuke are you on the discord server?

@gdkchan gdkchan added enhancement New feature or request gui Related to Ryujinx.Ui review/waiting-on-author Waiting on the contributor for a PR labels Dec 16, 2022
@GodAkisuke
Copy link
Author

Well, there are a lot of things that should be done differently, UI

  1. Make the export buttons part of the content view, and not the content dialog. In this case, they should be in SaveManager.axaml
  2. You don't have to create an ICommand interface to bind a command to a button. You can bind delegates and methods to buttons straight from the viewmodel. you need to do the above first.
  3. To enhance UX, you can make the saves in the save list checkable, and then allow exporting the selected or all saves.

Export

  1. You export the whole save directory, which includes saves for all users, even though the options are only accessible when you open the saves for 1 user
  2. Switch saves have a specific way they are created an managed. Use the libhac save client to actually access and export the actual user's save directory.
  3. The output of the export should be in a format that you can reverse the export when restoring. That is, if the game already has a save, it should replace the save, if it doesn't, it should create a new save for that user. In both cases, Libhac will handle save directory creation.
    @GodAkisuke are you on the discord server?

yes I am

@GodAkisuke
Copy link
Author

GodAkisuke commented Dec 16, 2022

Well, there are a lot of things that should be done differently, UI

  1. Make the export buttons part of the content view, and not the content dialog. In this case, they should be in SaveManager.axaml
  2. You don't have to create an ICommand interface to bind a command to a button. You can bind delegates and methods to buttons straight from the viewmodel. you need to do the above first.
  3. To enhance UX, you can make the saves in the save list checkable, and then allow exporting the selected or all saves.

Export

  1. You export the whole save directory, which includes saves for all users, even though the options are only accessible when you open the saves for 1 user
  2. Switch saves have a specific way they are created an managed. Use the libhac save client to actually access and export the actual user's save directory.
  3. The output of the export should be in a format that you can reverse the export when restoring. That is, if the game already has a save, it should replace the save, if it doesn't, it should create a new save for that user. In both cases, Libhac will handle save directory creation.
    @GodAkisuke are you on the discord server?

yes I a

Well, there are a lot of things that should be done differently, UI

  1. Make the export buttons part of the content view, and not the content dialog. In this case, they should be in SaveManager.axaml
  2. You don't have to create an ICommand interface to bind a command to a button. You can bind delegates and methods to buttons straight from the viewmodel. you need to do the above first.
  3. To enhance UX, you can make the saves in the save list checkable, and then allow exporting the selected or all saves.

Export

  1. You export the whole save directory, which includes saves for all users, even though the options are only accessible when you open the saves for 1 user
  2. Switch saves have a specific way they are created an managed. Use the libhac save client to actually access and export the actual user's save directory.
  3. The output of the export should be in a format that you can reverse the export when restoring. That is, if the game already has a save, it should replace the save, if it doesn't, it should create a new save for that user. In both cases, Libhac will handle save directory creation.
    @GodAkisuke are you on the discord server?

yes I am

I try to use libhac but I did already and couldn't find a good documentation or the right things to use.
I got to get the game saves but i wasn't able to replace them with the backup files or backup the save models.
You got any Idea where i could start looking or have a doc for me?

@GodAkisuke
Copy link
Author

94a2c9d

Moved buttons to saveManager.
Removed ICommand interface.
Exporter working so far using libhac library.
Importer probably comming tomorrow (since its 2.am today)
Selection comes after export and import working.

@CeruleanSky
Copy link
Contributor

This may or may not be out of scope of your intentions as I haven't looked over what you are doing, and perhaps could be more trouble than you want to put working on management of saves; but if not and if you haven't already considered it, furthering your management work to also be able to import Yuza saves could be useful. If it is too much out of scope or trouble and you do decide to do so, it might be better to put in another pull request.

@GodAkisuke
Copy link
Author

So everythings working now as far as i tested it.

Feature

Added Import/Export buttons to the savemanager.
Also added a new SaveDataFileManager who handles restoring/saving backups through libhac horizon os.
Language support for all ryujinx supported languages.
Saves the backups in folders with their game ids because its some random number in ryujinx save folder.
With this said the backups can also be used in yuzu and vice versa if you zip the saves from there (don't pin me on that).

@jojodunet
Copy link

jojodunet commented Dec 22, 2022

@GodAkisuke In addition, could we please 'also' have Save Manager in the tools menu? (a quick link in the tools menu, at least for the part « Backup/Restore » of saves).
CE8E7792-9AB9-4705-8188-8DA6A43F2969

Per my discussion with the others devs, for this addition, we need also to have a quick additional dialog to select the user profile, as each user has separate saves.

Comment also referred here #3997

@jojodunet
Copy link

@GodAkisuke Could you please check the issues (branch conflicts) and rebase to test the PR?

return Result.Success;
}

private bool CreateSaveData(ApplicationData app)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a copy of the method in ApplicationHelper? It shouldn't be duplicated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gui Related to Ryujinx.Ui review/waiting-on-author Waiting on the contributor for a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants