Many bug and UI fixes, and improved client side caching of images (#248)

This commit is contained in:
Michael Green
2024-01-03 23:24:26 +11:00
committed by GitHub
parent 47c2fc8069
commit 49f36a2b99
62 changed files with 511 additions and 417 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -792,6 +792,15 @@ namespace gaseous_server.Classes
public string Name { get; set; } public string Name { get; set; }
public string Slug { get; set; } public string Slug { get; set; }
public long Cover { get; set;} public long Cover { get; set;}
public IGDB.Models.Cover CoverItem
{
get
{
IGDB.Models.Cover cover = Covers.GetCover(Cover, Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory, "Games", Slug), false);
return cover;
}
}
public CollectionItem.AlwaysIncludeItem InclusionStatus { get; set; } public CollectionItem.AlwaysIncludeItem InclusionStatus { get; set; }

View File

@@ -13,7 +13,7 @@ namespace gaseous_server.Classes.Metadata
{ {
} }
public static Artwork? GetArtwork(long? Id, string ImagePath) public static Artwork? GetArtwork(long? Id, string ImagePath, bool GetImages)
{ {
if ((Id == 0) || (Id == null)) if ((Id == 0) || (Id == null))
{ {
@@ -21,18 +21,18 @@ namespace gaseous_server.Classes.Metadata
} }
else else
{ {
Task<Artwork> RetVal = _GetArtwork(SearchUsing.id, Id, ImagePath); Task<Artwork> RetVal = _GetArtwork(SearchUsing.id, Id, ImagePath, GetImages);
return RetVal.Result; return RetVal.Result;
} }
} }
public static Artwork GetArtwork(string Slug, string ImagePath) public static Artwork GetArtwork(string Slug, string ImagePath, bool GetImages)
{ {
Task<Artwork> RetVal = _GetArtwork(SearchUsing.slug, Slug, ImagePath); Task<Artwork> RetVal = _GetArtwork(SearchUsing.slug, Slug, ImagePath, GetImages);
return RetVal.Result; return RetVal.Result;
} }
private static async Task<Artwork> _GetArtwork(SearchUsing searchUsing, object searchValue, string ImagePath) private static async Task<Artwork> _GetArtwork(SearchUsing searchUsing, object searchValue, string ImagePath, bool GetImages = true)
{ {
// check database first // check database first
Storage.CacheStatus? cacheStatus = new Storage.CacheStatus(); Storage.CacheStatus? cacheStatus = new Storage.CacheStatus();
@@ -67,14 +67,14 @@ namespace gaseous_server.Classes.Metadata
case Storage.CacheStatus.NotPresent: case Storage.CacheStatus.NotPresent:
returnValue = await GetObjectFromServer(WhereClause, ImagePath); returnValue = await GetObjectFromServer(WhereClause, ImagePath);
Storage.NewCacheValue(returnValue); Storage.NewCacheValue(returnValue);
forceImageDownload = true; if (GetImages == true) { forceImageDownload = true; }
break; break;
case Storage.CacheStatus.Expired: case Storage.CacheStatus.Expired:
try try
{ {
returnValue = await GetObjectFromServer(WhereClause, ImagePath); returnValue = await GetObjectFromServer(WhereClause, ImagePath);
Storage.NewCacheValue(returnValue, true); Storage.NewCacheValue(returnValue, true);
forceImageDownload = true; if (GetImages == true) { forceImageDownload = true; }
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -1,7 +1,9 @@
using System.ComponentModel; using System.ComponentModel;
using System.Drawing;
using System.Net; using System.Net;
using Humanizer; using Humanizer;
using IGDB; using IGDB;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using RestEase; using RestEase;
namespace gaseous_server.Classes.Metadata namespace gaseous_server.Classes.Metadata
@@ -318,6 +320,53 @@ namespace gaseous_server.Classes.Metadata
{ {
string returnPath = ""; string returnPath = "";
// check for artificial sizes first
switch (size)
{
case IGDBAPI_ImageSize.screenshot_small:
case IGDBAPI_ImageSize.screenshot_thumb:
string BasePath = Path.Combine(ImagePath, size.ToString());
if (!Directory.Exists(BasePath))
{
Directory.CreateDirectory(BasePath);
}
returnPath = Path.Combine(BasePath, ImageId + ".jpg");
if (!File.Exists(returnPath))
{
// get original size image and resize
string originalSizePath = await GetSpecificImageFromServer(ImagePath, ImageId, IGDBAPI_ImageSize.original, null);
int width = 0;
int height = 0;
switch (size)
{
case IGDBAPI_ImageSize.screenshot_small:
// 235x128
width = 235;
height = 128;
break;
case IGDBAPI_ImageSize.screenshot_thumb:
// 165x90
width = 165;
height = 90;
break;
}
using (var image = new ImageMagick.MagickImage(originalSizePath))
{
image.Resize(width, height);
image.Strip();
image.Write(returnPath);
}
}
break;
default:
// these sizes are IGDB native
if (RateLimitResumeTime > DateTime.UtcNow) if (RateLimitResumeTime > DateTime.UtcNow)
{ {
Logging.Log(Logging.LogType.Information, "API Connection", "IGDB rate limit hit. Pausing API communications until " + RateLimitResumeTime.ToString() + ". Attempt " + RetryAttempts + " of " + RetryAttemptsMax + " retries."); Logging.Log(Logging.LogType.Information, "API Connection", "IGDB rate limit hit. Pausing API communications until " + RateLimitResumeTime.ToString() + ". Attempt " + RetryAttempts + " of " + RetryAttemptsMax + " retries.");
@@ -341,8 +390,11 @@ namespace gaseous_server.Classes.Metadata
{ {
returnPath = Path.Combine(ImagePath, size.ToString(), ImageId + ".jpg"); returnPath = Path.Combine(ImagePath, size.ToString(), ImageId + ".jpg");
if (File.Exists(returnPath)) { File.Delete(returnPath); } // fail early if the file is already downloaded
if (!File.Exists(returnPath))
{
await comms.IGDBAPI_GetImage(imageSizes, ImageId, ImagePath); await comms.IGDBAPI_GetImage(imageSizes, ImageId, ImagePath);
}
} }
catch (HttpRequestException ex) catch (HttpRequestException ex)
@@ -364,6 +416,9 @@ namespace gaseous_server.Classes.Metadata
// increment rate limiter avoidance call count // increment rate limiter avoidance call count
RateLimitAvoidanceCallCount += 1; RateLimitAvoidanceCallCount += 1;
break;
}
return returnPath; return returnPath;
} }
@@ -383,25 +438,9 @@ namespace gaseous_server.Classes.Metadata
string OutputFile = ImageId + ".jpg"; string OutputFile = ImageId + ".jpg";
string fullPath = Path.Combine(newOutputPath, OutputFile); string fullPath = Path.Combine(newOutputPath, OutputFile);
bool AllowDownload = true;
FileInfo fi;
if (File.Exists(fullPath))
{
fi = new FileInfo(fullPath);
if (fi.LastWriteTimeUtc.AddDays(14) < DateTime.UtcNow)
{
File.Delete(fullPath);
AllowDownload = true;
}
}
if (AllowDownload == true)
{
await _DownloadFile(new Uri(url), fullPath); await _DownloadFile(new Uri(url), fullPath);
} }
} }
}
public enum IGDBAPI_ImageSize public enum IGDBAPI_ImageSize
{ {
@@ -417,6 +456,18 @@ namespace gaseous_server.Classes.Metadata
[Description("cover_big")] [Description("cover_big")]
cover_big, cover_big,
/// <summary>
/// 165x90 Lfill, Centre gravity - resized by Gaseous and is not a real IGDB size
/// </summary>
[Description("screenshot_thumb")]
screenshot_thumb,
/// <summary>
/// 235x128 Lfill, Centre gravity - resized by Gaseous and is not a real IGDB size
/// </summary>
[Description("screenshot_small")]
screenshot_small,
/// <summary> /// <summary>
/// 589x320 Lfill, Centre gravity /// 589x320 Lfill, Centre gravity
/// </summary> /// </summary>

View File

@@ -15,7 +15,7 @@ namespace gaseous_server.Classes.Metadata
{ {
} }
public static Cover? GetCover(long? Id, string ImagePath, bool GetImages = true) public static Cover? GetCover(long? Id, string ImagePath, bool GetImages)
{ {
if ((Id == 0) || (Id == null)) if ((Id == 0) || (Id == null))
{ {
@@ -28,7 +28,7 @@ namespace gaseous_server.Classes.Metadata
} }
} }
public static Cover GetCover(string Slug, string ImagePath, bool GetImages = true) public static Cover GetCover(string Slug, string ImagePath, bool GetImages)
{ {
Task<Cover> RetVal = _GetCover(SearchUsing.slug, Slug, ImagePath, GetImages); Task<Cover> RetVal = _GetCover(SearchUsing.slug, Slug, ImagePath, GetImages);
return RetVal.Result; return RetVal.Result;
@@ -91,7 +91,8 @@ namespace gaseous_server.Classes.Metadata
throw new Exception("How did you get here?"); throw new Exception("How did you get here?");
} }
if (forceImageDownload == true) string localFile = Path.Combine(ImagePath, Communications.IGDBAPI_ImageSize.original.ToString(), returnValue.ImageId + ".jpg");
if ((!File.Exists(localFile)) || forceImageDownload == true)
{ {
Logging.Log(Logging.LogType.Information, "Metadata: " + returnValue.GetType().Name, "Cover download forced."); Logging.Log(Logging.LogType.Information, "Metadata: " + returnValue.GetType().Name, "Cover download forced.");
@@ -105,7 +106,7 @@ namespace gaseous_server.Classes.Metadata
Communications comms = new Communications(); Communications comms = new Communications();
foreach (Communications.IGDBAPI_ImageSize size in imageSizes) foreach (Communications.IGDBAPI_ImageSize size in imageSizes)
{ {
string localFile = Path.Combine(ImagePath, size.ToString(), returnValue.ImageId + ".jpg"); localFile = Path.Combine(ImagePath, size.ToString(), returnValue.ImageId + ".jpg");
if ((!File.Exists(localFile)) || forceImageDownload == true) if ((!File.Exists(localFile)) || forceImageDownload == true)
{ {
comms.GetSpecificImageFromServer(ImagePath, returnValue.ImageId, size, null); comms.GetSpecificImageFromServer(ImagePath, returnValue.ImageId, size, null);

View File

@@ -98,14 +98,14 @@ namespace gaseous_server.Classes.Metadata
case Storage.CacheStatus.NotPresent: case Storage.CacheStatus.NotPresent:
returnValue = await GetObjectFromServer(WhereClause); returnValue = await GetObjectFromServer(WhereClause);
Storage.NewCacheValue(returnValue); Storage.NewCacheValue(returnValue);
UpdateSubClasses(returnValue, getAllMetadata, followSubGames); UpdateSubClasses(returnValue, getAllMetadata, followSubGames, forceRefresh);
return returnValue; return returnValue;
case Storage.CacheStatus.Expired: case Storage.CacheStatus.Expired:
try try
{ {
returnValue = await GetObjectFromServer(WhereClause); returnValue = await GetObjectFromServer(WhereClause);
Storage.NewCacheValue(returnValue, true); Storage.NewCacheValue(returnValue, true);
UpdateSubClasses(returnValue, getAllMetadata, followSubGames); UpdateSubClasses(returnValue, getAllMetadata, followSubGames, forceRefresh);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -115,21 +115,21 @@ namespace gaseous_server.Classes.Metadata
return returnValue; return returnValue;
case Storage.CacheStatus.Current: case Storage.CacheStatus.Current:
returnValue = Storage.GetCacheValue<Game>(returnValue, "id", (long)searchValue); returnValue = Storage.GetCacheValue<Game>(returnValue, "id", (long)searchValue);
UpdateSubClasses(returnValue, false, false); UpdateSubClasses(returnValue, false, false, false);
return returnValue; return returnValue;
default: default:
throw new Exception("How did you get here?"); throw new Exception("How did you get here?");
} }
} }
private static void UpdateSubClasses(Game Game, bool getAllMetadata, bool followSubGames) private static void UpdateSubClasses(Game Game, bool getAllMetadata, bool followSubGames, bool forceRefresh)
{ {
// required metadata // required metadata
if (Game.Cover != null) if (Game.Cover != null)
{ {
try try
{ {
Cover GameCover = Covers.GetCover(Game.Cover.Id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game), false); Cover GameCover = Covers.GetCover(Game.Cover.Id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game), forceRefresh);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -211,7 +211,7 @@ namespace gaseous_server.Classes.Metadata
{ {
try try
{ {
Artwork GameArtwork = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game)); Artwork GameArtwork = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game), forceRefresh);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -285,7 +285,7 @@ namespace gaseous_server.Classes.Metadata
{ {
try try
{ {
Screenshot GameScreenshot = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game)); Screenshot GameScreenshot = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game), forceRefresh);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -117,7 +117,7 @@ namespace gaseous_server.Classes.Metadata
{ {
// get Artwork metadata // get Artwork metadata
Communications comms = new Communications(); Communications comms = new Communications();
var results = await comms.APIComm<PlatformLogo>(IGDBClient.Endpoints.Artworks, fieldList, WhereClause); var results = await comms.APIComm<PlatformLogo>(IGDBClient.Endpoints.PlatformLogos, fieldList, WhereClause);
var result = results.First(); var result = results.First();
return result; return result;

View File

@@ -38,10 +38,18 @@ namespace gaseous_server.Classes.Metadata
} }
} }
else else
{
try
{ {
Task<Platform> RetVal = _GetPlatform(SearchUsing.id, Id, forceRefresh); Task<Platform> RetVal = _GetPlatform(SearchUsing.id, Id, forceRefresh);
return RetVal.Result; return RetVal.Result;
} }
catch(Exception ex)
{
Logging.Log(Logging.LogType.Warning, "Metadata", "An error occurred fetching Platform Id " + Id, ex);
return null;
}
}
} }
public static Platform GetPlatform(string Slug, bool forceRefresh = false) public static Platform GetPlatform(string Slug, bool forceRefresh = false)

View File

@@ -13,7 +13,7 @@ namespace gaseous_server.Classes.Metadata
{ {
} }
public static Screenshot? GetScreenshot(long? Id, string ImagePath) public static Screenshot? GetScreenshot(long? Id, string ImagePath, bool GetImages)
{ {
if ((Id == 0) || (Id == null)) if ((Id == 0) || (Id == null))
{ {
@@ -21,18 +21,18 @@ namespace gaseous_server.Classes.Metadata
} }
else else
{ {
Task<Screenshot> RetVal = _GetScreenshot(SearchUsing.id, Id, ImagePath); Task<Screenshot> RetVal = _GetScreenshot(SearchUsing.id, Id, ImagePath, GetImages);
return RetVal.Result; return RetVal.Result;
} }
} }
public static Screenshot GetScreenshot(string Slug, string ImagePath) public static Screenshot GetScreenshot(string Slug, string ImagePath, bool GetImages)
{ {
Task<Screenshot> RetVal = _GetScreenshot(SearchUsing.slug, Slug, ImagePath); Task<Screenshot> RetVal = _GetScreenshot(SearchUsing.slug, Slug, ImagePath, GetImages);
return RetVal.Result; return RetVal.Result;
} }
private static async Task<Screenshot> _GetScreenshot(SearchUsing searchUsing, object searchValue, string ImagePath) private static async Task<Screenshot> _GetScreenshot(SearchUsing searchUsing, object searchValue, string ImagePath, bool GetImages = true)
{ {
// check database first // check database first
Storage.CacheStatus? cacheStatus = new Storage.CacheStatus(); Storage.CacheStatus? cacheStatus = new Storage.CacheStatus();
@@ -67,14 +67,14 @@ namespace gaseous_server.Classes.Metadata
case Storage.CacheStatus.NotPresent: case Storage.CacheStatus.NotPresent:
returnValue = await GetObjectFromServer(WhereClause, ImagePath); returnValue = await GetObjectFromServer(WhereClause, ImagePath);
Storage.NewCacheValue(returnValue); Storage.NewCacheValue(returnValue);
forceImageDownload = true; if (GetImages == true) { forceImageDownload = true; }
break; break;
case Storage.CacheStatus.Expired: case Storage.CacheStatus.Expired:
try try
{ {
returnValue = await GetObjectFromServer(WhereClause, ImagePath); returnValue = await GetObjectFromServer(WhereClause, ImagePath);
Storage.NewCacheValue(returnValue, true); Storage.NewCacheValue(returnValue, true);
forceImageDownload = true; if (GetImages == true) { forceImageDownload = true; }
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -8,6 +8,7 @@ using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using gaseous_server.Classes; using gaseous_server.Classes;
using gaseous_server.Classes.Metadata; using gaseous_server.Classes.Metadata;
using gaseous_server.Models;
using IGDB.Models; using IGDB.Models;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@@ -291,7 +292,7 @@ namespace gaseous_server.Controllers
{ {
try try
{ {
IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, forceRefresh, false, forceRefresh); GaseousGame gameObject = new GaseousGame(Classes.Metadata.Games.GetGame(GameId, forceRefresh, false, forceRefresh));
if (gameObject != null) if (gameObject != null)
{ {
@@ -374,87 +375,6 @@ namespace gaseous_server.Controllers
} }
} }
[MapToApiVersion("1.0")]
[MapToApiVersion("1.1")]
[HttpGet]
[Route("{GameId}/agerating/{RatingId}/image")]
[ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameAgeClassification(long GameId, long RatingId)
{
try
{
GameAgeRating gameAgeRating = GetConsolidatedAgeRating(RatingId);
string fileExtension = "";
string fileType = "";
switch (gameAgeRating.RatingBoard)
{
case AgeRatingCategory.ESRB:
fileExtension = "svg";
fileType = "image/svg+xml";
break;
case AgeRatingCategory.PEGI:
fileExtension = "svg";
fileType = "image/svg+xml";
break;
case AgeRatingCategory.ACB:
fileExtension = "svg";
fileType = "image/svg+xml";
break;
case AgeRatingCategory.CERO:
fileExtension = "svg";
fileType = "image/svg+xml";
break;
case AgeRatingCategory.USK:
fileExtension = "svg";
fileType = "image/svg+xml";
break;
case AgeRatingCategory.GRAC:
fileExtension = "svg";
fileType = "image/svg+xml";
break;
case AgeRatingCategory.CLASS_IND:
fileExtension = "svg";
fileType = "image/svg+xml";
break;
}
string resourceName = "gaseous_server.Assets.Ratings." + gameAgeRating.RatingBoard.ToString() + "." + gameAgeRating.RatingTitle.ToString() + "." + fileExtension;
var assembly = Assembly.GetExecutingAssembly();
string[] resources = assembly.GetManifestResourceNames();
if (resources.Contains(resourceName))
{
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
byte[] filedata = new byte[stream.Length];
stream.Read(filedata, 0, filedata.Length);
string filename = gameAgeRating.RatingBoard.ToString() + "-" + gameAgeRating.RatingTitle.ToString() + "." + fileExtension;
string contentType = fileType;
var cd = new System.Net.Mime.ContentDisposition
{
FileName = filename,
Inline = true,
};
Response.Headers.Add("Content-Disposition", cd.ToString());
Response.Headers.Add("Cache-Control", "public, max-age=604800");
return File(filedata, contentType);
}
}
return NotFound();
}
catch
{
return NotFound();
}
}
[MapToApiVersion("1.0")] [MapToApiVersion("1.0")]
[MapToApiVersion("1.1")] [MapToApiVersion("1.1")]
[HttpGet] [HttpGet]
@@ -473,7 +393,7 @@ namespace gaseous_server.Controllers
{ {
foreach (long ArtworkId in gameObject.Artworks.Ids) foreach (long ArtworkId in gameObject.Artworks.Ids)
{ {
Artwork GameArtwork = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject)); Artwork GameArtwork = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), false);
artworks.Add(GameArtwork); artworks.Add(GameArtwork);
} }
} }
@@ -501,7 +421,7 @@ namespace gaseous_server.Controllers
try try
{ {
IGDB.Models.Artwork artworkObject = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject)); IGDB.Models.Artwork artworkObject = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), false);
if (artworkObject != null) if (artworkObject != null)
{ {
return Ok(artworkObject); return Ok(artworkObject);
@@ -526,9 +446,10 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.1")] [MapToApiVersion("1.1")]
[HttpGet] [HttpGet]
[Route("{GameId}/artwork/{ArtworkId}/image/{size}")] [Route("{GameId}/artwork/{ArtworkId}/image/{size}")]
[Route("{GameId}/artwork/{ArtworkId}/image/{size}/{ImageName}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameCoverImage(long GameId, long ArtworkId, Communications.IGDBAPI_ImageSize size) public ActionResult GameCoverImage(long GameId, long ArtworkId, Communications.IGDBAPI_ImageSize size, string ImageName)
{ {
try try
{ {
@@ -536,7 +457,7 @@ namespace gaseous_server.Controllers
try try
{ {
IGDB.Models.Artwork artworkObject = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject)); IGDB.Models.Artwork artworkObject = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), true);
if (artworkObject != null) { if (artworkObject != null) {
//string coverFilePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Artwork", size.ToString(), artworkObject.ImageId + ".jpg"); //string coverFilePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Artwork", size.ToString(), artworkObject.ImageId + ".jpg");
@@ -627,9 +548,10 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.1")] [MapToApiVersion("1.1")]
[HttpGet] [HttpGet]
[Route("{GameId}/cover/image/{size}")] [Route("{GameId}/cover/image/{size}")]
[Route("{GameId}/cover/image/{size}/{imagename}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameCoverImage(long GameId, Communications.IGDBAPI_ImageSize size) public ActionResult GameCoverImage(long GameId, Communications.IGDBAPI_ImageSize size, string imagename = "")
{ {
try try
{ {
@@ -1295,7 +1217,7 @@ namespace gaseous_server.Controllers
{ {
foreach (long ScreenshotId in gameObject.Screenshots.Ids) foreach (long ScreenshotId in gameObject.Screenshots.Ids)
{ {
Screenshot GameScreenshot = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject)); Screenshot GameScreenshot = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), false);
screenshots.Add(GameScreenshot); screenshots.Add(GameScreenshot);
} }
} }
@@ -1321,7 +1243,7 @@ namespace gaseous_server.Controllers
{ {
IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false); IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
if (gameObject != null) { if (gameObject != null) {
IGDB.Models.Screenshot screenshotObject = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject)); IGDB.Models.Screenshot screenshotObject = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), false);
if (screenshotObject != null) if (screenshotObject != null)
{ {
return Ok(screenshotObject); return Ok(screenshotObject);
@@ -1346,17 +1268,16 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.1")] [MapToApiVersion("1.1")]
[HttpGet] [HttpGet]
[Route("{GameId}/screenshots/{ScreenshotId}/image/{size}")] [Route("{GameId}/screenshots/{ScreenshotId}/image/{size}")]
[Route("{GameId}/screenshots/{ScreenshotId}/image/{size}/{ImageName}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameScreenshotImage(long GameId, long ScreenshotId, Communications.IGDBAPI_ImageSize Size) public ActionResult GameScreenshotImage(long GameId, long ScreenshotId, Communications.IGDBAPI_ImageSize Size, string ImageName)
{ {
try try
{ {
IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false); IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
IGDB.Models.Screenshot screenshotObject = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject)); IGDB.Models.Screenshot screenshotObject = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), true);
//string coverFilePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Screenshots", Size.ToString(), screenshotObject.ImageId + ".jpg");
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Screenshots"); string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Screenshots");

View File

@@ -0,0 +1,94 @@
using System.Reflection;
using gaseous_server.Classes;
using gaseous_server.Classes.Metadata;
using IGDB;
namespace gaseous_server.Models
{
public class GaseousGame : IGDB.Models.Game
{
public GaseousGame()
{
}
public GaseousGame(IGDB.Models.Game game)
{
var targetType = this.GetType();
var sourceType = game.GetType();
foreach(var prop in targetType.GetProperties(BindingFlags.Instance | BindingFlags.Public| BindingFlags.SetProperty))
{
// check whether source object has the the property
var sp = sourceType.GetProperty(prop.Name);
if (sp != null)
{
// if yes, copy the value to the matching property
var value = sp.GetValue(game, null);
prop.SetValue(this, value, null);
}
}
}
public IGDB.Models.Cover? CoverItem
{
get
{
if (this.Cover != null)
{
if (this.Cover.Id != null)
{
IGDB.Models.Cover cover = Covers.GetCover(Cover.Id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(this), false);
return cover;
}
}
return null;
}
}
public List<IGDB.Models.Artwork>? ArtworksItem
{
get
{
if (this.Artworks != null)
{
if (this.Artworks.Ids != null)
{
List<IGDB.Models.Artwork> artworks = new List<IGDB.Models.Artwork>();
foreach (long id in this.Artworks.Ids)
{
artworks.Add(gaseous_server.Classes.Metadata.Artworks.GetArtwork(id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(this), false));
}
return artworks;
}
}
return null;
}
}
public List<IGDB.Models.Screenshot>? ScreenshotsItem
{
get
{
if (this.Screenshots != null)
{
if (this.Screenshots.Ids != null)
{
List<IGDB.Models.Screenshot> screenshots = new List<IGDB.Models.Screenshot>();
foreach (long id in this.Screenshots.Ids)
{
screenshots.Add(gaseous_server.Classes.Metadata.Screenshots.GetScreenshot(id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(this), false));
}
return screenshots;
}
}
return null;
}
}
}
}

View File

@@ -253,8 +253,10 @@ namespace gaseous_server.Models
string sql = ""; string sql = "";
// get platform data // get platform data
IGDB.Models.Platform platform = Platforms.GetPlatform(IGDBId); IGDB.Models.Platform? platform = Platforms.GetPlatform(IGDBId);
if (platform != null)
{
// get platform alternate names // get platform alternate names
sql = "SELECT * FROM PlatformMap_AlternateNames WHERE Id = @Id ORDER BY Name"; sql = "SELECT * FROM PlatformMap_AlternateNames WHERE Id = @Id ORDER BY Name";
dbDict.Clear(); dbDict.Clear();
@@ -358,6 +360,9 @@ namespace gaseous_server.Models
return mapItem; return mapItem;
} }
return null;
}
public static void GetIGDBPlatformMapping(ref gaseous_server.Models.Signatures_Games Signature, FileInfo RomFileInfo, bool SetSystemName) public static void GetIGDBPlatformMapping(ref gaseous_server.Models.Signatures_Games Signature, FileInfo RomFileInfo, bool SetSystemName)
{ {
bool PlatformFound = false; bool PlatformFound = false;

View File

@@ -21,6 +21,7 @@
<PackageReference Include="gaseous-signature-parser" Version="2.0.0" /> <PackageReference Include="gaseous-signature-parser" Version="2.0.0" />
<PackageReference Include="gaseous.IGDB" Version="1.0.1" /> <PackageReference Include="gaseous.IGDB" Version="1.0.1" />
<PackageReference Include="hasheous-client" Version="0.1.0" /> <PackageReference Include="hasheous-client" Version="0.1.0" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.13" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.13" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
@@ -56,59 +57,6 @@
<None Remove="Support\Database\MySQL\gaseous-1010.sql" /> <None Remove="Support\Database\MySQL\gaseous-1010.sql" />
<None Remove="Support\Database\MySQL\gaseous-1011.sql" /> <None Remove="Support\Database\MySQL\gaseous-1011.sql" />
<None Remove="Classes\Metadata\" /> <None Remove="Classes\Metadata\" />
<None Remove="Assets\" />
<None Remove="Assets\Ratings\" />
<None Remove="Assets\Ratings\ESRB\" />
<None Remove="Assets\Ratings\ACB\" />
<None Remove="Assets\Ratings\PEGI\" />
<None Remove="Assets\Ratings\ESRB\AO.svg" />
<None Remove="Assets\Ratings\ESRB\E.svg" />
<None Remove="Assets\Ratings\ESRB\E10plus.svg" />
<None Remove="Assets\Ratings\ESRB\M.svg" />
<None Remove="Assets\Ratings\ESRB\RP.svg" />
<None Remove="Assets\Ratings\ESRB\RP-LM17-English.svg" />
<None Remove="Assets\Ratings\ESRB\T.svg" />
<None Remove="Assets\Ratings\CERO\" />
<None Remove="Assets\Ratings\CERO\CERO_A.png" />
<None Remove="Assets\Ratings\CERO\CERO_B.png" />
<None Remove="Assets\Ratings\CERO\CERO_C.png" />
<None Remove="Assets\Ratings\CERO\CERO_D.png" />
<None Remove="Assets\Ratings\CERO\CERO_Z.png" />
<None Remove="Assets\Ratings\USK\" />
<None Remove="Assets\Ratings\USK\USK_0.svg" />
<None Remove="Assets\Ratings\USK\USK_12.svg" />
<None Remove="Assets\Ratings\USK\USK_16.svg" />
<None Remove="Assets\Ratings\USK\USK_18.svg" />
<None Remove="Assets\Ratings\USK\USK_6.svg" />
<None Remove="Assets\Ratings\ACB\ACB_G.svg" />
<None Remove="Assets\Ratings\ACB\ACB_M.svg" />
<None Remove="Assets\Ratings\ACB\ACB_MA15.svg" />
<None Remove="Assets\Ratings\ACB\ACB_PG.svg" />
<None Remove="Assets\Ratings\ACB\ACB_R18.svg" />
<None Remove="Assets\Ratings\ACB\ACB_RC.svg" />
<None Remove="Assets\Ratings\CERO\CERO_A.svg" />
<None Remove="Assets\Ratings\CERO\CERO_B.svg" />
<None Remove="Assets\Ratings\CERO\CERO_C.svg" />
<None Remove="Assets\Ratings\CERO\CERO_D.svg" />
<None Remove="Assets\Ratings\CERO\CERO_Z.svg" />
<None Remove="Assets\Ratings\PEGI\Eighteen.svg" />
<None Remove="Assets\Ratings\PEGI\Seven.svg" />
<None Remove="Assets\Ratings\PEGI\Sixteen.svg" />
<None Remove="Assets\Ratings\PEGI\Three.svg" />
<None Remove="Assets\Ratings\PEGI\Twelve.svg" />
<None Remove="Assets\Ratings\GRAC\" />
<None Remove="Assets\Ratings\GRAC\GRAC_All.svg" />
<None Remove="Assets\Ratings\GRAC\GRAC_Eighteen.svg" />
<None Remove="Assets\Ratings\GRAC\GRAC_Fifteen.svg" />
<None Remove="Assets\Ratings\GRAC\GRAC_Testing.svg" />
<None Remove="Assets\Ratings\GRAC\GRAC_Twelve.svg" />
<None Remove="Assets\Ratings\CLASS_IND\" />
<None Remove="Assets\Ratings\CLASS_IND\CLASS_IND_Eighteen.svg" />
<None Remove="Assets\Ratings\CLASS_IND\CLASS_IND_Fourteen.svg" />
<None Remove="Assets\Ratings\CLASS_IND\CLASS_IND_L.svg" />
<None Remove="Assets\Ratings\CLASS_IND\CLASS_IND_Sixteen.svg" />
<None Remove="Assets\Ratings\CLASS_IND\CLASS_IND_Ten.svg" />
<None Remove="Assets\Ratings\CLASS_IND\CLASS_IND_Twelve.svg" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Controllers\" /> <Folder Include="Controllers\" />
@@ -117,15 +65,6 @@
<Folder Include="Classes\SignatureIngestors\" /> <Folder Include="Classes\SignatureIngestors\" />
<Folder Include="Support\" /> <Folder Include="Support\" />
<Folder Include="Classes\Metadata\" /> <Folder Include="Classes\Metadata\" />
<Folder Include="Assets\" />
<Folder Include="Assets\Ratings\" />
<Folder Include="Assets\Ratings\ESRB\" />
<Folder Include="Assets\Ratings\ACB\" />
<Folder Include="Assets\Ratings\PEGI\" />
<Folder Include="Assets\Ratings\CERO\" />
<Folder Include="Assets\Ratings\USK\" />
<Folder Include="Assets\Ratings\GRAC\" />
<Folder Include="Assets\Ratings\CLASS_IND\" />
<Folder Remove="Reference" /> <Folder Remove="Reference" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -138,45 +77,6 @@
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Assets\Ratings\ESRB\AO.svg" />
<EmbeddedResource Include="Assets\Ratings\ESRB\E.svg" />
<EmbeddedResource Include="Assets\Ratings\ESRB\E10.svg" />
<EmbeddedResource Include="Assets\Ratings\ESRB\M.svg" />
<EmbeddedResource Include="Assets\Ratings\ESRB\RP.svg" />
<EmbeddedResource Include="Assets\Ratings\ESRB\RP-LM17-English.svg" />
<EmbeddedResource Include="Assets\Ratings\ESRB\T.svg" />
<EmbeddedResource Include="Assets\Ratings\USK\USK_0.svg" />
<EmbeddedResource Include="Assets\Ratings\USK\USK_12.svg" />
<EmbeddedResource Include="Assets\Ratings\USK\USK_16.svg" />
<EmbeddedResource Include="Assets\Ratings\USK\USK_18.svg" />
<EmbeddedResource Include="Assets\Ratings\USK\USK_6.svg" />
<EmbeddedResource Include="Assets\Ratings\ACB\ACB_G.svg" />
<EmbeddedResource Include="Assets\Ratings\ACB\ACB_M.svg" />
<EmbeddedResource Include="Assets\Ratings\ACB\ACB_MA15.svg" />
<EmbeddedResource Include="Assets\Ratings\ACB\ACB_PG.svg" />
<EmbeddedResource Include="Assets\Ratings\ACB\ACB_R18.svg" />
<EmbeddedResource Include="Assets\Ratings\ACB\ACB_RC.svg" />
<EmbeddedResource Include="Assets\Ratings\CERO\CERO_A.svg" />
<EmbeddedResource Include="Assets\Ratings\CERO\CERO_B.svg" />
<EmbeddedResource Include="Assets\Ratings\CERO\CERO_C.svg" />
<EmbeddedResource Include="Assets\Ratings\CERO\CERO_D.svg" />
<EmbeddedResource Include="Assets\Ratings\CERO\CERO_Z.svg" />
<EmbeddedResource Include="Assets\Ratings\PEGI\Eighteen.svg" />
<EmbeddedResource Include="Assets\Ratings\PEGI\Seven.svg" />
<EmbeddedResource Include="Assets\Ratings\PEGI\Sixteen.svg" />
<EmbeddedResource Include="Assets\Ratings\PEGI\Three.svg" />
<EmbeddedResource Include="Assets\Ratings\PEGI\Twelve.svg" />
<EmbeddedResource Include="Assets\Ratings\GRAC\GRAC_All.svg" />
<EmbeddedResource Include="Assets\Ratings\GRAC\GRAC_Eighteen.svg" />
<EmbeddedResource Include="Assets\Ratings\GRAC\GRAC_Fifteen.svg" />
<EmbeddedResource Include="Assets\Ratings\GRAC\GRAC_Testing.svg" />
<EmbeddedResource Include="Assets\Ratings\GRAC\GRAC_Twelve.svg" />
<EmbeddedResource Include="Assets\Ratings\CLASS_IND\CLASS_IND_Eighteen.svg" />
<EmbeddedResource Include="Assets\Ratings\CLASS_IND\CLASS_IND_Fourteen.svg" />
<EmbeddedResource Include="Assets\Ratings\CLASS_IND\CLASS_IND_L.svg" />
<EmbeddedResource Include="Assets\Ratings\CLASS_IND\CLASS_IND_Sixteen.svg" />
<EmbeddedResource Include="Assets\Ratings\CLASS_IND\CLASS_IND_Ten.svg" />
<EmbeddedResource Include="Assets\Ratings\CLASS_IND\CLASS_IND_Twelve.svg" />
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1000.sql" /> <EmbeddedResource Include="Support\Database\MySQL\gaseous-1000.sql" />
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1001.sql" /> <EmbeddedResource Include="Support\Database\MySQL\gaseous-1001.sql" />
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1002.sql" /> <EmbeddedResource Include="Support\Database\MySQL\gaseous-1002.sql" />

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -480,7 +480,7 @@
} }
function DisplayPreview(data, targetDiv) { function DisplayPreview(data, targetDiv) {
console.log(JSON.stringify(data)); console.log(data);
var container = document.getElementById(targetDiv); var container = document.getElementById(targetDiv);
container.innerHTML = ''; container.innerHTML = '';
@@ -579,7 +579,7 @@
var gameImage = document.createElement('img'); var gameImage = document.createElement('img');
gameImage.className = 'game_tile_image game_tile_image_small'; gameImage.className = 'game_tile_image game_tile_image_small';
if (gameItem.cover) { if (gameItem.cover) {
gameImage.src = '/api/v1.1/Games/' + gameItem.id + '/cover/image/cover_small'; gameImage.src = '/api/v1.1/Games/' + gameItem.id + '/cover/image/cover_small/' + gameItem.coverItem.imageId + '.jpg';
} else { } else {
gameImage.src = '/images/unknowngame.png'; gameImage.src = '/images/unknowngame.png';
gameImage.className = 'game_tile_image game_tile_image_small unknown'; gameImage.className = 'game_tile_image game_tile_image_small unknown';

View File

@@ -208,7 +208,7 @@
for (var classBoard in classBoards) { for (var classBoard in classBoards) {
for (var rating in classBoards[classBoard]) { for (var rating in classBoards[classBoard]) {
ratingsValues += "<img src='/api/v1.1/Ratings/Images/" + classBoard + "/" + classBoards[classBoard][rating] + "/image.svg' class='rating_image_mini' />"; ratingsValues += "<img src='/images/Ratings/" + classBoard + "/" + AgeRatingStrings[classBoards[classBoard][rating]] + ".svg' class='rating_image_mini' />";
} }
} }

View File

@@ -34,17 +34,17 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<input type="checkbox" id="profile_pref_LibraryShowGameTitle" data-pref="LibraryShowGameTitle" data-minimum-results-for-search="Infinity"><label for="profile_pref_LibraryShowGameTitle"> Show title</label> <input type="checkbox" id="profile_pref_LibraryShowGameTitle" data-pref="LibraryShowGameTitle"><label for="profile_pref_LibraryShowGameTitle"> Show title</label>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<input type="checkbox" id="profile_pref_LibraryShowGameRating" data-pref="LibraryShowGameRating" data-minimum-results-for-search="Infinity"><label for="profile_pref_LibraryShowGameRating"> Show rating</label> <input type="checkbox" id="profile_pref_LibraryShowGameRating" data-pref="LibraryShowGameRating"><label for="profile_pref_LibraryShowGameRating"> Show rating</label>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<input type="checkbox" id="profile_pref_LibraryShowGameClassification" data-pref="LibraryShowGameClassification" onclick="updateDisplay(this.getAttribute('data-pref'), this.checked);"><label for="profile_pref_LibraryShowGameClassification"> Show age classification badges</label> <input type="checkbox" id="profile_pref_LibraryShowGameClassification" data-pref="LibraryShowGameClassification"><label for="profile_pref_LibraryShowGameClassification"> Show age classification badges</label>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -55,7 +55,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<select id="profile_pref_LibraryPrimaryClassificationBadge" data-primary="primary" onchange="SavePrefValue_ClassBadge(this);"> <select id="profile_pref_LibraryPrimaryClassificationBadge" data-primary="primary" data-minimum-results-for-search="Infinity" onchange="SavePrefValue_ClassBadge(this);">
</select> </select>
</td> </td>
</tr> </tr>
@@ -64,7 +64,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<select id="profile_pref_LibraryFallbackClassificationBadge" onchange="SavePrefValue_ClassBadge(this);"> <select id="profile_pref_LibraryFallbackClassificationBadge" onchange="SavePrefValue_ClassBadge(this);" data-minimum-results-for-search="Infinity">
</select> </select>
</td> </td>
</tr> </tr>
@@ -207,7 +207,9 @@
SetPreference_Batch(model); SetPreference_Batch(model);
if (getQueryString('page', 'string') == 'home' || getQueryString('page', 'string') == undefined) {
executeFilter1_1(1); executeFilter1_1(1);
}
closeDialog(); closeDialog();
} }
@@ -227,12 +229,12 @@
function updateDisplay(ValueName, ValueSetting) { function updateDisplay(ValueName, ValueSetting) {
switch(ValueName) { switch(ValueName) {
case "LibraryShowGameClassification": case "LibraryShowGameClassification":
var badgeSelector = document.getElementById("profile_pref_LibraryClassificationBadgeSelect"); // var badgeSelector = document.getElementById("profile_pref_LibraryClassificationBadgeSelect");
if (ValueSetting == true || ValueSetting == "true") { // if (ValueSetting == true || ValueSetting == "true") {
badgeSelector.style.display = ''; // badgeSelector.style.display = '';
} else { // } else {
badgeSelector.style.display = 'none'; // badgeSelector.style.display = 'none';
} // }
break; break;
} }
} }

View File

@@ -27,12 +27,12 @@
} else { } else {
if (result.cover) { if (result.cover) {
var bg = document.getElementById('bgImage'); var bg = document.getElementById('bgImage');
bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/cover/image/original"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);'); bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/cover/image/original/' + result.cover.imageId + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);');
} }
} }
if (result.cover) { if (result.cover) {
emuBackground = '/api/v1.1/Games/' + gameId + '/cover/image/original'; emuBackground = '/api/v1.1/Games/' + gameId + '/cover/image/original/' + result.cover.imageId + '.jpg';
} }
emuGameTitle = gameData.name; emuGameTitle = gameData.name;
@@ -59,7 +59,7 @@
artworksPosition = 0; artworksPosition = 0;
} }
var bg = document.getElementById('bgImage'); var bg = document.getElementById('bgImage');
bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/artwork/' + artworks[artworksPosition] + '/image/original"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);'); bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/artwork/' + artworks[artworksPosition] + '/image/original/' + artworks[artworksPosition] + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);');
} }
} }
</script> </script>

View File

@@ -102,6 +102,8 @@
var selectedScreenshot = 0; var selectedScreenshot = 0;
ajaxCall('/api/v1.1/Games/' + gameId, 'GET', function (result) { ajaxCall('/api/v1.1/Games/' + gameId, 'GET', function (result) {
console.log(result);
// populate games page // populate games page
gameData = result; gameData = result;
@@ -160,15 +162,15 @@
} }
// load artwork // load artwork
if (result.artworks) { if (result.artworksItem) {
artworks = result.artworks.ids; artworks = result.artworksItem;
var startPos = randomIntFromInterval(0, result.artworks.ids.length); var startPos = randomIntFromInterval(0, result.artworksItem.length);
artworksPosition = startPos; artworksPosition = startPos;
rotateBackground(); rotateBackground();
} else { } else {
var bg = document.getElementById('bgImage'); var bg = document.getElementById('bgImage');
if (result.cover) { if (result.coverItem) {
bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/cover/image/original"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);'); bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/cover/image/original/' + result.coverItem.imageId + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);');
} else { } else {
var randomInt = randomIntFromInterval(1, 3); var randomInt = randomIntFromInterval(1, 3);
bg.setAttribute('style', 'background-image: url("/images/gamebg' + randomInt + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);'); bg.setAttribute('style', 'background-image: url("/images/gamebg' + randomInt + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);');
@@ -234,7 +236,7 @@
var gameImage = document.createElement('img'); var gameImage = document.createElement('img');
gameImage.className = 'game_cover_image'; gameImage.className = 'game_cover_image';
if (result.cover) { if (result.cover) {
gameImage.src = '/api/v1.1/Games/' + result.id + '/cover/image/cover_big'; gameImage.src = '/api/v1.1/Games/' + result.id + '/cover/image/cover_big/' + result.coverItem.imageId + '.jpg';
} else { } else {
gameImage.src = '/images/unknowngame.png'; gameImage.src = '/images/unknowngame.png';
gameImage.className = 'game_cover_image unknown'; gameImage.className = 'game_cover_image unknown';
@@ -254,14 +256,44 @@
// load ratings // load ratings
var gameSummaryRatings = document.getElementById('gamesummary_ratings'); var gameSummaryRatings = document.getElementById('gamesummary_ratings');
if (result.ageRatings) { if (result.ageRatings) {
var gameRatings = document.createElement('div'); ajaxCall('/api/v1.1/games/' + gameId + '/agerating', 'GET', function (result) {
for (var i = 0; i < result.ageRatings.ids.length; i++) { var classTable = document.createElement('table');
var gameRatingsSml = document.createElement('div');
var SpotlightClassifications = GetPreference("LibraryGameClassificationDisplayOrder", JSON.stringify([ "ESRB" ]));
for (var i = 0; i < result.length; i++) {
var ratingImage = document.createElement('img'); var ratingImage = document.createElement('img');
ratingImage.src = '/api/v1.1/Games/' + result.id + '/agerating/' + result.ageRatings.ids[i] + '/image'; ratingImage.src = '/images/Ratings/' + result[i].ratingBoard + '/' + result[i].ratingTitle + '.svg';
ratingImage.className = 'rating_image'; var ratingString = ClassificationBoards[result[i].ratingBoard] + "\nRating: " + ClassificationRatings[result[i].ratingTitle];
gameRatings.appendChild(ratingImage); if (result[i].descriptions.length > 0) {
ratingString += '\nContains: ' + result[i].descriptions.join(', ');
} }
gameSummaryRatings.appendChild(gameRatings); ratingImage.title = ratingString;
if (SpotlightClassifications.includes(result[i].ratingBoard)) {
ratingImage.className = 'rating_image';
var classTableRow = document.createElement('tr');
var classTableLogo = document.createElement('td');
classTableLogo.className = 'rating_image_logo_table';
classTableLogo.appendChild(ratingImage);
classTableRow.appendChild(classTableLogo);
var classTableDescription = document.createElement('td');
if (result[i].descriptions.length > 0) {
classTableDescription.innerHTML = result[i].descriptions.join('<br />');
} else {
classTableDescription.innerHTML = ClassificationRatings[result[i].ratingTitle];
}
classTableRow.appendChild(classTableDescription);
classTable.appendChild(classTableRow);
} else {
ratingImage.className = 'rating_image rating_image_mini';
gameRatingsSml.appendChild(ratingImage);
}
}
gameSummaryRatings.appendChild(classTable);
gameSummaryRatings.appendChild(gameRatingsSml);
});
} else { } else {
gameSummaryRatings.setAttribute('style', 'display: none;'); gameSummaryRatings.setAttribute('style', 'display: none;');
} }
@@ -293,12 +325,12 @@
if (result.videos) { if (result.videos) {
imageIndex = result.videos.ids.length; imageIndex = result.videos.ids.length;
} }
if (result.screenshots) { if (result.screenshotsItem) {
for (var i = 0; i < result.screenshots.ids.length; i++) { for (var i = 0; i < result.screenshotsItem.length; i++) {
var screenshotItem = document.createElement('div'); var screenshotItem = document.createElement('div');
screenshotItem.id = 'gamescreenshots_gallery_' + imageIndex; screenshotItem.id = 'gamescreenshots_gallery_' + imageIndex;
screenshotItem.setAttribute('name', 'gamescreenshots_gallery_item'); screenshotItem.setAttribute('name', 'gamescreenshots_gallery_item');
screenshotItem.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/screenshots/' + result.screenshots.ids[i] + '/image/thumb"); background-position: center; background-repeat: no-repeat; background-size: contain;)'); screenshotItem.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/screenshots/' + result.screenshotsItem[i].id + '/image/screenshot_thumb/' + result.screenshotsItem[i].imageId + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: contain;)');
screenshotItem.setAttribute('imageid', imageIndex); screenshotItem.setAttribute('imageid', imageIndex);
screenshotItem.setAttribute('imagetype', 0); screenshotItem.setAttribute('imagetype', 0);
screenshotItem.className = 'gamescreenshots_gallery_item'; screenshotItem.className = 'gamescreenshots_gallery_item';
@@ -697,15 +729,19 @@
var romCounter = document.createElement('div'); var romCounter = document.createElement('div');
romCounter.className = 'games_library_controlblock'; romCounter.className = 'games_library_controlblock';
var romCounterLabel = document.createElement('span');
romCounterLabel.className = 'games_library_label';
if (result.count) { if (result.count) {
if (result.count < 1000) { if (result.count < 1000) {
romCounter.innerHTML = result.count + ' ROMs'; romCounterLabel.innerHTML = result.count + ' ROMs';
} else { } else {
romCounter.innerHTML = 'Maximum of 1000 ROMs'; romCounterLabel.innerHTML = 'Maximum of 1000 ROMs';
} }
} else { } else {
romCounter.innerHTML = '0 ROMs'; romCounterLabel.innerHTML = '0 ROMs';
} }
romCounter.appendChild(romCounterLabel);
filterControls.appendChild(romCounter); filterControls.appendChild(romCounter);
gameRoms.appendChild(filterControls); gameRoms.appendChild(filterControls);
@@ -718,7 +754,7 @@
artworksPosition = 0; artworksPosition = 0;
} }
var bg = document.getElementById('bgImage'); var bg = document.getElementById('bgImage');
bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/artwork/' + artworks[artworksPosition] + '/image/original"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);'); bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/artwork/' + artworks[artworksPosition].id + '/image/original/' + artworks[artworksPosition].imageId + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);');
artworksTimer = setTimeout(rotateBackground, 60000); artworksTimer = setTimeout(rotateBackground, 60000);
} }
} }
@@ -743,7 +779,7 @@
switch (gameScreenshots_Selected.getAttribute('imagetype')) { switch (gameScreenshots_Selected.getAttribute('imagetype')) {
case "0": case "0":
// screenshot // screenshot
gameScreenshots_Main.setAttribute('style', gameScreenshots_Selected.getAttribute('style').replace("/image/thumb", "/image/original")); gameScreenshots_Main.setAttribute('style', gameScreenshots_Selected.getAttribute('style').replace("/image/screenshot_thumb", "/image/original"));
break; break;
case "1": case "1":
// video // video

View File

@@ -8,8 +8,10 @@
<div id="games_home"> <div id="games_home">
<div id="games_home_box"> <div id="games_home_box">
<div id="games_library_controls"> <div id="games_library_controls">
<div class="games_library_controlblock">
<span class="games_library_label">Order by: </span>
</div>
<div id="games_library_orderby" class="games_library_controlblock" style="text-align: left;"> <div id="games_library_orderby" class="games_library_controlblock" style="text-align: left;">
<span>Order by: </span>
<select id="games_library_orderby_select" data-minimum-results-for-search="Infinity" onchange="executeFilter1_1(1);"> <select id="games_library_orderby_select" data-minimum-results-for-search="Infinity" onchange="executeFilter1_1(1);">
<option selected="selected" value="NameThe">Name, The</option> <option selected="selected" value="NameThe">Name, The</option>
<option value="Name">Name</option> <option value="Name">Name</option>
@@ -21,7 +23,9 @@
<option value="Descending">Descending</option> <option value="Descending">Descending</option>
</select> </select>
</div> </div>
<div id="games_library_recordcount" class="games_library_controlblock"></div> <div class="games_library_controlblock">
<span id="games_library_recordcount" class="games_library_label"></span>
</div>
</div> </div>
<div id="games_library"></div> <div id="games_library"></div>
<div id="games_library_pagerstore" style="display: none;">0</div> <div id="games_library_pagerstore" style="display: none;">0</div>

View File

@@ -8,6 +8,53 @@
"ACB": "Australian Classification Board (ACB)" "ACB": "Australian Classification Board (ACB)"
}; };
var ClassificationRatings = {
"E": "Everyone",
"E10": "Everyone 10+",
"T": "Teen",
"M": "Mature 17+",
"AO": "Adults Only 18+",
"RP": "Rating Pending",
"Three": "PEGI 3",
"Seven": "PEGI 7",
"Twelve": "PEGI 12",
"Sixteen": "PEGI 16",
"Eighteen": "PEGI 18",
"CERO_A": "All Ages",
"CERO_B": "Ages 12 and up",
"CERO_C": "Ages 15 and up",
"CERO_D": "Ages 17 and up",
"CERO_Z": "Ages 18 and up only",
"USK_0": "Approved without age restriction",
"USK_6": "Approved for children aged 6 and above",
"USK_12": "Approved for children aged 12 and above",
"USK_16": "Approved for children aged 16 and above",
"USK_18": "Not approved for young persons",
"GRAC_All": "All",
"GRAC_Twelve": "12+",
"GRAC_Fifteen": "15+",
"GRAC_Eighteen": "18+",
"GRAC_Testing": "Testing",
"CLASS_IND_L": "General Audiences",
"CLASS_IND_Ten": "Not recommended for minors under ten",
"CLASS_IND_Twelve": "Not recommended for minors under twelve",
"CLASS_IND_Fourteen": "Not recommended for minors under fourteen",
"CLASS_IND_Sixteen": "Not recommended for minors under sixteen",
"CLASS_IND_Eighteen": "Not recommended for minors under eighteen",
"ACB_G": "General",
"ACB_PG": "Parental Guidance",
"ACB_M": "Mature",
"ACB_MA15": "Mature Accompanied",
"ACB_R18": "Restricted",
"ACB_RC": "Refused Classification"
};
function formatGamesPanel(targetElement, result, pageNumber, pageSize) { function formatGamesPanel(targetElement, result, pageNumber, pageSize) {
console.log("Displaying page: " + pageNumber); console.log("Displaying page: " + pageNumber);
console.log("Page size: " + pageSize); console.log("Page size: " + pageSize);
@@ -194,7 +241,7 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
} }
gameImage.src = '/images/unknowngame.png'; gameImage.src = '/images/unknowngame.png';
if (gameObject.cover) { if (gameObject.cover) {
gameImage.setAttribute('data-src', '/api/v1.1/Games/' + gameObject.id + '/cover/image/cover_big'); gameImage.setAttribute('data-src', '/api/v1.1/Games/' + gameObject.id + '/cover/image/cover_big/' + gameObject.cover.imageId + '.jpg');
} else { } else {
gameImage.className = 'game_tile_image unknown'; gameImage.className = 'game_tile_image unknown';
} }
@@ -210,7 +257,8 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
if (gameObject.ageRatings[c].category == classificationDisplayOrder[b]) { if (gameObject.ageRatings[c].category == classificationDisplayOrder[b]) {
shownClassificationBoard = classificationDisplayOrder[b]; shownClassificationBoard = classificationDisplayOrder[b];
displayClassification = true; displayClassification = true;
classificationPath = '/api/v1.1/Ratings/Images/' + classificationDisplayOrder[b] + '/' + getKeyByValue(AgeRatingStrings, gameObject.ageRatings[c].rating) + '/image.svg'; //classificationPath = '/api/v1.1/Ratings/Images/' + classificationDisplayOrder[b] + '/' + getKeyByValue(AgeRatingStrings, gameObject.ageRatings[c].rating) + '/image.svg';
classificationPath = '/images/Ratings/' + classificationDisplayOrder[b] + '/' + gameObject.ageRatings[c].rating + '.svg';
} }
} }
} else { } else {

View File

@@ -245,7 +245,7 @@ function intToRGB(i) {
} }
function DropDownRenderGameOption(state) { function DropDownRenderGameOption(state) {
console.log(JSON.stringify(state)); console.log(state);
if (state.loading) { if (state.loading) {
return state; return state;
@@ -260,7 +260,7 @@ function DropDownRenderGameOption(state) {
if (state.cover) { if (state.cover) {
response = $( response = $(
'<table class="dropdown-div"><tr><td class="dropdown-cover"><img src="/api/v1.1/Games/' + state.id + '/cover/image/cover_small" /></td><td class="dropdown-label"><span class="dropdown-title">' + state.text + '</span><span class="dropdown-releasedate">' + releaseDate + '</span></td></tr></table>' '<table class="dropdown-div"><tr><td class="dropdown-cover"><img src="/api/v1.1/Games/' + state.id + '/cover/image/cover_small/' + state.cover.value.imageId + '.jpg" /></td><td class="dropdown-label"><span class="dropdown-title">' + state.text + '</span><span class="dropdown-releasedate">' + releaseDate + '</span></td></tr></table>'
); );
} else { } else {
response = $( response = $(

View File

@@ -289,6 +289,7 @@ input[type='text'], input[type='number'], input[type="email"], input[type="passw
border-style: solid; border-style: solid;
/* border-color: lightgray; */ /* border-color: lightgray; */
border-color: #2b2b2b; border-color: #2b2b2b;
height: 21px;
} }
input[type='text']:hover, input[type='number']:hover, input[type="email"]:hover, input[type="password"]:hover, input[type="datetime-local"]:hover { input[type='text']:hover, input[type='number']:hover, input[type="email"]:hover, input[type="password"]:hover, input[type="datetime-local"]:hover {
@@ -448,13 +449,21 @@ input[id='filter_panel_userrating_max'] {
border-color: #2b2b2b; border-color: #2b2b2b;
border-radius: 5px; border-radius: 5px;
margin-bottom: 10px; margin-bottom: 10px;
padding: 10px; padding-top: 7px;
padding-bottom: 10px;
padding-right: 20px;
text-align: right; text-align: right;
} }
.games_library_controlblock { .games_library_controlblock {
margin-left: 20px; margin-left: 10px;
display: inline-block; display: inline-block;
vertical-align: top;
}
.games_library_label {
display: inline-block;
padding-top: 7px;
} }
#games_library { #games_library {
@@ -636,13 +645,17 @@ input[id='filter_panel_userrating_max'] {
.rating_image { .rating_image {
display: inline-block; display: inline-block;
height: 64px;
max-width: 64px; max-width: 64px;
max-height: 64px; max-height: 64px;
margin-right: 20px; margin-right: 20px;
margin-bottom: 20px; /* margin-bottom: 20px; */
box-shadow: 5px 5px 19px 0px rgba(0,0,0,0.44); }
-webkit-box-shadow: 5px 5px 19px 0px rgba(0,0,0,0.44);
-moz-box-shadow: 5px 5px 19px 0px rgba(0,0,0,0.44); .rating_image_logo_table {
min-height: 70px;
min-width: 70px;
text-align: center;
} }
.rating_image_mini { .rating_image_mini {
@@ -1001,7 +1014,7 @@ div[name="properties_toc_item"]:hover,div[name="properties_user_toc_item"]:hover
color: lightgray; color: lightgray;
} }
button { button:not(.select2-selection__choice__remove):not(.ejs_menu_button) {
background-color: #555; background-color: #555;
color: white; color: white;
border-width: 1px; border-width: 1px;
@@ -1009,10 +1022,12 @@ button {
border-style: solid; border-style: solid;
padding-top: 5px; padding-top: 5px;
padding-bottom: 5px; padding-bottom: 5px;
padding-left: 10px; padding-left: 15px;
padding-right: 10px; padding-right: 15px;
margin-right: 3px; margin-right: 3px;
margin-bottom: 3px; margin-bottom: 3px;
font-size: 13px;
height: 30px;
} }
button:hover { button:hover {