fix(player): boot from the picked save and file web saves under sync slots

Picking a save on the v2 EmulatorJS launch screen never disarmed the
auto-selected newest state, and the player loads a state in preference
to a save, so the pick was ignored whenever any state existed. Selection
rules now live in a pure module: a picked save disarms the state, a
picked state keeps the bound save as the write-back target.

Web saves now follow the sync clients' slot model. New saves go to the
"autosave" slot (capped history) or the slot picked on the launch
screen; a save that already has a slot keeps it; a legacy slot-less save
stays as an archive and its progress moves to the picked slot. Each
session opens one new version in the slot and updates it on later
writes, so periodic sync does not churn the history.

The launch screen gains a slot selector with an info tooltip, the save
preview collapses to a compact row so the list gets the height, the
pre-game screen fits the viewport on desktop with only the asset list
scrolling, and the slot chip drops its redundant label.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
zurdi
2026-09-15 18:14:53 +02:00
parent 5294bd61b5
commit 4a8d530ce1
29 changed files with 678 additions and 189 deletions

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Показва бутон „Присъединяване“ на страницата на играта и запазва чата и уеб камерата видими.",
"mute": "Заглушаване",
"new-memory-card": "Нова карта",
"new-slot": "Нов слот…",
"no-memory-cards": "Все още няма карти памет",
"no-save-selected": "Няма избран запис",
"no-saves-available": "Няма налични записи",
@@ -129,6 +130,7 @@
"save-data-none-note": "Играйте и запишете в играта. Ще се синхронизира при края на сесията.",
"save-data-note": "Възстановено на конзолата преди стартиране. Заредете го от менюто на самата игра.",
"save-data-synced": "Синхронизирано",
"save-progress-to": "Записвай напредъка в",
"save-slot": "Слот за запазване",
"save-state": "Запазване на състояние",
"select-background-color": "Избери цвят на фона",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Показване на рамка",
"slot": "Слот",
"slot-name": "Име на слота",
"slot-tooltip": "Напредъкът се записва като нови версии в този слот, откъдето го вземат другите устройства.",
"start-fresh-hint": "Избери един по-долу, за да продължиш, или натисни Играй, за да започнеш отначало.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Na stránce hry se zobrazí tlačítko Připojit se a chat i webkamera zůstanou viditelné.",
"mute": "Ztlumit",
"new-memory-card": "Nová karta",
"new-slot": "Nový slot…",
"no-memory-cards": "Zatím žádné paměťové karty",
"no-save-selected": "Není vybrána žádná uložená pozice",
"no-saves-available": "Nejsou k dispozici žádné uložené pozice",
@@ -129,6 +130,7 @@
"save-data-none-note": "Hrajte a uložte ve hře. Po skončení relace se data synchronizují.",
"save-data-note": "Obnoveno do konzole před spuštěním. Načtěte je z nabídky samotné hry.",
"save-data-synced": "Synchronizováno",
"save-progress-to": "Ukládat postup do",
"save-slot": "Pozice uložení",
"save-state": "Uložit stav",
"select-background-color": "Vybrat barvu pozadí",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Zobrazit rámeček",
"slot": "Slot",
"slot-name": "Název slotu",
"slot-tooltip": "Postup se ukládá jako nové verze do tohoto slotu, odkud si ho stáhnou ostatní zařízení.",
"start-fresh-hint": "Vyberte níže pro pokračování, nebo stiskněte Hrát pro nový začátek.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Zeigt auf der Seite dieses Spiels eine Schaltfläche zum Beitreten und hält Chat und Webcam sichtbar.",
"mute": "Stummschalten",
"new-memory-card": "Neue Karte",
"new-slot": "Neuer Slot…",
"no-memory-cards": "Noch keine Speicherkarten",
"no-save-selected": "Kein Speicherstand ausgewählt",
"no-saves-available": "Keine Speicherstände verfügbar",
@@ -129,6 +130,7 @@
"save-data-none-note": "Spiele und speichere im Spiel. Der Stand wird am Ende der Sitzung synchronisiert.",
"save-data-note": "Vor dem Start auf die Konsole übertragen. Lade ihn im Menü des Spiels.",
"save-data-synced": "Synchronisiert",
"save-progress-to": "Fortschritt speichern in",
"save-slot": "Speicherplatz",
"save-state": "Spielstand speichern",
"select-background-color": "Hintergrundfarbe auswählen",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Bezel anzeigen",
"slot": "Slot",
"slot-name": "Slot-Name",
"slot-tooltip": "Der Fortschritt wird als neue Versionen in diesem Slot gespeichert, wo andere Geräte ihn abholen.",
"start-fresh-hint": "Wähle unten einen, um fortzufahren, oder klicke auf Play, um neu zu starten.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Shows a Join button on this game's page and keeps chat and webcam visible.",
"mute": "Mute",
"new-memory-card": "New card",
"new-slot": "New slot…",
"no-memory-cards": "No memory cards yet",
"no-save-selected": "No save selected",
"no-saves-available": "No saves available",
@@ -129,6 +130,7 @@
"save-data-none-note": "Play, then save in-game. It syncs back when the session ends.",
"save-data-note": "Restored to the console before launch. Load it from the game's own menu.",
"save-data-synced": "Synced",
"save-progress-to": "Save progress to",
"save-slot": "Save slot",
"save-state": "Save state",
"select-background-color": "Select background colour",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Show bezel",
"slot": "Slot",
"slot-name": "Slot name",
"slot-tooltip": "Progress is saved as new versions in this slot, where other devices pick it up.",
"start-fresh-hint": "Pick one below to resume, or hit Play to start fresh.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Shows a Join button on this game's page and keeps chat and webcam visible.",
"mute": "Mute",
"new-memory-card": "New card",
"new-slot": "New slot…",
"no-memory-cards": "No memory cards yet",
"no-save-selected": "No save selected",
"no-saves-available": "No saves available",
@@ -129,6 +130,7 @@
"save-data-none-note": "Play, then save in-game. It syncs back when the session ends.",
"save-data-note": "Restored to the console before launch. Load it from the game's own menu.",
"save-data-synced": "Synced",
"save-progress-to": "Save progress to",
"save-slot": "Save slot",
"save-state": "Save state",
"select-background-color": "Select background color",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Show bezel",
"slot": "Slot",
"slot-name": "Slot name",
"slot-tooltip": "Progress is saved as new versions in this slot, where other devices pick it up.",
"start-fresh-hint": "Pick one below to resume, or hit Play to start fresh.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Muestra un botón Unirse en la página de este juego y mantiene visibles el chat y la cámara web.",
"mute": "Silenciar",
"new-memory-card": "Nueva tarjeta",
"new-slot": "Nueva ranura…",
"no-memory-cards": "Aún no hay tarjetas de memoria",
"no-save-selected": "Ningún guardado seleccionado",
"no-saves-available": "No hay guardados disponibles",
@@ -129,6 +130,7 @@
"save-data-none-note": "Juega y guarda dentro del juego. Se sincronizará al terminar la sesión.",
"save-data-note": "Restaurado en la consola antes de iniciar. Cárgalo desde el menú del propio juego.",
"save-data-synced": "Sincronizado",
"save-progress-to": "Guardar progreso en",
"save-slot": "Ranura de guardado",
"save-state": "Guardar estado",
"select-background-color": "Seleccionar color de fondo",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Mostrar marco",
"slot": "Ranura",
"slot-name": "Nombre de la ranura",
"slot-tooltip": "El progreso se guarda como versiones nuevas en esta ranura, de donde lo recogen otros dispositivos.",
"start-fresh-hint": "Empezar desde cero — sin partidas guardadas.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Affiche un bouton Rejoindre sur la page de ce jeu et garde le chat et la webcam visibles.",
"mute": "Couper le son",
"new-memory-card": "Nouvelle carte",
"new-slot": "Nouvel emplacement…",
"no-memory-cards": "Aucune carte mémoire pour le moment",
"no-save-selected": "Aucune sauvegarde sélectionnée",
"no-saves-available": "Aucune sauvegarde disponible",
@@ -129,6 +130,7 @@
"save-data-none-note": "Jouez, puis sauvegardez dans le jeu. La synchronisation se fait à la fin de la session.",
"save-data-note": "Restauré sur la console avant le lancement. Chargez-le depuis le menu du jeu.",
"save-data-synced": "Synchronisé",
"save-progress-to": "Enregistrer la progression dans",
"save-slot": "Emplacement de sauvegarde",
"save-state": "Sauvegarder l'état",
"select-background-color": "Sélectionner la couleur d'arrière-plan",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Afficher le cadre",
"slot": "Emplacement",
"slot-name": "Nom de l'emplacement",
"slot-tooltip": "La progression est enregistrée sous forme de nouvelles versions dans cet emplacement, où les autres appareils la récupèrent.",
"start-fresh-hint": "Choisissez-en un ci-dessous pour reprendre, ou appuyez sur Jouer pour démarrer une nouvelle partie.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Csatlakozás gombot jelenít meg a játék oldalán, és láthatóan tartja a csevegést és a webkamerát.",
"mute": "Némítás",
"new-memory-card": "Új kártya",
"new-slot": "Új hely…",
"no-memory-cards": "Még nincsenek memóriakártyák",
"no-save-selected": "Nincs kiválasztott mentés",
"no-saves-available": "Nincs elérhető mentés",
@@ -129,6 +130,7 @@
"save-data-none-note": "Játssz, majd ments a játékon belül. A munkamenet végén szinkronizálódik.",
"save-data-note": "Indítás előtt visszaállítva a konzolra. Töltsd be a játék saját menüjéből.",
"save-data-synced": "Szinkronizálva",
"save-progress-to": "Haladás mentése ide",
"save-slot": "Mentési hely",
"save-state": "Állapot mentése",
"select-background-color": "Háttérszín kiválasztása",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Keret megjelenítése",
"slot": "Hely",
"slot-name": "Hely neve",
"slot-tooltip": "A haladás új verziókként kerül ebbe a helyre, ahonnan a többi eszköz átveszi.",
"start-fresh-hint": "Válassz egyet az alábbiak közül a folytatáshoz, vagy nyomd meg az Indítást egy új játékhoz.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Mostra un pulsante Partecipa nella pagina di questo gioco e mantiene visibili chat e webcam.",
"mute": "Disattiva audio",
"new-memory-card": "Nuova card",
"new-slot": "Nuovo slot…",
"no-memory-cards": "Nessuna memory card",
"no-save-selected": "Nessun salvataggio selezionato",
"no-saves-available": "Nessun salvataggio disponibile",
@@ -129,6 +130,7 @@
"save-data-none-note": "Gioca e salva dentro il gioco. Verrà sincronizzato al termine della sessione.",
"save-data-note": "Ripristinato sulla console prima dell'avvio. Caricalo dal menu del gioco.",
"save-data-synced": "Sincronizzato",
"save-progress-to": "Salva i progressi in",
"save-slot": "Slot di salvataggio",
"save-state": "Salva stato",
"select-background-color": "Seleziona colore di sfondo",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Mostra cornice",
"slot": "Slot",
"slot-name": "Nome dello slot",
"slot-tooltip": "I progressi vengono salvati come nuove versioni in questo slot, da cui gli altri dispositivi li recuperano.",
"start-fresh-hint": "Scegline uno qui sotto per riprendere, oppure premi Gioca per iniziare da capo.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "このゲームのページに参加ボタンを表示し、チャットとウェブカメラを表示したままにします。",
"mute": "ミュート",
"new-memory-card": "新しいカード",
"new-slot": "新しいスロット…",
"no-memory-cards": "メモリーカードはまだありません",
"no-save-selected": "セーブデータが選択されていません",
"no-saves-available": "利用可能なセーブデータがありません",
@@ -129,6 +130,7 @@
"save-data-none-note": "プレイしてゲーム内でセーブしてください。セッション終了時に同期されます。",
"save-data-note": "起動前に本体へ復元されます。ゲーム内のメニューから読み込んでください。",
"save-data-synced": "同期済み",
"save-progress-to": "進行状況の保存先",
"save-slot": "セーブスロット",
"save-state": "ステートをセーブ",
"select-background-color": "背景色を選択",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "ベゼルを表示",
"slot": "スロット",
"slot-name": "スロット名",
"slot-tooltip": "進行状況はこのスロットに新しいバージョンとして保存され、他のデバイスがそこから取得します。",
"start-fresh-hint": "下から選んで再開するか、Playを押して最初から始めてください。",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "이 게임 페이지에 참가 버튼을 표시하고 채팅과 웹캠을 계속 보이게 합니다.",
"mute": "음소거",
"new-memory-card": "새 카드",
"new-slot": "새 슬롯…",
"no-memory-cards": "메모리 카드가 아직 없습니다",
"no-save-selected": "선택된 세이브 없음",
"no-saves-available": "사용 가능한 세이브 없음",
@@ -129,6 +130,7 @@
"save-data-none-note": "플레이한 뒤 게임에서 저장하세요. 세션이 끝나면 동기화됩니다.",
"save-data-note": "실행 전에 콘솔로 복원됩니다. 게임 자체 메뉴에서 불러오세요.",
"save-data-synced": "동기화됨",
"save-progress-to": "진행 상황 저장 위치",
"save-slot": "저장 슬롯",
"save-state": "상태 저장",
"select-background-color": "배경색 선택",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "베젤 표시",
"slot": "슬롯",
"slot-name": "슬롯 이름",
"slot-tooltip": "진행 상황은 이 슬롯에 새 버전으로 저장되며, 다른 기기가 여기서 가져갑니다.",
"start-fresh-hint": "아래에서 하나를 선택하여 이어 하거나, 실행을 눌러 새로 시작하세요.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Wyświetla przycisk Dołącz na stronie tej gry i utrzymuje widoczny czat oraz kamerę internetową.",
"mute": "Wycisz",
"new-memory-card": "Nowa karta",
"new-slot": "Nowy slot…",
"no-memory-cards": "Brak kart pamięci",
"no-save-selected": "Nie wybrano zapisu",
"no-saves-available": "Brak dostępnych zapisów",
@@ -129,6 +130,7 @@
"save-data-none-note": "Zagraj i zapisz w grze. Synchronizacja nastąpi po zakończeniu sesji.",
"save-data-note": "Przywrócone na konsolę przed uruchomieniem. Wczytaj je z menu samej gry.",
"save-data-synced": "Zsynchronizowano",
"save-progress-to": "Zapisuj postęp do",
"save-slot": "Miejsce zapisu",
"save-state": "Zapisz stan",
"select-background-color": "Wybierz kolor tła",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Pokaż ramkę",
"slot": "Slot",
"slot-name": "Nazwa slotu",
"slot-tooltip": "Postęp jest zapisywany jako nowe wersje w tym slocie, skąd pobierają go inne urządzenia.",
"start-fresh-hint": "Wybierz jeden poniżej, aby wznowić, lub naciśnij Graj, aby zacząć od nowa.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Mostra um botão Entrar na página deste jogo e mantém o chat e a webcam visíveis.",
"mute": "Silenciar",
"new-memory-card": "Novo cartão",
"new-slot": "Novo slot…",
"no-memory-cards": "Nenhum cartão de memória ainda",
"no-save-selected": "Nenhum save selecionado",
"no-saves-available": "Nenhum save disponível",
@@ -129,6 +130,7 @@
"save-data-none-note": "Jogue e salve dentro do jogo. A sincronização acontece ao encerrar a sessão.",
"save-data-note": "Restaurado no console antes de iniciar. Carregue pelo menu do próprio jogo.",
"save-data-synced": "Sincronizado",
"save-progress-to": "Salvar progresso em",
"save-slot": "Slot de salvamento",
"save-state": "Salvar estado",
"select-background-color": "Selecionar cor de fundo",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Mostrar moldura",
"slot": "Slot",
"slot-name": "Nome do slot",
"slot-tooltip": "O progresso é salvo como novas versões neste slot, de onde outros dispositivos o recebem.",
"start-fresh-hint": "Escolha um abaixo para retomar, ou clique em Jogar para começar do zero.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Afișează un buton Alătură-te pe pagina acestui joc și păstrează vizibile chatul și camera web.",
"mute": "Dezactivează sunetul",
"new-memory-card": "Card nou",
"new-slot": "Slot nou…",
"no-memory-cards": "Încă niciun card de memorie",
"no-save-selected": "Nicio salvare selectată",
"no-saves-available": "Nicio salvare disponibilă",
@@ -129,6 +130,7 @@
"save-data-none-note": "Joacă, apoi salvează în joc. Se sincronizează la încheierea sesiunii.",
"save-data-note": "Restaurat pe consolă înainte de lansare. Încarcă-l din meniul jocului.",
"save-data-synced": "Sincronizat",
"save-progress-to": "Salvează progresul în",
"save-slot": "Slot de salvare",
"save-state": "Salvează starea",
"select-background-color": "Selectează culoarea de fundal",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Afișează rama",
"slot": "Slot",
"slot-name": "Numele slotului",
"slot-tooltip": "Progresul se salvează ca versiuni noi în acest slot, de unde îl preiau celelalte dispozitive.",
"start-fresh-hint": "Alege una mai jos pentru a relua sau apasă Joacă pentru a începe de la zero.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Показывает кнопку «Присоединиться» на странице этой игры и оставляет чат и веб-камеру видимыми.",
"mute": "Отключить звук",
"new-memory-card": "Новая карта",
"new-slot": "Новый слот…",
"no-memory-cards": "Пока нет карт памяти",
"no-save-selected": "Сохранение не выбрано",
"no-saves-available": "Нет доступных сохранений",
@@ -129,6 +130,7 @@
"save-data-none-note": "Играйте и сохранитесь в игре. Синхронизация произойдёт в конце сеанса.",
"save-data-note": "Восстановлено на консоль перед запуском. Загрузите его из меню самой игры.",
"save-data-synced": "Синхронизировано",
"save-progress-to": "Сохранять прогресс в",
"save-slot": "Слот сохранения",
"save-state": "Сохранить состояние",
"select-background-color": "Выбрать цвет фона",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Показать рамку",
"slot": "Слот",
"slot-name": "Название слота",
"slot-tooltip": "Прогресс сохраняется как новые версии в этом слоте, откуда его забирают другие устройства.",
"start-fresh-hint": "Выберите одно из ниже, чтобы продолжить, или нажмите «Играть», чтобы начать заново.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "Bu oyunun sayfasında bir Katıl düğmesi gösterir, sohbeti ve web kamerasını görünür tutar.",
"mute": "Sessize al",
"new-memory-card": "Yeni kart",
"new-slot": "Yeni yuva…",
"no-memory-cards": "Henüz hafıza kartı yok",
"no-save-selected": "Kayıt seçilmedi",
"no-saves-available": "Mevcut kayıt yok",
@@ -129,6 +130,7 @@
"save-data-none-note": "Oyna, sonra oyun içinde kaydet. Oturum bitince eşitlenir.",
"save-data-note": "Başlatmadan önce konsola geri yüklendi. Oyunun kendi menüsünden yükle.",
"save-data-synced": "Eşitlendi",
"save-progress-to": "İlerlemeyi şuraya kaydet",
"save-slot": "Kayıt yuvası",
"save-state": "Durumu kaydet",
"select-background-color": "Arka plan rengi seç",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "Çerçeveyi göster",
"slot": "Slot",
"slot-name": "Yuva adı",
"slot-tooltip": "İlerleme bu yuvaya yeni sürümler olarak kaydedilir ve diğer cihazlar buradan alır.",
"start-fresh-hint": "Devam etmek için aşağıdan birini seçin veya baştan başlamak için Oyna'ya basın.",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "在该游戏页面显示“加入”按钮,并保持聊天和摄像头可见。",
"mute": "静音",
"new-memory-card": "新建卡",
"new-slot": "新建存档位…",
"no-memory-cards": "尚无记忆卡",
"no-save-selected": "未选择存档",
"no-saves-available": "无可用存档",
@@ -129,6 +130,7 @@
"save-data-none-note": "先游玩,然后在游戏内存档。会话结束时会同步回来。",
"save-data-note": "启动前已还原到主机。请从游戏自身的菜单中读取。",
"save-data-synced": "已同步",
"save-progress-to": "进度保存到",
"save-slot": "存档位",
"save-state": "保存即时存档",
"select-background-color": "选择背景颜色",
@@ -140,6 +142,8 @@
"session-ended-title": "会话已结束",
"show-bezel": "显示边框",
"slot": "存档位",
"slot-name": "存档位名称",
"slot-tooltip": "进度会作为新版本保存到此存档位,其他设备从这里获取。",
"start-fresh-hint": "选择下方任一项继续,或点击开始从头开始。",
"states-view": "状态视图",
"states-view-grid": "网格",

