From 941a1fad4fd4813d22e9a1917edd4058c26d3cdc Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Sun, 8 Nov 2026 00:38:08 +0700 Subject: [PATCH] =?UTF-8?q?feat(editor):=20upscaled=20video=20=E2=80=94=20?= =?UTF-8?q?[4K=20Upscaled]=20badge,=20upscale=20line=20and=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Video settings gain "Upscaled from" next to Resolution: footage recorded at 1440p and exported at 4K in the video editor is now declared as such. - Title: the quality badge reads "[4K Upscaled]" ("[2K Upscaled]", "[4K Upscaled 120FPS]"), with the word in the output language; badge position, case and the "Show quality badge" setting apply as before. 1080p 60fps keeps no badge, upscaled or not. - Description, VIDEO SETTINGS: "Upscale: 1440p → 4K (DaVinci Resolve Studio 21.2)" right under the Video line, the editor taken from My Rig. It stays when the graphics settings are hidden. - Description, TECH NOTES: an automatic bilingual note that upscaling reconstructs fine detail, so text, textures and edges may look slightly different from the original image. It is not in the checklist and goes away with the upscale. - The Select lists only resolutions below the video's; lowering the resolution to or below the source ends the upscale. The collapsed section reads "1440p → 4K · 60 FPS". Saved with the channel profile. - Editor store v20 → v21 (back-fills "" and drops unknown values); backups and applied items read an unknown value as not upscaled. `validUpscaleSource` in src/engine/upscale.ts is the one rule the title, description and form share. AUTO_TECH_NOTES holds the engine's own notes; their bullets share description.techNotes.items. Co-Authored-By: Claude Opus 5.5 --- src/components/editor/VideoSettingsForm.tsx | 46 +++++++++--- src/config/defaults.ts | 4 + src/config/graphics-settings.ts | 21 ++++++ src/config/library-fields.ts | 1 + src/engine/description-builder.ts | 39 ++++++++-- src/engine/title-builder.ts | 22 ++++-- src/engine/types.ts | 19 +++++ src/engine/upscale.ts | 39 ++++++++++ src/hooks/use-current-generator-input.ts | 1 + src/i18n/locales/_schema.json | 9 ++- src/i18n/locales/en/templates.json | 7 +- src/i18n/locales/en/ui.json | 3 + src/i18n/locales/es/templates.json | 7 +- src/i18n/locales/es/ui.json | 3 + src/i18n/locales/id/templates.json | 7 +- src/i18n/locales/id/ui.json | 3 + src/i18n/locales/ja/templates.json | 7 +- src/i18n/locales/ja/ui.json | 3 + src/i18n/locales/ko/templates.json | 7 +- src/i18n/locales/ko/ui.json | 3 + src/i18n/locales/pt-BR/templates.json | 7 +- src/i18n/locales/pt-BR/ui.json | 3 + src/i18n/locales/vi/templates.json | 7 +- src/i18n/locales/vi/ui.json | 3 + src/i18n/locales/zh/templates.json | 7 +- src/i18n/locales/zh/ui.json | 3 + src/pages/EditorPage.tsx | 9 ++- src/store/editor-store.ts | 22 +++++- src/store/profile-store.ts | 6 +- src/utils/backup/sanitize.ts | 2 + tests/config/tech-note-groups.test.ts | 13 +++- tests/engine/description-builder.test.ts | 82 +++++++++++++++++++++ tests/engine/title-builder.test.ts | 68 +++++++++++++++++ tests/engine/upscale.test.ts | 56 ++++++++++++++ tests/hooks/generator-input-mapping.test.ts | 9 +++ tests/store/editor-store.migrate.test.ts | 28 +++++++ tests/utils/backup-sanitize.test.ts | 18 ++++- 37 files changed, 549 insertions(+), 45 deletions(-) create mode 100644 src/engine/upscale.ts create mode 100644 tests/engine/upscale.test.ts diff --git a/src/components/editor/VideoSettingsForm.tsx b/src/components/editor/VideoSettingsForm.tsx index 503035a..70fe375 100644 --- a/src/components/editor/VideoSettingsForm.tsx +++ b/src/components/editor/VideoSettingsForm.tsx @@ -9,12 +9,14 @@ import { RT_MODES, FRAMEGEN_VENDORS, ART_STYLES, + VIDEO_RESOLUTIONS, type GraphicsPreset, type RTMode, type FrameGenVendor, type FrameGenMultiplier, type UpscaleQuality, type ArtStyle, + type UpscaledFrom, } from "@config/graphics-settings"; import { getValidUpscaleQualities, @@ -22,15 +24,11 @@ import { coerceUpscaleQuality, coerceFrameGenMultiplier, } from "@engine/graphics-vendor"; +import { upscaleSourcesFor, validUpscaleSource } from "@engine/upscale"; import { VIDEO_STYLE_ERA_IDS, type VideoStyleEra } from "@config/video-styles"; import { FIELD_LIMITS } from "@config/field-limits"; -const RESOLUTION_OPTIONS = [ - { value: "720p", label: "720p" }, - { value: "1080p", label: "1080p" }, - { value: "1440p", label: "1440p" }, - { value: "4K", label: "4K" }, -]; +const RESOLUTION_OPTIONS = VIDEO_RESOLUTIONS.map((r) => ({ value: r, label: r })); const FPS_OPTIONS = [ { value: "30", label: "30 FPS" }, @@ -105,6 +103,26 @@ export function VideoSettingsForm() { if (coercedM !== store.frameGenMultiplier) store.set("frameGenMultiplier", coercedM); } + // v1.5.0: "Upscaled from" lists only resolutions below the video's own. + // A stale pair (an older profile applied over a 4K draft, say) shows as + // "Not upscaled" — the engine ignores it too. + const resolution = store.resolution ?? "1080p"; + const upscaledFrom = validUpscaleSource(resolution, store.upscaledFrom); + const upscaleSources = upscaleSourcesFor(resolution); + const upscaledFromOptions = [ + { value: "", label: t("editor.upscaledFromNone") }, + ...upscaleSources.map((r) => ({ value: r, label: r })), + ]; + + // Lowering the resolution to or below the upscale source ends the upscale, + // so the draft never keeps a pair the Select can't show. + function handleResolutionChange(next: string) { + store.set("resolution", next); + if (store.upscaledFrom && !validUpscaleSource(next, store.upscaledFrom)) { + store.set("upscaledFrom", ""); + } + } + const artStyleOptions = ART_STYLES.map((s) => ({ value: s, label: t(`editor.artStyleOptions.${s}`), @@ -112,12 +130,19 @@ export function VideoSettingsForm() { return (
-
+
store.set("upscaledFrom", v as UpscaledFrom)} /> = { kofi: "☕", @@ -223,6 +224,26 @@ function composeVideoStyleLine(input: GeneratorInput, t: TranslationFn): string return t("description.videoSettings.styleLineNoEditor", { era: eraLabel }); } +/** + * The v1.5.0 "Upscale:" line — `Upscale: 1440p → 4K (DaVinci Resolve Studio + * 21.2)`, the editor named by the rig's `video_editor` field (no brackets when + * it's empty). Empty string when the video isn't upscaled. Like the style + * line, it survives `skipGraphicsSettings`: it describes the video, not the + * game's settings, and the title's "Upscaled" badge needs it explained. + */ +function composeUpscaleLine(input: GeneratorInput, t: TranslationFn): string { + const from = validUpscaleSource(input.resolution, input.upscaledFrom); + if (!from) return ""; + const editor = formatRigValue("video_editor", input.rig?.video_editor ?? "").trim(); + const tool = editor ? ` (${editor})` : ""; + return `${t("description.graphics.upscaleLabel")}: ${from} → ${input.resolution}${tool}`; +} + +/** The tech notes the engine adds after the user's own ({@link AUTO_TECH_NOTES}). */ +function autoTechNotes(input: GeneratorInput): AutoTechNote[] { + return validUpscaleSource(input.resolution, input.upscaledFrom) ? ["editor_upscaled"] : []; +} + export interface BuildDescriptionOptions { hashtagCount?: number; /** When true and channelName is non-empty, appends an auto-generated @@ -450,6 +471,7 @@ export function buildDescription( // still edit their footage, so the style credit shouldn't disappear // with the graphics block. const styleLine = composeVideoStyleLine(input, t); + const upscaleLine = composeUpscaleLine(input, t); if (!input.skipGraphicsSettings) { const lines: string[] = []; @@ -461,6 +483,8 @@ export function buildDescription( if (captureParts.length > 0) { lines.push(`${t("description.graphics.videoLabel")}: ${captureParts.join(" - ")}`); } + // v1.5.0: what the video was upscaled from, right under its resolution. + if (upscaleLine) lines.push(upscaleLine); // In-game side: preset + modifiers + RT. const gfxPart = composeGraphicsPart(input, t); @@ -489,11 +513,12 @@ export function buildDescription( if (lines.length > 0) { sections.push(`${t("description.sections.videoSettings")}\n${lines.join("\n")}`); } - } else if (styleLine) { + } else if (upscaleLine || styleLine) { // 2D / pixel-art path: the graphics block is suppressed but the - // creator still set a style era, so emit a single-line standalone - // section under the same header. - sections.push(`${t("description.sections.videoSettings")}\n${styleLine}`); + // creator still upscaled the video or set a style era, so emit those + // lines as a standalone section under the same header. + const lines = [upscaleLine, styleLine].filter(Boolean); + sections.push(`${t("description.sections.videoSettings")}\n${lines.join("\n")}`); } // 5.5 Difficulty — moved into the unified Playthrough Notes block @@ -534,8 +559,10 @@ export function buildDescription( // Sits next to Content Warnings because both are transparency blocks; // grouping them keeps disclaimers visually together. Same bilingual // checklist shape. + // v1.5.0: the engine's own notes (the upscaling warning) follow the user's. + const techNotes = [...(input.techNotes ?? []), ...autoTechNotes(input)]; const tnSection = buildBilingualBulletSection( - input.techNotes ?? [], + techNotes, "description.techNotes", input.language, t, diff --git a/src/engine/title-builder.ts b/src/engine/title-builder.ts index 3917440..6536468 100644 --- a/src/engine/title-builder.ts +++ b/src/engine/title-builder.ts @@ -15,6 +15,7 @@ import { } from "@config/gacha-quest-types"; import { formatEndingEntry, sliceEndingsForVideo } from "./endings-format"; import type { EndingEntry } from "./types"; +import { validUpscaleSource } from "./upscale"; /** * Compact "[2K 60FPS]" badge appended to the video-type segment when the @@ -26,10 +27,15 @@ import type { EndingEntry } from "./types"; * - Non-default FPS → include the resolution alongside (e.g. "1080p 120FPS") * so a lonely FPS number isn't ambiguous. * - * Always returns upper-case. Callers apply `badgeCase: "lower"` downstream - * — this function is a label producer, not a display formatter. + * - v1.5.0: `upscaledWord` (the locale's "Upscaled", passed only when the + * video was upscaled in the editor) follows the resolution — "4K Upscaled", + * "4K Upscaled 120FPS". It never makes a badge on its own: 1080p 60fps + * upscaled from 720p still has none (the description says so instead). + * + * Callers apply `badgeCase: "lower"` downstream — this function is a label + * producer, not a display formatter. */ -export function buildQualityBadge(resolution?: string, fps?: string): string { +export function buildQualityBadge(resolution?: string, fps?: string, upscaledWord = ""): string { const res = resolution || "1080p"; const fpsValue = fps || "60"; const resDefault = res === "1080p"; @@ -37,7 +43,8 @@ export function buildQualityBadge(resolution?: string, fps?: string): string { if (resDefault && fpsDefault) return ""; const resLabel = res === "1440p" ? "2K" : res; - return fpsDefault ? resLabel : `${resLabel} ${fpsValue}FPS`; + const head = upscaledWord ? `${resLabel} ${upscaledWord}` : resLabel; + return fpsDefault ? head : `${head} ${fpsValue}FPS`; } export interface BuildTitleOptions { @@ -285,7 +292,12 @@ export function buildTitle( const gameName = input.gameNameLocalized?.[input.language] ?? input.gameName; - let badge = opts.showQualityBadge ? buildQualityBadge(input.resolution, input.fps) : ""; + const upscaledWord = validUpscaleSource(input.resolution, input.upscaledFrom) + ? t("title.upscaled") + : ""; + let badge = opts.showQualityBadge + ? buildQualityBadge(input.resolution, input.fps, upscaledWord) + : ""; if (badge && opts.badgeCase === "lower") badge = badge.toLowerCase(); // Gacha-quest titles compose their own head segment via the diff --git a/src/engine/types.ts b/src/engine/types.ts index a12a024..f726cb1 100644 --- a/src/engine/types.ts +++ b/src/engine/types.ts @@ -255,6 +255,17 @@ export const TECH_NOTES = [ ] as const; export type TechNote = (typeof TECH_NOTES)[number]; +/** + * Tech notes the engine adds on its own (v1.5.0), after the ones the user + * picked — never stored in `techNotes` and not in the editor's checklist. + * `editor_upscaled` comes with a valid {@link GeneratorInput.upscaledFrom}: the + * structured "Upscale:" line in 🖥 VIDEO SETTINGS says what was upscaled to + * what, this note warns what upscaling does to the image. Their bullets share + * `description.techNotes.items` with {@link TECH_NOTES}. + */ +export const AUTO_TECH_NOTES = ["editor_upscaled"] as const; +export type AutoTechNote = (typeof AUTO_TECH_NOTES)[number]; + /** * Content warnings (v0.11 unified bilingual checklist). Replaces the * v0.7 trio (flashing_lights / loud_noises / jump_scares) plus the @@ -644,7 +655,15 @@ export interface GeneratorInput { * is rendered inside Gacha-specific intros (showcase / anniversary etc.). */ gachaVersion?: string; + /** The video's resolution — the uploaded file's ("4K" when 1440p footage was upscaled). */ resolution?: string; + /** + * v1.5.0: recorded at this resolution and upscaled to {@link resolution} in + * the video editor. Adds "Upscaled" to the title badge, an "Upscale:" line + * to 🖥 VIDEO SETTINGS and the {@link AUTO_TECH_NOTES} warning. Ignored + * unless it is below `resolution` (`@engine/upscale`). + */ + upscaledFrom?: string; fps?: string; /** * Graphics-quality preset (v0.8 enum + `"custom"` escape hatch). diff --git a/src/engine/upscale.ts b/src/engine/upscale.ts new file mode 100644 index 0000000..9f8421c --- /dev/null +++ b/src/engine/upscale.ts @@ -0,0 +1,39 @@ +import { + UPSCALED_FROM_OPTIONS, + VIDEO_RESOLUTIONS, + type UpscaledFrom, +} from "@config/graphics-settings"; + +/** + * Upscaling in the video editor (v1.5.0): footage recorded at one resolution + * and exported at a higher one, e.g. 1440p → 4K. The title badge, the + * description's "Upscale:" line and the automatic tech note all go through + * {@link validUpscaleSource}, so a pair that isn't an upscale (same or higher + * source, unknown value) changes nothing anywhere. + */ + +function rank(resolution: string): number { + return (VIDEO_RESOLUTIONS as readonly string[]).indexOf(resolution); +} + +/** + * `from` when it is a known resolution below `resolution` (the video's own, + * 1080p when unset — the editor's default); otherwise `""`. + */ +export function validUpscaleSource( + resolution: string | undefined, + from: string | undefined, +): string { + if (!from) return ""; + const source = rank(from); + const target = rank(resolution || "1080p"); + return source >= 0 && target >= 0 && source < target ? from : ""; +} + +/** The sources a video at `resolution` can be upscaled from, lowest first. */ +export function upscaleSourcesFor(resolution: string | undefined): Exclude[] { + return UPSCALED_FROM_OPTIONS.filter( + (from): from is Exclude => + from !== "" && validUpscaleSource(resolution, from) !== "", + ); +} diff --git a/src/hooks/use-current-generator-input.ts b/src/hooks/use-current-generator-input.ts index adbc46d..1a1a09a 100644 --- a/src/hooks/use-current-generator-input.ts +++ b/src/hooks/use-current-generator-input.ts @@ -44,6 +44,7 @@ export function buildGeneratorInputFromEditor( anniversaryYear: state.anniversaryYear, gachaVersion: state.gachaVersion, resolution: state.resolution, + upscaledFrom: state.upscaledFrom, fps: state.fps, graphicsPreset: state.graphicsPreset, graphicsPresetCustom: state.graphicsPresetCustom, diff --git a/src/i18n/locales/_schema.json b/src/i18n/locales/_schema.json index af5848b..0b2e7c1 100644 --- a/src/i18n/locales/_schema.json +++ b/src/i18n/locales/_schema.json @@ -109,6 +109,9 @@ "vnZalopay", "vnZalopayPlaceholder", "resolution", + "upscaledFrom", + "upscaledFromNone", + "upscaledFromHelp", "fps", "graphicsPreset", "graphicsPresetCustom", @@ -1138,7 +1141,7 @@ "editor.socialGroups": ["donate", "social"] }, "templates": { - "title": ["separator", "suffix"], + "title": ["separator", "suffix", "upscaled"], "title.separators": ["emDash", "hyphen", "colon", "pipe"], "title.videoType": [ "full", @@ -1305,6 +1308,7 @@ "low_graphics_performance", "fps_drops_hardware", "upscaling_artifacts_possible", + "editor_upscaled", "bug_from_game", "crash_kept_transparency", "loading_cut", @@ -1588,7 +1592,8 @@ "artStyle", "videoLabel", "inGameSettingLabel", - "versionLabel" + "versionLabel", + "upscaleLabel" ], "description.graphics.presetOptions": [ "low", diff --git a/src/i18n/locales/en/templates.json b/src/i18n/locales/en/templates.json index 286228c..e4a7176 100644 --- a/src/i18n/locales/en/templates.json +++ b/src/i18n/locales/en/templates.json @@ -8,6 +8,7 @@ "pipe": " | " }, "suffix": "Gameplay No Commentary", + "upscaled": "Upscaled", "videoType": { "full": "", "part": "Part {{partNumber}}", @@ -209,7 +210,8 @@ "edited_for_pacing": "Edited for pacing — not real-time", "support_developers": "Original game music — please support the developers", "online_connectivity_issues": "Online game — possible connectivity issues", - "upscaling_artifacts_possible": "Possible upscaling / frame-generation artifacts (DLSS, FSR, XeSS)" + "upscaling_artifacts_possible": "Possible upscaling / frame-generation artifacts (DLSS, FSR, XeSS)", + "editor_upscaled": "Upscaled to a higher resolution in editing — fine detail is reconstructed, so text, textures and edges may look slightly different from the original image" } }, "contentWarnings": { @@ -558,7 +560,8 @@ }, "videoLabel": "Video", "inGameSettingLabel": "In-game Setting", - "versionLabel": "Version" + "versionLabel": "Version", + "upscaleLabel": "Upscale" }, "videoSettings": { "styleLine": "Edited in {{era}} style using {{editor}}", diff --git a/src/i18n/locales/en/ui.json b/src/i18n/locales/en/ui.json index cdfda1b..a53bf43 100644 --- a/src/i18n/locales/en/ui.json +++ b/src/i18n/locales/en/ui.json @@ -168,6 +168,9 @@ "vnZalopay": "ZaloPay", "vnZalopayPlaceholder": "ZaloPay phone number", "resolution": "Resolution", + "upscaledFrom": "Upscaled from", + "upscaledFromNone": "Not upscaled", + "upscaledFromHelp": "The title says “Upscaled”; the description adds an Upscale line and a note that fine detail may differ from the original image.", "fps": "FPS", "graphicsPreset": "Graphics Preset", "graphicsPresetOptions": { diff --git a/src/i18n/locales/es/templates.json b/src/i18n/locales/es/templates.json index bb6511e..d080c3f 100644 --- a/src/i18n/locales/es/templates.json +++ b/src/i18n/locales/es/templates.json @@ -8,6 +8,7 @@ "pipe": " | " }, "suffix": "Gameplay No Commentary", + "upscaled": "Reescalado", "videoType": { "full": "", "part": "Parte {{partNumber}}", @@ -209,7 +210,8 @@ "edited_for_pacing": "Editado para el ritmo — no es en tiempo real", "support_developers": "Música original del juego — apoya a los desarrolladores", "online_connectivity_issues": "Juego online — posibles problemas de conexión", - "upscaling_artifacts_possible": "Posibles artefactos de escalado / generación de fotogramas (DLSS, FSR, XeSS)" + "upscaling_artifacts_possible": "Posibles artefactos de escalado / generación de fotogramas (DLSS, FSR, XeSS)", + "editor_upscaled": "Reescalado a una resolución mayor en la edición: los detalles finos se reconstruyen, así que textos, texturas y bordes pueden verse algo distintos de la imagen original" } }, "contentWarnings": { @@ -558,7 +560,8 @@ }, "videoLabel": "Video", "inGameSettingLabel": "In-game Setting", - "versionLabel": "Version" + "versionLabel": "Version", + "upscaleLabel": "Upscale" }, "videoSettings": { "styleLine": "Editado con estilo {{era}} usando {{editor}}", diff --git a/src/i18n/locales/es/ui.json b/src/i18n/locales/es/ui.json index eb17cf4..0fc28b6 100644 --- a/src/i18n/locales/es/ui.json +++ b/src/i18n/locales/es/ui.json @@ -168,6 +168,9 @@ "vnZalopay": "ZaloPay", "vnZalopayPlaceholder": "ZaloPay phone number", "resolution": "Resolución", + "upscaledFrom": "Reescalado desde", + "upscaledFromNone": "Sin reescalar", + "upscaledFromHelp": "El título dice «Reescalado»; la descripción añade una línea de reescalado y un aviso de que los detalles finos pueden diferir de la imagen original.", "fps": "FPS", "graphicsPreset": "Calidad Gráfica", "graphicsPresetOptions": { diff --git a/src/i18n/locales/id/templates.json b/src/i18n/locales/id/templates.json index 30f74dc..209cb77 100644 --- a/src/i18n/locales/id/templates.json +++ b/src/i18n/locales/id/templates.json @@ -8,6 +8,7 @@ "pipe": " | " }, "suffix": "Gameplay Tanpa Komentar", + "upscaled": "Upscale", "videoType": { "full": "", "part": "Part {{partNumber}}", @@ -209,7 +210,8 @@ "edited_for_pacing": "Diedit demi tempo — bukan waktu nyata", "support_developers": "Musik asli game — dukung para pengembangnya", "online_connectivity_issues": "Game online — kemungkinan ada kendala koneksi", - "upscaling_artifacts_possible": "Kemungkinan ada artefak upscaling / frame generation (DLSS, FSR, XeSS)" + "upscaling_artifacts_possible": "Kemungkinan ada artefak upscaling / frame generation (DLSS, FSR, XeSS)", + "editor_upscaled": "Di-upscale ke resolusi lebih tinggi saat editing — detail halus direkonstruksi, jadi teks, tekstur, dan tepi bisa terlihat sedikit berbeda dari gambar asli" } }, "contentWarnings": { @@ -558,7 +560,8 @@ }, "videoLabel": "Video", "inGameSettingLabel": "Pengaturan dalam game", - "versionLabel": "Versi" + "versionLabel": "Versi", + "upscaleLabel": "Upscale" }, "videoSettings": { "styleLine": "Diedit dengan gaya {{era}} memakai {{editor}}", diff --git a/src/i18n/locales/id/ui.json b/src/i18n/locales/id/ui.json index e37ba93..48334bb 100644 --- a/src/i18n/locales/id/ui.json +++ b/src/i18n/locales/id/ui.json @@ -168,6 +168,9 @@ "vnZalopay": "ZaloPay", "vnZalopayPlaceholder": "Nomor telepon ZaloPay", "resolution": "Resolusi", + "upscaledFrom": "Di-upscale dari", + "upscaledFromNone": "Tanpa upscale", + "upscaledFromHelp": "Judul menampilkan “Upscale”; deskripsi menambahkan baris Upscale dan catatan bahwa detail halus bisa berbeda dari gambar asli.", "fps": "FPS", "graphicsPreset": "Preset Grafis", "graphicsPresetOptions": { diff --git a/src/i18n/locales/ja/templates.json b/src/i18n/locales/ja/templates.json index 7101466..1d8a82a 100644 --- a/src/i18n/locales/ja/templates.json +++ b/src/i18n/locales/ja/templates.json @@ -8,6 +8,7 @@ "pipe": " | " }, "suffix": "Gameplay No Commentary", + "upscaled": "アップスケール", "videoType": { "full": "", "part": "パート{{partNumber}}", @@ -209,7 +210,8 @@ "edited_for_pacing": "テンポ調整の編集あり — 実時間ではありません", "support_developers": "原曲使用 — 開発者への応援をよろしくお願いします", "online_connectivity_issues": "オンラインゲーム — 接続不調の可能性", - "upscaling_artifacts_possible": "アップスケーリング / フレーム生成(DLSS・FSR・XeSS)由来のアーティファクトの可能性あり" + "upscaling_artifacts_possible": "アップスケーリング / フレーム生成(DLSS・FSR・XeSS)由来のアーティファクトの可能性あり", + "editor_upscaled": "編集時に高解像度へアップスケール — 細部は再構成されるため、文字・テクスチャ・輪郭が元の映像とわずかに異なる場合があります" } }, "contentWarnings": { @@ -558,7 +560,8 @@ }, "videoLabel": "Video", "inGameSettingLabel": "In-game Setting", - "versionLabel": "Version" + "versionLabel": "Version", + "upscaleLabel": "Upscale" }, "videoSettings": { "styleLine": "{{editor}}で{{era}}スタイルに編集", diff --git a/src/i18n/locales/ja/ui.json b/src/i18n/locales/ja/ui.json index b0c7e16..c4ba33b 100644 --- a/src/i18n/locales/ja/ui.json +++ b/src/i18n/locales/ja/ui.json @@ -168,6 +168,9 @@ "vnZalopay": "ZaloPay", "vnZalopayPlaceholder": "ZaloPay phone number", "resolution": "解像度", + "upscaledFrom": "アップスケール元", + "upscaledFromNone": "なし", + "upscaledFromHelp": "タイトルに「アップスケール」と表示し、説明欄にアップスケールの行と、細部が元の映像と異なる場合がある旨の注意を追加します。", "fps": "FPS", "graphicsPreset": "グラフィック設定", "graphicsPresetOptions": { diff --git a/src/i18n/locales/ko/templates.json b/src/i18n/locales/ko/templates.json index cd4d149..9c14467 100644 --- a/src/i18n/locales/ko/templates.json +++ b/src/i18n/locales/ko/templates.json @@ -8,6 +8,7 @@ "pipe": " | " }, "suffix": "Gameplay No Commentary", + "upscaled": "업스케일", "videoType": { "full": "", "part": "파트 {{partNumber}}", @@ -209,7 +210,8 @@ "edited_for_pacing": "리듬을 위해 편집 — 실시간 아님", "support_developers": "원곡 사용 — 개발자를 응원해 주세요", "online_connectivity_issues": "온라인 게임 — 연결 문제 가능성", - "upscaling_artifacts_possible": "업스케일링 / 프레임 생성 (DLSS, FSR, XeSS) 아티팩트 가능성" + "upscaling_artifacts_possible": "업스케일링 / 프레임 생성 (DLSS, FSR, XeSS) 아티팩트 가능성", + "editor_upscaled": "편집 과정에서 더 높은 해상도로 업스케일 — 세부 묘사가 재구성되므로 글자, 텍스처, 윤곽이 원본과 조금 다르게 보일 수 있습니다" } }, "contentWarnings": { @@ -558,7 +560,8 @@ }, "videoLabel": "Video", "inGameSettingLabel": "In-game Setting", - "versionLabel": "Version" + "versionLabel": "Version", + "upscaleLabel": "Upscale" }, "videoSettings": { "styleLine": "{{editor}}로 {{era}} 스타일 편집", diff --git a/src/i18n/locales/ko/ui.json b/src/i18n/locales/ko/ui.json index 436b103..ce9f3a8 100644 --- a/src/i18n/locales/ko/ui.json +++ b/src/i18n/locales/ko/ui.json @@ -168,6 +168,9 @@ "vnZalopay": "ZaloPay", "vnZalopayPlaceholder": "ZaloPay phone number", "resolution": "해상도", + "upscaledFrom": "업스케일 원본", + "upscaledFromNone": "업스케일 안 함", + "upscaledFromHelp": "제목에 ‘업스케일’이 표시되고, 설명에 업스케일 줄과 세부 묘사가 원본과 다를 수 있다는 안내가 추가됩니다.", "fps": "FPS", "graphicsPreset": "그래픽 프리셋", "graphicsPresetOptions": { diff --git a/src/i18n/locales/pt-BR/templates.json b/src/i18n/locales/pt-BR/templates.json index ab732c0..2e64853 100644 --- a/src/i18n/locales/pt-BR/templates.json +++ b/src/i18n/locales/pt-BR/templates.json @@ -8,6 +8,7 @@ "pipe": " | " }, "suffix": "Gameplay Sem Comentários", + "upscaled": "Upscale", "videoType": { "full": "", "part": "Parte {{partNumber}}", @@ -209,7 +210,8 @@ "edited_for_pacing": "Editado para o ritmo — não é em tempo real", "support_developers": "Música original do jogo — apoiem os desenvolvedores", "online_connectivity_issues": "Jogo online — possíveis problemas de conexão", - "upscaling_artifacts_possible": "Possíveis artefatos de upscaling / geração de quadros (DLSS, FSR, XeSS)" + "upscaling_artifacts_possible": "Possíveis artefatos de upscaling / geração de quadros (DLSS, FSR, XeSS)", + "editor_upscaled": "Upscale para uma resolução maior na edição — os detalhes finos são reconstruídos, então textos, texturas e bordas podem parecer um pouco diferentes da imagem original" } }, "contentWarnings": { @@ -558,7 +560,8 @@ }, "videoLabel": "Vídeo", "inGameSettingLabel": "Configuração no jogo", - "versionLabel": "Versão" + "versionLabel": "Versão", + "upscaleLabel": "Upscale" }, "videoSettings": { "styleLine": "Editado no estilo {{era}} usando {{editor}}", diff --git a/src/i18n/locales/pt-BR/ui.json b/src/i18n/locales/pt-BR/ui.json index 12c4d5a..c61b003 100644 --- a/src/i18n/locales/pt-BR/ui.json +++ b/src/i18n/locales/pt-BR/ui.json @@ -168,6 +168,9 @@ "vnZalopay": "ZaloPay", "vnZalopayPlaceholder": "Número de telefone do ZaloPay", "resolution": "Resolução", + "upscaledFrom": "Upscale a partir de", + "upscaledFromNone": "Sem upscale", + "upscaledFromHelp": "O título mostra “Upscale”; a descrição ganha uma linha de upscale e um aviso de que detalhes finos podem diferir da imagem original.", "fps": "FPS", "graphicsPreset": "Preset gráfico", "graphicsPresetOptions": { diff --git a/src/i18n/locales/vi/templates.json b/src/i18n/locales/vi/templates.json index ac1a409..f1b0360 100644 --- a/src/i18n/locales/vi/templates.json +++ b/src/i18n/locales/vi/templates.json @@ -8,6 +8,7 @@ "pipe": " | " }, "suffix": "Gameplay No Commentary", + "upscaled": "Upscale", "videoType": { "full": "", "part": "Phần {{partNumber}}", @@ -209,7 +210,8 @@ "edited_for_pacing": "Đã edit cho hợp nhịp — không phải thời gian thực", "support_developers": "Nhạc gốc của game — hãy ủng hộ nhà phát triển", "online_connectivity_issues": "Game online — có thể có vấn đề kết nối", - "upscaling_artifacts_possible": "Có thể có lỗi hình do upscaling / frame generation (DLSS, FSR, XeSS)" + "upscaling_artifacts_possible": "Có thể có lỗi hình do upscaling / frame generation (DLSS, FSR, XeSS)", + "editor_upscaled": "Đã upscale lên độ phân giải cao hơn khi dựng — chi tiết nhỏ được tái tạo, nên chữ, texture và đường viền có thể hơi khác so với hình gốc" } }, "contentWarnings": { @@ -558,7 +560,8 @@ }, "videoLabel": "Video", "inGameSettingLabel": "In-game Setting", - "versionLabel": "Version" + "versionLabel": "Version", + "upscaleLabel": "Upscale" }, "videoSettings": { "styleLine": "Dựng theo phong cách {{era}} bằng {{editor}}", diff --git a/src/i18n/locales/vi/ui.json b/src/i18n/locales/vi/ui.json index 0050d8d..74308be 100644 --- a/src/i18n/locales/vi/ui.json +++ b/src/i18n/locales/vi/ui.json @@ -168,6 +168,9 @@ "vnZalopay": "ZaloPay", "vnZalopayPlaceholder": "Số điện thoại ZaloPay", "resolution": "Độ phân giải", + "upscaledFrom": "Upscale từ", + "upscaledFromNone": "Không upscale", + "upscaledFromHelp": "Tiêu đề ghi “Upscale”; mô tả thêm dòng Upscale và ghi chú rằng chi tiết nhỏ có thể khác hình gốc.", "fps": "FPS", "graphicsPreset": "Cài đặt đồ họa", "graphicsPresetOptions": { diff --git a/src/i18n/locales/zh/templates.json b/src/i18n/locales/zh/templates.json index 80254b2..21649ae 100644 --- a/src/i18n/locales/zh/templates.json +++ b/src/i18n/locales/zh/templates.json @@ -8,6 +8,7 @@ "pipe": " | " }, "suffix": "Gameplay No Commentary", + "upscaled": "超分", "videoType": { "full": "", "part": "第{{partNumber}}集", @@ -209,7 +210,8 @@ "edited_for_pacing": "为节奏剪辑 — 并非实时", "support_developers": "原版游戏音乐 — 请支持开发者", "online_connectivity_issues": "联机游戏 — 可能存在连线问题", - "upscaling_artifacts_possible": "可能存在超分辨率 / 帧生成(DLSS、FSR、XeSS)造成的瑕疵" + "upscaling_artifacts_possible": "可能存在超分辨率 / 帧生成(DLSS、FSR、XeSS)造成的瑕疵", + "editor_upscaled": "剪辑时已超分至更高分辨率 — 细节经过重建,文字、纹理和边缘可能与原画面略有不同" } }, "contentWarnings": { @@ -558,7 +560,8 @@ }, "videoLabel": "Video", "inGameSettingLabel": "In-game Setting", - "versionLabel": "Version" + "versionLabel": "Version", + "upscaleLabel": "Upscale" }, "videoSettings": { "styleLine": "使用 {{editor}} 以 {{era}} 风格剪辑", diff --git a/src/i18n/locales/zh/ui.json b/src/i18n/locales/zh/ui.json index 121e6a1..543b990 100644 --- a/src/i18n/locales/zh/ui.json +++ b/src/i18n/locales/zh/ui.json @@ -168,6 +168,9 @@ "vnZalopay": "ZaloPay", "vnZalopayPlaceholder": "ZaloPay phone number", "resolution": "分辨率", + "upscaledFrom": "超分前分辨率", + "upscaledFromNone": "未超分", + "upscaledFromHelp": "标题会显示“超分”,简介会加上一行超分信息,并提示细节可能与原画面略有不同。", "fps": "帧率", "graphicsPreset": "画质预设", "graphicsPresetOptions": { diff --git a/src/pages/EditorPage.tsx b/src/pages/EditorPage.tsx index b249d6c..3e59c8a 100644 --- a/src/pages/EditorPage.tsx +++ b/src/pages/EditorPage.tsx @@ -48,6 +48,7 @@ import { PageContainer, PageHeader } from "@components/ui/PageHeader"; import { StrictModeBanner } from "@components/ui/StrictModeBanner"; import { FIELD_LIMITS } from "@config/field-limits"; import { VIDEO_TYPES } from "@config/video-types"; +import { validUpscaleSource } from "@engine/upscale"; import { useEditorStore } from "@store/editor-store"; import { useSettingsStore } from "@store/settings-store"; import { useDocumentTitle } from "@hooks/use-document-title"; @@ -163,13 +164,19 @@ function useSectionSummaries(): Partial> { const videoType = useEditorStore((s) => s.videoType); const language = useEditorStore((s) => s.language); const resolution = useEditorStore((s) => s.resolution); + const upscaledFrom = useEditorStore((s) => validUpscaleSource(s.resolution, s.upscaledFrom)); const fps = useEditorStore((s) => s.fps); const typeLabelKey = VIDEO_TYPES.find((vt) => vt.id === videoType)?.labelKey; return { gameInfo: [gameName || null, typeLabelKey ? t(typeLabelKey) : null, language.toUpperCase()] .filter(Boolean) .join(" · "), - videoSettings: [resolution, fps && `${fps} FPS`].filter(Boolean).join(" · "), + videoSettings: [ + upscaledFrom ? `${upscaledFrom} → ${resolution}` : resolution, + fps && `${fps} FPS`, + ] + .filter(Boolean) + .join(" · "), }; } diff --git a/src/store/editor-store.ts b/src/store/editor-store.ts index 045b643..a5614c4 100644 --- a/src/store/editor-store.ts +++ b/src/store/editor-store.ts @@ -23,6 +23,8 @@ import { type FrameGenMultiplier, type UpscaleQuality, type ArtStyle, + type UpscaledFrom, + isUpscaledFrom, } from "@config/graphics-settings"; import { isVideoStyleEra, type VideoStyleEra } from "@config/video-styles"; import { coerceUpscaleQuality, coerceFrameGenMultiplier } from "@engine/graphics-vendor"; @@ -66,6 +68,12 @@ export interface EditorData { /** Gacha-quest game version (v0.13) — e.g. "1.2", "2.4". Only used for gacha_quest videoType. */ gachaVersion: string; resolution: string; + /** + * v1.5.0: the resolution the footage was recorded at when it was upscaled + * to {@link resolution} in the video editor (1440p → 4K). `""` = not + * upscaled; a value that isn't below `resolution` is ignored by the engine. + */ + upscaledFrom: UpscaledFrom; fps: string; graphicsPreset: GraphicsPreset; graphicsPresetCustom: string; @@ -238,6 +246,9 @@ export function normalizeEditorPatch( // v1.0.0: profiles and templates saved before the GPU catalog rewrite // carry `brand|series|model` (or `rig: null` when hand-edited). if ("rig" in patch) out.rig = migrateRig((patch as { rig?: unknown }).rig); + // v1.5.0: a hand-edited or newer item's unknown upscale source would leave + // the editor's Select on a missing option — read it as "not upscaled". + if ("upscaledFrom" in patch && !isUpscaledFrom(patch.upscaledFrom)) out.upscaledFrom = ""; const raw: unknown = (patch as { graphicsPreset?: unknown }).graphicsPreset; if (typeof raw === "string" && !(GRAPHICS_PRESETS as readonly string[]).includes(raw)) { const { preset, custom } = legacyGraphicsPresetToEnum(raw); @@ -400,6 +411,7 @@ const initialState: EditorData = { anniversaryYear: DEFAULTS.editor.anniversaryYear, gachaVersion: DEFAULTS.editor.gachaVersion, resolution: DEFAULTS.editor.resolution, + upscaledFrom: DEFAULTS.editor.upscaledFrom, fps: DEFAULTS.editor.fps, graphicsPreset: DEFAULTS.editor.graphicsPreset, graphicsPresetCustom: DEFAULTS.editor.graphicsPresetCustom, @@ -481,7 +493,7 @@ export function editorDataOf(state: EditorData): EditorData { * Bump together with a new step in {@link migrateEditorState}; backups * record this number so an import can run the steps a draft still needs. */ -export const EDITOR_STORE_VERSION = 20; +export const EDITOR_STORE_VERSION = 21; export const useEditorStore = create()( persist( @@ -633,6 +645,10 @@ export const useEditorStore = create()( // Saved `adEmail` / `gameKeyEmail` values are left as they // are even when they lack a purpose word — Strict Mode points // at them instead of a migration deleting the user's data. + // v20 → v21: v1.5.0. `upscaledFrom` (recorded at a lower resolution, + // upscaled to `resolution` in the video editor) joined the + // schema. Additive: back-fills to "" (not upscaled); a value + // outside UPSCALED_FROM_OPTIONS coerces to "". version: EDITOR_STORE_VERSION, migrate: (persistedState, version) => migrateEditorState(persistedState, version), partialize: (state) => editorDataOf(state), @@ -908,6 +924,10 @@ export function migrateEditorState(persistedState: unknown, version: number): Ed // v1.1.0 copyright email. Additive back-fill + defensive coercion. if (typeof state.copyrightEmail !== "string") state.copyrightEmail = ""; } + if (version < 21) { + // v1.5.0 upscaled video. Additive back-fill + defensive coercion. + if (!isUpscaledFrom(state.upscaledFrom)) state.upscaledFrom = ""; + } return { ...initialState, ...state } as EditorData; } diff --git a/src/store/profile-store.ts b/src/store/profile-store.ts index d29ff48..f37b1db 100644 --- a/src/store/profile-store.ts +++ b/src/store/profile-store.ts @@ -2,7 +2,7 @@ import { create } from "zustand"; import { persist, createJSONStorage } from "zustand/middleware"; import { generateId } from "@utils/uuid"; import { migrateRig } from "@config/rig-fields"; -import type { GraphicsPreset } from "@config/graphics-settings"; +import type { GraphicsPreset, UpscaledFrom } from "@config/graphics-settings"; /** * A channel profile — the editor's channel-stable fields @@ -19,7 +19,8 @@ import type { GraphicsPreset } from "@config/graphics-settings"; * donate fields, the community invite links and `graphicsPresetCustom` — * optional, because profiles saved before then don't have them and * applying one must leave those editor fields alone. v1.1.0's - * `copyrightEmail` is optional for the same reason. + * `copyrightEmail` and v1.5.0's `upscaledFrom` are optional for the same + * reason. */ export interface Profile { id: string; @@ -32,6 +33,7 @@ export interface Profile { social: Record; rig: Record; resolution: string; + upscaledFrom?: UpscaledFrom; fps: string; graphicsPreset: GraphicsPreset; graphicsPresetCustom?: string; diff --git a/src/utils/backup/sanitize.ts b/src/utils/backup/sanitize.ts index d4a3953..0b9782c 100644 --- a/src/utils/backup/sanitize.ts +++ b/src/utils/backup/sanitize.ts @@ -7,6 +7,7 @@ import { GRAPHICS_PRESETS, RT_MODES, UPSCALE_QUALITIES, + UPSCALED_FROM_OPTIONS, } from "@config/graphics-settings"; import { VIDEO_STYLE_ERAS } from "@config/video-styles"; import { GACHA_QUEST_TYPES } from "@config/gacha-quest-types"; @@ -67,6 +68,7 @@ const CHOICES: Partial> = { frameGenVendor: FRAMEGEN_VENDORS, frameGenMultiplier: FRAMEGEN_MULTIPLIERS, upscaleQuality: UPSCALE_QUALITIES, + upscaledFrom: UPSCALED_FROM_OPTIONS, artStyle: ART_STYLES, videoStyleEra: VIDEO_STYLE_ERAS, gachaQuestType: GACHA_QUEST_TYPES, diff --git a/tests/config/tech-note-groups.test.ts b/tests/config/tech-note-groups.test.ts index f8a81d1..7aaca4c 100644 --- a/tests/config/tech-note-groups.test.ts +++ b/tests/config/tech-note-groups.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect } from "vitest"; import { TECH_NOTE_GROUPS } from "@config/tech-note-groups"; -import { TECH_NOTES } from "@engine/types"; +import { AUTO_TECH_NOTES, TECH_NOTES } from "@engine/types"; import { schemaKeys } from "../helpers/locale-schema"; /** @@ -29,7 +29,16 @@ describe("tech-note i18n keys", () => { }); it("has a description bullet for every tech note, and none for unknown ids", () => { - expect(schemaKeys("templates", "description.techNotes.items")).toEqual(ids); + // The engine's own notes (v1.5.0) have a bullet but no checklist label. + expect(schemaKeys("templates", "description.techNotes.items")).toEqual( + [...TECH_NOTES, ...AUTO_TECH_NOTES].sort(), + ); + }); + + it("keeps the engine's own notes out of the checklist", () => { + for (const id of AUTO_TECH_NOTES) { + expect(TECH_NOTES as readonly string[]).not.toContain(id); + } }); it("has a heading for every group", () => { diff --git a/tests/engine/description-builder.test.ts b/tests/engine/description-builder.test.ts index d3ed31e..c198a4e 100644 --- a/tests/engine/description-builder.test.ts +++ b/tests/engine/description-builder.test.ts @@ -1880,6 +1880,88 @@ describe("buildDescription — translation quality notice (v0.24.0)", () => { }); }); +describe("buildDescription — upscaled video (v1.5.0)", () => { + const EN_NOTE = + "Upscaled to a higher resolution in editing — fine detail is reconstructed, so text, textures and edges may look slightly different from the original image"; + const VI_NOTE = + "Đã upscale lên độ phân giải cao hơn khi dựng — chi tiết nhỏ được tái tạo, nên chữ, texture và đường viền có thể hơi khác so với hình gốc"; + const upscaled = (overrides: Partial = {}) => + makeInput({ + resolution: "4K", + upscaledFrom: "1440p", + fps: "60", + rig: { video_editor: "davinci_resolve_studio|21.2" }, + ...overrides, + }); + + it("adds an Upscale line right under the Video line, naming the editor", () => { + const result = buildDescription(upscaled(), createMockT("en")); + expect(result).toContain( + "Video: 4K - 60 FPS\nUpscale: 1440p → 4K (DaVinci Resolve Studio 21.2)", + ); + }); + + it("leaves the brackets out when the rig has no video editor", () => { + const result = buildDescription(upscaled({ rig: {} }), createMockT("en")); + expect(result).toContain("Upscale: 1440p → 4K\n"); + expect(result).not.toContain("Upscale: 1440p → 4K ("); + }); + + it("keeps the Upscale line when the graphics settings are skipped", () => { + const result = buildDescription( + upscaled({ skipGraphicsSettings: true, videoStyleEra: "retro" }), + createMockT("en"), + ); + expect(result).toContain( + "🖥 VIDEO SETTINGS\nUpscale: 1440p → 4K (DaVinci Resolve Studio 21.2)\nEdited in retro style using DaVinci Resolve Studio 21.2", + ); + expect(result).not.toContain("Video: "); + }); + + it("adds the warning to TECH NOTES after the user's own notes", () => { + const result = buildDescription( + upscaled({ techNotes: ["fps_drops_hardware"] }), + createMockT("en"), + ); + const own = result.indexOf("• FPS drops"); + const auto = result.indexOf(`• ${EN_NOTE}`); + expect(own).toBeGreaterThan(-1); + expect(auto).toBeGreaterThan(own); + }); + + it("shows the TECH NOTES block for the warning alone", () => { + const result = buildDescription(upscaled({ techNotes: [] }), createMockT("en")); + expect(result).toContain( + `▸ 🛠 TECH NOTES\nProduction and playstyle notes for transparency.\n\n• ${EN_NOTE}`, + ); + }); + + it("is bilingual in the Output tab and single-language in the language tabs", () => { + const t = createMockT("vi"); + const tEn = createMockT("en"); + const input = upscaled({ language: "vi" }); + expect(buildDescription(input, t, { tEn })).toContain(`• ${EN_NOTE} · ${VI_NOTE}`); + const single = buildDescription(input, t, { tEn, bilingualContentBlocks: false }); + expect(single).toContain(`• ${VI_NOTE}`); + expect(single).not.toContain(EN_NOTE); + }); + + it("adds nothing when not upscaled, or when the pair is not an upscale", () => { + const t = createMockT("en"); + for (const input of [ + upscaled({ upscaledFrom: "" }), + upscaled({ upscaledFrom: undefined }), + upscaled({ resolution: "1440p" }), + upscaled({ resolution: "1080p" }), + ]) { + const result = buildDescription(input, t); + expect(result).not.toContain("Upscale:"); + expect(result).not.toContain(EN_NOTE); + expect(result).not.toContain("TECH NOTES"); + } + }); +}); + describe("buildDescription — bilingualContentBlocks gate (v0.29.3)", () => { it("multi-language tabs: content blocks single-language but translation-quality stays bilingual", () => { const t = createMockT("ja"); diff --git a/tests/engine/title-builder.test.ts b/tests/engine/title-builder.test.ts index acc3f9b..c5df842 100644 --- a/tests/engine/title-builder.test.ts +++ b/tests/engine/title-builder.test.ts @@ -599,6 +599,74 @@ describe("buildQualityBadge", () => { it("falls back to defaults when inputs are undefined", () => { expect(buildQualityBadge(undefined, undefined)).toBe(""); }); + + it("puts the upscaled word after the resolution, before the FPS (v1.5.0)", () => { + expect(buildQualityBadge("4K", "60", "Upscaled")).toBe("4K Upscaled"); + expect(buildQualityBadge("1440p", "60", "Upscaled")).toBe("2K Upscaled"); + expect(buildQualityBadge("4K", "120", "Upscaled")).toBe("4K Upscaled 120FPS"); + }); + + it("never makes a badge from the upscaled word alone", () => { + expect(buildQualityBadge("1080p", "60", "Upscaled")).toBe(""); + expect(buildQualityBadge("1080p", "120", "Upscaled")).toBe("1080p Upscaled 120FPS"); + }); +}); + +describe("buildTitle — upscaled video (v1.5.0)", () => { + const upscaled = { videoType: "part" as const, partNumber: "3", resolution: "4K" }; + + it("marks the badge when the video was upscaled from a lower resolution", () => { + const t = createMockT("en"); + expect(buildTitle(makeInput({ ...upscaled, upscaledFrom: "1440p" }), t)).toBe( + "Elden Ring — Part 3 [4K Upscaled] — Gameplay No Commentary", + ); + }); + + it("keeps the plain badge when not upscaled or the pair is not an upscale", () => { + const t = createMockT("en"); + const plain = "Elden Ring — Part 3 [4K] — Gameplay No Commentary"; + expect(buildTitle(makeInput(upscaled), t)).toBe(plain); + expect(buildTitle(makeInput({ ...upscaled, upscaledFrom: "" }), t)).toBe(plain); + expect( + buildTitle(makeInput({ ...upscaled, resolution: "1440p", upscaledFrom: "1440p" }), t), + ).toBe("Elden Ring — Part 3 [2K] — Gameplay No Commentary"); + }); + + it("follows the badge position, case and FPS", () => { + const t = createMockT("en"); + const input = makeInput({ ...upscaled, upscaledFrom: "1440p", fps: "120" }); + expect(buildTitle(input, t, { badgePosition: "prefix" })).toBe( + "[4K Upscaled 120FPS] Elden Ring — Part 3 — Gameplay No Commentary", + ); + expect(buildTitle(input, t, { badgePosition: "suffix", badgeCase: "lower" })).toBe( + "Elden Ring — Part 3 — [4k upscaled 120fps] Gameplay No Commentary", + ); + }); + + it("has no badge when the badge is off, or at 1080p 60fps upscaled from 720p", () => { + const t = createMockT("en"); + expect(buildTitle(makeInput({ ...upscaled, upscaledFrom: "1440p" }), t, false)).toBe( + "Elden Ring — Part 3 — Gameplay No Commentary", + ); + expect( + buildTitle(makeInput({ ...upscaled, resolution: "1080p", upscaledFrom: "720p" }), t), + ).toBe("Elden Ring — Part 3 — Gameplay No Commentary"); + }); + + it("uses the output language's word", () => { + expect( + buildTitle( + makeInput({ ...upscaled, language: "vi", upscaledFrom: "1440p" }), + createMockT("vi"), + ), + ).toContain("[4K Upscale]"); + expect( + buildTitle( + makeInput({ ...upscaled, language: "ja", upscaledFrom: "1440p" }), + createMockT("ja"), + ), + ).toContain("[4K アップスケール]"); + }); }); describe("checkTitleWarning", () => { diff --git a/tests/engine/upscale.test.ts b/tests/engine/upscale.test.ts new file mode 100644 index 0000000..966bd4c --- /dev/null +++ b/tests/engine/upscale.test.ts @@ -0,0 +1,56 @@ +import { describe, it, expect } from "vitest"; +import { upscaleSourcesFor, validUpscaleSource } from "@engine/upscale"; +import { isUpscaledFrom, UPSCALED_FROM_OPTIONS } from "@config/graphics-settings"; + +describe("validUpscaleSource", () => { + it("keeps a source below the video's resolution", () => { + expect(validUpscaleSource("4K", "1440p")).toBe("1440p"); + expect(validUpscaleSource("4K", "720p")).toBe("720p"); + expect(validUpscaleSource("1440p", "1080p")).toBe("1080p"); + }); + + it("reads an unset resolution as 1080p, the editor's default", () => { + expect(validUpscaleSource(undefined, "720p")).toBe("720p"); + expect(validUpscaleSource("", "1440p")).toBe(""); + }); + + it("drops a source that is not below the resolution", () => { + expect(validUpscaleSource("1440p", "1440p")).toBe(""); + expect(validUpscaleSource("1080p", "1440p")).toBe(""); + expect(validUpscaleSource("720p", "720p")).toBe(""); + }); + + it("drops empty and unknown values on either side", () => { + expect(validUpscaleSource("4K", "")).toBe(""); + expect(validUpscaleSource("4K", undefined)).toBe(""); + expect(validUpscaleSource("4K", "480p")).toBe(""); + expect(validUpscaleSource("8K", "1440p")).toBe(""); + }); +}); + +describe("upscaleSourcesFor", () => { + it("lists every lower resolution, lowest first", () => { + expect(upscaleSourcesFor("4K")).toEqual(["720p", "1080p", "1440p"]); + expect(upscaleSourcesFor("1440p")).toEqual(["720p", "1080p"]); + expect(upscaleSourcesFor("1080p")).toEqual(["720p"]); + expect(upscaleSourcesFor(undefined)).toEqual(["720p"]); + }); + + it("has nothing below 720p or for an unknown resolution", () => { + expect(upscaleSourcesFor("720p")).toEqual([]); + expect(upscaleSourcesFor("8K")).toEqual([]); + }); +}); + +describe("isUpscaledFrom", () => { + it("accepts every option, the empty one included", () => { + for (const option of UPSCALED_FROM_OPTIONS) expect(isUpscaledFrom(option)).toBe(true); + }); + + it("rejects anything else", () => { + expect(isUpscaledFrom("4K")).toBe(false); + expect(isUpscaledFrom("2K")).toBe(false); + expect(isUpscaledFrom(1440)).toBe(false); + expect(isUpscaledFrom(null)).toBe(false); + }); +}); diff --git a/tests/hooks/generator-input-mapping.test.ts b/tests/hooks/generator-input-mapping.test.ts index b3be522..eb2e7f6 100644 --- a/tests/hooks/generator-input-mapping.test.ts +++ b/tests/hooks/generator-input-mapping.test.ts @@ -61,6 +61,7 @@ function makeEditorData(overrides: Partial = {}): EditorData { anniversaryYear: DEFAULTS.editor.anniversaryYear, gachaVersion: DEFAULTS.editor.gachaVersion, resolution: DEFAULTS.editor.resolution, + upscaledFrom: DEFAULTS.editor.upscaledFrom, fps: DEFAULTS.editor.fps, graphicsPreset: DEFAULTS.editor.graphicsPreset as GraphicsPreset, graphicsPresetCustom: DEFAULTS.editor.graphicsPresetCustom, @@ -195,6 +196,14 @@ describe("buildGeneratorInputFromEditor — v0.12 fields propagation (regression expect(input.facebookGroupLink).toBe("https://facebook.com/groups/mygroup"); }); + it("passes through the upscale source (v1.5.0)", () => { + const input = buildGeneratorInputFromEditor( + makeEditorData({ resolution: "4K", upscaledFrom: "1440p" }), + ); + expect(input.resolution).toBe("4K"); + expect(input.upscaledFrom).toBe("1440p"); + }); + it("respects languageOverride for batch / multi-language rendering", () => { const input = buildGeneratorInputFromEditor(makeEditorData({ language: "en" }), "vi"); expect(input.language).toBe("vi"); diff --git a/tests/store/editor-store.migrate.test.ts b/tests/store/editor-store.migrate.test.ts index 8ba2497..6634701 100644 --- a/tests/store/editor-store.migrate.test.ts +++ b/tests/store/editor-store.migrate.test.ts @@ -464,3 +464,31 @@ describe("migrateEditorState — v19 → v20 (v1.1.0 copyright email)", () => { expect(result.gameKeyEmail).toBe("me@channel.com"); }); }); + +describe("migrateEditorState — v20 → v21 (v1.5.0 upscaled video)", () => { + function makeV20Persisted(overrides: Record = {}): Record { + const full = migrateEditorState(makeV9Persisted(), 9) as unknown as Record; + delete full.upscaledFrom; + return { ...full, ...overrides }; + } + + it("back-fills upscaledFrom as not upscaled", () => { + expect(migrateEditorState(makeV20Persisted(), 20).upscaledFrom).toBe(""); + }); + + it("coerces an unknown or non-string value to not upscaled", () => { + expect(migrateEditorState(makeV20Persisted({ upscaledFrom: "2K" }), 20).upscaledFrom).toBe(""); + expect(migrateEditorState(makeV20Persisted({ upscaledFrom: 1440 }), 20).upscaledFrom).toBe(""); + expect(migrateEditorState(makeV20Persisted({ upscaledFrom: null }), 20).upscaledFrom).toBe(""); + }); + + it("keeps a valid value, and running it again changes nothing", () => { + const once = migrateEditorState( + makeV20Persisted({ resolution: "4K", upscaledFrom: "1440p" }), + 20, + ); + expect(once.upscaledFrom).toBe("1440p"); + expect(once.resolution).toBe("4K"); + expect(migrateEditorState({ ...once }, 20)).toEqual(once); + }); +}); diff --git a/tests/utils/backup-sanitize.test.ts b/tests/utils/backup-sanitize.test.ts index 8cc0133..1b0f9ec 100644 --- a/tests/utils/backup-sanitize.test.ts +++ b/tests/utils/backup-sanitize.test.ts @@ -74,6 +74,13 @@ describe("sanitizeEditorFields", () => { expect(out.techNotes).toEqual(["upscaling_artifacts_possible"]); }); + it("keeps a known upscale source and reads anything else as not upscaled (v1.5.0)", () => { + expect(sanitizeEditorFields({ upscaledFrom: "1440p" })).toEqual({ upscaledFrom: "1440p" }); + expect(sanitizeEditorFields({ upscaledFrom: "" })).toEqual({ upscaledFrom: "" }); + expect(sanitizeEditorFields({ upscaledFrom: "2K" })).toEqual({ upscaledFrom: "" }); + expect(sanitizeEditorFields({ upscaledFrom: 1440 })).toEqual({ upscaledFrom: "" }); + }); + it("limits the result to the given fields", () => { const out = sanitizeEditorFields({ gameName: "Hades", channelName: "Me" }, ["channelName"]); expect(out).toEqual({ channelName: "Me" }); @@ -91,7 +98,15 @@ describe("row sanitizers", () => { it("builds a complete profile from a partial one", () => { const profile = sanitizeProfile( - { id: "p1", name: " ", channelName: "Skullmute", rig: null, vnMomo: "0900", junk: 1 }, + { + id: "p1", + name: " ", + channelName: "Skullmute", + rig: null, + vnMomo: "0900", + upscaledFrom: "1440p", + junk: 1, + }, new IdKeeper(), NOW, ); @@ -102,6 +117,7 @@ describe("row sanitizers", () => { rig: {}, social: {}, vnMomo: "0900", + upscaledFrom: "1440p", createdAt: NOW, updatedAt: NOW, });