mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
define expost isEmulationSupported from playbtn
This commit is contained in:
@@ -1,46 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
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 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 { 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 { value: heartbeat } = storeToRefs(heartbeatStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const configStore = storeConfig();
|
||||
const { config } = storeToRefs(configStore);
|
||||
const auth = storeAuth();
|
||||
const { t } = useI18n();
|
||||
const playBtnRef = ref<InstanceType<typeof PlayBtn>>();
|
||||
|
||||
const computedSize = computed(() => {
|
||||
return props.sizeActionBar === 1 ? "small" : "x-small";
|
||||
});
|
||||
|
||||
const isEmulationSupported = computed(() => {
|
||||
return isAnyEmulationSupported(
|
||||
props.rom.platform_slug,
|
||||
heartbeat.value,
|
||||
config.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) => {
|
||||
@@ -64,8 +55,9 @@ watch(menuOpen, (val) => {
|
||||
</v-col>
|
||||
<v-col v-if="isEmulationSupported" class="d-flex">
|
||||
<play-btn
|
||||
ref="playBtnRef"
|
||||
:rom="rom"
|
||||
:iconEmbedded="true"
|
||||
icon-embedded
|
||||
@click.prevent
|
||||
class="action-bar-btn-small flex-grow-1"
|
||||
:size="computedSize"
|
||||
|
||||
@@ -2,15 +2,11 @@
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, useAttrs } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import storeConfig from "@/stores/config";
|
||||
import storeHeartbeat from "@/stores/heartbeat";
|
||||
import { type SimpleRom } from "@/stores/roms";
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import {
|
||||
isAnyEmulationSupported,
|
||||
isEJSEmulationSupported,
|
||||
isRuffleEmulationSupported,
|
||||
} from "@/utils";
|
||||
import { isEJSEmulationSupported, isRuffleEmulationSupported } from "@/utils";
|
||||
|
||||
const props = defineProps<{ rom: SimpleRom; iconEmbedded?: boolean }>();
|
||||
const attrs = useAttrs();
|
||||
@@ -21,10 +17,17 @@ const { config } = storeToRefs(configStore);
|
||||
const { value: heartbeat } = storeToRefs(heartbeatStore);
|
||||
|
||||
const isEmulationSupported = computed(() => {
|
||||
return isAnyEmulationSupported(
|
||||
props.rom.platform_slug,
|
||||
heartbeat.value,
|
||||
config.value,
|
||||
return (
|
||||
isEJSEmulationSupported(
|
||||
props.rom.platform_slug,
|
||||
heartbeat.value,
|
||||
config.value,
|
||||
) ||
|
||||
isRuffleEmulationSupported(
|
||||
props.rom.platform_slug,
|
||||
heartbeat.value,
|
||||
config.value,
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -45,25 +48,28 @@ function goToPlayer(rom: SimpleRom) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ isEmulationSupported });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-btn
|
||||
v-if="isEmulationSupported && iconEmbedded"
|
||||
v-bind="attrs"
|
||||
:disabled="rom.missing_from_fs"
|
||||
:aria-label="`Play ${rom.name}`"
|
||||
icon="mdi-play"
|
||||
@click="goToPlayer(rom)"
|
||||
/>
|
||||
|
||||
<v-btn
|
||||
v-if="isEmulationSupported && !iconEmbedded"
|
||||
v-bind="attrs"
|
||||
:disabled="rom.missing_from_fs"
|
||||
:aria-label="`Play ${rom.name}`"
|
||||
@click="goToPlayer(rom)"
|
||||
>
|
||||
<v-icon>mdi-play</v-icon>
|
||||
</v-btn>
|
||||
<template v-if="isEmulationSupported">
|
||||
<v-btn
|
||||
v-if="iconEmbedded"
|
||||
v-bind="attrs"
|
||||
:disabled="rom.missing_from_fs"
|
||||
:aria-label="`Play ${rom.name}`"
|
||||
icon="mdi-play"
|
||||
@click="goToPlayer(rom)"
|
||||
/>
|
||||
<v-btn
|
||||
v-else
|
||||
v-bind="attrs"
|
||||
:disabled="rom.missing_from_fs"
|
||||
:aria-label="`Play ${rom.name}`"
|
||||
@click="goToPlayer(rom)"
|
||||
>
|
||||
<v-icon>mdi-play</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -539,25 +539,6 @@ export function isRuffleEmulationSupported(
|
||||
return ["flash", "browser"].includes(slug.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether any kind of emulation is supported for a given platform.
|
||||
*
|
||||
* @param platformSlug The platform slug.
|
||||
* @param heartbeat The heartbeat object.
|
||||
* @param config Optional configuration object.
|
||||
* @returns True if any emulation is supported, false otherwise.
|
||||
*/
|
||||
export function isAnyEmulationSupported(
|
||||
platformSlug: string,
|
||||
heartbeat: Heartbeat,
|
||||
config?: Config,
|
||||
) {
|
||||
return (
|
||||
isEJSEmulationSupported(platformSlug, heartbeat, config) ||
|
||||
isRuffleEmulationSupported(platformSlug, heartbeat, config)
|
||||
);
|
||||
}
|
||||
|
||||
type PlayingStatus = RomUserStatus | "backlogged" | "now_playing" | "hidden";
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user