View File

@@ -100,6 +100,7 @@
"multiplayer-hint": "在此遊戲頁面顯示「加入」按鈕,並保持聊天與網路攝影機可見。",
"mute": "靜音",
"new-memory-card": "新增卡",
"new-slot": "新增存檔格…",
"no-memory-cards": "尚無記憶卡",
"no-save-selected": "未選擇存檔",
"no-saves-available": "無可用存檔",
@@ -129,6 +130,7 @@
"save-data-none-note": "先遊玩,然後在遊戲內存檔。工作階段結束時會同步回來。",
"save-data-note": "啟動前已還原到主機。請從遊戲本身的選單中讀取。",
"save-data-synced": "已同步",
"save-progress-to": "進度儲存至",
"save-slot": "存檔格",
"save-state": "儲存即時存檔",
"select-background-color": "選擇背景顏色",
@@ -140,6 +142,8 @@
"session-ended-title": "Session ended",
"show-bezel": "顯示邊框",
"slot": "存檔槽",
"slot-name": "存檔格名稱",
"slot-tooltip": "進度會以新版本儲存到此存檔格,其他裝置會從這裡取得。",
"start-fresh-hint": "從下方選擇一項繼續遊玩,或按下 Play 重新開始。",
"states-view": "State view",
"states-view-grid": "Grid",

