Jump to content
LaunchBox Community Forums

How do I save data for edited game entries?


Recommended Posts

I have made my first small plugin for Launchbox, through which you can make some changes to selected game entries. However, if I restart LaunchBox, my games no longer have the values I have previously set through the plugin. How come? There's barely any API documentation on plugin development, so I'm doing a lot of trial and error...

I also tried the following method, but it didn't do what I wanted:

PluginHelper.DataManager.Save();

 

Edited by SsjCosty
Link to comment
Share on other sites

Like I said im no expert but iv just tested this and it works, even after reloading LB. But the changes arnt displayed straight away when using this simple code. Selecting another game then going back to the "changed" game, shows the changes. There's probably a better way but it does work.

 

private IGame _igame;

public void OnSelected(IGame selectedGame)
{
    _igame = selectedGame;
            
    Unbroken.LaunchBox.Plugins.PluginHelper.DataManager.BackgroundReloadSave(Save);
}

public void Save()
{
    _igame.Developer = "Test Developer";
    _igame.Notes = "Test Notes";
}

 

Edit: beaten by the master.

Edited by jayjay
  • Like 1
Link to comment
Share on other sites

Per @jayjay's post above, BackgroundReloadSave is generally a good idea to use; the primary reason to use it is so that there are no conflicts with a third-party syncing app like Dropbox or Google Drive. Basically, it reloads any changed data from disk before saving the new values, just in case Dropbox or Google Drive happened to update a data file since the last time it was loaded.

Regardless, though, either @jayjay's solution above or just PluginHelper.DataManager.Save() should both be working to save data that has been changed in games.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...