diff --git a/gaseous-server/Controllers/V1.0/BiosController.cs b/gaseous-server/Controllers/V1.0/BiosController.cs index 9e26bd9..c2cfc2b 100644 --- a/gaseous-server/Controllers/V1.0/BiosController.cs +++ b/gaseous-server/Controllers/V1.0/BiosController.cs @@ -99,7 +99,11 @@ namespace gaseous_server.Controllers if (bios.hash == hash) { // add the bios file to the zip - zipArchive.CreateEntryFromFile(Path.Combine(Config.LibraryConfiguration.LibraryFirmwareDirectory, hash + ".bios"), bios.filename); + string biosFilePath = Path.Combine(Config.LibraryConfiguration.LibraryFirmwareDirectory, hash + ".bios"); + if (System.IO.File.Exists(biosFilePath)) + { + zipArchive.CreateEntryFromFile(biosFilePath, bios.filename); + } } } } diff --git a/gaseous-server/Models/PlatformMapping.cs b/gaseous-server/Models/PlatformMapping.cs index e8c7b52..ef80916 100644 --- a/gaseous-server/Models/PlatformMapping.cs +++ b/gaseous-server/Models/PlatformMapping.cs @@ -46,7 +46,7 @@ namespace gaseous_server.Models } else { - WritePlatformMap(mapItem, true, true); + WritePlatformMap(mapItem, true, true, true); Logging.Log(Logging.LogType.Information, "Platform Map", "Overwriting " + mapItem.IGDBName + " with default values."); } } @@ -164,7 +164,7 @@ namespace gaseous_server.Models } } - public static void WritePlatformMap(PlatformMapItem item, bool Update, bool AllowAvailableEmulatorOverwrite) + public static void WritePlatformMap(PlatformMapItem item, bool Update, bool AllowAvailableEmulatorOverwrite, bool overwriteBios = false) { CreateDummyPlatform(item); @@ -247,14 +247,21 @@ namespace gaseous_server.Models foreach (PlatformMapItem.EmulatorBiosItem biosItem in item.Bios) { bool isEnabled = false; - if (item.EnabledBIOSHashes == null) - { - item.EnabledBIOSHashes = new List(); - } - if (item.EnabledBIOSHashes.Contains(biosItem.hash)) + if (overwriteBios == true) { isEnabled = true; } + else + { + if (item.EnabledBIOSHashes == null) + { + item.EnabledBIOSHashes = new List(); + } + if (item.EnabledBIOSHashes.Contains(biosItem.hash)) + { + isEnabled = true; + } + } sql = "INSERT INTO PlatformMap_Bios (Id, Filename, Description, Hash, Enabled) VALUES (@Id, @Filename, @Description, @Hash, @Enabled);"; dbDict.Clear(); diff --git a/gaseous-server/wwwroot/pages/settings/mapping.html b/gaseous-server/wwwroot/pages/settings/mapping.html index 4f9352e..fc6bc88 100644 --- a/gaseous-server/wwwroot/pages/settings/mapping.html +++ b/gaseous-server/wwwroot/pages/settings/mapping.html @@ -17,9 +17,9 @@

This list is pre-populated with some of the more common platforms. New platforms will appear in this list as titles are added.

- diff --git a/gaseous-server/wwwroot/pages/settings/mapping.js b/gaseous-server/wwwroot/pages/settings/mapping.js index 7ba220a..9191ed8 100644 --- a/gaseous-server/wwwroot/pages/settings/mapping.js +++ b/gaseous-server/wwwroot/pages/settings/mapping.js @@ -70,6 +70,7 @@ function SetupButtons() { if (userProfile.roles.includes("Admin")) { document.getElementById('settings_mapping_import').style.display = ''; + // Setup the JSON import button document.getElementById('uploadjson').addEventListener('change', function () { $(this).simpleUpload("/api/v1.1/PlatformMaps", { start: function (file) { @@ -84,6 +85,24 @@ function SetupButtons() { }); document.getElementById('importjson').addEventListener('click', openDialog); + + // Setup the JSON export button + document.getElementById('exportjson').addEventListener('click', DownloadJSON); + + // Setup the reset to defaults button + document.getElementById('resetmapping').addEventListener('click', function () { + let warningDialog = new MessageBox("Platform Mapping Reset", "This will reset the platform mappings to the default values. Are you sure you want to continue?"); + warningDialog.addButton(new ModalButton("OK", 2, warningDialog, async (callingObject) => { + loadPlatformMapping(true); + callingObject.msgDialog.close(); + let completedDialog = new MessageBox("Platform Mapping Reset", "All platform mappings have been reset to default values."); + completedDialog.open(); + })); + warningDialog.addButton(new ModalButton("Cancel", 0, warningDialog, async (callingObject) => { + callingObject.msgDialog.close(); + })); + warningDialog.open(); + }); } }