View File

@@ -9,6 +9,14 @@ import { buildFormInput } from "@/utils/formData";
export const saveApi = api;
// The slot sync clients (Argosy, Tender) file automatic progress under. A
// null slot is an archival manual upload that is never paired with devices.
export const AUTOSAVE_SLOT = "autosave";
export function isAutosaveSlot(slot: string | null | undefined): boolean {
return slot?.toLowerCase() === AUTOSAVE_SLOT;
}
type SaveUploadInput = Omit<AddSaveInput, "saveFile" | "screenshotFile"> & {
saveFile: File;
screenshotFile?: File;
@@ -27,11 +35,18 @@ async function uploadSaves({
savesToUpload,
emulator,
deviceId,
slot,
autocleanup,
overwrite,
}: {
rom: DetailedRomSchema;
savesToUpload: SaveUploadInput[];
emulator?: string;
deviceId?: string;
slot?: string;
autocleanup?: boolean;
/** Skip the stale-device conflict check on a slotted upload. */
overwrite?: boolean;
}) {
const promises = savesToUpload.map(({ saveFile, screenshotFile }) => {
const formData = buildFormInput<SaveUploadInput>([
@@ -45,7 +60,14 @@ async function uploadSaves({
headers: {
"Content-Type": "multipart/form-data",
},
params: { rom_id: rom.id, emulator, device_id: deviceId },
params: {
rom_id: rom.id,
emulator,
device_id: deviceId,
slot,
autocleanup,
overwrite,
},
})
.then(({ data }) => {
resolve(data);

View File

@@ -75,8 +75,7 @@ const relativeText = computed(() => formatRelativeDate(props.asset.updated_at));
v-if="'slot' in asset && asset.slot"
tone="brand"
size="x-small"
prepend-icon="mdi-bookmark-outline"
:label="t('play.slot')"
prepend-icon="mdi-content-save-all-outline"
:text="asset.slot"
/>
<RTag

View File

@@ -123,6 +123,24 @@ export const SaveSelected: Story = {
}),
};
// A state is armed, so the save is the write-back target, not what boots.
export const SaveAsWriteTarget: Story = {
name: "Save · write-back target",
render: () => ({
components: { AssetPreview },
setup: () => ({ asset: makeSave() }),
template: `<AssetPreview :asset="asset" type="save" state-armed />`,
}),
};
export const EmptySaveWithStateArmed: Story = {
name: "Empty · no save, state armed",
render: () => ({
components: { AssetPreview },
template: `<AssetPreview :asset="null" type="save" state-armed />`,
}),
};
// Long filename should ellipsis cleanly.
export const LongFilename: Story = {
name: "Long filename",

View File

@@ -1,18 +1,16 @@
<script setup lang="ts">
// Big "now showing" preview of the asset the user is about to resume
// from. All three variants (state filled, save filled, empty) share a
// single skeleton — a 16:9 "stage" on top and a metadata strip below.
// Keeping the dimensions fixed prevents the AssetStrip/AssetList from
// jumping when the user switches tabs or clears the selection.
// from. States get a "stage" on top (screenshot, or a placeholder when
// none was captured) and a metadata strip below. Saves never carry a
// screenshot, so they collapse to a single compact row (icon + the same
// metadata) and leave the vertical room to the list underneath.
//
// What changes inside the stage:
// • State: screenshot (or placeholder when none was captured).
// • Save: a featured save graphic — saves never carry a screenshot,
// so we lean on the icon + decorative backdrop.
// • Empty: the empty-state art for the active type.
// The metadata carries the filename + chips + exact timestamp when
// something is selected, or the start-fresh hint when empty.
//
// The metadata strip carries the filename + chips + exact timestamp
// when something is selected, or the start-fresh hint when empty.
// With a state armed the save no longer boots (the state restores the
// whole machine, SRAM included), so the save variant relabels itself as
// the write-back target instead of a resume point.
import { RIcon, RTag, RTooltip } from "@v2/lib";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
@@ -30,8 +28,10 @@ const props = withDefaults(
type: AssetType;
/** Set false where the surrounding panel already carries the title. */
showHeading?: boolean;
/** A state boots first, so a save is only where progress is written. */
stateArmed?: boolean;
}>(),
{ showHeading: true },
{ showHeading: true, stateArmed: false },
);
defineEmits<{
@@ -48,11 +48,14 @@ const screenshotUrl = computed(() => {
return null;
});
const heading = computed(() =>
props.type === "save"
const saveIsTarget = computed(() => props.type === "save" && props.stateArmed);
const heading = computed(() => {
if (saveIsTarget.value) return t("play.save-progress-to");
return props.type === "save"
? t("play.resume-from-save")
: t("play.resume-from-state"),
);
: t("play.resume-from-state");
});
const emptyText = computed(() =>
props.type === "save"
@@ -62,19 +65,20 @@ const emptyText = computed(() =>
</script>
<template>
<div class="r-asset-preview">
<div
class="r-asset-preview"
:class="{ 'r-asset-preview--save': type === 'save' }"
>
<p v-if="showHeading" class="r-asset-preview__eyebrow">{{ heading }}</p>
<!-- ── Stage — same 16:9 dimensions across all variants ───── -->
<!-- ── Stage — states only ────────────────────────────────── -->
<div
v-if="type === 'state'"
class="r-asset-preview__stage"
:class="{
'r-asset-preview__stage--save': type === 'save' && asset,
'r-asset-preview__stage--empty': !asset,
}"
:class="{ 'r-asset-preview__stage--empty': !asset }"
>
<!-- State: screenshot or placeholder. -->
<template v-if="asset && type === 'state'">
<!-- Screenshot or placeholder. -->
<template v-if="asset">
<div v-if="screenshotUrl" class="r-asset-preview__stage-shot">
<!-- Blurred cover copy fills the letterbox left by the
contained frame, so the whole screenshot stays visible
@@ -94,27 +98,15 @@ const emptyText = computed(() =>
</div>
</template>
<!-- Save: big icon + decorative backdrop. -->
<div
v-else-if="asset && type === 'save'"
class="r-asset-preview__stage-fill"
>
<div class="r-asset-preview__save-medallion">
<RIcon icon="mdi-content-save" size="56" />
</div>
</div>
<!-- Empty: friendly art for the active type. -->
<!-- Empty: friendly art. -->
<div v-else class="r-asset-preview__stage-fill">
<div class="r-asset-preview__empty-art">
<RIcon
:icon="
type === 'save' ? 'mdi-content-save-outline' : 'mdi-image-area'
"
size="40"
/>
<RIcon icon="mdi-image-area" size="40" />
</div>
<p class="r-asset-preview__empty-title">{{ emptyText }}</p>
<p class="r-asset-preview__empty-hint">
{{ t("play.start-fresh-hint") }}
</p>
</div>
<!-- Clear button — only when something is selected. -->
@@ -129,56 +121,82 @@ const emptyText = computed(() =>
</button>
</div>
<!-- ── Meta — filled when selected, hint when empty ──────── -->
<div v-if="asset" class="r-asset-preview__meta">
<p class="r-asset-preview__name">
{{ asset.file_name }}
<RTooltip activator="parent" location="top" :open-delay="400">
<div class="r-asset-preview__tip">
<span class="r-asset-preview__tip-name">
{{ asset.file_name }}
</span>
<span class="r-asset-preview__tip-sub">
{{ t("rom.updated") }}:
{{ formatTimestamp(asset.updated_at, locale) }}
</span>
</div>
</RTooltip>
</p>
<div class="r-asset-preview__chips">
<RTag
v-if="'slot' in asset && asset.slot"
tone="brand"
size="x-small"
prepend-icon="mdi-bookmark-outline"
:label="t('play.slot')"
:text="asset.slot"
/>
<span class="r-asset-preview__chip">
<RIcon icon="mdi-clock-outline" size="12" />
{{ formatRelativeDate(asset.updated_at) }}
</span>
<span class="r-asset-preview__chip">
<RIcon icon="mdi-weight" size="12" />
{{ formatBytes(asset.file_size_bytes) }}
</span>
<RTag
v-if="asset.emulator"
tone="warning"
size="x-small"
:text="asset.emulator"
<!-- ── Body — meta strip; for saves also the icon and clear ─── -->
<div
class="r-asset-preview__body"
:class="{ 'r-asset-preview__body--empty': !asset }"
>
<div v-if="type === 'save'" class="r-asset-preview__save-badge">
<RIcon
:icon="asset ? 'mdi-content-save' : 'mdi-content-save-outline'"
size="22"
/>
</div>
<p class="r-asset-preview__exact">
<RIcon icon="mdi-calendar-clock" size="11" />
{{ formatTimestamp(asset.updated_at, locale) }}
</p>
</div>
<div v-else class="r-asset-preview__meta r-asset-preview__meta--empty">
<p class="r-asset-preview__empty-hint">
{{ t("play.start-fresh-hint") }}
</p>
<div v-if="asset" class="r-asset-preview__meta">
<p class="r-asset-preview__name">
{{ asset.file_name }}
<RTooltip activator="parent" location="top" :open-delay="400">
<div class="r-asset-preview__tip">
<span class="r-asset-preview__tip-name">
{{ asset.file_name }}
</span>
<span class="r-asset-preview__tip-sub">
{{ t("rom.updated") }}:
{{ formatTimestamp(asset.updated_at, locale) }}
</span>
</div>
</RTooltip>
</p>
<div class="r-asset-preview__chips">
<RTag
v-if="'slot' in asset && asset.slot"
tone="brand"
size="x-small"
prepend-icon="mdi-content-save-all-outline"
:text="asset.slot"
/>
<span class="r-asset-preview__chip">
<RIcon icon="mdi-clock-outline" size="12" />
{{ formatRelativeDate(asset.updated_at) }}
</span>
<span class="r-asset-preview__chip">
<RIcon icon="mdi-weight" size="12" />
{{ formatBytes(asset.file_size_bytes) }}
</span>
<RTag
v-if="asset.emulator"
tone="warning"
size="x-small"
:text="asset.emulator"
/>
</div>
<p class="r-asset-preview__exact">
<RIcon icon="mdi-calendar-clock" size="11" />
{{ formatTimestamp(asset.updated_at, locale) }}
</p>
</div>
<!-- For states this stays as an empty block: the stage already carries
the empty copy, and the reserved height keeps the strip below put. -->
<div v-else class="r-asset-preview__meta r-asset-preview__meta--empty">
<template v-if="type === 'save'">
<p class="r-asset-preview__empty-title">{{ emptyText }}</p>
<p v-if="!saveIsTarget" class="r-asset-preview__empty-hint">
{{ t("play.start-fresh-hint") }}
</p>
</template>
</div>
<button
v-if="asset && type === 'save'"
type="button"
class="r-asset-preview__clear r-asset-preview__clear--inline"
:aria-label="t('common.clear')"
@click="$emit('clear')"
>
<RIcon icon="mdi-close" size="14" />
</button>
</div>
</div>
</template>
@@ -216,18 +234,6 @@ const emptyText = computed(() =>
0 0 0 1px color-mix(in srgb, var(--r-color-brand-primary) 30%, transparent);
}
/* Save and empty variants use the surface backdrop instead of the
cover-placeholder gradient — they're "panels" not screenshots. */
.r-asset-preview__stage--save,
.r-asset-preview__stage--empty {
background: linear-gradient(
135deg,
color-mix(in srgb, var(--r-color-brand-primary) 8%, var(--r-color-surface)),
var(--r-color-surface)
);
box-shadow: 0 8px 22px color-mix(in srgb, black 25%, transparent);
}
.r-asset-preview__stage--empty {
border-style: dashed;
background: var(--r-color-surface);
@@ -279,9 +285,7 @@ const emptyText = computed(() =>
/* State placeholder backdrop (no screenshot) inherits the cover-
placeholder gradient on the base stage; just dim the foreground. */
.r-asset-preview__stage:not(.r-asset-preview__stage--save):not(
.r-asset-preview__stage--empty
)
.r-asset-preview__stage:not(.r-asset-preview__stage--empty)
.r-asset-preview__stage-fill {
background: linear-gradient(
135deg,
@@ -290,17 +294,38 @@ const emptyText = computed(() =>
);
}
/* Save medallion — brand-tinted circle behind the save icon. Sized
to feel like a badge inside the shorter stage, not a hero element. */
.r-asset-preview__save-medallion {
/* ── Save row — badge + meta + clear, no stage ───────────── */
.r-asset-preview--save .r-asset-preview__body {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 12px;
border: 1px solid var(--r-color-border);
border-radius: var(--r-radius-md);
background: linear-gradient(
135deg,
color-mix(in srgb, var(--r-color-brand-primary) 8%, var(--r-color-surface)),
var(--r-color-surface)
);
}
.r-asset-preview--save .r-asset-preview__body--empty {
border-style: dashed;
background: var(--r-color-surface);
}
.r-asset-preview__save-badge {
display: grid;
place-items: center;
width: 88px;
height: 88px;
flex-shrink: 0;
width: 40px;
height: 40px;
border-radius: 50%;
background: color-mix(in srgb, var(--r-color-brand-primary) 22%, transparent);
color: var(--r-color-brand-primary);
}
.r-asset-preview__body--empty .r-asset-preview__save-badge {
background: var(--r-color-bg-elevated);
color: var(--r-color-fg-muted);
}
/* Empty-state art — small circular badge with the type's icon. */
.r-asset-preview__empty-art {
@@ -312,7 +337,11 @@ const emptyText = computed(() =>
background: var(--r-color-bg-elevated);
color: var(--r-color-fg-muted);
}
.r-asset-preview__stage-fill .r-asset-preview__empty-title {
margin-bottom: -6px;
}
.r-asset-preview__empty-title {
margin: 0;
font-size: 13px !important;
font-weight: var(--r-font-weight-semibold);
color: var(--r-color-fg);
@@ -343,16 +372,20 @@ const emptyText = computed(() =>
);
}
/* On save / empty stages the overlay-style clear button reads too
heavy against a light surface; switch to a tonal pill. */
.r-asset-preview__stage--save .r-asset-preview__clear,
/* Off the screenshot the overlay-style clear button reads too heavy
against a light surface; switch to a tonal pill. */
.r-asset-preview__clear--inline {
position: static;
flex-shrink: 0;
}
.r-asset-preview__clear--inline,
.r-asset-preview__stage--empty .r-asset-preview__clear {
border-color: var(--r-color-border);
background: var(--r-color-bg-elevated);
color: var(--r-color-fg-secondary);
backdrop-filter: none;
}
.r-asset-preview__stage--save .r-asset-preview__clear:hover,
.r-asset-preview__clear--inline:hover,
.r-asset-preview__stage--empty .r-asset-preview__clear:hover {
background: color-mix(
in srgb,
@@ -369,6 +402,8 @@ const emptyText = computed(() =>
flex-direction: column;
gap: 6px;
padding: 0 2px;
flex: 1;
min-width: 0;
/* Reserve the row even when content is shorter, so the strip below
doesn't shift between filled and empty. Worst case so far is
name + wrapped chips + exact = ~3 lines @ ~22px each. */
@@ -378,6 +413,12 @@ const emptyText = computed(() =>
display: flex;
align-items: center;
}
.r-asset-preview--save .r-asset-preview__meta--empty {
flex-direction: column;
align-items: flex-start;
justify-content: center;
gap: 2px;
}
.r-asset-preview__name {
margin: 0;

View File

@@ -124,8 +124,7 @@ function ownerOf(asset: Asset): UserSaveSchema | UserStateSchema | null {
v-if="'slot' in asset && asset.slot"
tone="brand"
size="x-small"
prepend-icon="mdi-bookmark-outline"
:label="t('play.slot')"
prepend-icon="mdi-content-save-all-outline"
:text="asset.slot"
/>
<RTag

View File

@@ -21,6 +21,8 @@ import {
RSliderBtnGroup,
RSpinner,
RSwitch,
RTextField,
RTooltip,
} from "@v2/lib";
import { useEventListener, useLocalStorage } from "@vueuse/core";
import type { Emitter } from "mitt";
@@ -39,6 +41,7 @@ import { useI18n } from "vue-i18n";
import type { FirmwareSchema, SaveSchema, StateSchema } from "@/__generated__";
import firmwareApi from "@/services/api/firmware";
import romApi from "@/services/api/rom";
import { AUTOSAVE_SLOT } from "@/services/api/save";
import storeConfig from "@/stores/config";
import storePlaying from "@/stores/playing";
import type { DetailedRom } from "@/stores/roms";
@@ -77,6 +80,13 @@ import { suppressVirtualGamepadZoneTouch } from "@/v2/utils/playerTouchGuard";
import { isJsResource, loadScript } from "@/v2/utils/scriptLoader";
import { installIOSFullscreenShim } from "@/views/Player/EmulatorJS/utils";
import { rememberCore, resolveRememberedCore } from "./coreStorage";
import {
defaultResumeSelection,
pickSave,
pickState,
slotOptions,
type ResumeSelection,
} from "./resumeSelection";
// Reuse v1's heavy emulator integration — do NOT rewrite this. Lazy so the
// bundle doesn't pull in the EJS shims until we actually mount the player.
@@ -105,7 +115,7 @@ function focusPlayButton() {
const rom = ref<DetailedRom | null>(null);
const firmwareOptions = ref<FirmwareSchema[]>([]);
const selectedSave = ref<SaveSchema | null>(null);
const resume = ref<ResumeSelection>({ save: null, state: null });
const { romId, heroRom, title, platformLabel } = usePlayerHero(rom);
const { backToRom, backToPlatform } = usePlayerNav(
@@ -113,7 +123,6 @@ const { backToRom, backToPlatform } = usePlayerNav(
() => heroRom.value?.platform_id,
);
const isSavesTabSelected = ref(true);
const selectedState = ref<StateSchema | null>(null);
const selectedDisc = ref<DiscSelection>(null);
const selectedCore = ref<string | null>(null);
const selectedFirmware = ref<FirmwareSchema | null>(null);
@@ -264,42 +273,26 @@ async function onPlay() {
}
function selectSave(save: SaveSchema) {
selectedSave.value = save;
localStorage.setItem(
`player:${rom.value?.platform_slug}:save_id`,
save.id.toString(),
);
resume.value = pickSave(save);
isSavesTabSelected.value = true;
}
function unselectSave() {
selectedSave.value = null;
localStorage.removeItem(`player:${rom.value?.platform_slug}:save_id`);
resume.value = { ...resume.value, save: null };
}
function selectState(state: StateSchema) {
selectedState.value = state;
localStorage.setItem(
`player:${rom.value?.platform_slug}:state_id`,
state.id.toString(),
);
resume.value = pickState(resume.value, state);
isSavesTabSelected.value = false;
}
function unselectState() {
selectedState.value = null;
localStorage.removeItem(`player:${rom.value?.platform_slug}:state_id`);
resume.value = { ...resume.value, state: null };
}
watch(selectedCore, (newSelectedCore) => {
if (
selectedState.value &&
selectedState.value.emulator &&
selectedState.value.emulator !== newSelectedCore
) {
selectedState.value = null;
localStorage.removeItem(`player:${rom.value?.platform_slug}:state_id`);
}
const armed = resume.value.state;
if (armed?.emulator && armed.emulator !== newSelectedCore) unselectState();
});
onMounted(async () => {
@@ -347,24 +340,11 @@ onMounted(async () => {
configStore.getEJSDefaultCore(platformSlug),
);
// Default selection — save and state are independent, so both can be
// armed at once. The bound save is the write-back target for "Save &
// Quit" (PUT in place), so we only auto-bind it when the choice is
// unambiguous: never silently pick a slot when a state is armed and
// there are multiple saves, since loading the state injects a different
// SRAM timeline that would overwrite an arbitrary save the user never
// picked. In that case the user must select the save slot explicitly.
const hasCompatibleState = compatibleStates.value.length > 0;
if (hasCompatibleState) {
selectedState.value = compatibleStates.value[0];
}
const safeToBindSave =
rom.value.user_saves.length === 1 || !hasCompatibleState;
if (rom.value.user_saves.length > 0 && safeToBindSave) {
selectedSave.value = rom.value.user_saves[0];
}
isSavesTabSelected.value = !hasCompatibleState;
resume.value = defaultResumeSelection(
rom.value.user_saves,
compatibleStates.value,
);
isSavesTabSelected.value = !resume.value.state;
selectedDisc.value = resolveRememberedDisc(
rom.value.id,
@@ -477,17 +457,45 @@ const activeAssets = computed<(SaveSchema | StateSchema)[]>(() =>
const selectedAssetId = computed(() =>
isSavesTabSelected.value
? (selectedSave.value?.id ?? null)
: (selectedState.value?.id ?? null),
? (resume.value.save?.id ?? null)
: (resume.value.state?.id ?? null),
);
const selectedAsset = computed<SaveSchema | StateSchema | null>(() =>
isSavesTabSelected.value ? selectedSave.value : selectedState.value,
isSavesTabSelected.value ? resume.value.save : resume.value.state,
);
// Slot for saves the session creates. A bound save with a slot fixes it (the
// picker just shows it); a slot-less legacy save is archived and progress
// moves to the picked slot. The picker is always rendered on the Saves tab so
// the panel keeps the same height whether or not a save is selected.
const NEW_SLOT = "";
const slotChoice = ref(AUTOSAVE_SLOT);
const customSlot = ref("");
const boundSlot = computed(() => resume.value.save?.slot ?? null);
function onSlotChoice(value: unknown) {
slotChoice.value = typeof value === "string" ? value : AUTOSAVE_SLOT;
}
const slotItems = computed(() => [
...slotOptions(rom.value?.user_saves ?? []).map((slot) => ({
title: slot,
value: slot,
})),
{ title: t("play.new-slot"), value: NEW_SLOT },
]);
const saveSlot = computed(() =>
slotChoice.value === NEW_SLOT
? customSlot.value.trim() || AUTOSAVE_SLOT
: slotChoice.value,
);
</script>
<template>
<section v-if="heroRom" class="r-v2-ejs">
<section
v-if="heroRom"
class="r-v2-ejs"
:class="{ 'r-v2-ejs--config': !gameRunning }"
>
<!-- Pre-game configuration -->
<div v-if="!gameRunning" class="r-v2-ejs__config">
<!-- Hero: cover + title + Play CTA -->
@@ -562,9 +570,50 @@ const selectedAsset = computed<SaveSchema | StateSchema | null>(() =>
<AssetPreview
:asset="selectedAsset"
:type="activeAssetTab"
:state-armed="!!resume.state"
@clear="clearSelectedAsset"
/>
<div v-if="isSavesTabSelected" class="r-v2-ejs__slot">
<div class="r-v2-ejs__slot-row">
<RSelect
:model-value="boundSlot ?? slotChoice"
:disabled="!!boundSlot"
variant="outlined"
density="compact"
prefix-label="inline"
hide-details
:items="slotItems"
@update:model-value="onSlotChoice"
>
<template #prefix-label>
<RIcon icon="mdi-content-save-all-outline" size="14" />
{{ t("play.slot") }}
</template>
</RSelect>
<span
class="r-v2-ejs__slot-info"
tabindex="0"
:aria-label="t('play.slot-tooltip')"
>
<RIcon icon="mdi-information-outline" size="16" />
<RTooltip activator="parent" location="top">
{{ t("play.slot-tooltip") }}
</RTooltip>
</span>
</div>
<RTextField
v-if="!boundSlot && slotChoice === NEW_SLOT"
v-model="customSlot"
variant="outlined"
density="compact"
prefix-label="inline"
hide-details
:label="t('play.slot-name')"
:placeholder="AUTOSAVE_SLOT"
/>
</div>
<div
v-if="activeAssets.length > 0"
class="r-v2-ejs__strip-label"
@@ -580,21 +629,24 @@ const selectedAsset = computed<SaveSchema | StateSchema | null>(() =>
<!-- Saves render as a vertical list (no screenshot ⇒ density);
states keep the horizontal tile strip (screenshot is the
point). -->
<AssetList
v-if="activeAssetTab === 'save'"
:assets="activeAssets"
type="save"
:selected-id="selectedAssetId"
@select="pickAsset"
/>
<AssetStrip
v-else
:assets="activeAssets"
type="state"
:selected-id="selectedAssetId"
@select="pickAsset"
/>
point). The wrapper owns the only scroll on the screen. -->
<div class="r-v2-ejs__assets">
<AssetList
v-if="activeAssetTab === 'save'"
:assets="activeAssets"
type="save"
:selected-id="selectedAssetId"
:scrollable="false"
@select="pickAsset"
/>
<AssetStrip
v-else
:assets="activeAssets"
type="state"
:selected-id="selectedAssetId"
@select="pickAsset"
/>
</div>
</div>
</RCard>
@@ -675,8 +727,9 @@ const selectedAsset = computed<SaveSchema | StateSchema | null>(() =>
<div v-else-if="rom" ref="stageRef" class="r-v2-ejs__stage">
<Player
:rom="rom"
:state="selectedState"
:save="selectedSave"
:state="resume.state"
:save="resume.save"
:save-slot="saveSlot"
:bios="selectedFirmware"
:core="selectedCore"
:disc="bootDiscId(selectedDisc)"
@@ -839,6 +892,39 @@ const selectedAsset = computed<SaveSchema | StateSchema | null>(() =>
flex-direction: column;
gap: 14px;
flex: 1;
min-height: 0;
}
.r-v2-ejs__slot {
display: flex;
flex-direction: column;
gap: 8px;
}
.r-v2-ejs__slot-row {
display: flex;
align-items: center;
gap: 8px;
}
.r-v2-ejs__slot-row > :first-child {
flex: 1;
min-width: 0;
}
.r-v2-ejs__slot-info {
display: inline-flex;
color: var(--r-color-fg-secondary);
border-radius: var(--r-radius-pill);
cursor: help;
}
.r-v2-ejs__slot-info:focus-visible {
outline: 2px solid var(--r-color-brand-primary);
outline-offset: 2px;
}
.r-v2-ejs__assets {
flex: 1;
min-height: 0;
max-height: 380px;
overflow-y: auto;
scrollbar-color: var(--r-color-border-strong) transparent;
scrollbar-width: thin;
}
.r-v2-ejs__strip-label {
display: flex;
@@ -936,6 +1022,38 @@ const selectedAsset = computed<SaveSchema | StateSchema | null>(() =>
place-items: center;
}
/* ── Viewport fit ────────────────────────────────────────── */
/* On screens tall enough for the hero column, the pre-game screen fits the
viewport: panels shrink, only the asset list scrolls, and the footer brand
stays in view. Shorter or narrower screens fall back to page scroll. */
@media (min-height: 720px) {
.r-v2-ejs--config {
height: calc(100vh - var(--r-nav-h));
overflow: hidden;
}
.r-v2-ejs--config .r-v2-ejs__config {
height: 100%;
grid-template-rows: minmax(0, 1fr) auto;
}
.r-v2-ejs--config .r-v2-ejs__panel {
min-height: 0;
}
.r-v2-ejs--config .r-v2-ejs__assets {
max-height: none;
}
}
html[data-bp~="md-and-down"] .r-v2-ejs--config {
height: auto;
overflow: visible;
}
html[data-bp~="md-and-down"] .r-v2-ejs--config .r-v2-ejs__config {
height: auto;
grid-template-rows: none;
}
html[data-bp~="md-and-down"] .r-v2-ejs--config .r-v2-ejs__assets {
max-height: 380px;
}
/* ── Responsive ──────────────────────────────────────────── */
html[data-bp~="md-and-down"] .r-v2-ejs__config {
grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);

View File

@@ -0,0 +1,70 @@
import { describe, expect, it } from "vitest";
import type { SaveSchema, StateSchema } from "@/__generated__";
import {
defaultResumeSelection,
pickSave,
pickState,
slotOptions,
} from "./resumeSelection";
const save = (id: number, slot: string | null = null) =>
({ id, file_name: `${id}.srm`, slot }) as SaveSchema;
const state = (id: number) => ({ id, file_name: `${id}.state` }) as StateSchema;
describe("defaultResumeSelection", () => {
it("starts fresh when there is nothing to resume from", () => {
expect(defaultResumeSelection([], [])).toEqual({ save: null, state: null });
});
it("boots from the newest save when no state is compatible", () => {
expect(defaultResumeSelection([save(1), save(2)], [])).toEqual({
save: save(1),
state: null,
});
});
it("arms the newest state and binds the only save as write-back target", () => {
const selection = defaultResumeSelection([save(1)], [state(9), state(8)]);
expect(selection).toEqual({ save: save(1), state: state(9) });
});
it("leaves the save unbound when a state is armed and several saves exist", () => {
const selection = defaultResumeSelection([save(1), save(2)], [state(9)]);
expect(selection).toEqual({ save: null, state: state(9) });
});
});
describe("pickSave", () => {
it("disarms the state so the picked save is what boots", () => {
expect(pickSave(save(2))).toEqual({ save: save(2), state: null });
});
});
describe("pickState", () => {
it("boots from the state and keeps the bound save for write-back", () => {
expect(pickState(pickSave(save(2)), state(9))).toEqual({
save: save(2),
state: state(9),
});
});
});
describe("slotOptions", () => {
it("offers autosave even when no save exists yet", () => {
expect(slotOptions([])).toEqual(["autosave"]);
});
it("lists every named slot once and skips slot-less archives", () => {
const saves = [
save(1, "main_quest"),
save(2, null),
save(3, "Autosave"),
save(4, "main_quest"),
save(5, "speedrun"),
];
expect(slotOptions(saves)).toEqual(["autosave", "main_quest", "speedrun"]);
});
});

View File

@@ -0,0 +1,49 @@
import type { SaveSchema, StateSchema } from "@/__generated__";
import { AUTOSAVE_SLOT, isAutosaveSlot } from "@/services/api/save";
// What the player boots from and where progress is written back. A state
// restores the whole machine, SRAM included, so it always wins at boot; the
// save is then only the "Save & Quit" write-back target.
export interface ResumeSelection {
save: SaveSchema | null;
state: StateSchema | null;
}
/**
* Newest compatible state, plus a save only when the write-back choice is
* unambiguous.
*
* With a state armed and several saves, loading the state injects a different
* SRAM timeline, so auto-binding an arbitrary save would let "Save & Quit"
* overwrite a slot the user never picked. That case stays unbound until the
* user picks a save explicitly.
*/
export function defaultResumeSelection(
saves: readonly SaveSchema[],
compatibleStates: readonly StateSchema[],
): ResumeSelection {
const state = compatibleStates[0] ?? null;
const safeToBindSave = saves.length === 1 || !state;
return { save: safeToBindSave ? (saves[0] ?? null) : null, state };
}
/** A picked save is the boot source, so any armed state is disarmed. */
export function pickSave(save: SaveSchema): ResumeSelection {
return { save, state: null };
}
/** A picked state boots first; the bound save stays as the write-back target. */
export function pickState(
selection: ResumeSelection,
state: StateSchema,
): ResumeSelection {
return { save: selection.save, state };
}
/** Slots a new save can go to: autosave first, then every slot in use. */
export function slotOptions(saves: readonly SaveSchema[]): string[] {
const named = saves
.map((save) => save.slot)
.filter((slot): slot is string => !!slot && !isAutosaveSlot(slot));
return [AUTOSAVE_SLOT, ...new Set(named)];
}

View File

@@ -1,7 +1,14 @@
<script setup lang="ts">
import type { Emitter } from "mitt";
import { storeToRefs } from "pinia";
import { inject, onBeforeUnmount, onMounted, onUnmounted, ref } from "vue";
import {
computed,
inject,
onBeforeUnmount,
onMounted,
onUnmounted,
ref,
} from "vue";
import { useRouter } from "vue-router";
import { useTheme } from "vuetify";
import type {
@@ -11,7 +18,7 @@ import type {
NetplayICEServer,
} from "@/__generated__";
import { ROUTES } from "@/plugins/router";
import { saveApi as api } from "@/services/api/save";
import { AUTOSAVE_SLOT, saveApi as api } from "@/services/api/save";
import storeAuth from "@/stores/auth";
import storeConfig from "@/stores/config";
import storeLanguage from "@/stores/language";
@@ -54,9 +61,17 @@ const props = defineProps<{
bios: FirmwareSchema | null;
core: string | null;
disc: number | null;
/** Slot for new saves when the loaded save has none; defaults to autosave. */
saveSlot?: string | null;
}>();
const romRef = ref<DetailedRom>(props.rom);
// The save the session booted from, and the version this session has written
// so far. Loading a save resets the version so the next write opens a new one.
const saveRef = ref<SaveSchema | null>(props.save);
const sessionSaveRef = ref<SaveSchema | null>(null);
const saveSlot = computed(
() => saveRef.value?.slot ?? props.saveSlot ?? AUTOSAVE_SLOT,
);
const deviceIDRef = ref(authStore.user?.current_device_id ?? undefined);
const theme = useTheme();
const emitter = inject<Emitter<Events>>("emitter");
@@ -301,13 +316,14 @@ function installAutoSaveSync() {
try {
const save = await saveSave({
rom: romRef.value,
save: saveRef.value,
save: sessionSaveRef.value,
saveFile: toArrayBuffer(saveFile),
deviceId: deviceIDRef.value,
slot: saveSlot.value,
});
if (save) {
tracker.markUploaded(saveFile);
saveRef.value = save;
sessionSaveRef.value = save;
romsStore.update(romRef.value);
displayMessage("Save synced with server", {
duration: 3000,
@@ -325,6 +341,7 @@ function installAutoSaveSync() {
// Saves management
async function loadSave(save: SaveSchema) {
saveRef.value = save;
sessionSaveRef.value = null;
const { data } = await api.get(save.download_path.replace("/api", ""), {
responseType: "arraybuffer",
@@ -354,15 +371,17 @@ window.EJS_onSaveSave = async function ({
}) {
const save = await saveSave({
rom: romRef.value,
save: saveRef.value,
save: sessionSaveRef.value,
saveFile,
screenshotFile,
deviceId: deviceIDRef.value,
slot: saveSlot.value,
});
romsStore.update(romRef.value);
if (save) {
sessionSaveRef.value = save;
displayMessage("Save synced with server", {
duration: 4000,
icon: "mdi-cloud-sync",
@@ -556,10 +575,11 @@ window.EJS_onGameStart = async () => {
// Force a save of the save file
await saveSave({
rom: romRef.value,
save: saveRef.value,
save: sessionSaveRef.value,
saveFile,
screenshotFile,
deviceId: deviceIDRef.value,
slot: saveSlot.value,
});
romsStore.update(romRef.value);

View File

@@ -1,5 +1,21 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { createSaveSyncTracker, installEJSDefaultOptionsTrap } from "./utils";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { SaveSchema } from "@/__generated__";
import type { DetailedRom } from "@/stores/roms";
import {
createSaveSyncTracker,
installEJSDefaultOptionsTrap,
saveSave,
} from "./utils";
const saveApiMocks = vi.hoisted(() => ({
uploadSaves: vi.fn(),
updateSave: vi.fn(),
}));
vi.mock("@/services/api/save", async (importOriginal) => ({
...(await importOriginal<typeof import("@/services/api/save")>()),
default: saveApiMocks,
}));
const STORAGE_KEY = "ejs-7-n64-Test Game-settings";
@@ -187,3 +203,55 @@ describe("createSaveSyncTracker", () => {
expect(tracker.shouldUpload(bytes(1, 2, 3, 0))).toBe(false);
});
});
describe("saveSave", () => {
const rom = {
id: 1,
fs_name_no_ext: "game",
user_saves: [],
} as unknown as DetailedRom;
const bytes = new Uint8Array([1, 2, 3]).buffer;
beforeEach(() => {
saveApiMocks.uploadSaves.mockReset();
saveApiMocks.updateSave.mockReset();
saveApiMocks.uploadSaves.mockResolvedValue([
{ status: "fulfilled", value: { id: 2, slot: "autosave" } },
]);
saveApiMocks.updateSave.mockResolvedValue({ data: { id: 3 } });
});
it("updates the version this session already created", async () => {
const save = {
id: 3,
file_name: "a.srm",
slot: "main_quest",
} as SaveSchema;
await saveSave({ rom, save, saveFile: bytes, slot: "main_quest" });
expect(saveApiMocks.updateSave).toHaveBeenCalledOnce();
expect(saveApiMocks.uploadSaves).not.toHaveBeenCalled();
});
it("opens a capped autosave version when the session has none", async () => {
await saveSave({ rom, save: null, saveFile: bytes });
expect(saveApiMocks.uploadSaves).toHaveBeenCalledWith(
expect.objectContaining({
slot: "autosave",
autocleanup: true,
overwrite: true,
}),
);
});
it("keeps every version in a named slot", async () => {
await saveSave({ rom, save: null, saveFile: bytes, slot: "speedrun" });
expect(saveApiMocks.updateSave).not.toHaveBeenCalled();
expect(saveApiMocks.uploadSaves).toHaveBeenCalledWith(
expect.objectContaining({ slot: "speedrun", autocleanup: false }),
);
});
});

View File

@@ -1,7 +1,7 @@
import Bowser from "bowser";
import { type SaveSchema } from "@/__generated__";
import { type StateSchema } from "@/__generated__";
import saveApi from "@/services/api/save";
import saveApi, { AUTOSAVE_SLOT, isAutosaveSlot } from "@/services/api/save";
import stateApi from "@/services/api/state";
import { type DetailedRom } from "@/stores/roms";
@@ -63,18 +63,24 @@ export async function saveState({
return null;
}
// One version per session, like a sync client's end-of-session upload: the
// first write creates a new save in `slot` (the backend caps the slot's
// history), and `save`, the version this session already created, is then
// updated in place so periodic sync does not churn the history.
export async function saveSave({
rom,
save,
saveFile,
screenshotFile,
deviceId,
slot = AUTOSAVE_SLOT,
}: {
rom: DetailedRom;
save: SaveSchema | null;
saveFile: ArrayBuffer;
screenshotFile?: ArrayBuffer;
deviceId?: string;
slot?: string;
}): Promise<SaveSchema | null> {
if (save) {
try {
@@ -109,6 +115,13 @@ export async function saveSave({
rom: rom,
emulator: window.EJS_core,
deviceId,
slot,
// Like Argosy: the autosave slot keeps a capped history, named slots
// keep every version.
autocleanup: isAutosaveSlot(slot),
// The launch screen makes the boot source an explicit choice, so the
// "slot has a newer save since your last sync" guard does not apply.
overwrite: true,
savesToUpload: [
{
saveFile: new File([saveFile], `${filename}.srm`, {