feat: roms are now display by platform
This commit is contained in:
@@ -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; }
|
||||
|
@@ -149,6 +149,36 @@ namespace gaseous_server.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("{GameId}/alternativename")]
|
||||
[ProducesResponseType(typeof(List<AlternativeName>), 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<AlternativeName> altNames = new List<AlternativeName>();
|
||||
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<AgeRatings.GameAgeRating>), StatusCodes.Status200OK)]
|
||||
|
@@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@@ -1,7 +1,12 @@
|
||||
<div id="bgImage"></div>
|
||||
|
||||
<div id="gamepage">
|
||||
<div id="gametitle"><h1 id="gametitle_label"></h1></div>
|
||||
<div id="gametitle">
|
||||
<h1 id="gametitle_label"></h1>
|
||||
<p id="gametitle_alts">
|
||||
<span>Also known as: </span><span id="gametitle_alts_label"></span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="gamesummary">
|
||||
@@ -28,6 +33,9 @@
|
||||
|
||||
<p id="gamesummarytext_label_button_contract" class="text_link" style="display: none;" onclick="document.querySelector('#gamesummarytext_label').classList.add('line-clamp-4'); document.querySelector('#gamesummarytext_label_button_expand').setAttribute('style', ''); document.querySelector('#gamesummarytext_label_button_contract').setAttribute('style', 'display: none;');">Read less...</p>
|
||||
</div>
|
||||
<div id="gamesummaryroms">
|
||||
<h3>ROM's</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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 = [
|
||||
'<a href="/api/v1/Games/' + gameId + '/roms/' + result[i].id + '/file" class="romlink">' + result[i].name + '</a>',
|
||||
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;
|
||||
}
|
||||
</script>
|
@@ -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]}`
|
||||
}
|
@@ -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 {
|
||||
@@ -327,3 +330,31 @@ iframe {
|
||||
/* 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;
|
||||
}
|
Reference in New Issue
Block a user