unified emulation experience

This commit is contained in:
zurdi
2024-06-12 12:33:36 +02:00
parent 0e8b06fdfc
commit ce70e9499e
17 changed files with 108 additions and 310 deletions

View File

@@ -2,8 +2,8 @@
import { ref, inject } from "vue";
import { useDisplay } from "vuetify";
import type { Emitter } from "mitt";
import RDialog from "@/components/common/Dialog.vue";
import type { Events } from "@/types/emitter";
import storeRoms, { type DetailedRom } from "@/stores/roms";
import saveApi from "@/services/api/save";
import stateApi from "@/services/api/state";
@@ -16,7 +16,6 @@ const assetType = ref<"user_saves" | "user_states">("user_saves");
const romRef = ref<DetailedRom | null>(null);
const assets = ref<(SaveSchema | StateSchema)[]>([]);
const deleteFromFs = ref(false);
const emitter = inject<Emitter<Events>>("emitter");
emitter?.on("showDeleteSavesDialog", ({ rom, saves }) => {
assetType.value = "user_saves";
@@ -80,7 +79,22 @@ function closeDialog() {
</script>
<template>
<v-dialog
<r-dialog
@close="closeDialog"
v-model="show"
icon="mdi-pencil-box"
:width="lgAndUp ? '60vw' : '95vw'"
>
<template #content>
<v-row class="justify-center pa-2" no-gutters>
<span>Deleting the following</span>
<span class="text-romm-accent-1 mx-1">{{ assets.length }}</span>
<span>{{ assetType }}. Do you confirm?</span>
</v-row>
</template>
</r-dialog>
<!-- <v-dialog
:model-value="show"
width="auto"
no-click-animation
@@ -154,22 +168,5 @@ function closeDialog() {
/>
</v-toolbar>
</v-card>
</v-dialog>
</v-dialog> -->
</template>
<style scoped>
.delete-content {
width: 900px;
max-height: 600px;
}
.delete-content-tablet {
width: 570px;
max-height: 600px;
}
.delete-content-mobile {
width: 85vw;
max-height: 600px;
}
</style>

View File

@@ -6,13 +6,11 @@ import RommLogo from "@/components/common/RommLogo.vue";
defineProps<{ rail: boolean }>();
</script>
<template>
<v-list-item :class="{ 'ml-1': !rail, 'ml-0': rail }" class="my-2">
<template #prepend>
<router-link :to="{ name: 'dashboard' }">
<romm-iso :size="rail ? 40 : 60" />
<romm-logo v-if="!rail" :size="60" class="ml-3 mt-1" />
</router-link>
</template>
<v-list-item :class="{ 'ml-0': rail }" class="my-4">
<router-link :to="{ name: 'dashboard' }">
<romm-iso :size="rail ? 40 : 60" class="ml-1" />
<romm-logo v-if="!rail" :size="60" class="ml-3" />
</router-link>
<template v-if="!rail" #append>
<rail-btn :rail="rail" class="ml-1" />
</template>

View File

@@ -9,20 +9,15 @@ import { getDownloadLink, isEmulationSupported } from "@/utils";
import type { Emitter } from "mitt";
import { inject, ref } from "vue";
// Props
const props = defineProps<{ rom: DetailedRom }>();
const downloadStore = storeDownload();
const emitter = inject<Emitter<Events>>("emitter");
const auth = storeAuth();
const emulation = ref(false);
const playInfoIcon = ref("mdi-play");
const emulationSupported = isEmulationSupported(props.rom.platform_slug);
function toggleEmulation() {
emulation.value = !emulation.value;
playInfoIcon.value = emulation.value ? "mdi-information" : "mdi-play";
emitter?.emit("showEmulation", null);
}
// Functions
async function copyDownloadLink(rom: DetailedRom) {
const downloadLink =
location.protocol +

View File

@@ -1,171 +0,0 @@
<script setup lang="ts">
import type { FirmwareSchema, SaveSchema, StateSchema } from "@/__generated__";
import rom from "@/services/api/rom";
import type { Platform } from "@/stores/platforms";
import type { DetailedRom } from "@/stores/roms";
import { formatBytes, getSupportedCores } from "@/utils";
import Player from "@/views/Play/Player.vue";
import { isNull } from "lodash";
import { ref } from "vue";
const props = defineProps<{ rom: DetailedRom; platform: Platform }>();
const biosRef = ref<FirmwareSchema | null>(null);
const saveRef = ref<SaveSchema | null>(null);
const stateRef = ref<StateSchema | null>(null);
const gameRunning = ref(false);
const supportedCores = getSupportedCores(props.platform.slug);
const coreRef = ref<string | null>(supportedCores[0]);
const storedFSOP = localStorage.getItem("fullScreenOnPlay");
const fullScreenOnPlay = ref(isNull(storedFSOP) ? true : storedFSOP === "true");
const script = document.createElement("script");
script.src = "/assets/emulatorjs/loader.js";
script.async = true;
function onPlay() {
window.EJS_fullscreenOnLoaded = fullScreenOnPlay.value;
document.body.appendChild(script);
gameRunning.value = true;
}
function onFullScreenChange() {
localStorage.setItem("fullScreenOnPlay", fullScreenOnPlay.value.toString());
}
</script>
<template>
<v-row v-if="rom && !gameRunning" no-gutters class="align-center">
<v-col cols="5" class="text-truncate mx-1">
<v-select
v-if="supportedCores.length > 1"
v-model="coreRef"
density="compact"
class="my-2"
hide-details
variant="outlined"
clearable
label="Core"
:items="
supportedCores.map((c) => ({
title: c,
value: c,
}))
"
/>
<v-select
v-model="biosRef"
density="compact"
class="my-2"
hide-details
variant="outlined"
clearable
label="BIOS"
:items="
props.platform.firmware?.map((f) => ({
title: f.file_name,
value: f,
})) ?? []
"
/>
<v-select
v-model="saveRef"
density="compact"
class="my-2"
hide-details
variant="outlined"
clearable
label="Save"
:items="
props.rom.user_saves?.map((s) => ({
title: s.file_name,
subtitle: `${s.emulator} - ${formatBytes(s.file_size_bytes)}`,
value: s,
})) ?? []
"
/>
<v-select
v-model="stateRef"
density="compact"
class="my-2"
hide-details
variant="outlined"
clearable
label="State"
:items="
props.rom.user_states?.map((s) => ({
title: s.file_name,
subtitle: `${s.emulator} - ${formatBytes(s.file_size_bytes)}`,
value: s,
})) ?? []
"
/>
<!-- <v-select
density="compact"
class="my-2"
hide-details
variant="outlined"
clearable
disabled
label="Patch"
:items="[
'Advance Wars Balance (AW1) by Kartal',
'War Room Sturm (AW1) by Kartal',
]"
/> -->
<v-checkbox
v-model="fullScreenOnPlay"
hide-details
color="romm-accent-1"
label="Full screen"
@change="onFullScreenChange"
/>
</v-col>
<v-col cols="6" class="mx-1">
<v-img
class="bg-black"
height="160"
:src="
stateRef?.screenshot?.download_path ??
props.rom.merged_screenshots[0] ??
`/assets/emulatorjs/loading_black.png`
"
/>
</v-col>
</v-row>
<v-row v-if="!gameRunning" no-gutters class="align-center mt-6">
<v-col cols="5">
<v-btn
block
density="compact"
class="text-romm-accent-1"
variant="outlined"
size="x-large"
@click="onPlay()"
>
<v-icon class="mr-2"> mdi-play </v-icon>Play
</v-btn>
</v-col>
<v-spacer />
<v-col cols="5">
<img width="150" src="/assets/emulatorjs/powered_by_emulatorjs.png" />
</v-col>
</v-row>
<v-row no-gutters>
<v-col v-if="gameRunning" id="game-wrapper" cols="12" rounded>
<player
:rom="props.rom"
:state="stateRef"
:save="saveRef"
:bios="biosRef"
:core="coreRef"
/>
</v-col>
</v-row>
</template>
<style>
#game-wrapper {
aspect-ratio: 16 / 9;
}
</style>

View File

@@ -6,51 +6,40 @@ defineProps<{ platform: Platform }>();
</script>
<template>
<router-link
id="router-link"
:to="{ name: 'platform', params: { platform: platform.id } }"
>
<v-hover v-slot="{ isHovering, props }">
<v-card
v-bind="props"
class="bg-terciary transform-scale"
:class="{ 'on-hover': isHovering }"
:elevation="isHovering ? 20 : 3"
>
<v-card-text>
<v-row class="pa-1 justify-center bg-primary">
<div
:title="platform.name?.toString()"
class="px-2 text-truncate text-caption"
>
{{ platform.name }}
</div>
</v-row>
<v-row class="pa-1 justify-center">
<platform-icon
:key="platform.slug"
:slug="platform.slug"
:size="105"
class="mt-2"
/>
<v-chip
class="bg-chip position-absolute"
size="x-small"
style="bottom: 1rem; right: 1rem"
label
>
{{ platform.rom_count }}
</v-chip>
</v-row>
</v-card-text>
</v-card>
</v-hover>
</router-link>
<v-hover v-slot="{ isHovering, props }">
<v-card
v-bind="props"
class="bg-terciary transform-scale"
:class="{ 'on-hover': isHovering }"
:elevation="isHovering ? 20 : 3"
:to="{ name: 'platform', params: { platform: platform.id } }"
>
<v-card-text>
<v-row class="pa-1 justify-center bg-primary">
<div
:title="platform.name?.toString()"
class="px-2 text-truncate text-caption"
>
{{ platform.name }}
</div>
</v-row>
<v-row class="pa-1 justify-center">
<platform-icon
:key="platform.slug"
:slug="platform.slug"
:size="105"
class="mt-2"
/>
<v-chip
class="bg-chip position-absolute"
size="x-small"
style="bottom: 1rem; right: 1rem"
label
>
{{ platform.rom_count }}
</v-chip>
</v-row>
</v-card-text>
</v-card>
</v-hover>
</template>
<style scoped>
#router-link {
text-decoration: none;
color: inherit;
}
</style>

View File

@@ -92,6 +92,10 @@ onMounted(() => {
:headers="HEADERS"
:items="usersStore.all"
:sort-by="[{ key: 'username', order: 'asc' }]"
fixed-header
fixed-footer
hide-default-footer
hover
>
<template #item.avatar_path="{ item }">
<v-avatar>

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import InterfaceOption from "@/components/ControlPanel/General/Interface/Option.vue";
import InterfaceOption from "@/components/ControlPanel/General/InterfaceOption.vue";
import RSection from "@/components/common/Section.vue";
import { isNull } from "lodash";
import { computed, ref } from "vue";

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import Task from "@/components/ControlPanel/General/Tasks/Task.vue";
import Task from "@/components/ControlPanel/General/TaskOption.vue";
import RSection from "@/components/common/Section.vue";
import api from "@/services/api/index";
import storeHeartbeat from "@/stores/heartbeat";

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import ThemeOption from "@/components/ControlPanel/General/Theme/Option.vue";
import ThemeOption from "@/components/ControlPanel/General/ThemeOption.vue";
import RSection from "@/components/common/Section.vue";
import { autoThemeKey, themes } from "@/styles/themes";
import { isKeyof } from "@/types";

View File

@@ -12,7 +12,7 @@ const userSearch = ref("");
const { mdAndDown } = useDisplay();
</script>
<template>
<r-section icon="mdi-account-group" title="Users">
<!-- <r-section icon="mdi-account-group" title="Users">
<template #toolbar-append>
<v-btn
prepend-icon="mdi-plus"
@@ -24,30 +24,30 @@ const { mdAndDown } = useDisplay();
</v-btn>
</template>
<template #content>
<v-text-field
v-model="userSearch"
prepend-inner-icon="mdi-magnify"
label="Search"
rounded="0"
single-line
hide-details
clearable
density="comfortable"
class="bg-secondary"
/>
<users-table
:class="{ 'table-desktop': !mdAndDown, 'table-mobile': mdAndDown }"
:user-search="userSearch"
/>
</template>
</r-section>
</r-section> -->
<v-text-field
v-model="userSearch"
prepend-inner-icon="mdi-magnify"
label="Search"
rounded="0"
single-line
hide-details
clearable
density="comfortable"
class="bg-secondary"
/>
<users-table
:class="{ 'table-desktop': !mdAndDown, 'table-mobile': mdAndDown }"
:user-search="userSearch"
/>
</template>
<style scoped>
.table-desktop {
height: calc(100vh - 189px) !important;
height: calc(100vh - 132px) !important;
}
.table-mobile {
height: calc(100vh - 245px) !important;
height: calc(100vh - 243px) !important;
}
</style>

View File

@@ -318,9 +318,9 @@ watch(currentView, (newView) => {
<style scoped>
.table-desktop {
height: calc(100vh - 50px) !important;
height: calc(100vh - 48px) !important;
}
.table-mobile {
height: calc(100vh - 164px) !important;
height: calc(100vh - 104px) !important;
}
</style>

View File

@@ -4,7 +4,6 @@ import Cover from "@/components/Game/Card/Base.vue";
import ActionBar from "@/components/Game/Details/ActionBar.vue";
import AdditionalContent from "@/components/Game/Details/AdditionalContent.vue";
import BackgroundHeader from "@/components/Game/Details/BackgroundHeader.vue";
import Emulation from "@/components/Game/Details/Emulation.vue";
import Info from "@/components/Game/Details/Info/Base.vue";
import Notes from "@/components/Game/Details/Notes.vue";
import RelatedGames from "@/components/Game/Details/RelatedGames.vue";
@@ -33,15 +32,9 @@ const tab = ref<
| "additionalcontent"
| "screenshots"
| "relatedgames"
| "emulation"
>("details");
const { smAndDown, mdAndDown, mdAndUp, lgAndUp } = useDisplay();
const emitter = inject<Emitter<Events>>("emitter");
const showEmulation = ref(false);
emitter?.on("showEmulation", () => {
showEmulation.value = !showEmulation.value;
tab.value = showEmulation.value ? "emulation" : "details";
});
const noRomError = ref(false);
async function fetchDetails() {
@@ -152,12 +145,7 @@ watch(
}"
no-gutters
>
<v-tabs
v-if="!showEmulation"
v-model="tab"
slider-color="romm-accent-1"
rounded="0"
>
<v-tabs v-model="tab" slider-color="romm-accent-1" rounded="0">
<v-tab value="details" rounded="0"> Details </v-tab>
<v-tab value="saves" rounded="0"> Saves </v-tab>
<v-tab value="states" rounded="0"> States </v-tab>
@@ -188,18 +176,10 @@ watch(
Related Games
</v-tab>
</v-tabs>
<v-tabs
v-if="showEmulation"
v-model="tab"
slider-color="romm-accent-1"
rounded="0"
>
<v-tab value="emulation" rounded="0"> Emulation </v-tab>
</v-tabs>
</v-row>
<v-row no-gutters class="mb-4">
<v-col cols="12">
<v-window v-if="!showEmulation" v-model="tab" class="py-2">
<v-window v-model="tab" class="py-2">
<v-window-item value="details">
<info :rom="rom" :platform="platform" />
</v-window-item>
@@ -237,11 +217,6 @@ watch(
<related-games :rom="rom" />
</v-window-item>
</v-window>
<v-window v-if="showEmulation" v-model="tab" class="py-2">
<v-window-item value="emulation">
<emulation :rom="rom" :platform="platform" />
</v-window-item>
</v-window>
</v-col>
</v-row>
</v-col>

View File

@@ -57,7 +57,7 @@ onMounted(async () => {
<template>
<v-row
v-if="rom"
class="align-center justify-center h-screen scroll"
class="align-center justify-center scroll"
no-gutters
>
<v-col

View File

@@ -1,11 +1,13 @@
<script setup lang="ts">
import { ref, onBeforeUnmount } from "vue";
import stateApi from "@/services/api/state";
import type { FirmwareSchema, SaveSchema, StateSchema } from "@/__generated__";
import saveApi, { saveApi as api } from "@/services/api/save";
import screenshotApi from "@/services/api/screenshot";
import { getSupportedCores } from "@/utils";
import type { FirmwareSchema, SaveSchema, StateSchema } from "@/__generated__";
import stateApi from "@/services/api/state";
import type { DetailedRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import { getSupportedCores } from "@/utils";
import type { Emitter } from "mitt";
import { inject, onBeforeUnmount, ref } from "vue";
const props = defineProps<{
rom: DetailedRom;
@@ -17,6 +19,7 @@ const props = defineProps<{
const romRef = ref<DetailedRom>(props.rom);
const saveRef = ref<SaveSchema | null>(props.save);
const stateRef = ref<StateSchema | null>(props.state);
const emitter = inject<Emitter<Events>>("emitter");
onBeforeUnmount(() => {
window.location.reload();
@@ -203,7 +206,15 @@ window.EJS_onSaveState = function ({
.catch((e) => console.log(e));
}
})
.catch(() => {
.catch(({ response, message }) => {
emitter?.emit("snackbarShow", {
msg: `Unable to save state to RomM: ${
response?.data?.detail || response?.statusText || message
}`,
icon: "mdi-close-circle",
color: "red",
timeout: 4000,
});
if (window.EJS_emulator.saveInBrowserSupported()) {
window.EJS_emulator.displayMessage("SAVED TO BROWSER");
} else {