fix(player): hover feedback on the launch screen only, no save restore

State tiles now lift and highlight on hover like the save rows, and
neither does so in the Save data tab: the entrance animation released
its transform so the lift shows, and static tiles keep a flat hover.
Clearing a picked state leaves nothing picked again; the save it
displaced no longer comes back. The Save data tab's four copies of the
per-item buttons collapse into one AssetActions composite.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
zurdi
2026-09-16 11:53:57 +02:00
parent 029a78d213
commit 0c03c833c2
6 changed files with 103 additions and 150 deletions

View File

@@ -0,0 +1,60 @@
<script setup lang="ts">
// The per-item buttons of the Save data tab: visibility toggle and delete
// for the user's own saves and states, download for everything.
import { RBtn } from "@v2/lib";
import { useI18n } from "vue-i18n";
import type { Asset, AssetType } from "@/v2/utils/assets";
defineOptions({ inheritAttrs: false });
withDefaults(
defineProps<{
asset: Asset;
type: AssetType;
/** Own items also get the visibility toggle and delete. */
own?: boolean;
toggling?: boolean;
}>(),
{ own: false, toggling: false },
);
const emit = defineEmits<{
toggleVisibility: [];
download: [];
delete: [];
}>();
const { t } = useI18n();
</script>
<template>
<RBtn
v-if="own"
:icon="asset.is_public ? 'mdi-lock-open-variant' : 'mdi-lock'"
variant="text"
size="small"
:color="asset.is_public ? 'var(--r-color-fg-muted)' : 'primary'"
:loading="toggling"
:tooltip="asset.is_public ? t('rom.make-private') : t('rom.make-public')"
:aria-label="asset.is_public ? t('rom.make-private') : t('rom.make-public')"
@click="emit('toggleVisibility')"
/>
<RBtn
icon="mdi-download-outline"
variant="text"
size="small"
:tooltip="t('common.download')"
:aria-label="t('rom.download-named', { name: asset.file_name })"
@click="emit('download')"
/>
<RBtn
v-if="own"
icon="mdi-delete-outline"
variant="text"
size="small"
color="romm-red"
:tooltip="t('common.delete')"
:aria-label="type === 'save' ? t('rom.delete-save') : t('rom.delete-state')"
@click="emit('delete')"
/>
</template>

View File

