diff --git a/bun.lock b/bun.lock index a5119c4c..c0b3601e 100644 --- a/bun.lock +++ b/bun.lock @@ -15,7 +15,7 @@ "ajv": "^8.18.0", "husky": "^9.1.7", "prettier": "^3.7.4", - "route-graphics": "1.7.0", + "route-graphics": "1.7.5", "vitest": "^4.0.16", }, }, @@ -377,7 +377,7 @@ "rollup": ["rollup@4.54.0", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.54.0", "@rollup/rollup-android-arm64": "4.54.0", "@rollup/rollup-darwin-arm64": "4.54.0", "@rollup/rollup-darwin-x64": "4.54.0", "@rollup/rollup-freebsd-arm64": "4.54.0", "@rollup/rollup-freebsd-x64": "4.54.0", "@rollup/rollup-linux-arm-gnueabihf": "4.54.0", "@rollup/rollup-linux-arm-musleabihf": "4.54.0", "@rollup/rollup-linux-arm64-gnu": "4.54.0", "@rollup/rollup-linux-arm64-musl": "4.54.0", "@rollup/rollup-linux-loong64-gnu": "4.54.0", "@rollup/rollup-linux-ppc64-gnu": "4.54.0", "@rollup/rollup-linux-riscv64-gnu": "4.54.0", "@rollup/rollup-linux-riscv64-musl": "4.54.0", "@rollup/rollup-linux-s390x-gnu": "4.54.0", "@rollup/rollup-linux-x64-gnu": "4.54.0", "@rollup/rollup-linux-x64-musl": "4.54.0", "@rollup/rollup-openharmony-arm64": "4.54.0", "@rollup/rollup-win32-arm64-msvc": "4.54.0", "@rollup/rollup-win32-ia32-msvc": "4.54.0", "@rollup/rollup-win32-x64-gnu": "4.54.0", "@rollup/rollup-win32-x64-msvc": "4.54.0", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-3nk8Y3a9Ea8szgKhinMlGMhGMw89mqule3KWczxhIzqudyHdCIOHw8WJlj/r329fACjKLEh13ZSk7oE22kyeIw=="], - "route-graphics": ["route-graphics@1.7.0", "", { "dependencies": { "@pixi/unsafe-eval": "^7.4.3", "hotkeys-js": "^4.0.0-beta.7", "pixi.js": "^8.7.1" } }, "sha512-70yMFdQyuuSHNwdtFcA0YYaCF0qZl3JJXTXsLFrl9N4HwqRTYO9Iepyp9Aqfi587dZRjqjTz7pk935TiFdYWtQ=="], + "route-graphics": ["route-graphics@1.7.5", "", { "dependencies": { "@pixi/unsafe-eval": "^7.4.3", "hotkeys-js": "^4.0.0-beta.7", "pixi.js": "^8.7.1" } }, "sha512-s3Syu73lEY0yzFxbKCdwOUF1gw00EaDZb1UsYJhZ4T5WO5FCMcZODluHQwkg2gI3Y88FltpgfDMdj5k49GSaSw=="], "semver": ["semver@7.6.3", "", { "bin": "bin/semver.js" }, "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A=="], diff --git a/package.json b/package.json index 49f62f5e..fde53caf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "route-engine-js", - "version": "1.0.2", + "version": "1.0.3", "description": "A lightweight Visual Novel engine built in JavaScript for creating interactive narrative games with branching storylines", "repository": { "type": "git", @@ -58,7 +58,7 @@ "ajv": "^8.18.0", "husky": "^9.1.7", "prettier": "^3.7.4", - "route-graphics": "1.7.0", + "route-graphics": "1.7.5", "vitest": "^4.0.16" } } diff --git a/spec/RouteEngine.runtime.test.js b/spec/RouteEngine.runtime.test.js index f1519cb1..de5f7f2a 100644 --- a/spec/RouteEngine.runtime.test.js +++ b/spec/RouteEngine.runtime.test.js @@ -78,8 +78,8 @@ describe("RouteEngine runtime", () => { autoForwardDelay: 1000, skipUnseenText: false, skipTransitionsAndAnimations: false, - soundVolume: 500, - musicVolume: 500, + soundVolume: 50, + musicVolume: 50, muteAll: false, }, }, diff --git a/spec/system/createInitialState.spec.yaml b/spec/system/createInitialState.spec.yaml index 25220964..26d1db3f 100644 --- a/spec/system/createInitialState.spec.yaml +++ b/spec/system/createInitialState.spec.yaml @@ -30,8 +30,8 @@ out: autoForwardDelay: 1000 skipUnseenText: false skipTransitionsAndAnimations: false - soundVolume: 500 - musicVolume: 500 + soundVolume: 50 + musicVolume: 50 muteAll: false confirmDialog: null viewedRegistry: @@ -123,8 +123,8 @@ out: autoForwardDelay: 1000 skipUnseenText: false skipTransitionsAndAnimations: false - soundVolume: 500 - musicVolume: 500 + soundVolume: 50 + musicVolume: 50 muteAll: false confirmDialog: null viewedRegistry: @@ -229,8 +229,8 @@ out: autoForwardDelay: 1000 skipUnseenText: false skipTransitionsAndAnimations: false - soundVolume: 500 - musicVolume: 500 + soundVolume: 50 + musicVolume: 50 muteAll: false confirmDialog: null viewedRegistry: @@ -329,8 +329,8 @@ out: autoForwardDelay: 1000 skipUnseenText: false skipTransitionsAndAnimations: false - soundVolume: 500 - musicVolume: 500 + soundVolume: 50 + musicVolume: 50 muteAll: false confirmDialog: null viewedRegistry: @@ -426,8 +426,8 @@ out: autoForwardDelay: 1000 skipUnseenText: false skipTransitionsAndAnimations: false - soundVolume: 500 - musicVolume: 500 + soundVolume: 50 + musicVolume: 50 muteAll: false confirmDialog: null viewedRegistry: diff --git a/spec/system/renderState/addBgm.spec.yaml b/spec/system/renderState/addBgm.spec.yaml index b45dc742..28d9bf77 100644 --- a/spec/system/renderState/addBgm.spec.yaml +++ b/spec/system/renderState/addBgm.spec.yaml @@ -25,7 +25,7 @@ in: backgroundMusic: fileId: "bgm.mp3" runtime: - musicVolume: 700 + musicVolume: 70 out: elements: - id: "story" @@ -39,7 +39,7 @@ out: type: "sound" src: "bgm.mp3" loop: true - volume: 700 + volume: 70 delay: 0 --- case: add bgm with default values @@ -72,7 +72,7 @@ out: type: "sound" src: "simple.mp3" loop: true - volume: 500 + volume: 50 delay: null --- case: add bgm with custom settings @@ -95,7 +95,7 @@ in: customMusic: fileId: "custom.mp3" runtime: - musicVolume: 300 + musicVolume: 30 out: elements: - id: "story" @@ -109,7 +109,7 @@ out: type: "sound" src: "custom.mp3" loop: false - volume: 300 + volume: 30 delay: 1000 --- case: no presentationState.bgm - return unchanged state @@ -128,7 +128,7 @@ in: backgroundMusic: fileId: "bgm.mp3" loop: true - volume: 700 + volume: 70 out: elements: - id: "story" @@ -155,7 +155,7 @@ in: backgroundMusic: fileId: "bgm.mp3" loop: true - volume: 700 + volume: 70 out: elements: - id: "notStory" @@ -182,7 +182,7 @@ in: existing: fileId: "existing.mp3" loop: true - volume: 700 + volume: 70 out: elements: - id: "story" diff --git a/spec/system/renderState/addSfx.spec.yaml b/spec/system/renderState/addSfx.spec.yaml index 768fcc94..7076edf1 100644 --- a/spec/system/renderState/addSfx.spec.yaml +++ b/spec/system/renderState/addSfx.spec.yaml @@ -25,7 +25,7 @@ in: soundEffect: fileId: "effect.mp3" loop: false - volume: 700 + volume: 70 delay: 0 out: elements: @@ -40,7 +40,7 @@ out: type: "sound" src: "effect.mp3" loop: false - volume: 700 + volume: 70 delay: 0 --- case: add sfx with default values @@ -75,7 +75,7 @@ out: type: "sound" src: "simple.mp3" loop: false - volume: 500 + volume: 50 delay: null --- case: add sfx with custom settings @@ -94,7 +94,7 @@ in: - id: "sfx1" resourceId: "customSound" loop: true - volume: 300 + volume: 30 delay: 500 resources: sounds: @@ -113,7 +113,7 @@ out: type: "sound" src: "custom.mp3" loop: true - volume: 300 + volume: 30 delay: 500 --- case: multiple sfx items @@ -137,7 +137,7 @@ in: sounds: firstSound: fileId: "first.mp3" - volume: 600 + volume: 60 secondSound: fileId: "second.mp3" out: @@ -153,13 +153,13 @@ out: type: "sound" src: "first.mp3" loop: false - volume: 600 + volume: 60 delay: null - id: "sfx2" type: "sound" src: "second.mp3" loop: false - volume: 500 + volume: 50 delay: null --- case: no presentationState.sfx - return unchanged state @@ -178,7 +178,7 @@ in: soundEffect: fileId: "effect.mp3" loop: true - volume: 700 + volume: 70 out: elements: - id: "story" @@ -207,7 +207,7 @@ in: soundEffect: fileId: "effect.mp3" loop: true - volume: 700 + volume: 70 out: elements: - id: "notStory" @@ -219,7 +219,7 @@ out: type: "sound" src: "effect.mp3" loop: true - volume: 700 + volume: 70 delay: null --- case: audio not found - skip item @@ -242,7 +242,7 @@ in: existing: fileId: "existing.mp3" loop: true - volume: 700 + volume: 70 out: elements: - id: "story" @@ -271,7 +271,7 @@ in: soundEffect: fileId: "effect.mp3" loop: true - volume: 700 + volume: 70 out: elements: - id: "story" diff --git a/spec/system/renderState/addVoice.spec.yaml b/spec/system/renderState/addVoice.spec.yaml index bfa95223..2077bf60 100644 --- a/spec/system/renderState/addVoice.spec.yaml +++ b/spec/system/renderState/addVoice.spec.yaml @@ -18,7 +18,7 @@ in: - presentationState: voice: fileId: "voice.mp3" - volume: 800 + volume: 80 loop: false resources: {} out: @@ -33,7 +33,7 @@ out: - id: "voice-voice.mp3" type: "sound" src: "voice.mp3" - volume: 800 + volume: 80 loop: false --- case: add voice with default values @@ -62,7 +62,7 @@ out: - id: "voice-simpleVoice.mp3" type: "sound" src: "simpleVoice.mp3" - volume: 500 + volume: 50 loop: false --- case: add voice with loop enabled @@ -78,7 +78,7 @@ in: - presentationState: voice: fileId: "loopingVoice.mp3" - volume: 600 + volume: 60 loop: true resources: {} out: @@ -93,7 +93,7 @@ out: - id: "voice-loopingVoice.mp3" type: "sound" src: "loopingVoice.mp3" - volume: 600 + volume: 60 loop: true --- case: no presentationState.voice - return unchanged state @@ -129,7 +129,7 @@ in: - presentationState: voice: fileId: "voice.mp3" - volume: 700 + volume: 70 loop: false resources: {} out: @@ -142,7 +142,7 @@ out: - id: "voice-voice.mp3" type: "sound" src: "voice.mp3" - volume: 700 + volume: 70 loop: false --- case: null presentationState - return unchanged state @@ -180,7 +180,7 @@ in: - presentationState: voice: fileId: "customVoice.mp3" - volume: 300 + volume: 30 loop: true resources: {} out: @@ -195,7 +195,7 @@ out: - id: "voice-customVoice.mp3" type: "sound" src: "customVoice.mp3" - volume: 300 + volume: 30 loop: true --- case: null resources - still works (voice doesn't use resources) @@ -211,7 +211,7 @@ in: - presentationState: voice: fileId: "voice.mp3" - volume: 700 + volume: 70 loop: false resources: null out: @@ -226,5 +226,5 @@ out: - id: "voice-voice.mp3" type: "sound" src: "voice.mp3" - volume: 700 - loop: false \ No newline at end of file + volume: 70 + loop: false diff --git a/spec/system/selectors/selectRenderState.spec.yaml b/spec/system/selectors/selectRenderState.spec.yaml index 0c1a428f..d62db535 100644 --- a/spec/system/selectors/selectRenderState.spec.yaml +++ b/spec/system/selectors/selectRenderState.spec.yaml @@ -99,7 +99,7 @@ out: type: "sound" src: "audio/cde.mp3" loop: true - volume: 500 + volume: 50 delay: null global: {} --- @@ -153,6 +153,6 @@ out: type: "sound" src: "audio/cde.mp3" loop: true - volume: 500 + volume: 50 delay: null global: {} diff --git a/src/runtimeFields.js b/src/runtimeFields.js index 771b2c0b..3156c07c 100644 --- a/src/runtimeFields.js +++ b/src/runtimeFields.js @@ -48,8 +48,8 @@ export const GLOBAL_RUNTIME_DEFAULTS = Object.freeze({ autoForwardDelay: 1000, skipUnseenText: false, skipTransitionsAndAnimations: false, - soundVolume: 500, - musicVolume: 500, + soundVolume: 50, + musicVolume: 50, muteAll: false, autoMode: false, skipMode: false, diff --git a/src/schemas/presentationActions.yaml b/src/schemas/presentationActions.yaml index 68d6b784..f0c014c0 100644 --- a/src/schemas/presentationActions.yaml +++ b/src/schemas/presentationActions.yaml @@ -210,7 +210,7 @@ properties: description: Whether the sound effect loops volume: type: number - description: Sound effect volume from 0 to 1000 + description: Sound effect volume from 0 to 100 delay: type: number description: Delay before the sound effect starts in milliseconds diff --git a/src/schemas/systemActions.yaml b/src/schemas/systemActions.yaml index 36062bf9..a9d7d36c 100644 --- a/src/schemas/systemActions.yaml +++ b/src/schemas/systemActions.yaml @@ -156,6 +156,8 @@ properties: properties: value: type: number + minimum: 0 + maximum: 100 required: [value] additionalProperties: false @@ -165,6 +167,8 @@ properties: properties: value: type: number + minimum: 0 + maximum: 100 required: [value] additionalProperties: false diff --git a/src/schemas/systemState/systemState.yaml b/src/schemas/systemState/systemState.yaml index 811ac61b..40686469 100644 --- a/src/schemas/systemState/systemState.yaml +++ b/src/schemas/systemState/systemState.yaml @@ -241,8 +241,12 @@ properties: type: boolean soundVolume: type: number + minimum: 0 + maximum: 100 musicVolume: type: number + minimum: 0 + maximum: 100 muteAll: type: boolean confirmDialog: diff --git a/src/stores/constructRenderState.js b/src/stores/constructRenderState.js index 59c5ed30..ba21310f 100644 --- a/src/stores/constructRenderState.js +++ b/src/stores/constructRenderState.js @@ -958,11 +958,11 @@ const getStoryContainer = (elements = []) => { }; const getEffectiveSoundVolume = (runtime = {}) => { - return runtime?.muteAll ? 0 : (runtime?.soundVolume ?? 500); + return runtime?.muteAll ? 0 : (runtime?.soundVolume ?? 50); }; const getEffectiveMusicVolume = (runtime = {}) => { - return runtime?.muteAll ? 0 : (runtime?.musicVolume ?? 500); + return runtime?.muteAll ? 0 : (runtime?.musicVolume ?? 50); }; const createLayoutTemplateData = ({ @@ -987,8 +987,8 @@ const createLayoutTemplateData = ({ skipUnseenText: runtime?.skipUnseenText ?? false, skipTransitionsAndAnimations: runtime?.skipTransitionsAndAnimations ?? false, - soundVolume: runtime?.soundVolume ?? 500, - musicVolume: runtime?.musicVolume ?? 500, + soundVolume: runtime?.soundVolume ?? 50, + musicVolume: runtime?.musicVolume ?? 50, muteAll: runtime?.muteAll ?? false, saveLoadPagination: runtime?.saveLoadPagination ?? 1, menuPage: runtime?.menuPage ?? "", @@ -1453,7 +1453,7 @@ export const addBackgroundOrCg = ( if (isVideo) { element.loop = presentationState.background.loop ?? false; - element.volume = background.volume ?? 500; + element.volume = background.volume ?? 50; } storyContainer.children.push(element); @@ -1779,7 +1779,7 @@ export const addVisuals = ( if (isVideo) { element.loop = resource.loop ?? false; - element.volume = resource.volume ?? 500; + element.volume = resource.volume ?? 50; } storyContainer.children.push(element); @@ -2247,7 +2247,7 @@ export const addSfx = (state, { presentationState, resources }) => { type: "sound", src: audioResource.fileId, loop: item.loop ?? audioResource.loop ?? false, - volume: item.volume ?? audioResource.volume ?? 500, + volume: item.volume ?? audioResource.volume ?? 50, delay: item.delay ?? audioResource.delay ?? null, }); } @@ -2269,7 +2269,7 @@ export const addVoice = (state, { presentationState, resources }) => { id: `voice-${fileId}`, type: "sound", src: fileId, - volume: volume ?? 500, + volume: volume ?? 50, loop: loop ?? false, }); diff --git a/vt/specs/complete/one.yaml b/vt/specs/complete/one.yaml index f26faddd..56b2ba8a 100644 --- a/vt/specs/complete/one.yaml +++ b/vt/specs/complete/one.yaml @@ -1473,7 +1473,7 @@ story: characterId: ajf34a voice: fileId: 39csl - volume: 0.5 + volume: 50 - id: line4 actions: dialogue: diff --git a/vt/specs/sfx/sound-volume.yaml b/vt/specs/sfx/sound-volume.yaml index 7aaeaf1c..4f5371f0 100644 --- a/vt/specs/sfx/sound-volume.yaml +++ b/vt/specs/sfx/sound-volume.yaml @@ -16,41 +16,41 @@ resources: anchorX: 0.5 content: "Sound Volume: ${runtime.soundVolume}" textStyleId: textStyle1 - - id: vol-250 + - id: vol-25 type: text x: 400 y: 300 - content: "250" + content: "25" click: soundSrc: xj323 - soundVolume: 250 + soundVolume: 25 textStyleId: textStyle2 - - id: vol-500 + - id: vol-50 type: text x: 700 y: 300 - content: "500" + content: "50" click: soundSrc: xj323 - soundVolume: 500 + soundVolume: 50 textStyleId: textStyle2 - - id: vol-750 + - id: vol-75 type: text x: 1000 y: 300 - content: "750" + content: "75" click: soundSrc: xj323 - soundVolume: 750 + soundVolume: 75 textStyleId: textStyle2 - - id: vol-1000 + - id: vol-100 type: text x: 1300 y: 300 - content: "1000" + content: "100" click: soundSrc: xj323 - soundVolume: 1000 + soundVolume: 100 textStyleId: textStyle2 - id: play-dynamic type: text