diff --git a/gaseous-server/Classes/Roms.cs b/gaseous-server/Classes/Roms.cs index 4195489..919525a 100644 --- a/gaseous-server/Classes/Roms.cs +++ b/gaseous-server/Classes/Roms.cs @@ -92,6 +92,7 @@ namespace gaseous_server.Classes { Id = (long)romDR["id"], PlatformId = (long)romDR["platformid"], + Platform = Classes.Metadata.Platforms.GetPlatform((long)romDR["platformid"]), GameId = (long)romDR["gameid"], Name = (string)romDR["name"], Size = (long)romDR["size"], @@ -113,6 +114,7 @@ namespace gaseous_server.Classes { public long Id { get; set; } public long PlatformId { get; set; } + public IGDB.Models.Platform Platform { get; set; } public long GameId { get; set; } public string? Name { get; set; } public long Size { get; set; } diff --git a/gaseous-server/Controllers/GamesController.cs b/gaseous-server/Controllers/GamesController.cs index 27e4e54..0fd0ac9 100644 --- a/gaseous-server/Controllers/GamesController.cs +++ b/gaseous-server/Controllers/GamesController.cs @@ -149,6 +149,36 @@ namespace gaseous_server.Controllers } } + [HttpGet] + [Route("{GameId}/alternativename")] + [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public ActionResult GameAlternativeNames(long GameId) + { + try + { + Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false); + + if (gameObject.AlternativeNames != null) + { + List altNames = new List(); + foreach (long altNameId in gameObject.AlternativeNames.Ids) + { + altNames.Add(AlternativeNames.GetAlternativeNames(altNameId)); + } + return Ok(altNames); + } + else + { + return NotFound(); + } + } + catch + { + return NotFound(); + } + } + [HttpGet] [Route("{GameId}/agerating")] [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] diff --git a/gaseous-server/Support/PlatformMap.json b/gaseous-server/Support/PlatformMap.json index e403b63..c620907 100644 --- a/gaseous-server/Support/PlatformMap.json +++ b/gaseous-server/Support/PlatformMap.json @@ -18,8 +18,7 @@ ".G64", ".PRG", ".T64", - ".TAP", - ".Z64" + ".TAP" ] }, { @@ -62,5 +61,16 @@ ".SG", ".SMD" ] + }, + { + "IGDBId": 4, + "IGDBName": "Nintendo 64", + "AlternateNames": [ + "Nintendo 64", + "N64" + ], + "KnownFileExtensions": [ + ".Z64" + ] } ] diff --git a/gaseous-server/wwwroot/pages/game.html b/gaseous-server/wwwroot/pages/game.html index dc81f59..9bbe21c 100644 --- a/gaseous-server/wwwroot/pages/game.html +++ b/gaseous-server/wwwroot/pages/game.html @@ -1,7 +1,12 @@ 
-

+
+

+

+ Also known as: +

+
@@ -28,6 +33,9 @@
+
+

ROM's

