Przeglądaj źródła

Fix loading cores in webretro

Colin Powell 3 lat temu
rodzic
commit
0bda75f8eb
3 zmienionych plików z 13 dodań i 1 usunięć
  1. 8 0
      emus/settings.py
  2. 4 0
      games/models.py
  3. 1 1
      templates/games/game_detail.html

+ 8 - 0
emus/settings.py

@@ -140,6 +140,14 @@ SCRAPER_SITE = os.getenv("EMUS_SCRAPER_SITE", "screenscraper")
 JSON_LOGGING = os.getenv("EMUS_JSON_LOGGING", False)
 LOG_TYPE = "json" if JSON_LOGGING else "log"
 
+RETROPIE_WEBRETRO_SYSTEM_MAP = {
+    "n64": "mupen64plus_next",
+    "nes": "nestopia",
+    "megadrive": "genesis_plus_gx",
+    "gba": "mgba",
+    "snes": "snes9x",
+}
+
 default_level = "INFO"
 if DEBUG:
     default_level = "DEBUG"

+ 4 - 0
games/models.py

@@ -67,6 +67,10 @@ class GameSystem(BaseModel):
         max_length=50,
     )
 
+    @property
+    def webretro_core(self):
+        return settings.RETROPIE_WEBRETRO_SYSTEM_MAP.get(self.retropie_slug, None)
+
     def get_absolute_url(self):
         return reverse("games:game_system_detail", args=[self.slug])
 

+ 1 - 1
templates/games/game_detail.html

@@ -34,6 +34,6 @@
 
     <p><a href="{{object.rom_file.url}}">Download ROM</a></p>
     <div id="webretro-container" style="width:800px; height:600px"></div>
-    <script>webretroEmbed(document.getElementById("webretro-container"), "{% static 'js/webretro/index.html' %}", {system: "{{object.game_system.retropie_slug}}", rom:"{{request.scheme}}://{{request.META.HTTP_HOST}}{{object.rom_file.url}}"});</script>
+    <script>webretroEmbed(document.getElementById("webretro-container"), "{% static 'js/webretro/index.html' %}", {core: "{{object.game_system.webretro_core}}", rom:"{{request.scheme}}://{{request.META.HTTP_HOST}}{{object.rom_file.url}}"});</script>
 
 {% endblock %}