SsjCosty Posted March 20, 2019 Share Posted March 20, 2019 (edited) 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 March 20, 2019 by SsjCosty Quote Link to comment Share on other sites More sharing options...
jayjay Posted March 20, 2019 Share Posted March 20, 2019 I'm attempting to make a user control that uses addnewgame(). To have the data save I'm using backgroundreloadsave(). I'm no expert but can post an example of what I have, when I'm near my pc if u need? Quote Link to comment Share on other sites More sharing options...
SsjCosty Posted March 20, 2019 Author Share Posted March 20, 2019 Thanks! I'll see if I can use that method. Don't worry about posting an example - I'll write back if I can't figure it out and you could post it then. Cheers! Quote Link to comment Share on other sites More sharing options...
SsjCosty Posted March 20, 2019 Author Share Posted March 20, 2019 It didn't work. Once I reset Launchbox, my game details reverted back to what they were before. ? Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 20, 2019 Share Posted March 20, 2019 Hi @SsjCosty, calling PluginHelper.DataManager.Save() should save any changes to games. Feel free to PM me your code and I can look through it to see what might be causing the issue. Quote Link to comment Share on other sites More sharing options...
jayjay Posted March 20, 2019 Share Posted March 20, 2019 (edited) 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 March 20, 2019 by jayjay 1 Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 20, 2019 Share Posted March 20, 2019 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. 1 Quote Link to comment Share on other sites More sharing options...
SsjCosty Posted March 20, 2019 Author Share Posted March 20, 2019 Thank you both Jason and jayjay for helping out. Jason noticed in a PM that I was adding to the game's selectedGame.Genres property, which is read-only and I should have edited the selectedGame.GenresString property instead. 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.