+
@@ -47,6 +55,24 @@ var gameTitleLabel = document.getElementById('gametitle_label'); gameTitleLabel.innerHTML = result.name; + // get alt name + var gameTitleAltLabel = document.getElementById('gametitle_alts'); + if (result.alternativeNames) { + ajaxCall('/api/v1/Games/' + gameId + '/alternativename', 'GET', function (result) { + var altNames = ''; + for (var i = 0; i < result.length; i++) { + if (altNames.length > 0) { + altNames += ', '; + } + altNames += result[i].name; + } + var gameTitleAltLabelText = document.getElementById('gametitle_alts_label'); + gameTitleAltLabelText.innerHTML = altNames; + }); + } else { + gameTitleAltLabel.setAttribute('style', 'display: none;'); + } + // get summary var gameSummaryLabel = document.getElementById('gamesummarytext_label'); if (result.summary || result.storyline) { @@ -170,6 +196,44 @@ } else { gamescreenshots.setAttribute('style', 'display: none;'); } + + // load roms + var gameRoms = document.getElementById('gamesummaryroms'); + ajaxCall('/api/v1/Games/' + gameId + '/roms', 'GET', function (result) { + if (result) { + result.sort((a, b) => a.platform.name.charCodeAt(0) - b.platform.name.charCodeAt(0)); + + var newTable = document.createElement('table'); + newTable.className = 'romtable'; + newTable.setAttribute('cellspacing', 0); + newTable.appendChild(createTableRow(true, ['Name', 'Size', 'Media', ''])); + + var lastPlatform = ''; + for (var i = 0; i < result.length; i++) { + if (result[i].platform.name != lastPlatform) { + lastPlatform = result[i].platform.name; + var platformRow = document.createElement('tr'); + var platformHeader = document.createElement('th'); + platformHeader.setAttribute('colspan', 4); + platformHeader.innerHTML = result[i].platform.name; + platformRow.appendChild(platformHeader); + newTable.appendChild(platformRow); + } + + var newRow = [ + '' + result[i].name + '', + formatBytes(result[i].size, 2), + result[i].romTypeMedia, + result[i].mediaLabel + ]; + newTable.appendChild(createTableRow(false, newRow, 'romrow', 'romcell')); + } + + gameRoms.appendChild(newTable); + } else { + gameRoms.setAttribute('style', 'display: none;'); + } + }); }); function rotateBackground() { @@ -247,4 +311,24 @@ selectScreenshot(selectedScreenshot); } + + function createTableRow(isHeader, row, rowClass, cellClass) { + var newRow = document.createElement('tr'); + newRow.className = rowClass; + + for (var i = 0; i < row.length; i++) { + var cellType = 'td'; + if (isHeader == true) { + cellType = 'th'; + } + + var newCell = document.createElement(cellType); + newCell.innerHTML = row[i]; + newCell.className = cellClass; + + newRow.appendChild(newCell); + } + + return newRow; + } \ No newline at end of file diff --git a/gaseous-server/wwwroot/scripts/main.js b/gaseous-server/wwwroot/scripts/main.js index 9fc64e2..de5e108 100644 --- a/gaseous-server/wwwroot/scripts/main.js +++ b/gaseous-server/wwwroot/scripts/main.js @@ -22,3 +22,15 @@ } }); } + +function formatBytes(bytes, decimals = 2) { + if (!+bytes) return '0 Bytes' + + const k = 1024 + const dm = decimals < 0 ? 0 : decimals + const sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] + + const i = Math.floor(Math.log(bytes) / Math.log(k)) + + return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}` +} \ No newline at end of file diff --git a/gaseous-server/wwwroot/styles/style.css b/gaseous-server/wwwroot/styles/style.css index a435479..6927b06 100644 --- a/gaseous-server/wwwroot/styles/style.css +++ b/gaseous-server/wwwroot/styles/style.css @@ -9,9 +9,12 @@ } h3 { - text-decoration: underline; - text-decoration-color: #916b01; - text-decoration-thickness: 3px; + border-bottom-style: solid; + /*border-bottom-color: #916b01;*/ + border-bottom-width: 3px; + /*border-image: linear-gradient(to right, blue 25%, yellow 25%, yellow 50%,red 50%, red 75%, teal 75%) 5;*/ + + border-image: linear-gradient(to right, rgba(255,0,0,1) 0%, rgba(251,255,0,1) 16%, rgba(0,255,250,1) 30%, rgba(0,16,255,1) 46%, rgba(250,0,255,1) 62%, rgba(255,0,0,1) 78%, rgba(255,237,0,1) 90%, rgba(20,255,0,1) 100%) 5; } #banner_icon { @@ -326,4 +329,32 @@ iframe { -webkit-box-orient: vertical; /* truncate to 4 lines */ -webkit-line-clamp: 4; +} + +.romtable { + width: 100%; +} + +.romrow:hover { + background-color: #383838; +} + +.romcell { + padding: 5px; +} + +th { + text-align: left; + padding: 5px; +} + +.romlink { + color: white; + text-decoration: none; +} + +.romlink:hover { + color: white; + text-decoration: underline; + cursor: pointer; } \ No newline at end of file