@@ -32,6 +32,7 @@ import stateApi from "@/services/api/state";
import storeAuth from "@/stores/auth";
import storeConfig from "@/stores/config";
import { getSupportedEJSCores } from "@/utils";
import AssetActions from "@/v2/components/GameDetails/AssetActions.vue";
import UploadAssetDialog, {
type UploadAssetPayload,
} from "@/v2/components/GameDetails/UploadAssetDialog.vue";
@@ -425,44 +426,14 @@ async function toggleStateVisibility(state: StateSchema) {
:scrollable="false"
>
<template #actions="{ asset }">
<RBtn
:icon="asset.is_public ? 'mdi-lock-open-variant' : 'mdi-lock'"
variant="text"
size="small"
:color="
asset.is_public ? 'var(--r-color-fg-muted)' : 'primary'
"
:loading="togglingSaveId === asset.id"
:tooltip="
asset.is_public
? t('rom.make-private')
: t('rom.make-public')
"
:aria-label="
asset.is_public
? t('rom.make-private')
: t('rom.make-public')
"
@click="toggleSaveVisibility(asSave(asset))"
/>
<RBtn
icon="mdi-download-outline"
variant="text"
size="small"
:tooltip="t('common.download')"
:aria-label="
t('rom.download-named', { name: asset.file_name })
"
@click="downloadAsset(asset)"
/>
<RBtn
icon="mdi-delete-outline"
variant="text"
size="small"
color="romm-red"
:tooltip="t('common.delete')"
:aria-label="t('rom.delete-save')"
@click="deleteSave(asSave(asset))"
<AssetActions
:asset="asset"
type="save"
own
:toggling="togglingSaveId === asset.id"
@toggle-visibility="toggleSaveVisibility(asSave(asset))"
@download="downloadAsset(asset)"
@delete="deleteSave(asSave(asset))"
/>
</template>
</AssetList>
@@ -486,13 +457,10 @@ async function toggleStateVisibility(state: StateSchema) {
show-owner
>
<template #actions="{ asset }">
<RBtn
icon="mdi-download-outline"
variant="text"
size="small"
:tooltip="t('common.download')"
:aria-label="t('rom.download-named', { name: asset.file_name })"
@click="downloadAsset(asset)"
<AssetActions
:asset="asset"
type="save"
@download="downloadAsset(asset)"
/>
</template>
</AssetList>
@@ -550,44 +518,14 @@ async function toggleStateVisibility(state: StateSchema) {
group-by="emulator"
>
<template #actions="{ asset }">
<RBtn
:icon="asset.is_public ? 'mdi-lock-open-variant' : 'mdi-lock'"
variant="text"
size="small"
:color="
asset.is_public ? 'var(--r-color-fg-muted)' : 'primary'
"
:loading="togglingStateId === asset.id"
:tooltip="
asset.is_public
? t('rom.make-private')
: t('rom.make-public')
"
:aria-label="
asset.is_public
? t('rom.make-private')
: t('rom.make-public')
"
@click="toggleStateVisibility(asState(asset))"
/>
<RBtn
icon="mdi-download-outline"
variant="text"
size="small"
:tooltip="t('common.download')"
:aria-label="
t('rom.download-named', { name: asset.file_name })
"
@click="downloadAsset(asset)"
/>
<RBtn
icon="mdi-delete-outline"
variant="text"
size="small"
color="romm-red"
:tooltip="t('common.delete')"
:aria-label="t('rom.delete-state')"
@click="deleteState(asState(asset))"
<AssetActions
:asset="asset"
type="state"
own
:toggling="togglingStateId === asset.id"
@toggle-visibility="toggleStateVisibility(asState(asset))"
@download="downloadAsset(asset)"
@delete="deleteState(asState(asset))"
/>
</template>
</AssetStrip>
@@ -612,13 +550,10 @@ async function toggleStateVisibility(state: StateSchema) {
show-owner
>
<template #actions="{ asset }">
<RBtn
icon="mdi-download-outline"
variant="text"
size="small"
:tooltip="t('common.download')"
:aria-label="t('rom.download-named', { name: asset.file_name })"
@click="downloadAsset(asset)"
<AssetActions
:asset="asset"
type="state"
@download="downloadAsset(asset)"
/>
</template>
</AssetStrip>

View File

@@ -496,9 +496,15 @@ const fadeIndex = computed(() =>
background var(--r-motion-fast) var(--r-motion-ease-out),
border-color var(--r-motion-fast) var(--r-motion-ease-out);
}
/* The entrance animation sits on the tile itself, so its final frame would
pin the transform; releasing the fill lets the hover lift through. */
.r-asset-strip__tile.r-v2-asset-fade {
animation-fill-mode: backwards;
}
.r-asset-strip__tile:hover {
transform: translateY(-2px);
transform: translateY(-1px);
border-color: var(--r-color-border-strong);
background: var(--r-color-surface);
}
.r-asset-strip__tile--active {
border-color: var(--r-color-brand-primary);
@@ -514,6 +520,7 @@ const fadeIndex = computed(() =>
.r-asset-strip__tile--static:hover {
transform: none;
border-color: var(--r-color-border);
background: transparent;
}
/* Kept visible so the count adds up; the tooltip carries the reason. */
.r-asset-strip__tile--disabled {
@@ -524,6 +531,7 @@ const fadeIndex = computed(() =>
.r-asset-strip__tile--disabled:hover {
transform: none;
border-color: var(--r-color-border);
background: transparent;
}
/* One card: the screenshot fills the top, the tinted body sits flush below. */

View File

@@ -99,7 +99,6 @@ import {
import { isJsResource, loadScript } from "@/v2/utils/scriptLoader";
import { rememberCore, resolveRememberedCore } from "./coreStorage";
import {
clearState,
defaultResumeSelection,
newerThanPick,
pickSave,
@@ -306,12 +305,12 @@ function unselectSave() {
}
function selectState(state: StateSchema) {
resume.value = pickState(resume.value, state);
resume.value = pickState(state);
isSavesTabSelected.value = false;
}
function unselectState() {
resume.value = clearState(resume.value);
resume.value = { ...resume.value, state: null };
}
watch(selectedCore, (newSelectedCore) => {

View File

@@ -1,7 +1,6 @@
import { describe, expect, it } from "vitest";
import type { SaveSchema, StateSchema } from "@/__generated__";
import {
clearState,
defaultResumeSelection,
newerThanPick,
pickSave,
@@ -41,34 +40,8 @@ describe("pickSave", () => {
});
describe("pickState", () => {
it("boots from the state and sets the picked save aside", () => {
expect(pickState(pickSave(save(2)), state(9))).toEqual({
save: null,
state: state(9),
aside: save(2),
});
});
it("keeps the aside save across a second state pick", () => {
const first = pickState(pickSave(save(2)), state(9));
expect(pickState(first, state(8)).aside).toEqual(save(2));
});
});
describe("clearState", () => {
it("restores the save the state displaced", () => {
expect(clearState(pickState(pickSave(save(2)), state(9)))).toEqual({
save: save(2),
state: null,
});
});
it("leaves nothing picked when the state was the default", () => {
expect(clearState(defaultResumeSelection([save(1)], [state(9)]))).toEqual({
save: null,
state: null,
});
it("boots from the state and drops any picked save", () => {
expect(pickState(state(9))).toEqual({ save: null, state: state(9) });
});
});
@@ -85,23 +58,11 @@ describe("newerThanPick", () => {
stateAt(8, "2026-09-05T10:00:00Z"),
];
expect(
newerThanPick(
saves,
states,
pickState({ save: null, state: null }, states[0]),
),
).toEqual({
expect(newerThanPick(saves, states, pickState(states[0]))).toEqual({
kind: "state",
asset: states[1],
});
expect(
newerThanPick(
saves,
[states[0]],
pickState({ save: null, state: null }, states[0]),
),
).toEqual({
expect(newerThanPick(saves, [states[0]], pickState(states[0]))).toEqual({
kind: "save",
asset: saves[0],
});

View File

@@ -6,8 +6,6 @@ import { newest } from "@/v2/utils/assets";
export interface ResumeSelection {
save: SaveSchema | null;
state: StateSchema | null;
/** The save a picked state displaced, restored when the state is cleared. */
aside?: SaveSchema | null;
}
/** The newest compatible state, else the newest save; never both. */
@@ -24,17 +22,9 @@ export function pickSave(save: SaveSchema): ResumeSelection {
return { save, state: null };
}
/** A picked state carries its own SRAM, so the picked save steps aside. */
export function pickState(
selection: ResumeSelection,
state: StateSchema,
): ResumeSelection {
return { save: null, state, aside: selection.save ?? selection.aside };
}
/** Clearing the state hands the boot back to the save it displaced. */
export function clearState(selection: ResumeSelection): ResumeSelection {
return { save: selection.aside ?? null, state: null };
/** A picked state carries its own SRAM, so no save stays picked. */
export function pickState(state: StateSchema): ResumeSelection {
return { save: null, state };
}
export type NewerAsset =