diff --git a/spec/system/constructPresentationState.spec.yaml b/spec/system/constructPresentationState.spec.yaml index 85cf15f..a3d3a03 100644 --- a/spec/system/constructPresentationState.spec.yaml +++ b/spec/system/constructPresentationState.spec.yaml @@ -384,3 +384,95 @@ out: characterId: "bob" content: - text: "Second ADV line" +--- +case: nvl-mode-maxLines-trims-oldest +in: + - - dialogue: + mode: "nvl" + gui: + resourceId: "nvl-layout" + characterId: "narrator" + content: + - text: "Line 1" + - dialogue: + mode: "nvl" + characterId: "alice" + content: + - text: "Line 2" + - dialogue: + mode: "nvl" + characterId: "bob" + content: + - text: "Line 3" + - dialogue: + mode: "nvl" + characterId: "narrator" + content: + - text: "Line 4" + - dialogue: + mode: "nvl" + maxLines: 4 + characterId: "alice" + content: + - text: "Line 5" +out: + dialogue: + mode: "nvl" + gui: + resourceId: "nvl-layout" + characterId: "alice" + content: + - text: "Line 5" + lines: + - content: + - text: "Line 2" + characterId: "alice" + - content: + - text: "Line 3" + characterId: "bob" + - content: + - text: "Line 4" + characterId: "narrator" + - content: + - text: "Line 5" + characterId: "alice" +--- +case: nvl-mode-maxLines-no-trim-under-limit +in: + - - dialogue: + mode: "nvl" + gui: + resourceId: "nvl-layout" + characterId: "narrator" + content: + - text: "Line 1" + - dialogue: + mode: "nvl" + maxLines: 4 + characterId: "alice" + content: + - text: "Line 2" + - dialogue: + mode: "nvl" + maxLines: 4 + characterId: "bob" + content: + - text: "Line 3" +out: + dialogue: + mode: "nvl" + gui: + resourceId: "nvl-layout" + characterId: "bob" + content: + - text: "Line 3" + lines: + - content: + - text: "Line 1" + characterId: "narrator" + - content: + - text: "Line 2" + characterId: "alice" + - content: + - text: "Line 3" + characterId: "bob" diff --git a/src/stores/constructPresentationState.js b/src/stores/constructPresentationState.js index 922ed63..86c616a 100644 --- a/src/stores/constructPresentationState.js +++ b/src/stores/constructPresentationState.js @@ -180,6 +180,16 @@ export const dialogue = (state, presentation) => { characterId: presentation.dialogue.characterId || null, }); } + + // Handle NVL maxLines trimming (scroll effect) + if ( + presentation.dialogue?.maxLines && + state.dialogue?.lines?.length > presentation.dialogue.maxLines + ) { + state.dialogue.lines = state.dialogue.lines.slice( + -presentation.dialogue.maxLines, + ); + } }; /** diff --git a/vt/specs/dialogue/nvl-mode.yaml b/vt/specs/dialogue/nvl-mode.yaml index 689952d..368fcab 100644 --- a/vt/specs/dialogue/nvl-mode.yaml +++ b/vt/specs/dialogue/nvl-mode.yaml @@ -170,8 +170,58 @@ story: content: - text: "Second line on the new page." - # Back to ADV + # maxLines scroll effect - id: "8" + actions: + dialogue: + mode: nvl + clearPage: true + content: + - text: "[maxLines test] Line 1 - This should scroll away." + + - id: "9" + actions: + dialogue: + mode: nvl + characterId: alice + content: + - text: "[maxLines test] Line 2 - This should scroll away." + + - id: "10" + actions: + dialogue: + mode: nvl + characterId: bob + content: + - text: "[maxLines test] Line 3 - Stays visible." + + - id: "11" + actions: + dialogue: + mode: nvl + content: + - text: "[maxLines test] Line 4 - Stays visible." + + - id: "12" + actions: + dialogue: + mode: nvl + maxLines: 4 + characterId: alice + content: + - text: "[maxLines test] Line 5 - Line 1 should be gone now." + + - id: "13" + actions: + dialogue: + mode: nvl + maxLines: 4 + characterId: bob + content: + - text: "[maxLines test] Line 6 - Lines 1-2 should be gone." + + # Back to ADV + - id: "14" actions: dialogue: mode: adv