From 7a8e445471cd99abb3e4b7dd459b805d5b36de76 Mon Sep 17 00:00:00 2001 From: Michael Green <84688932+michael-j-green@users.noreply.github.com> Date: Thu, 13 Jul 2023 13:31:38 +1000 Subject: [PATCH] EmulatorJS - First Version (#23) * feat: added EmulatorJS support for Mega Drive, NES, and N64 (see: #15) * doc: updated attribution in README.MD to include EmulatorJS * ci: updated action to include submodules --- .DS_Store | Bin 10244 -> 12292 bytes .github/workflows/BuildDockerOnTag.yml | 2 + .gitmodules | 3 ++ README.MD | 3 +- gaseous-server/.DS_Store | Bin 6148 -> 6148 bytes gaseous-server/Classes/Roms.cs | 14 +++++ gaseous-server/Controllers/GamesController.cs | 1 + gaseous-server/Models/PlatformMapping.cs | 2 + gaseous-server/Program.cs | 6 ++- gaseous-server/Support/PlatformMap.json | 18 +++++-- gaseous-server/gaseous-server.csproj | 9 ++++ gaseous-server/wwwroot/.DS_Store | Bin 6148 -> 6148 bytes gaseous-server/wwwroot/EmulatorJS | 1 + gaseous-server/wwwroot/pages/EmulatorJS.html | 25 +++++++++ gaseous-server/wwwroot/pages/emulator.html | 48 ++++++++++++++++++ gaseous-server/wwwroot/pages/game.html | 8 ++- gaseous-server/wwwroot/styles/style.css | 6 +++ 17 files changed, 140 insertions(+), 6 deletions(-) create mode 160000 gaseous-server/wwwroot/EmulatorJS create mode 100644 gaseous-server/wwwroot/pages/EmulatorJS.html create mode 100644 gaseous-server/wwwroot/pages/emulator.html diff --git a/.DS_Store b/.DS_Store index b928088be8fce5cada909137566a2e30afe1daf6..75ed3e9f6d008102f3396ac876344f121d6c2a4b 100644 GIT binary patch delta 1827 zcmd6oTWl0n7{||lc3aNSkxrMwmcqELU1)=aZfna`=nZHKtyJ04Z9#E&=g^K!XX?)E z7D#j@qG)1*x@h8yL@Pcv)=JPAygiwCi>5J=L}HXEzUWI|FabQXr;9?A_~;}v-+bRW z=RfE2|7DK%AAh)t5Q2`h-bhFtf2I8PqN)($Ur0z*$qQArn$PRR?{)mWy!diOq+3+wVS5bnb%64WXd+p ze%moz!?uQEE<5ZNgt9la#fBX_<#y)P4ybC{VGl4aW@OklF3Gh5-sg6YdpgcumU4Kk zX^Zg1@JpUr6byyy)-wc=xJHc+vwa`_5PyR~~kCYDYZkERXxh+0Fb_(-)@BdcfWex1*< z&(=LfJ>Q~LYqgZ_^Xi=`#-F0Btk&vfHBO^WmhX|!Xiyqu)sdrz3~PRDv$Bq=x;$XU z6U-EH8CP`VAkW z8dk<|`9X1q@Q`+BP1{;=Dm87Z=U+r1B)`jYxk$5xDmN`98d*g)kTwz}2f1aBk>|*1 z@(wvqJ|JI^Z^=b+iTp;ckUz*(at%Hx2w(-mSc3*c(1=agj4jxTU5H`;dy&8)n6O~O z#bbCJPv97y#z{Pn7m>p&cpZ~qXYeMba1QU{J$!=C@HxK3SGb5@a2da14p(sv*QGM4 zQVL5erBzac6p@;wd!!vwm((u}NeO908WoF>JgU6wK@kd1=}7M6;!KI)k{4;obUf&v zsZ}od5G+7AE+CYq{u#nhS9i}&rT702;dhHX>=u_VSsJWbxw@fw!IC8QQ{mPER$mZ!y>Baz;n ztq+A%i32S1NMlG*eH>3YKe(lyr2PA`@t{*1CMY3Tx4(=JPfn=9zWtIG0PkF?h|?8 zi8;^1Gv|W+bb9=(A9v0u>SS@QE0Ct^);HEywX`(lS}R*~QiYZ~5iHB?TwyIM5`*hF o6lD9~e__+{-+j5#aF6$M^ZsKrHyVC5_j5p-S-#{HZYO%^Pga@JUH||9 delta 236 zcmZokXbF&DU|?W$DortDU{C-uIe-{M3-C-V6q~3gIoUvmMHI+qFacslpg2QLx?yl~ zes00$i4s-p6B~3nfubP5!3`7XcgA}-dv@6I7n*}+(Gf(E%@to|> b!@ah=BG1f6-C*;H3D5^elsHep`?0{Syq diff --git a/.github/workflows/BuildDockerOnTag.yml b/.github/workflows/BuildDockerOnTag.yml index a4963cd..e4e1a6d 100644 --- a/.github/workflows/BuildDockerOnTag.yml +++ b/.github/workflows/BuildDockerOnTag.yml @@ -12,6 +12,8 @@ jobs: - name: Checkout uses: actions/checkout@v3 + with: + submodules: 'true' - name: Set up QEMU uses: docker/setup-qemu-action@v2 diff --git a/.gitmodules b/.gitmodules index e69de29..6863741 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "gaseous-server/wwwroot/EmulatorJS"] + path = gaseous-server/wwwroot/EmulatorJS + url = https://github.com/EmulatorJS/EmulatorJS.git diff --git a/README.MD b/README.MD index 8022cfb..0a48c1f 100644 --- a/README.MD +++ b/README.MD @@ -16,6 +16,7 @@ The following projects are used by Gaseous * https://github.com/JamesNK/Newtonsoft.Json * https://www.nuget.org/packages/MySql.Data/8.0.32.1 * https://github.com/kamranayub/igdb-dotnet +* https://github.com/EmulatorJS/EmulatorJS ## Configuration File When Gaseous-Server is started for the first time, it creates a configuration file at ~/.gaseous-server/config.json if it doesn't exist. Some values can be filled in using environment variables (such as in the case of using docker). @@ -105,4 +106,4 @@ Loop through each of the search candidates searching using: 2. "wherefuzzy" - partial match using wildcards 3. "search" - uses a more flexible search method -Note: that if more than one result is found, the image will be set as "Unknown" as there is no way for Gaseous to know which title is the correct one. \ No newline at end of file +Note: that if more than one result is found, the image will be set as "Unknown" as there is no way for Gaseous to know which title is the correct one. diff --git a/gaseous-server/.DS_Store b/gaseous-server/.DS_Store index f0d37de2d8be1531103bcdcde6a11a61f063f1dd..a751656423110459fd56dc4228311d85da9c1a0c 100644 GIT binary patch delta 125 zcmZoMXfc=|#>B)qu~2NHo+2a5#DLw4m>3yZCi5^p=Vxaq2g4$Ud>|~DEXLT#Zf>Zf zU}|bKc^;#^G@5)_a8X`PeqK5Q0|VpckBrJJo7p+|Ie>-(Ip3Kl^NUz=Fao83(hQpe IM7A&k0Gn|g)c^nh delta 68 zcmZoMXfc=|#>B`mu~2NHo+2aD#DLwC4MbQb^D{l!{G3^VWfRL6#?9;;{2V|vn?Evt XXP(S2V#&b(1dI#}Oq&BlwlD(#oP!a~ diff --git a/gaseous-server/Classes/Roms.cs b/gaseous-server/Classes/Roms.cs index a22b3e4..70c59cc 100644 --- a/gaseous-server/Classes/Roms.cs +++ b/gaseous-server/Classes/Roms.cs @@ -107,6 +107,19 @@ namespace gaseous_server.Classes Path = (string)romDR["path"], Source = (GameRomItem.SourceType)(Int32)romDR["metadatasource"] }; + + // check for a web emulator and update the romItem + foreach (Models.PlatformMapping.PlatformMapItem platformMapping in Models.PlatformMapping.PlatformMap) + { + if (platformMapping.IGDBId == romItem.PlatformId) + { + if (platformMapping.WebEmulator != null) + { + romItem.Emulator = platformMapping.WebEmulator; + } + } + } + return romItem; } @@ -115,6 +128,7 @@ namespace gaseous_server.Classes public long Id { get; set; } public long PlatformId { get; set; } public IGDB.Models.Platform Platform { get; set; } + public Dictionary? Emulator { get; set; } public long GameId { get; set; } public string? Name { get; set; } public long Size { get; set; } diff --git a/gaseous-server/Controllers/GamesController.cs b/gaseous-server/Controllers/GamesController.cs index 0dce880..ca019eb 100644 --- a/gaseous-server/Controllers/GamesController.cs +++ b/gaseous-server/Controllers/GamesController.cs @@ -749,6 +749,7 @@ namespace gaseous_server.Controllers } [HttpGet] + [HttpHead] [Route("{GameId}/roms/{RomId}/file")] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] diff --git a/gaseous-server/Models/PlatformMapping.cs b/gaseous-server/Models/PlatformMapping.cs index f97dd7b..70408c8 100644 --- a/gaseous-server/Models/PlatformMapping.cs +++ b/gaseous-server/Models/PlatformMapping.cs @@ -78,6 +78,8 @@ namespace gaseous_server.Models public string IGDBName { get; set; } public List AlternateNames { get; set; } = new List(); public List KnownFileExtensions { get; set; } = new List(); + public Dictionary? WebEmulator { get; set; } + } } } diff --git a/gaseous-server/Program.cs b/gaseous-server/Program.cs index 82181bf..08d0eec 100644 --- a/gaseous-server/Program.cs +++ b/gaseous-server/Program.cs @@ -76,7 +76,11 @@ app.UseResponseCaching(); app.UseAuthorization(); app.UseDefaultFiles(); -app.UseStaticFiles(); +app.UseStaticFiles(new StaticFileOptions +{ + ServeUnknownFileTypes = true, //allow unkown file types also to be served + DefaultContentType = "plain/text" //content type to returned if fileType is not known. +}); app.MapControllers(); diff --git a/gaseous-server/Support/PlatformMap.json b/gaseous-server/Support/PlatformMap.json index 2790941..2b61be6 100644 --- a/gaseous-server/Support/PlatformMap.json +++ b/gaseous-server/Support/PlatformMap.json @@ -60,7 +60,11 @@ ".MD", ".SG", ".SMD" - ] + ], + "WebEmulator": { + "Type": "EmulatorJS", + "Core": "segaMD" + } }, { "IGDBId": 4, @@ -71,7 +75,11 @@ ], "KnownFileExtensions": [ ".Z64" - ] + ], + "WebEmulator": { + "Type": "EmulatorJS", + "Core": "n64" + } }, { "IGDBId": 18, @@ -88,6 +96,10 @@ ".SFC", ".SMC", ".SWC" - ] + ], + "WebEmulator": { + "Type": "EmulatorJS", + "Core": "nes" + } } ] diff --git a/gaseous-server/gaseous-server.csproj b/gaseous-server/gaseous-server.csproj index 98adb37..50fdd8a 100644 --- a/gaseous-server/gaseous-server.csproj +++ b/gaseous-server/gaseous-server.csproj @@ -119,6 +119,10 @@ + + + + @@ -165,4 +169,9 @@ + + + Always + + diff --git a/gaseous-server/wwwroot/.DS_Store b/gaseous-server/wwwroot/.DS_Store index 022e6adfa8abea1fa9290e20313444f157376fd2..d8ac01facdd8a2f1e6e256fc67eb2df883f224b0 100644 GIT binary patch delta 167 zcmZoMXfc=|#>B)qu~2NHo}wrV0|Nsi1A_nqLn1>7Lq0u(X6A-E3Z|w;wK@vbmPQ6T3MR&8lQ%FLD`M4B7F?8>T_YKxY80`p!I=U&N9F=n5cWVAvcWvV|D{x9cH{ delta 84 zcmZoMXfc=|#>B`mu~2NHo}wrd0|Nsi1A_nqLn=dYQh9MfQcix-#KPs14MbQr^E3Zo lSuDW9w3(fQp9838Gb77)=E?jbmK;D`AZ<*W14Onk0{}+B63GAn diff --git a/gaseous-server/wwwroot/EmulatorJS b/gaseous-server/wwwroot/EmulatorJS new file mode 160000 index 0000000..f7fa5d4 --- /dev/null +++ b/gaseous-server/wwwroot/EmulatorJS @@ -0,0 +1 @@ +Subproject commit f7fa5d41487a424233b40e903020455606d68fee diff --git a/gaseous-server/wwwroot/pages/EmulatorJS.html b/gaseous-server/wwwroot/pages/EmulatorJS.html new file mode 100644 index 0000000..bb720d2 --- /dev/null +++ b/gaseous-server/wwwroot/pages/EmulatorJS.html @@ -0,0 +1,25 @@ +
+
+
+ + + \ No newline at end of file diff --git a/gaseous-server/wwwroot/pages/emulator.html b/gaseous-server/wwwroot/pages/emulator.html new file mode 100644 index 0000000..d742394 --- /dev/null +++ b/gaseous-server/wwwroot/pages/emulator.html @@ -0,0 +1,48 @@ +
+
+
+ +
+ + diff --git a/gaseous-server/wwwroot/pages/game.html b/gaseous-server/wwwroot/pages/game.html index 80a1851..bd878fd 100644 --- a/gaseous-server/wwwroot/pages/game.html +++ b/gaseous-server/wwwroot/pages/game.html @@ -304,7 +304,7 @@ var newTable = document.createElement('table'); newTable.className = 'romtable'; newTable.setAttribute('cellspacing', 0); - newTable.appendChild(createTableRow(true, ['Name', 'Size', 'Media', '', ''])); + newTable.appendChild(createTableRow(true, ['Name', 'Size', 'Media', '', '', ''])); var lastPlatform = ''; for (var i = 0; i < result.length; i++) { @@ -318,11 +318,17 @@ newTable.appendChild(platformRow); } + var launchButton = ''; + if (result[i].emulator) { + launchButton = 'Start'; + } + var newRow = [ '' + result[i].name + '', formatBytes(result[i].size, 2), result[i].romTypeMedia, result[i].mediaLabel, + launchButton, '...' ]; newTable.appendChild(createTableRow(false, newRow, 'romrow', 'romcell')); diff --git a/gaseous-server/wwwroot/styles/style.css b/gaseous-server/wwwroot/styles/style.css index 449efc9..1b3d73e 100644 --- a/gaseous-server/wwwroot/styles/style.css +++ b/gaseous-server/wwwroot/styles/style.css @@ -578,4 +578,10 @@ button:disabled { .redbutton:disabled { background-color: #555; +} + +#emulator { + margin: 0 auto; + width: 640px; + padding-top: 100px; } \ No newline at end of file