diff --git a/gaseous-server/Classes/Metadata/Communications.cs b/gaseous-server/Classes/Metadata/Communications.cs index 37cd181..a26177a 100644 --- a/gaseous-server/Classes/Metadata/Communications.cs +++ b/gaseous-server/Classes/Metadata/Communications.cs @@ -1298,7 +1298,7 @@ namespace gaseous_server.Classes.Metadata Platform? platform = Platforms.GetPlatform(Id); if (platform != null) { - platform.PlatformLogo = platformLogo.Id; + platform.PlatformLogo = (long)platformLogo.Id; Storage.NewCacheValue(HasheousClient.Models.MetadataSources.None, platform, true); } } diff --git a/gaseous-server/Classes/Metadata/Games.cs b/gaseous-server/Classes/Metadata/Games.cs index 4f49bbd..8ba7eaf 100644 --- a/gaseous-server/Classes/Metadata/Games.cs +++ b/gaseous-server/Classes/Metadata/Games.cs @@ -454,7 +454,7 @@ ORDER BY Platform.`Name`;"; public bool IsFavourite { get; set; } = false; public DateTimeOffset? FirstReleaseDate { get; set; } public object Cover { get; set; } - public List Artworks { get; set; } + public List Artworks { get; set; } public List AgeRatings { get; set; } } } diff --git a/gaseous-server/Classes/Metadata/Platforms.cs b/gaseous-server/Classes/Metadata/Platforms.cs index 9b42194..8b9d14b 100644 --- a/gaseous-server/Classes/Metadata/Platforms.cs +++ b/gaseous-server/Classes/Metadata/Platforms.cs @@ -18,14 +18,30 @@ namespace gaseous_server.Classes.Metadata { if ((Id == 0) || (Id == null)) { - return null; + Platform returnValue = new Platform(); + if (Storage.GetCacheStatus(Communications.MetadataSource, "Platform", 0) == Storage.CacheStatus.NotPresent) + { + returnValue = new Platform + { + Id = 0, + Name = "Unknown Platform", + Slug = "Unknown" + }; + Storage.NewCacheValue(Communications.MetadataSource, returnValue); + + return returnValue; + } + else + { + return Storage.GetCacheValue(Communications.MetadataSource, returnValue, "id", 0); + } } else { Platform? RetVal = new Platform(); if (Config.MetadataConfiguration.DefaultMetadataSource == HasheousClient.Models.MetadataSources.None) { - + RetVal = (Platform?)Storage.GetCacheValue(HasheousClient.Models.MetadataSources.None, RetVal, "Id", (long)Id); } else diff --git a/gaseous-server/Classes/MetadataManagement.cs b/gaseous-server/Classes/MetadataManagement.cs index c24d200..45e125a 100644 --- a/gaseous-server/Classes/MetadataManagement.cs +++ b/gaseous-server/Classes/MetadataManagement.cs @@ -334,7 +334,7 @@ namespace gaseous_server.Classes else { // when run normally, update all games (since this will honour cache timeouts) - sql = "SELECT Id, `Name` FROM Game;"; + sql = "SELECT MetadataSourceId AS `Id`, MetadataSourceType AS `GameIdType`, SignatureGameName AS `Name` FROM gaseous.view_MetadataMap;"; } dt = db.ExecuteCMD(sql); @@ -345,8 +345,8 @@ namespace gaseous_server.Classes try { - MetadataSources metadataSource = MetadataSources.IGDB; - Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for game " + dr["name"] + " (" + dr["id"] + ")"); + MetadataSources metadataSource = (MetadataSources)Enum.Parse(typeof(MetadataSources), dr["GameIdType"].ToString()); + Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for game " + dr["name"] + " (" + dr["id"] + ") using source " + metadataSource.ToString()); HasheousClient.Models.Metadata.IGDB.Game game = Metadata.Games.GetGame(metadataSource, (long)dr["id"]); // get supporting metadata diff --git a/gaseous-server/Controllers/V1.0/PlatformsController.cs b/gaseous-server/Controllers/V1.0/PlatformsController.cs index 6c65c0d..60bbd6a 100644 --- a/gaseous-server/Controllers/V1.0/PlatformsController.cs +++ b/gaseous-server/Controllers/V1.0/PlatformsController.cs @@ -77,44 +77,45 @@ namespace gaseous_server.Controllers } } - [MapToApiVersion("1.0")] - [MapToApiVersion("1.1")] - [HttpGet] - [Route("{PlatformId}/platformlogo")] - [ProducesResponseType(typeof(PlatformLogo), StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] - public ActionResult PlatformLogo(long PlatformId) - { - try - { - Platform platformObject = Classes.Metadata.Platforms.GetPlatform(PlatformId); - if (platformObject != null) - { - PlatformLogo logoObjectParent = (PlatformLogo)platformObject.PlatformLogo; - PlatformLogo logoObject = PlatformLogos.GetPlatformLogo(logoObjectParent.Id); - if (logoObject != null) - { - return Ok(logoObject); - } - else - { - return NotFound(); - } - } - else - { - return NotFound(); - } - } - catch - { - return NotFound(); - } - } + // [MapToApiVersion("1.0")] + // [MapToApiVersion("1.1")] + // [HttpGet] + // [Route("{PlatformId}/platformlogo")] + // [ProducesResponseType(typeof(PlatformLogo), StatusCodes.Status200OK)] + // [ProducesResponseType(StatusCodes.Status404NotFound)] + // public ActionResult PlatformLogo(long PlatformId) + // { + // try + // { + // Platform platformObject = Classes.Metadata.Platforms.GetPlatform(PlatformId); + // if (platformObject != null) + // { + // PlatformLogo logoObjectParent = (PlatformLogo)platformObject.PlatformLogo; + // PlatformLogo logoObject = PlatformLogos.GetPlatformLogo(logoObjectParent.Id); + // if (logoObject != null) + // { + // return Ok(logoObject); + // } + // else + // { + // return NotFound(); + // } + // } + // else + // { + // return NotFound(); + // } + // } + // catch + // { + // return NotFound(); + // } + // } [MapToApiVersion("1.0")] [MapToApiVersion("1.1")] [HttpGet] + [Route("{PlatformId}/platformlogo/{size}/")] [Route("{PlatformId}/platformlogo/{size}/logo.png")] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] @@ -124,12 +125,10 @@ namespace gaseous_server.Controllers { Platform platformObject = Classes.Metadata.Platforms.GetPlatform(PlatformId); PlatformLogo? logoObject = null; - try - { - logoObject = PlatformLogos.GetPlatformLogo((long)platformObject.PlatformLogo, Communications.MetadataSource); - } - catch + logoObject = PlatformLogos.GetPlatformLogo((long)platformObject.PlatformLogo, Communications.MetadataSource); + + if (logoObject == null) { // getting the logo failed, so we'll try a platform variant if available if (platformObject.Versions != null) diff --git a/gaseous-server/gaseous-server.csproj b/gaseous-server/gaseous-server.csproj index f11a46f..9cef16e 100644 --- a/gaseous-server/gaseous-server.csproj +++ b/gaseous-server/gaseous-server.csproj @@ -20,7 +20,7 @@ - + diff --git a/gaseous-server/wwwroot/pages/game.js b/gaseous-server/wwwroot/pages/game.js index e675fe2..788ee34 100644 --- a/gaseous-server/wwwroot/pages/game.js +++ b/gaseous-server/wwwroot/pages/game.js @@ -411,7 +411,7 @@ function LoadGamePlatforms() { let platformContainer = document.getElementById('gamesummaryplatformscontent'); platformContainer.innerHTML = ''; for (let i = 0; i < result.length; i++) { - let logoUrl = '/api/v1.1/Platforms/' + result[i].id + '/platformlogo/original/logo.png'; + let logoUrl = '/api/v1.1/Platforms/' + result[i].id + '/platformlogo/original/'; // create platform container let platformItem = document.createElement('div'); diff --git a/gaseous-server/wwwroot/pages/settings/mapping.js b/gaseous-server/wwwroot/pages/settings/mapping.js index 8c16203..abf0094 100644 --- a/gaseous-server/wwwroot/pages/settings/mapping.js +++ b/gaseous-server/wwwroot/pages/settings/mapping.js @@ -28,12 +28,17 @@ function loadPlatformMapping(Overwrite) { ); for (let i = 0; i < result.length; i++) { + let logoBox = document.createElement('div'); + logoBox.classList.add('platform_image_container'); + let logo = document.createElement('img'); - logo.src = '/api/v1.1/Platforms/' + result[i].igdbId + '/platformlogo/original/logo.png'; + logo.src = '/api/v1.1/Platforms/' + result[i].igdbId + '/platformlogo/original/'; logo.alt = result[i].igdbName; logo.title = result[i].igdbName; logo.classList.add('platform_image'); + logoBox.appendChild(logo); + let hasWebEmulator = ''; if (result[i].webEmulator.type.length > 0) { hasWebEmulator = 'Yes'; @@ -56,7 +61,7 @@ function loadPlatformMapping(Overwrite) { } let newRow = [ - logo, + logoBox, result[i].igdbName, result[i].extensions.supportedFileExtensions.join(', '), result[i].extensions.uniqueFileExtensions.join(', '), diff --git a/gaseous-server/wwwroot/styles/style.css b/gaseous-server/wwwroot/styles/style.css index 0674f01..c997e2e 100644 --- a/gaseous-server/wwwroot/styles/style.css +++ b/gaseous-server/wwwroot/styles/style.css @@ -2958,6 +2958,8 @@ button:not(.select2-selection__choice__remove):not(.select2-selection__clear):no justify-content: center; align-items: center; + padding-top: 10px; + padding-bottom: 10px; padding-left: 20px; padding-right: 20px; background-color: white; @@ -2965,6 +2967,7 @@ button:not(.select2-selection__choice__remove):not(.select2-selection__clear):no .platform_image { width: 70px; + max-height: 70px; } .platform_name_container {