From 49f36a2b99f22a33a48bb9f582874bc896279cf1 Mon Sep 17 00:00:00 2001 From: Michael Green <84688932+michael-j-green@users.noreply.github.com> Date: Wed, 3 Jan 2024 23:24:26 +1100 Subject: [PATCH] Many bug and UI fixes, and improved client side caching of images (#248) --- gaseous-server/Assets/.DS_Store | Bin 6148 -> 0 bytes gaseous-server/Assets/Ratings/.DS_Store | Bin 8196 -> 0 bytes gaseous-server/Classes/Collections.cs | 9 + gaseous-server/Classes/Metadata/Artworks.cs | 14 +- .../Classes/Metadata/Communications.cs | 163 +++++++++++------ gaseous-server/Classes/Metadata/Covers.cs | 9 +- gaseous-server/Classes/Metadata/Games.cs | 14 +- .../Classes/Metadata/PlatformLogos.cs | 2 +- gaseous-server/Classes/Metadata/Platforms.cs | 12 +- .../Classes/Metadata/Screenshots.cs | 14 +- .../Controllers/V1.0/GamesController.cs | 107 ++--------- gaseous-server/Models/GaseousGame.cs | 94 ++++++++++ gaseous-server/Models/PlatformMapping.cs | 171 +++++++++--------- gaseous-server/gaseous-server.csproj | 102 +---------- .../images}/Ratings/ACB/ACB_G.svg | 0 .../images}/Ratings/ACB/ACB_M.svg | 0 .../images}/Ratings/ACB/ACB_MA15.svg | 0 .../images}/Ratings/ACB/ACB_PG.svg | 0 .../images}/Ratings/ACB/ACB_R18.svg | 0 .../images}/Ratings/ACB/ACB_RC.svg | 0 .../images}/Ratings/CERO/CERO_A.svg | 0 .../images}/Ratings/CERO/CERO_B.svg | 0 .../images}/Ratings/CERO/CERO_C.svg | 0 .../images}/Ratings/CERO/CERO_D.svg | 0 .../images}/Ratings/CERO/CERO_Z.svg | 0 .../Ratings/CLASS_IND/CLASS_IND_Eighteen.svg | 0 .../Ratings/CLASS_IND/CLASS_IND_Fourteen.svg | 0 .../images}/Ratings/CLASS_IND/CLASS_IND_L.svg | 0 .../Ratings/CLASS_IND/CLASS_IND_Sixteen.svg | 0 .../Ratings/CLASS_IND/CLASS_IND_Ten.svg | 0 .../Ratings/CLASS_IND/CLASS_IND_Twelve.svg | 0 .../images}/Ratings/ESRB/AO.svg | 0 .../images}/Ratings/ESRB/E.svg | 0 .../images}/Ratings/ESRB/E10.svg | 0 .../images}/Ratings/ESRB/M.svg | 0 .../images}/Ratings/ESRB/RP-LM17-English.svg | 0 .../images}/Ratings/ESRB/RP.svg | 0 .../images}/Ratings/ESRB/T.svg | 0 .../images}/Ratings/GRAC/GRAC_All.svg | 0 .../images}/Ratings/GRAC/GRAC_Eighteen.svg | 0 .../images}/Ratings/GRAC/GRAC_Fifteen.svg | 0 .../images}/Ratings/GRAC/GRAC_Testing.svg | 0 .../images}/Ratings/GRAC/GRAC_Twelve.svg | 0 .../images}/Ratings/PEGI/Eighteen.svg | 0 .../images}/Ratings/PEGI/Seven.svg | 0 .../images}/Ratings/PEGI/Sixteen.svg | 0 .../images}/Ratings/PEGI/Three.svg | 0 .../images}/Ratings/PEGI/Twelve.svg | 0 .../images}/Ratings/USK/USK_0.svg | 0 .../images}/Ratings/USK/USK_12.svg | 0 .../images}/Ratings/USK/USK_16.svg | 0 .../images}/Ratings/USK/USK_18.svg | 0 .../images}/Ratings/USK/USK_6.svg | 0 .../wwwroot/pages/dialogs/collectionedit.html | 4 +- .../pages/dialogs/settingsuseredit.html | 2 +- .../wwwroot/pages/dialogs/userprofile.html | 28 +-- gaseous-server/wwwroot/pages/emulator.html | 6 +- gaseous-server/wwwroot/pages/game.html | 80 +++++--- gaseous-server/wwwroot/pages/home.html | 8 +- .../wwwroot/scripts/gamesformating.js | 52 +++++- gaseous-server/wwwroot/scripts/main.js | 4 +- gaseous-server/wwwroot/styles/style.css | 33 +++- 62 files changed, 511 insertions(+), 417 deletions(-) delete mode 100644 gaseous-server/Assets/.DS_Store delete mode 100644 gaseous-server/Assets/Ratings/.DS_Store create mode 100644 gaseous-server/Models/GaseousGame.cs rename gaseous-server/{Assets => wwwroot/images}/Ratings/ACB/ACB_G.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ACB/ACB_M.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ACB/ACB_MA15.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ACB/ACB_PG.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ACB/ACB_R18.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ACB/ACB_RC.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CERO/CERO_A.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CERO/CERO_B.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CERO/CERO_C.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CERO/CERO_D.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CERO/CERO_Z.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CLASS_IND/CLASS_IND_Eighteen.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CLASS_IND/CLASS_IND_Fourteen.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CLASS_IND/CLASS_IND_L.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CLASS_IND/CLASS_IND_Sixteen.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CLASS_IND/CLASS_IND_Ten.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/CLASS_IND/CLASS_IND_Twelve.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ESRB/AO.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ESRB/E.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ESRB/E10.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ESRB/M.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ESRB/RP-LM17-English.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ESRB/RP.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/ESRB/T.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/GRAC/GRAC_All.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/GRAC/GRAC_Eighteen.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/GRAC/GRAC_Fifteen.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/GRAC/GRAC_Testing.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/GRAC/GRAC_Twelve.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/PEGI/Eighteen.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/PEGI/Seven.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/PEGI/Sixteen.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/PEGI/Three.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/PEGI/Twelve.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/USK/USK_0.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/USK/USK_12.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/USK/USK_16.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/USK/USK_18.svg (100%) rename gaseous-server/{Assets => wwwroot/images}/Ratings/USK/USK_6.svg (100%) diff --git a/gaseous-server/Assets/.DS_Store b/gaseous-server/Assets/.DS_Store deleted file mode 100644 index dd4ab63c88e494c223205350729575b214a0c1ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKK}+L66n;~yNf4ojUGNwXJc(BA9%L`sS`XgDEbBp+ZemIerkT>D+e0bjCg|Vs z;L(eJ!JnhPH!~G&c46_bh`a}HzBe=9o5_3$GZ_F7&0(|&Py+xPov`9y@du-R@{(0d zi-joE7%6li+fU?an3UMu@E#SQcW1#N1du}vFW#RFv4=j3Z|Lif$}lRi!%@}`6UDv> z`$?ST_4>W2%vI+XEX%PLt)Kpx9Qk>W53^=4IHuZnDU)y-2jP#nGiuj9?aDL{;+hEFWZwfcf7Mz$9QLJGI8wBD;r-A z+viCym6z(dLEty4Y{}pht}vL;(GPu;oy#xni;1j zqkmxa&tA;7aErstj`Q0eq=`(s*fU)PvDjDvR)7_Fn*wGhu@~Q#&RMJgEAW98p#8x` zC-e*!8r9Z;g}MSDRu%YdeLFLoncvLY&7?%cihH#=q6s2O zqjQ=a#}LyvpZAeArdFmw8T2XIss>RNPuUS!x8M+P2si{B0uBL(z`ub2?rh%DN8J08 z>qduwL*TzefS(T@I;RCidyjd9JoVV$jk24GS z)!*|g_S#1IY0wCx7t&3pjtV*_pY`|>Gv!UNGv{wbji%(i zZ4Ee$s8mvZrVr20PWAI2IU-805!H_2Hh0ZkKl9C%-ZQ@y22r?!6>eP;xUbL#-5$dJ z9e5`8TJDsful=#`XYaq6n3xf`KCL65blv7!Au8y3vP5jFjosW?p+0D>=xq<0UOmNhEU;dF3OshTdw%bKmqs%bl9c zQhwXf__QFRuXtt*ey-~nXe`XkisM^&%Tq?{4rNx7RuKi9uS5CtVkPv+W+^CzqW+O3t>sH7WL1Jk##4yN2DG zKd?KFA7gid?jgU|ZR>zD(JSlD5>l3JZ1N4Hl)h=%<>%Tm%^lb^%C)RwIc$2uT0+`8 z!R!B(qksQDVO}|N9Rd!4KS6*cOMa;c4SAJ~s`6UfLw|zK8<*=zDpW9tavW5Y RetVal = _GetArtwork(SearchUsing.id, Id, ImagePath); + Task RetVal = _GetArtwork(SearchUsing.id, Id, ImagePath, GetImages); return RetVal.Result; } } - public static Artwork GetArtwork(string Slug, string ImagePath) + public static Artwork GetArtwork(string Slug, string ImagePath, bool GetImages) { - Task RetVal = _GetArtwork(SearchUsing.slug, Slug, ImagePath); + Task RetVal = _GetArtwork(SearchUsing.slug, Slug, ImagePath, GetImages); return RetVal.Result; } - private static async Task _GetArtwork(SearchUsing searchUsing, object searchValue, string ImagePath) + private static async Task _GetArtwork(SearchUsing searchUsing, object searchValue, string ImagePath, bool GetImages = true) { // check database first Storage.CacheStatus? cacheStatus = new Storage.CacheStatus(); @@ -67,14 +67,14 @@ namespace gaseous_server.Classes.Metadata case Storage.CacheStatus.NotPresent: returnValue = await GetObjectFromServer(WhereClause, ImagePath); Storage.NewCacheValue(returnValue); - forceImageDownload = true; + if (GetImages == true) { forceImageDownload = true; } break; case Storage.CacheStatus.Expired: try { returnValue = await GetObjectFromServer(WhereClause, ImagePath); Storage.NewCacheValue(returnValue, true); - forceImageDownload = true; + if (GetImages == true) { forceImageDownload = true; } } catch (Exception ex) { diff --git a/gaseous-server/Classes/Metadata/Communications.cs b/gaseous-server/Classes/Metadata/Communications.cs index 752aa8f..285ec8f 100644 --- a/gaseous-server/Classes/Metadata/Communications.cs +++ b/gaseous-server/Classes/Metadata/Communications.cs @@ -1,7 +1,9 @@ using System.ComponentModel; +using System.Drawing; using System.Net; using Humanizer; using IGDB; +using Microsoft.CodeAnalysis.CSharp.Syntax; using RestEase; namespace gaseous_server.Classes.Metadata @@ -318,51 +320,104 @@ namespace gaseous_server.Classes.Metadata { string returnPath = ""; - if (RateLimitResumeTime > DateTime.UtcNow) + // check for artificial sizes first + switch (size) { - Logging.Log(Logging.LogType.Information, "API Connection", "IGDB rate limit hit. Pausing API communications until " + RateLimitResumeTime.ToString() + ". Attempt " + RetryAttempts + " of " + RetryAttemptsMax + " retries."); - Thread.Sleep(RateLimitRecoveryWaitTime); - } - - if (InRateLimitAvoidanceMode == true) - { - // sleep for a moment to help avoid hitting the rate limiter - Thread.Sleep(RateLimitAvoidanceWait); - } - - Communications comms = new Communications(); - List imageSizes = new List - { - size - }; - - // get the image - try - { - returnPath = Path.Combine(ImagePath, size.ToString(), ImageId + ".jpg"); - - if (File.Exists(returnPath)) { File.Delete(returnPath); } - await comms.IGDBAPI_GetImage(imageSizes, ImageId, ImagePath); - - } - catch (HttpRequestException ex) - { - if (ex.StatusCode == HttpStatusCode.NotFound) - { - Logging.Log(Logging.LogType.Information, "Image Download", "Image not found, trying a different size."); - - if (FallbackSizes != null) + case IGDBAPI_ImageSize.screenshot_small: + case IGDBAPI_ImageSize.screenshot_thumb: + string BasePath = Path.Combine(ImagePath, size.ToString()); + if (!Directory.Exists(BasePath)) { - foreach (Communications.IGDBAPI_ImageSize imageSize in FallbackSizes) + 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) { - returnPath = await GetSpecificImageFromServer(ImagePath, ImageId, imageSize, null); + 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); } } - } - } - // increment rate limiter avoidance call count - RateLimitAvoidanceCallCount += 1; + break; + + default: + // these sizes are IGDB native + 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."); + Thread.Sleep(RateLimitRecoveryWaitTime); + } + + if (InRateLimitAvoidanceMode == true) + { + // sleep for a moment to help avoid hitting the rate limiter + Thread.Sleep(RateLimitAvoidanceWait); + } + + Communications comms = new Communications(); + List imageSizes = new List + { + size + }; + + // get the image + try + { + returnPath = Path.Combine(ImagePath, size.ToString(), ImageId + ".jpg"); + + // fail early if the file is already downloaded + if (!File.Exists(returnPath)) + { + await comms.IGDBAPI_GetImage(imageSizes, ImageId, ImagePath); + } + + } + catch (HttpRequestException ex) + { + if (ex.StatusCode == HttpStatusCode.NotFound) + { + Logging.Log(Logging.LogType.Information, "Image Download", "Image not found, trying a different size."); + + if (FallbackSizes != null) + { + foreach (Communications.IGDBAPI_ImageSize imageSize in FallbackSizes) + { + returnPath = await GetSpecificImageFromServer(ImagePath, ImageId, imageSize, null); + } + } + } + } + + // increment rate limiter avoidance call count + RateLimitAvoidanceCallCount += 1; + + break; + } return returnPath; } @@ -383,23 +438,7 @@ namespace gaseous_server.Classes.Metadata string OutputFile = ImageId + ".jpg"; 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); } } @@ -417,6 +456,18 @@ namespace gaseous_server.Classes.Metadata [Description("cover_big")] cover_big, + /// + /// 165x90 Lfill, Centre gravity - resized by Gaseous and is not a real IGDB size + /// + [Description("screenshot_thumb")] + screenshot_thumb, + + /// + /// 235x128 Lfill, Centre gravity - resized by Gaseous and is not a real IGDB size + /// + [Description("screenshot_small")] + screenshot_small, + /// /// 589x320 Lfill, Centre gravity /// diff --git a/gaseous-server/Classes/Metadata/Covers.cs b/gaseous-server/Classes/Metadata/Covers.cs index 975e3f5..1e337b3 100644 --- a/gaseous-server/Classes/Metadata/Covers.cs +++ b/gaseous-server/Classes/Metadata/Covers.cs @@ -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)) { @@ -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 RetVal = _GetCover(SearchUsing.slug, Slug, ImagePath, GetImages); return RetVal.Result; @@ -91,7 +91,8 @@ namespace gaseous_server.Classes.Metadata 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."); @@ -105,7 +106,7 @@ namespace gaseous_server.Classes.Metadata Communications comms = new Communications(); 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) { comms.GetSpecificImageFromServer(ImagePath, returnValue.ImageId, size, null); diff --git a/gaseous-server/Classes/Metadata/Games.cs b/gaseous-server/Classes/Metadata/Games.cs index 7c19eff..0ce44ff 100644 --- a/gaseous-server/Classes/Metadata/Games.cs +++ b/gaseous-server/Classes/Metadata/Games.cs @@ -98,14 +98,14 @@ namespace gaseous_server.Classes.Metadata case Storage.CacheStatus.NotPresent: returnValue = await GetObjectFromServer(WhereClause); Storage.NewCacheValue(returnValue); - UpdateSubClasses(returnValue, getAllMetadata, followSubGames); + UpdateSubClasses(returnValue, getAllMetadata, followSubGames, forceRefresh); return returnValue; case Storage.CacheStatus.Expired: try { returnValue = await GetObjectFromServer(WhereClause); Storage.NewCacheValue(returnValue, true); - UpdateSubClasses(returnValue, getAllMetadata, followSubGames); + UpdateSubClasses(returnValue, getAllMetadata, followSubGames, forceRefresh); } catch (Exception ex) { @@ -115,21 +115,21 @@ namespace gaseous_server.Classes.Metadata return returnValue; case Storage.CacheStatus.Current: returnValue = Storage.GetCacheValue(returnValue, "id", (long)searchValue); - UpdateSubClasses(returnValue, false, false); + UpdateSubClasses(returnValue, false, false, false); return returnValue; default: 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 if (Game.Cover != null) { 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) { @@ -211,7 +211,7 @@ namespace gaseous_server.Classes.Metadata { 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) { @@ -285,7 +285,7 @@ namespace gaseous_server.Classes.Metadata { 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) { diff --git a/gaseous-server/Classes/Metadata/PlatformLogos.cs b/gaseous-server/Classes/Metadata/PlatformLogos.cs index b9ae3d1..0ff0604 100644 --- a/gaseous-server/Classes/Metadata/PlatformLogos.cs +++ b/gaseous-server/Classes/Metadata/PlatformLogos.cs @@ -117,7 +117,7 @@ namespace gaseous_server.Classes.Metadata { // get Artwork metadata Communications comms = new Communications(); - var results = await comms.APIComm(IGDBClient.Endpoints.Artworks, fieldList, WhereClause); + var results = await comms.APIComm(IGDBClient.Endpoints.PlatformLogos, fieldList, WhereClause); var result = results.First(); return result; diff --git a/gaseous-server/Classes/Metadata/Platforms.cs b/gaseous-server/Classes/Metadata/Platforms.cs index 331a872..9d754b5 100644 --- a/gaseous-server/Classes/Metadata/Platforms.cs +++ b/gaseous-server/Classes/Metadata/Platforms.cs @@ -39,8 +39,16 @@ namespace gaseous_server.Classes.Metadata } else { - Task RetVal = _GetPlatform(SearchUsing.id, Id, forceRefresh); - return RetVal.Result; + try + { + Task RetVal = _GetPlatform(SearchUsing.id, Id, forceRefresh); + return RetVal.Result; + } + catch(Exception ex) + { + Logging.Log(Logging.LogType.Warning, "Metadata", "An error occurred fetching Platform Id " + Id, ex); + return null; + } } } diff --git a/gaseous-server/Classes/Metadata/Screenshots.cs b/gaseous-server/Classes/Metadata/Screenshots.cs index 63cfa37..9f7a531 100644 --- a/gaseous-server/Classes/Metadata/Screenshots.cs +++ b/gaseous-server/Classes/Metadata/Screenshots.cs @@ -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)) { @@ -21,18 +21,18 @@ namespace gaseous_server.Classes.Metadata } else { - Task RetVal = _GetScreenshot(SearchUsing.id, Id, ImagePath); + Task RetVal = _GetScreenshot(SearchUsing.id, Id, ImagePath, GetImages); return RetVal.Result; } } - public static Screenshot GetScreenshot(string Slug, string ImagePath) + public static Screenshot GetScreenshot(string Slug, string ImagePath, bool GetImages) { - Task RetVal = _GetScreenshot(SearchUsing.slug, Slug, ImagePath); + Task RetVal = _GetScreenshot(SearchUsing.slug, Slug, ImagePath, GetImages); return RetVal.Result; } - private static async Task _GetScreenshot(SearchUsing searchUsing, object searchValue, string ImagePath) + private static async Task _GetScreenshot(SearchUsing searchUsing, object searchValue, string ImagePath, bool GetImages = true) { // check database first Storage.CacheStatus? cacheStatus = new Storage.CacheStatus(); @@ -67,14 +67,14 @@ namespace gaseous_server.Classes.Metadata case Storage.CacheStatus.NotPresent: returnValue = await GetObjectFromServer(WhereClause, ImagePath); Storage.NewCacheValue(returnValue); - forceImageDownload = true; + if (GetImages == true) { forceImageDownload = true; } break; case Storage.CacheStatus.Expired: try { returnValue = await GetObjectFromServer(WhereClause, ImagePath); Storage.NewCacheValue(returnValue, true); - forceImageDownload = true; + if (GetImages == true) { forceImageDownload = true; } } catch (Exception ex) { diff --git a/gaseous-server/Controllers/V1.0/GamesController.cs b/gaseous-server/Controllers/V1.0/GamesController.cs index 678f37d..d4a2024 100644 --- a/gaseous-server/Controllers/V1.0/GamesController.cs +++ b/gaseous-server/Controllers/V1.0/GamesController.cs @@ -8,6 +8,7 @@ using System.Reflection; using System.Threading.Tasks; using gaseous_server.Classes; using gaseous_server.Classes.Metadata; +using gaseous_server.Models; using IGDB.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; @@ -291,7 +292,7 @@ namespace gaseous_server.Controllers { 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) { @@ -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.1")] [HttpGet] @@ -473,7 +393,7 @@ namespace gaseous_server.Controllers { 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); } } @@ -501,7 +421,7 @@ namespace gaseous_server.Controllers 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) { return Ok(artworkObject); @@ -526,9 +446,10 @@ namespace gaseous_server.Controllers [MapToApiVersion("1.1")] [HttpGet] [Route("{GameId}/artwork/{ArtworkId}/image/{size}")] + [Route("{GameId}/artwork/{ArtworkId}/image/{size}/{ImageName}")] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [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 { @@ -536,7 +457,7 @@ namespace gaseous_server.Controllers 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) { //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")] [HttpGet] [Route("{GameId}/cover/image/{size}")] + [Route("{GameId}/cover/image/{size}/{imagename}")] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public ActionResult GameCoverImage(long GameId, Communications.IGDBAPI_ImageSize size) + public ActionResult GameCoverImage(long GameId, Communications.IGDBAPI_ImageSize size, string imagename = "") { try { @@ -1295,7 +1217,7 @@ namespace gaseous_server.Controllers { 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); } } @@ -1321,7 +1243,7 @@ namespace gaseous_server.Controllers { IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false); 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) { return Ok(screenshotObject); @@ -1346,17 +1268,16 @@ namespace gaseous_server.Controllers [MapToApiVersion("1.1")] [HttpGet] [Route("{GameId}/screenshots/{ScreenshotId}/image/{size}")] + [Route("{GameId}/screenshots/{ScreenshotId}/image/{size}/{ImageName}")] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [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 { IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false); - IGDB.Models.Screenshot screenshotObject = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject)); - - //string coverFilePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Screenshots", Size.ToString(), screenshotObject.ImageId + ".jpg"); + IGDB.Models.Screenshot screenshotObject = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), true); string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Screenshots"); diff --git a/gaseous-server/Models/GaseousGame.cs b/gaseous-server/Models/GaseousGame.cs new file mode 100644 index 0000000..e68e21d --- /dev/null +++ b/gaseous-server/Models/GaseousGame.cs @@ -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? ArtworksItem + { + get + { + if (this.Artworks != null) + { + if (this.Artworks.Ids != null) + { + List artworks = new List(); + 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? ScreenshotsItem + { + get + { + if (this.Screenshots != null) + { + if (this.Screenshots.Ids != null) + { + List screenshots = new List(); + 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; + } + } + } +} \ No newline at end of file diff --git a/gaseous-server/Models/PlatformMapping.cs b/gaseous-server/Models/PlatformMapping.cs index e62ac6f..77a1c48 100644 --- a/gaseous-server/Models/PlatformMapping.cs +++ b/gaseous-server/Models/PlatformMapping.cs @@ -253,109 +253,114 @@ namespace gaseous_server.Models string sql = ""; // get platform data - IGDB.Models.Platform platform = Platforms.GetPlatform(IGDBId); + IGDB.Models.Platform? platform = Platforms.GetPlatform(IGDBId); - // get platform alternate names - sql = "SELECT * FROM PlatformMap_AlternateNames WHERE Id = @Id ORDER BY Name"; - dbDict.Clear(); - dbDict.Add("Id", IGDBId); - DataTable altTable = db.ExecuteCMD(sql, dbDict); - - List alternateNames = new List(); - foreach (DataRow altRow in altTable.Rows) + if (platform != null) { - string altVal = (string)altRow["Name"]; - if (!alternateNames.Contains(altVal, StringComparer.OrdinalIgnoreCase)) + // get platform alternate names + sql = "SELECT * FROM PlatformMap_AlternateNames WHERE Id = @Id ORDER BY Name"; + dbDict.Clear(); + dbDict.Add("Id", IGDBId); + DataTable altTable = db.ExecuteCMD(sql, dbDict); + + List alternateNames = new List(); + foreach (DataRow altRow in altTable.Rows) { - alternateNames.Add(altVal); + string altVal = (string)altRow["Name"]; + if (!alternateNames.Contains(altVal, StringComparer.OrdinalIgnoreCase)) + { + alternateNames.Add(altVal); + } } - } - if (platform.AlternativeName != null) - { - if (!alternateNames.Contains(platform.AlternativeName, StringComparer.OrdinalIgnoreCase)) + if (platform.AlternativeName != null) { - alternateNames.Add(platform.AlternativeName); + if (!alternateNames.Contains(platform.AlternativeName, StringComparer.OrdinalIgnoreCase)) + { + alternateNames.Add(platform.AlternativeName); + } } - } - // get platform known extensions - sql = "SELECT * FROM PlatformMap_Extensions WHERE Id = @Id ORDER BY Extension"; - dbDict.Clear(); - dbDict.Add("Id", IGDBId); - DataTable extTable = db.ExecuteCMD(sql, dbDict); + // get platform known extensions + sql = "SELECT * FROM PlatformMap_Extensions WHERE Id = @Id ORDER BY Extension"; + dbDict.Clear(); + dbDict.Add("Id", IGDBId); + DataTable extTable = db.ExecuteCMD(sql, dbDict); - List knownExtensions = new List(); - foreach (DataRow extRow in extTable.Rows) - { - string extVal = (string)extRow["Extension"]; - if (!knownExtensions.Contains(extVal, StringComparer.OrdinalIgnoreCase)) + List knownExtensions = new List(); + foreach (DataRow extRow in extTable.Rows) { - knownExtensions.Add(extVal); + string extVal = (string)extRow["Extension"]; + if (!knownExtensions.Contains(extVal, StringComparer.OrdinalIgnoreCase)) + { + knownExtensions.Add(extVal); + } } - } - // get platform unique extensions - sql = "SELECT * FROM PlatformMap_UniqueExtensions WHERE Id = @Id ORDER BY Extension"; - dbDict.Clear(); - dbDict.Add("Id", IGDBId); - DataTable uextTable = db.ExecuteCMD(sql, dbDict); + // get platform unique extensions + sql = "SELECT * FROM PlatformMap_UniqueExtensions WHERE Id = @Id ORDER BY Extension"; + dbDict.Clear(); + dbDict.Add("Id", IGDBId); + DataTable uextTable = db.ExecuteCMD(sql, dbDict); - List uniqueExtensions = new List(); - foreach (DataRow uextRow in uextTable.Rows) - { - string uextVal = (string)uextRow["Extension"]; - if (!uniqueExtensions.Contains(uextVal, StringComparer.OrdinalIgnoreCase)) + List uniqueExtensions = new List(); + foreach (DataRow uextRow in uextTable.Rows) { - uniqueExtensions.Add(uextVal); + string uextVal = (string)uextRow["Extension"]; + if (!uniqueExtensions.Contains(uextVal, StringComparer.OrdinalIgnoreCase)) + { + uniqueExtensions.Add(uextVal); + } } - } - // get platform bios - sql = "SELECT * FROM PlatformMap_Bios WHERE Id = @Id ORDER BY Filename"; - dbDict.Clear(); - dbDict.Add("Id", IGDBId); - DataTable biosTable = db.ExecuteCMD(sql, dbDict); + // get platform bios + sql = "SELECT * FROM PlatformMap_Bios WHERE Id = @Id ORDER BY Filename"; + dbDict.Clear(); + dbDict.Add("Id", IGDBId); + DataTable biosTable = db.ExecuteCMD(sql, dbDict); - List bioss = new List(); - foreach (DataRow biosRow in biosTable.Rows) - { - PlatformMapItem.EmulatorBiosItem bios = new PlatformMapItem.EmulatorBiosItem + List bioss = new List(); + foreach (DataRow biosRow in biosTable.Rows) { - filename = (string)Common.ReturnValueIfNull(biosRow["Filename"], ""), - description = (string)Common.ReturnValueIfNull(biosRow["Description"], ""), - hash = ((string)Common.ReturnValueIfNull(biosRow["Hash"], "")).ToLower() + PlatformMapItem.EmulatorBiosItem bios = new PlatformMapItem.EmulatorBiosItem + { + filename = (string)Common.ReturnValueIfNull(biosRow["Filename"], ""), + description = (string)Common.ReturnValueIfNull(biosRow["Description"], ""), + hash = ((string)Common.ReturnValueIfNull(biosRow["Hash"], "")).ToLower() + }; + bioss.Add(bios); + } + + // build item + PlatformMapItem mapItem = new PlatformMapItem(); + mapItem.IGDBId = IGDBId; + mapItem.IGDBName = platform.Name; + mapItem.IGDBSlug = platform.Slug; + mapItem.AlternateNames = alternateNames; + mapItem.Extensions = new PlatformMapItem.FileExtensions{ + SupportedFileExtensions = knownExtensions, + UniqueFileExtensions = uniqueExtensions }; - bioss.Add(bios); + mapItem.RetroPieDirectoryName = (string)Common.ReturnValueIfNull(row["RetroPieDirectoryName"], ""); + mapItem.WebEmulator = new PlatformMapItem.WebEmulatorItem{ + Type = (string)Common.ReturnValueIfNull(row["WebEmulator_Type"], ""), + Core = (string)Common.ReturnValueIfNull(row["WebEmulator_Core"], ""), + AvailableWebEmulators = Newtonsoft.Json.JsonConvert.DeserializeObject>((string)Common.ReturnValueIfNull(row["AvailableWebEmulators"], "[]")) + }; + mapItem.Bios = bioss; + + if (PlatformMapCache.ContainsKey(IGDBId.ToString())) + { + PlatformMapCache[IGDBId.ToString()] = mapItem; + } + else + { + PlatformMapCache.Add(IGDBId.ToString(), mapItem); + } + + return mapItem; } - // build item - PlatformMapItem mapItem = new PlatformMapItem(); - mapItem.IGDBId = IGDBId; - mapItem.IGDBName = platform.Name; - mapItem.IGDBSlug = platform.Slug; - mapItem.AlternateNames = alternateNames; - mapItem.Extensions = new PlatformMapItem.FileExtensions{ - SupportedFileExtensions = knownExtensions, - UniqueFileExtensions = uniqueExtensions - }; - mapItem.RetroPieDirectoryName = (string)Common.ReturnValueIfNull(row["RetroPieDirectoryName"], ""); - mapItem.WebEmulator = new PlatformMapItem.WebEmulatorItem{ - Type = (string)Common.ReturnValueIfNull(row["WebEmulator_Type"], ""), - Core = (string)Common.ReturnValueIfNull(row["WebEmulator_Core"], ""), - AvailableWebEmulators = Newtonsoft.Json.JsonConvert.DeserializeObject>((string)Common.ReturnValueIfNull(row["AvailableWebEmulators"], "[]")) - }; - mapItem.Bios = bioss; - - if (PlatformMapCache.ContainsKey(IGDBId.ToString())) - { - PlatformMapCache[IGDBId.ToString()] = mapItem; - } - else - { - PlatformMapCache.Add(IGDBId.ToString(), mapItem); - } - - return mapItem; + return null; } public static void GetIGDBPlatformMapping(ref gaseous_server.Models.Signatures_Games Signature, FileInfo RomFileInfo, bool SetSystemName) diff --git a/gaseous-server/gaseous-server.csproj b/gaseous-server/gaseous-server.csproj index 44832f7..823a99e 100644 --- a/gaseous-server/gaseous-server.csproj +++ b/gaseous-server/gaseous-server.csproj @@ -21,6 +21,7 @@ + @@ -56,59 +57,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -117,15 +65,6 @@ - - - - - - - - - @@ -138,45 +77,6 @@ true PreserveNewest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gaseous-server/Assets/Ratings/ACB/ACB_G.svg b/gaseous-server/wwwroot/images/Ratings/ACB/ACB_G.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ACB/ACB_G.svg rename to gaseous-server/wwwroot/images/Ratings/ACB/ACB_G.svg diff --git a/gaseous-server/Assets/Ratings/ACB/ACB_M.svg b/gaseous-server/wwwroot/images/Ratings/ACB/ACB_M.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ACB/ACB_M.svg rename to gaseous-server/wwwroot/images/Ratings/ACB/ACB_M.svg diff --git a/gaseous-server/Assets/Ratings/ACB/ACB_MA15.svg b/gaseous-server/wwwroot/images/Ratings/ACB/ACB_MA15.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ACB/ACB_MA15.svg rename to gaseous-server/wwwroot/images/Ratings/ACB/ACB_MA15.svg diff --git a/gaseous-server/Assets/Ratings/ACB/ACB_PG.svg b/gaseous-server/wwwroot/images/Ratings/ACB/ACB_PG.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ACB/ACB_PG.svg rename to gaseous-server/wwwroot/images/Ratings/ACB/ACB_PG.svg diff --git a/gaseous-server/Assets/Ratings/ACB/ACB_R18.svg b/gaseous-server/wwwroot/images/Ratings/ACB/ACB_R18.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ACB/ACB_R18.svg rename to gaseous-server/wwwroot/images/Ratings/ACB/ACB_R18.svg diff --git a/gaseous-server/Assets/Ratings/ACB/ACB_RC.svg b/gaseous-server/wwwroot/images/Ratings/ACB/ACB_RC.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ACB/ACB_RC.svg rename to gaseous-server/wwwroot/images/Ratings/ACB/ACB_RC.svg diff --git a/gaseous-server/Assets/Ratings/CERO/CERO_A.svg b/gaseous-server/wwwroot/images/Ratings/CERO/CERO_A.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CERO/CERO_A.svg rename to gaseous-server/wwwroot/images/Ratings/CERO/CERO_A.svg diff --git a/gaseous-server/Assets/Ratings/CERO/CERO_B.svg b/gaseous-server/wwwroot/images/Ratings/CERO/CERO_B.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CERO/CERO_B.svg rename to gaseous-server/wwwroot/images/Ratings/CERO/CERO_B.svg diff --git a/gaseous-server/Assets/Ratings/CERO/CERO_C.svg b/gaseous-server/wwwroot/images/Ratings/CERO/CERO_C.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CERO/CERO_C.svg rename to gaseous-server/wwwroot/images/Ratings/CERO/CERO_C.svg diff --git a/gaseous-server/Assets/Ratings/CERO/CERO_D.svg b/gaseous-server/wwwroot/images/Ratings/CERO/CERO_D.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CERO/CERO_D.svg rename to gaseous-server/wwwroot/images/Ratings/CERO/CERO_D.svg diff --git a/gaseous-server/Assets/Ratings/CERO/CERO_Z.svg b/gaseous-server/wwwroot/images/Ratings/CERO/CERO_Z.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CERO/CERO_Z.svg rename to gaseous-server/wwwroot/images/Ratings/CERO/CERO_Z.svg diff --git a/gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Eighteen.svg b/gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Eighteen.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Eighteen.svg rename to gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Eighteen.svg diff --git a/gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Fourteen.svg b/gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Fourteen.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Fourteen.svg rename to gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Fourteen.svg diff --git a/gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_L.svg b/gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_L.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_L.svg rename to gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_L.svg diff --git a/gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Sixteen.svg b/gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Sixteen.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Sixteen.svg rename to gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Sixteen.svg diff --git a/gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Ten.svg b/gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Ten.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Ten.svg rename to gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Ten.svg diff --git a/gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Twelve.svg b/gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Twelve.svg similarity index 100% rename from gaseous-server/Assets/Ratings/CLASS_IND/CLASS_IND_Twelve.svg rename to gaseous-server/wwwroot/images/Ratings/CLASS_IND/CLASS_IND_Twelve.svg diff --git a/gaseous-server/Assets/Ratings/ESRB/AO.svg b/gaseous-server/wwwroot/images/Ratings/ESRB/AO.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ESRB/AO.svg rename to gaseous-server/wwwroot/images/Ratings/ESRB/AO.svg diff --git a/gaseous-server/Assets/Ratings/ESRB/E.svg b/gaseous-server/wwwroot/images/Ratings/ESRB/E.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ESRB/E.svg rename to gaseous-server/wwwroot/images/Ratings/ESRB/E.svg diff --git a/gaseous-server/Assets/Ratings/ESRB/E10.svg b/gaseous-server/wwwroot/images/Ratings/ESRB/E10.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ESRB/E10.svg rename to gaseous-server/wwwroot/images/Ratings/ESRB/E10.svg diff --git a/gaseous-server/Assets/Ratings/ESRB/M.svg b/gaseous-server/wwwroot/images/Ratings/ESRB/M.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ESRB/M.svg rename to gaseous-server/wwwroot/images/Ratings/ESRB/M.svg diff --git a/gaseous-server/Assets/Ratings/ESRB/RP-LM17-English.svg b/gaseous-server/wwwroot/images/Ratings/ESRB/RP-LM17-English.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ESRB/RP-LM17-English.svg rename to gaseous-server/wwwroot/images/Ratings/ESRB/RP-LM17-English.svg diff --git a/gaseous-server/Assets/Ratings/ESRB/RP.svg b/gaseous-server/wwwroot/images/Ratings/ESRB/RP.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ESRB/RP.svg rename to gaseous-server/wwwroot/images/Ratings/ESRB/RP.svg diff --git a/gaseous-server/Assets/Ratings/ESRB/T.svg b/gaseous-server/wwwroot/images/Ratings/ESRB/T.svg similarity index 100% rename from gaseous-server/Assets/Ratings/ESRB/T.svg rename to gaseous-server/wwwroot/images/Ratings/ESRB/T.svg diff --git a/gaseous-server/Assets/Ratings/GRAC/GRAC_All.svg b/gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_All.svg similarity index 100% rename from gaseous-server/Assets/Ratings/GRAC/GRAC_All.svg rename to gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_All.svg diff --git a/gaseous-server/Assets/Ratings/GRAC/GRAC_Eighteen.svg b/gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_Eighteen.svg similarity index 100% rename from gaseous-server/Assets/Ratings/GRAC/GRAC_Eighteen.svg rename to gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_Eighteen.svg diff --git a/gaseous-server/Assets/Ratings/GRAC/GRAC_Fifteen.svg b/gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_Fifteen.svg similarity index 100% rename from gaseous-server/Assets/Ratings/GRAC/GRAC_Fifteen.svg rename to gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_Fifteen.svg diff --git a/gaseous-server/Assets/Ratings/GRAC/GRAC_Testing.svg b/gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_Testing.svg similarity index 100% rename from gaseous-server/Assets/Ratings/GRAC/GRAC_Testing.svg rename to gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_Testing.svg diff --git a/gaseous-server/Assets/Ratings/GRAC/GRAC_Twelve.svg b/gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_Twelve.svg similarity index 100% rename from gaseous-server/Assets/Ratings/GRAC/GRAC_Twelve.svg rename to gaseous-server/wwwroot/images/Ratings/GRAC/GRAC_Twelve.svg diff --git a/gaseous-server/Assets/Ratings/PEGI/Eighteen.svg b/gaseous-server/wwwroot/images/Ratings/PEGI/Eighteen.svg similarity index 100% rename from gaseous-server/Assets/Ratings/PEGI/Eighteen.svg rename to gaseous-server/wwwroot/images/Ratings/PEGI/Eighteen.svg diff --git a/gaseous-server/Assets/Ratings/PEGI/Seven.svg b/gaseous-server/wwwroot/images/Ratings/PEGI/Seven.svg similarity index 100% rename from gaseous-server/Assets/Ratings/PEGI/Seven.svg rename to gaseous-server/wwwroot/images/Ratings/PEGI/Seven.svg diff --git a/gaseous-server/Assets/Ratings/PEGI/Sixteen.svg b/gaseous-server/wwwroot/images/Ratings/PEGI/Sixteen.svg similarity index 100% rename from gaseous-server/Assets/Ratings/PEGI/Sixteen.svg rename to gaseous-server/wwwroot/images/Ratings/PEGI/Sixteen.svg diff --git a/gaseous-server/Assets/Ratings/PEGI/Three.svg b/gaseous-server/wwwroot/images/Ratings/PEGI/Three.svg similarity index 100% rename from gaseous-server/Assets/Ratings/PEGI/Three.svg rename to gaseous-server/wwwroot/images/Ratings/PEGI/Three.svg diff --git a/gaseous-server/Assets/Ratings/PEGI/Twelve.svg b/gaseous-server/wwwroot/images/Ratings/PEGI/Twelve.svg similarity index 100% rename from gaseous-server/Assets/Ratings/PEGI/Twelve.svg rename to gaseous-server/wwwroot/images/Ratings/PEGI/Twelve.svg diff --git a/gaseous-server/Assets/Ratings/USK/USK_0.svg b/gaseous-server/wwwroot/images/Ratings/USK/USK_0.svg similarity index 100% rename from gaseous-server/Assets/Ratings/USK/USK_0.svg rename to gaseous-server/wwwroot/images/Ratings/USK/USK_0.svg diff --git a/gaseous-server/Assets/Ratings/USK/USK_12.svg b/gaseous-server/wwwroot/images/Ratings/USK/USK_12.svg similarity index 100% rename from gaseous-server/Assets/Ratings/USK/USK_12.svg rename to gaseous-server/wwwroot/images/Ratings/USK/USK_12.svg diff --git a/gaseous-server/Assets/Ratings/USK/USK_16.svg b/gaseous-server/wwwroot/images/Ratings/USK/USK_16.svg similarity index 100% rename from gaseous-server/Assets/Ratings/USK/USK_16.svg rename to gaseous-server/wwwroot/images/Ratings/USK/USK_16.svg diff --git a/gaseous-server/Assets/Ratings/USK/USK_18.svg b/gaseous-server/wwwroot/images/Ratings/USK/USK_18.svg similarity index 100% rename from gaseous-server/Assets/Ratings/USK/USK_18.svg rename to gaseous-server/wwwroot/images/Ratings/USK/USK_18.svg diff --git a/gaseous-server/Assets/Ratings/USK/USK_6.svg b/gaseous-server/wwwroot/images/Ratings/USK/USK_6.svg similarity index 100% rename from gaseous-server/Assets/Ratings/USK/USK_6.svg rename to gaseous-server/wwwroot/images/Ratings/USK/USK_6.svg diff --git a/gaseous-server/wwwroot/pages/dialogs/collectionedit.html b/gaseous-server/wwwroot/pages/dialogs/collectionedit.html index dc1ac18..2cdef56 100644 --- a/gaseous-server/wwwroot/pages/dialogs/collectionedit.html +++ b/gaseous-server/wwwroot/pages/dialogs/collectionedit.html @@ -480,7 +480,7 @@ } function DisplayPreview(data, targetDiv) { - console.log(JSON.stringify(data)); + console.log(data); var container = document.getElementById(targetDiv); container.innerHTML = ''; @@ -579,7 +579,7 @@ var gameImage = document.createElement('img'); gameImage.className = 'game_tile_image game_tile_image_small'; 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 { gameImage.src = '/images/unknowngame.png'; gameImage.className = 'game_tile_image game_tile_image_small unknown'; diff --git a/gaseous-server/wwwroot/pages/dialogs/settingsuseredit.html b/gaseous-server/wwwroot/pages/dialogs/settingsuseredit.html index e3b848a..f69f44a 100644 --- a/gaseous-server/wwwroot/pages/dialogs/settingsuseredit.html +++ b/gaseous-server/wwwroot/pages/dialogs/settingsuseredit.html @@ -208,7 +208,7 @@ for (var classBoard in classBoards) { for (var rating in classBoards[classBoard]) { - ratingsValues += ""; + ratingsValues += ""; } } diff --git a/gaseous-server/wwwroot/pages/dialogs/userprofile.html b/gaseous-server/wwwroot/pages/dialogs/userprofile.html index b29b104..b853127 100644 --- a/gaseous-server/wwwroot/pages/dialogs/userprofile.html +++ b/gaseous-server/wwwroot/pages/dialogs/userprofile.html @@ -34,17 +34,17 @@ - + - + - + @@ -55,7 +55,7 @@ - @@ -64,7 +64,7 @@ - @@ -206,8 +206,10 @@ ); SetPreference_Batch(model); - - executeFilter1_1(1); + + if (getQueryString('page', 'string') == 'home' || getQueryString('page', 'string') == undefined) { + executeFilter1_1(1); + } closeDialog(); } @@ -227,12 +229,12 @@ function updateDisplay(ValueName, ValueSetting) { switch(ValueName) { case "LibraryShowGameClassification": - var badgeSelector = document.getElementById("profile_pref_LibraryClassificationBadgeSelect"); - if (ValueSetting == true || ValueSetting == "true") { - badgeSelector.style.display = ''; - } else { - badgeSelector.style.display = 'none'; - } + // var badgeSelector = document.getElementById("profile_pref_LibraryClassificationBadgeSelect"); + // if (ValueSetting == true || ValueSetting == "true") { + // badgeSelector.style.display = ''; + // } else { + // badgeSelector.style.display = 'none'; + // } break; } } diff --git a/gaseous-server/wwwroot/pages/emulator.html b/gaseous-server/wwwroot/pages/emulator.html index 86c41ec..bd38b78 100644 --- a/gaseous-server/wwwroot/pages/emulator.html +++ b/gaseous-server/wwwroot/pages/emulator.html @@ -27,12 +27,12 @@ } else { if (result.cover) { 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) { - 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; @@ -59,7 +59,7 @@ artworksPosition = 0; } 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);'); } } diff --git a/gaseous-server/wwwroot/pages/game.html b/gaseous-server/wwwroot/pages/game.html index 01f1f85..9c97841 100644 --- a/gaseous-server/wwwroot/pages/game.html +++ b/gaseous-server/wwwroot/pages/game.html @@ -102,6 +102,8 @@ var selectedScreenshot = 0; ajaxCall('/api/v1.1/Games/' + gameId, 'GET', function (result) { + console.log(result); + // populate games page gameData = result; @@ -160,15 +162,15 @@ } // load artwork - if (result.artworks) { - artworks = result.artworks.ids; - var startPos = randomIntFromInterval(0, result.artworks.ids.length); + if (result.artworksItem) { + artworks = result.artworksItem; + var startPos = randomIntFromInterval(0, result.artworksItem.length); artworksPosition = startPos; rotateBackground(); } else { var bg = document.getElementById('bgImage'); - if (result.cover) { - 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);'); + if (result.coverItem) { + 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 { 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);'); @@ -234,7 +236,7 @@ var gameImage = document.createElement('img'); gameImage.className = 'game_cover_image'; 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 { gameImage.src = '/images/unknowngame.png'; gameImage.className = 'game_cover_image unknown'; @@ -254,14 +256,44 @@ // load ratings var gameSummaryRatings = document.getElementById('gamesummary_ratings'); if (result.ageRatings) { - var gameRatings = document.createElement('div'); - for (var i = 0; i < result.ageRatings.ids.length; i++) { - var ratingImage = document.createElement('img'); - ratingImage.src = '/api/v1.1/Games/' + result.id + '/agerating/' + result.ageRatings.ids[i] + '/image'; - ratingImage.className = 'rating_image'; - gameRatings.appendChild(ratingImage); - } - gameSummaryRatings.appendChild(gameRatings); + ajaxCall('/api/v1.1/games/' + gameId + '/agerating', 'GET', function (result) { + 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'); + ratingImage.src = '/images/Ratings/' + result[i].ratingBoard + '/' + result[i].ratingTitle + '.svg'; + var ratingString = ClassificationBoards[result[i].ratingBoard] + "\nRating: " + ClassificationRatings[result[i].ratingTitle]; + if (result[i].descriptions.length > 0) { + ratingString += '\nContains: ' + result[i].descriptions.join(', '); + } + 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('
'); + } 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 { gameSummaryRatings.setAttribute('style', 'display: none;'); } @@ -293,12 +325,12 @@ if (result.videos) { imageIndex = result.videos.ids.length; } - if (result.screenshots) { - for (var i = 0; i < result.screenshots.ids.length; i++) { + if (result.screenshotsItem) { + for (var i = 0; i < result.screenshotsItem.length; i++) { var screenshotItem = document.createElement('div'); screenshotItem.id = 'gamescreenshots_gallery_' + imageIndex; 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('imagetype', 0); screenshotItem.className = 'gamescreenshots_gallery_item'; @@ -697,15 +729,19 @@ var romCounter = document.createElement('div'); romCounter.className = 'games_library_controlblock'; + + var romCounterLabel = document.createElement('span'); + romCounterLabel.className = 'games_library_label'; if (result.count) { if (result.count < 1000) { - romCounter.innerHTML = result.count + ' ROMs'; + romCounterLabel.innerHTML = result.count + ' ROMs'; } else { - romCounter.innerHTML = 'Maximum of 1000 ROMs'; + romCounterLabel.innerHTML = 'Maximum of 1000 ROMs'; } } else { - romCounter.innerHTML = '0 ROMs'; + romCounterLabel.innerHTML = '0 ROMs'; } + romCounter.appendChild(romCounterLabel); filterControls.appendChild(romCounter); gameRoms.appendChild(filterControls); @@ -718,7 +754,7 @@ artworksPosition = 0; } 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); } } @@ -743,7 +779,7 @@ switch (gameScreenshots_Selected.getAttribute('imagetype')) { case "0": // 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; case "1": // video diff --git a/gaseous-server/wwwroot/pages/home.html b/gaseous-server/wwwroot/pages/home.html index 5e42b1e..03b822a 100644 --- a/gaseous-server/wwwroot/pages/home.html +++ b/gaseous-server/wwwroot/pages/home.html @@ -8,8 +8,10 @@
+
+ Order by: +
- Order by:
-
+
+ +
diff --git a/gaseous-server/wwwroot/scripts/gamesformating.js b/gaseous-server/wwwroot/scripts/gamesformating.js index 5b7b752..bd3d753 100644 --- a/gaseous-server/wwwroot/scripts/gamesformating.js +++ b/gaseous-server/wwwroot/scripts/gamesformating.js @@ -8,6 +8,53 @@ "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) { console.log("Displaying page: " + pageNumber); console.log("Page size: " + pageSize); @@ -194,7 +241,7 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification, } gameImage.src = '/images/unknowngame.png'; 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 { gameImage.className = 'game_tile_image unknown'; } @@ -210,7 +257,8 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification, if (gameObject.ageRatings[c].category == classificationDisplayOrder[b]) { shownClassificationBoard = classificationDisplayOrder[b]; 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 { diff --git a/gaseous-server/wwwroot/scripts/main.js b/gaseous-server/wwwroot/scripts/main.js index cff1dfb..e3eb8bf 100644 --- a/gaseous-server/wwwroot/scripts/main.js +++ b/gaseous-server/wwwroot/scripts/main.js @@ -245,7 +245,7 @@ function intToRGB(i) { } function DropDownRenderGameOption(state) { - console.log(JSON.stringify(state)); + console.log(state); if (state.loading) { return state; @@ -260,7 +260,7 @@ function DropDownRenderGameOption(state) { if (state.cover) { response = $( - '' + '' ); } else { response = $( diff --git a/gaseous-server/wwwroot/styles/style.css b/gaseous-server/wwwroot/styles/style.css index 3d620d3..8429a95 100644 --- a/gaseous-server/wwwroot/styles/style.css +++ b/gaseous-server/wwwroot/styles/style.css @@ -289,6 +289,7 @@ input[type='text'], input[type='number'], input[type="email"], input[type="passw border-style: solid; /* border-color: lightgray; */ 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 { @@ -448,13 +449,21 @@ input[id='filter_panel_userrating_max'] { border-color: #2b2b2b; border-radius: 5px; margin-bottom: 10px; - padding: 10px; + padding-top: 7px; + padding-bottom: 10px; + padding-right: 20px; text-align: right; } .games_library_controlblock { - margin-left: 20px; + margin-left: 10px; display: inline-block; + vertical-align: top; +} + +.games_library_label { + display: inline-block; + padding-top: 7px; } #games_library { @@ -636,13 +645,17 @@ input[id='filter_panel_userrating_max'] { .rating_image { display: inline-block; + height: 64px; max-width: 64px; max-height: 64px; margin-right: 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); + /* margin-bottom: 20px; */ +} + +.rating_image_logo_table { + min-height: 70px; + min-width: 70px; + text-align: center; } .rating_image_mini { @@ -1001,7 +1014,7 @@ div[name="properties_toc_item"]:hover,div[name="properties_user_toc_item"]:hover color: lightgray; } -button { +button:not(.select2-selection__choice__remove):not(.ejs_menu_button) { background-color: #555; color: white; border-width: 1px; @@ -1009,10 +1022,12 @@ button { border-style: solid; padding-top: 5px; padding-bottom: 5px; - padding-left: 10px; - padding-right: 10px; + padding-left: 15px; + padding-right: 15px; margin-right: 3px; margin-bottom: 3px; + font-size: 13px; + height: 30px; } button:hover {