diff --git a/gaseous-server/Classes/Metadata/Games.cs b/gaseous-server/Classes/Metadata/Games.cs index 11b7b2d..2444582 100644 --- a/gaseous-server/Classes/Metadata/Games.cs +++ b/gaseous-server/Classes/Metadata/Games.cs @@ -232,6 +232,7 @@ namespace gaseous_server.Classes.Metadata Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString); string sql = @" SELECT DISTINCT + view_Games_Roms.MetadataMapId, view_Games_Roms.GameId, view_Games_Roms.PlatformId, Platform.`Name`, @@ -239,7 +240,7 @@ SELECT DISTINCT User_RecentPlayedRoms.RomId AS MostRecentRomId, CASE User_RecentPlayedRoms.IsMediaGroup WHEN 0 THEN GMR.`Name` - WHEN 1 THEN 'Media Group' + WHEN 1 THEN view_Games_Roms.`MetadataGameName` ELSE NULL END AS `MostRecentRomName`, User_RecentPlayedRoms.IsMediaGroup AS MostRecentRomIsMediaGroup, @@ -247,7 +248,7 @@ SELECT DISTINCT User_GameFavouriteRoms.RomId AS FavouriteRomId, CASE User_GameFavouriteRoms.IsMediaGroup WHEN 0 THEN GFV.`Name` - WHEN 1 THEN 'Media Group' + WHEN 1 THEN view_Games_Roms.`MetadataGameName` ELSE NULL END AS `FavouriteRomName`, User_GameFavouriteRoms.IsMediaGroup AS FavouriteRomIsMediaGroup @@ -257,11 +258,11 @@ FROM Platform ON view_Games_Roms.PlatformId = Platform.Id LEFT JOIN User_RecentPlayedRoms ON User_RecentPlayedRoms.UserId = @userid - AND User_RecentPlayedRoms.GameId = view_Games_Roms.GameId + AND User_RecentPlayedRoms.GameId = view_Games_Roms.MetadataMapId AND User_RecentPlayedRoms.PlatformId = view_Games_Roms.PlatformId LEFT JOIN User_GameFavouriteRoms ON User_GameFavouriteRoms.UserId = @userid - AND User_GameFavouriteRoms.GameId = view_Games_Roms.GameId + AND User_GameFavouriteRoms.GameId = view_Games_Roms.MetadataMapId AND User_GameFavouriteRoms.PlatformId = view_Games_Roms.PlatformId LEFT JOIN view_Games_Roms AS GMR ON GMR.Id = User_RecentPlayedRoms.RomId diff --git a/gaseous-server/Classes/RomMediaGroup.cs b/gaseous-server/Classes/RomMediaGroup.cs index 5763442..3b8c33f 100644 --- a/gaseous-server/Classes/RomMediaGroup.cs +++ b/gaseous-server/Classes/RomMediaGroup.cs @@ -193,7 +193,7 @@ namespace gaseous_server.Classes public static void DeleteMediaGroup(long Id) { Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString); - string sql = "DELETE FROM RomMediaGroup WHERE Id=@id; DELETE FROM GameState WHERE RomId=@id AND IsMediaGroup=1; UPDATE UserTimeTracking SET PlatformId = NULL, IsMediaGroup = NULL, RomId = NULL WHERE RomId=@id AND IsMediaGroup = 1;"; + string sql = "DELETE FROM RomMediaGroup WHERE Id=@id; DELETE FROM GameState WHERE RomId=@id AND IsMediaGroup=1; DELETE FROM User_GameFavouriteRoms WHERE RomId = @id AND IsMediaGroup = 1; DELETE FROM User_RecentPlayedRoms WHERE RomId = @id AND IsMediaGroup = 1; UPDATE UserTimeTracking SET PlatformId = NULL, IsMediaGroup = NULL, RomId = NULL WHERE RomId=@id AND IsMediaGroup = 1;"; Dictionary dbDict = new Dictionary(); dbDict.Add("id", Id); db.ExecuteCMD(sql, dbDict); @@ -296,7 +296,8 @@ namespace gaseous_server.Classes GameRomMediaGroupItem mediaGroupItem = GetMediaGroup(Id); if (mediaGroupItem.Status == GameRomMediaGroupItem.GroupBuildStatus.WaitingForBuild) { - Models.Game GameObject = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, mediaGroupItem.GameId); + MetadataMap.MetadataMapItem metadataMap = Classes.MetadataManagement.GetMetadataMap(mediaGroupItem.GameId).PreferredMetadataMapItem; + Models.Game GameObject = Games.GetGame(metadataMap.SourceType, metadataMap.SourceId); Platform PlatformObject = Platforms.GetPlatform(mediaGroupItem.PlatformId); PlatformMapping.PlatformMapItem platformMapItem = PlatformMapping.GetPlatformMap(mediaGroupItem.PlatformId); diff --git a/gaseous-server/Classes/Roms.cs b/gaseous-server/Classes/Roms.cs index aa03573..c90aa2f 100644 --- a/gaseous-server/Classes/Roms.cs +++ b/gaseous-server/Classes/Roms.cs @@ -253,7 +253,7 @@ namespace gaseous_server.Classes } Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString); - string sql = "DELETE FROM Games_Roms WHERE Id = @id; DELETE FROM GameState WHERE RomId = @id; UPDATE UserTimeTracking SET PlatformId = NULL, IsMediaGroup = NULL, RomId = NULL WHERE RomId = @id AND IsMediaGroup = 0;"; + string sql = "DELETE FROM Games_Roms WHERE Id = @id; DELETE FROM GameState WHERE RomId = @id; DELETE FROM User_GameFavouriteRoms WHERE RomId = @id AND IsMediaGroup = 0; DELETE FROM User_RecentPlayedRoms WHERE RomId = @id AND IsMediaGroup = 0; UPDATE UserTimeTracking SET PlatformId = NULL, IsMediaGroup = NULL, RomId = NULL WHERE RomId = @id AND IsMediaGroup = 0;"; Dictionary dbDict = new Dictionary(); dbDict.Add("id", RomId); db.ExecuteCMD(sql, dbDict); diff --git a/gaseous-server/Classes/UserProfile.cs b/gaseous-server/Classes/UserProfile.cs index dd4acb0..90995da 100644 --- a/gaseous-server/Classes/UserProfile.cs +++ b/gaseous-server/Classes/UserProfile.cs @@ -59,12 +59,19 @@ namespace gaseous_server.Classes DataTable nowPlayingData = db.ExecuteCMD(sql, dbDict); if (nowPlayingData.Rows.Count > 0) { - NowPlaying = new Models.UserProfile.NowPlayingItem + try { - Game = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, (long)nowPlayingData.Rows[0]["GameId"]), - Platform = Platforms.GetPlatform((long)nowPlayingData.Rows[0]["PlatformId"]), - Duration = Convert.ToInt64(nowPlayingData.Rows[0]["SessionLength"]) - }; + NowPlaying = new Models.UserProfile.NowPlayingItem + { + Game = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, (long)nowPlayingData.Rows[0]["GameId"]), + Platform = Platforms.GetPlatform((long)nowPlayingData.Rows[0]["PlatformId"]), + Duration = Convert.ToInt64(nowPlayingData.Rows[0]["SessionLength"]) + }; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } } // return the user profile object diff --git a/gaseous-server/Controllers/V1.0/GamesController.cs b/gaseous-server/Controllers/V1.0/GamesController.cs index 6cdc889..2d4ab1a 100644 --- a/gaseous-server/Controllers/V1.0/GamesController.cs +++ b/gaseous-server/Controllers/V1.0/GamesController.cs @@ -1511,7 +1511,7 @@ namespace gaseous_server.Controllers gaseous_server.Models.Game game = Classes.Metadata.Games.GetGame(metadataMap.SourceType, metadataMap.SourceId); Classes.RomMediaGroup.GameRomMediaGroupItem rom = Classes.RomMediaGroup.GetMediaGroup(RomGroupId); - if (rom.GameId == MetadataMapId) + if (rom != null) { Classes.RomMediaGroup.DeleteMediaGroup(RomGroupId); return Ok(rom); diff --git a/gaseous-server/wwwroot/index.html b/gaseous-server/wwwroot/index.html index 3a7278c..d28c519 100644 --- a/gaseous-server/wwwroot/index.html +++ b/gaseous-server/wwwroot/index.html @@ -106,7 +106,7 @@ AgeRatingBoardStrings = versionFile.AgeRatingBoardStrings; AgeRatingStrings = versionFile.AgeRatingStrings; AgeRatingGroups = versionFile.AgeRatingGroups; - emulatorDebugMode = versionFile.EmulatorDebugMode; + emulatorDebugMode = versionFile.emulatorDebugMode; // load scripts and style files // update script links diff --git a/gaseous-server/wwwroot/pages/emulator.js b/gaseous-server/wwwroot/pages/emulator.js index a87e672..e6ebe2b 100644 --- a/gaseous-server/wwwroot/pages/emulator.js +++ b/gaseous-server/wwwroot/pages/emulator.js @@ -29,7 +29,7 @@ function SetupPage() { gameData = result; if (result.cover) { - emuBackground = '/api/v1.1/Games/' + gameId + '/cover/' + result.cover.id + '/image/original/' + result.cover.imageId + '.jpg'; + emuBackground = '/api/v1.1/Games/' + gameId + '/cover/' + result.cover + '/image/original/' + result.cover + '.jpg'; } emuGameTitle = gameData.name; diff --git a/gaseous-server/wwwroot/pages/game.js b/gaseous-server/wwwroot/pages/game.js index ff07642..e675fe2 100644 --- a/gaseous-server/wwwroot/pages/game.js +++ b/gaseous-server/wwwroot/pages/game.js @@ -430,6 +430,7 @@ function LoadGamePlatforms() { // 1. if FavouriteRomId is not null, load the rom, otherwise // 2. if LastPlayedRomId is null, load the rom, otherwise // 3. load the rom management dialog + console.log(result[i]); if (result[i].emulatorConfiguration.emulatorType.length > 0 && result[i].emulatorConfiguration.core.length > 0 && result[i].favouriteRomId) { showSaveState = true; romId = result[i].favouriteRomId; @@ -687,6 +688,7 @@ class RomManagement { 'Content-Type': 'application/json' } }).then(response => response.json()).then(result => { + console.log(result); // display media groups if (result.length == 0) { this.MediaGroups.style.display = 'none'; @@ -821,7 +823,7 @@ class RomManagement { let deleteButton = new ModalButton("Delete", 2, deleteWindow, function (callingObject) { ajaxCall( - '/api/v1.1/Games/' + gameData.id + '/romgroup/' + mediaGroup.id, + '/api/v1.1/Games/' + gameId + '/romgroup/' + mediaGroup.id, 'DELETE', function (result) { thisObject.#loadRoms(); diff --git a/gaseous-server/wwwroot/scripts/main.js b/gaseous-server/wwwroot/scripts/main.js index af854e4..256723d 100644 --- a/gaseous-server/wwwroot/scripts/main.js +++ b/gaseous-server/wwwroot/scripts/main.js @@ -717,7 +717,7 @@ async function BuildLaunchLink(engine, core, platformId, gameId, romId, isMediaG // fetch valid cores from json file /emulators/EmulatorJS/data/cores.json let validCores = []; - await fetch('/emulators/EmulatorJS/data/cores/cores.json', { + await fetch('/api/v1.1/PlatformMaps', { method: 'GET', headers: { 'Content-Type': 'application/json' @@ -728,11 +728,26 @@ async function BuildLaunchLink(engine, core, platformId, gameId, romId, isMediaG validCores = data; for (let i = 0; i < validCores.length; i++) { - if (validCores[i].name == core) { - isValid = true; + isValid = false; + if (validCores[i].webEmulator) { + if (validCores[i].webEmulator.availableWebEmulators) { + for (let y = 0; y < validCores[i].webEmulator.availableWebEmulators.length; y++) { + if (validCores[i].webEmulator.availableWebEmulators[y].emulatorType == engine) { + for (let x = 0; x < validCores[i].webEmulator.availableWebEmulators[y].availableWebEmulatorCores.length; x++) { + if (validCores[i].webEmulator.availableWebEmulators[y].availableWebEmulatorCores[x].core == core || + validCores[i].webEmulator.availableWebEmulators[y].availableWebEmulatorCores[x].alternateCoreName == core + ) { + isValid = true; + break; + } + } + } + } + } + } + + if (isValid == true) { break; - } else { - isValid = false; } } if (isValid == false) {