diff --git a/frontend/src/components/Details/ActionBar.vue b/frontend/src/components/Details/ActionBar.vue index 906194e03..f29f89be2 100644 --- a/frontend/src/components/Details/ActionBar.vue +++ b/frontend/src/components/Details/ActionBar.vue @@ -5,45 +5,21 @@ import { computed, inject, ref } from "vue"; import { useI18n } from "vue-i18n"; import AdminMenu from "@/components/common/Game/AdminMenu.vue"; import CopyRomDownloadLinkDialog from "@/components/common/Game/Dialog/CopyDownloadLink.vue"; +import PlayBtn from "@/components/common/Game/PlayBtn.vue"; import romApi from "@/services/api/rom"; import storeAuth from "@/stores/auth"; -import storeConfig from "@/stores/config"; import storeDownload from "@/stores/download"; -import storeHeartbeat from "@/stores/heartbeat"; import type { DetailedRom } from "@/stores/roms"; import type { Events } from "@/types/emitter"; -import { - getDownloadLink, - is3DSCIARom, - isEJSEmulationSupported, - isRuffleEmulationSupported, -} from "@/utils"; +import { getDownloadLink, is3DSCIARom } from "@/utils"; const props = defineProps<{ rom: DetailedRom }>(); const downloadStore = storeDownload(); -const heartbeatStore = storeHeartbeat(); const emitter = inject>("emitter"); -const playInfoIcon = ref("mdi-play"); const qrCodeIcon = ref("mdi-qrcode"); -const configStore = storeConfig(); -const { config } = storeToRefs(configStore); const auth = storeAuth(); const { t } = useI18n(); -const platformSlug = computed(() => - props.rom.platform_slug in config.value.PLATFORMS_VERSIONS - ? config.value.PLATFORMS_VERSIONS[props.rom.platform_slug] - : props.rom.platform_slug, -); - -const ejsEmulationSupported = computed(() => { - return isEJSEmulationSupported(platformSlug.value, heartbeatStore.value); -}); - -const ruffleEmulationSupported = computed(() => { - return isRuffleEmulationSupported(platformSlug.value, heartbeatStore.value); -}); - const is3DSRom = computed(() => { return is3DSCIARom(props.rom); }); @@ -105,34 +81,7 @@ async function copyDownloadLink(rom: DetailedRom) { > - - - - - - + import type { Emitter } from "mitt"; -import { storeToRefs } from "pinia"; import { computed, inject, ref, watch } from "vue"; import { useI18n } from "vue-i18n"; import AdminMenu from "@/components/common/Game/AdminMenu.vue"; -import { ROUTES } from "@/plugins/router"; +import PlayBtn from "@/components/common/Game/PlayBtn.vue"; import romApi from "@/services/api/rom"; import storeAuth from "@/stores/auth"; -import storeConfig from "@/stores/config"; import storeDownload from "@/stores/download"; -import storeHeartbeat from "@/stores/heartbeat"; import type { SimpleRom } from "@/stores/roms"; import type { Events } from "@/types/emitter"; -import { - isEJSEmulationSupported, - isRuffleEmulationSupported, - is3DSCIARom, -} from "@/utils"; +import { is3DSCIARom } from "@/utils"; const props = defineProps<{ rom: SimpleRom; sizeActionBar: number }>(); +const { t } = useI18n(); const emit = defineEmits(["menu-open", "menu-close"]); const downloadStore = storeDownload(); -const heartbeatStore = storeHeartbeat(); const emitter = inject>("emitter"); -const configStore = storeConfig(); -const { config } = storeToRefs(configStore); const auth = storeAuth(); -const { t } = useI18n(); +const playBtnRef = ref>(); const computedSize = computed(() => { return props.sizeActionBar === 1 ? "small" : "x-small"; }); -const platformSlug = computed(() => { - return props.rom.platform_slug in config.value.PLATFORMS_VERSIONS - ? config.value.PLATFORMS_VERSIONS[props.rom.platform_slug] - : props.rom.platform_slug; -}); - -const ejsEmulationSupported = computed(() => { - return isEJSEmulationSupported(platformSlug.value, heartbeatStore.value); -}); - -const ruffleEmulationSupported = computed(() => { - return isRuffleEmulationSupported(platformSlug.value, heartbeatStore.value); -}); - const is3DSRom = computed(() => { return is3DSCIARom(props.rom); }); +const isEmulationSupported = computed(() => { + // Default to true if playBtnRef is not set + return playBtnRef.value?.isEmulationSupported ?? true; +}); + const menuOpen = ref(false); watch(menuOpen, (val) => { @@ -71,43 +53,16 @@ watch(menuOpen, (val) => { :aria-label="`${t('rom.download')} ${rom.name}`" /> - - + - diff --git a/frontend/src/components/common/Game/PlayBtn.vue b/frontend/src/components/common/Game/PlayBtn.vue new file mode 100644 index 000000000..1ca31619d --- /dev/null +++ b/frontend/src/components/common/Game/PlayBtn.vue @@ -0,0 +1,75 @@ + + + diff --git a/frontend/src/components/common/Game/Table.vue b/frontend/src/components/common/Game/Table.vue index 18e78cd67..e1f7ce506 100644 --- a/frontend/src/components/common/Game/Table.vue +++ b/frontend/src/components/common/Game/Table.vue @@ -5,24 +5,17 @@ import { computed } from "vue"; import { useRouter } from "vue-router"; import AdminMenu from "@/components/common/Game/AdminMenu.vue"; import FavBtn from "@/components/common/Game/FavBtn.vue"; +import PlayBtn from "@/components/common/Game/PlayBtn.vue"; import RAvatarRom from "@/components/common/Game/RAvatar.vue"; import MissingFromFSIcon from "@/components/common/MissingFromFSIcon.vue"; import PlatformIcon from "@/components/common/Platform/Icon.vue"; import { ROUTES } from "@/plugins/router"; import romApi from "@/services/api/rom"; import storeAuth from "@/stores/auth"; -import storeConfig from "@/stores/config"; import storeDownload from "@/stores/download"; import storeGalleryFilter from "@/stores/galleryFilter"; -import storeHeartbeat from "@/stores/heartbeat"; import storeRoms, { type SimpleRom } from "@/stores/roms"; -import { - formatBytes, - isEJSEmulationSupported, - isRuffleEmulationSupported, - languageToEmoji, - regionToEmoji, -} from "@/utils"; +import { formatBytes, languageToEmoji, regionToEmoji } from "@/utils"; withDefaults( defineProps<{ @@ -38,9 +31,6 @@ const downloadStore = storeDownload(); const romsStore = storeRoms(); const { filteredRoms, selectedRoms, fetchingRoms, fetchTotalRoms } = storeToRefs(romsStore); -const heartbeatStore = storeHeartbeat(); -const configStore = storeConfig(); -const { config } = storeToRefs(configStore); const auth = storeAuth(); const galleryFilterStore = storeGalleryFilter(); @@ -102,22 +92,6 @@ function rowClick(_: Event, row: { item: SimpleRom }) { romsStore.resetSelection(); } -function getTruePlatformSlug(platformSlug: string) { - return platformSlug in config.value.PLATFORMS_VERSIONS - ? config.value.PLATFORMS_VERSIONS[platformSlug] - : platformSlug; -} - -function checkIfEJSEmulationSupported(platformSlug: string) { - const slug = getTruePlatformSlug(platformSlug); - return isEJSEmulationSupported(slug, heartbeatStore.value); -} - -function checkIfRuffleEmulationSupported(platformSlug: string) { - const slug = getTruePlatformSlug(platformSlug); - return isRuffleEmulationSupported(slug, heartbeatStore.value); -} - function updateSelectAll() { if (selectedRoms.value.length === filteredRoms.value.length) { romsStore.resetSelection(); @@ -317,34 +291,7 @@ function updateOptions({ sortBy }: { sortBy: SortBy }) { > mdi-download - - mdi-play - - - mdi-play - + 0 && - gl instanceof WebGLRenderingContext + getSupportedEJSCores(slug).length > 0 && gl instanceof WebGLRenderingContext ); } @@ -521,16 +525,18 @@ export function getControlSchemeForPlatform( * * @param platformSlug The platform slug. * @param heartbeat The heartbeat object. + * @param config Optional configuration object. * @returns True if supported, false otherwise. */ export function isRuffleEmulationSupported( platformSlug: string, heartbeat: Heartbeat, + config?: Config, ) { - return ( - ["flash", "browser"].includes(platformSlug.toLowerCase()) && - !heartbeat.EMULATION.DISABLE_RUFFLE_RS - ); + if (heartbeat.EMULATION.DISABLE_RUFFLE_RS) return false; + + const slug = config?.PLATFORMS_VERSIONS[platformSlug] || platformSlug; + return ["flash", "browser"].includes(slug.toLowerCase()); } type PlayingStatus = RomUserStatus | "backlogged" | "now_playing" | "hidden";