dsync89 Posted 20 hours ago Posted 20 hours ago (edited) Hey there fellow Launchbox Devs, this is my first attempt to develop a plugin that attempt to read all zip files in a a rom folder recursively and create a new Platform and Games for those. So far I've setup the full .NET 9.0 development environment and confirm LB can load this plugin and I can see it in the Tools menu. What's strange is despite calling `PluginHelper.DataManager.Save()` after `AddNewPlatform` and `AddNewGame` I don't see any XML created. I've checked the Plugin docs but couldn't find anywhere that mention how to save other than this. A snippet of the code. public void OnSelected() { var platformName = "JAKKS Pacific TV Games"; var romFolder = @"c:\temp\mame_curated_romset\jakks-pacific-plug-and-play-tv\"; // Your curated folder IPlatform platform = PluginHelper.DataManager.GetPlatformByName(platformName) ?? PluginHelper.DataManager.AddNewPlatform(platformName); platform.SortTitle = platformName; //platform.Save(); foreach (var file in Directory.GetFiles(romFolder, "*.zip", SearchOption.AllDirectories)) // This makes it recursive { var fileName = Path.GetFileNameWithoutExtension(file); IGame newGame = dataManager.AddNewGame(fileName); // STEP 4: Set game properties newGame.Platform = platform.Name; newGame.ApplicationPath = @"C:\MAME\roms\bubblebobble.zip"; newGame.CommandLine = ""; // optional newGame.EmulatorId = dataManager.GetAllEmulators().FirstOrDefault()?.Id; // optional newGame.Version = "Softlist"; newGame.SortTitle = "Bubble Bobble"; PluginHelper.DataManager.Save(); } MessageBox.Show("Import complete!", "JAKKS Importer", MessageBoxButtons.OK, MessageBoxIcon.Information); } public bool ShowInLaunchBox => true; public bool ShowInBigBox => false; public System.Drawing.Image IconImage { get { return Resource1.logo; } } public bool AllowInBigBoxWhenLocked => throw new NotImplementedException(); } Edit: Solved. Turned out I just have to refresh the menu! This will be a first step for a plugin to come that will handily import a curated MAME MESS list. Edited 20 hours ago by dsync89 solved Quote
C-Beats Posted 20 hours ago Posted 20 hours ago Not even sure how you'd get the code as is to compile. Where do you define "dataManager" variable at you are using in the for loop? Also if you want the code to wait and not release until the save is complete you need to pass true to the save function. You also only need to do it once after the for loop has completed, not after every game. Quote
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.