Added support for replay on click

This commit is contained in:
p11 2025-04-27 18:08:51 +02:00
parent 060e9d2969
commit 6ade74df7e

View File

@ -68,7 +68,7 @@ fn render_dialog_block(block: &DialogBlock<Parameter>) -> Markup {
convert(block.lines.iter().map(|l| l.text.as_ref()), &mut content); convert(block.lines.iter().map(|l| l.text.as_ref()), &mut content);
html! { html! {
fieldset .visual-novel-box { fieldset .visual-novel-box onclick="playCurrentAudio()" {
@if !block.name.is_empty() { @if !block.name.is_empty() {
legend .character-name { (block.name) } legend .character-name { (block.name) }
} }
@ -359,9 +359,9 @@ fn interactive_script(total_sections: usize, base_path: &str) -> Markup {
let currentAudio = null; let currentAudio = null;
function playSectionAudio(index) {{ function playCurrentAudio() {{
const section = document.querySelector( const section = document.querySelector(
`.selection-section[data-section-index="${{index}}"]` `.selection-section[data-section-index="${{currentScene}}"]`
); );
const audioElement = section?.querySelector('audio'); const audioElement = section?.querySelector('audio');
@ -379,10 +379,10 @@ fn interactive_script(total_sections: usize, base_path: &str) -> Markup {
}}); }});
toggleText(true); toggleText(true);
document.getElementById('section-counter').textContent = document.getElementById('section-counter').textContent =
`${{currentScene + 1}}/${{totalSections}}`; `${{currentScene + 1}}/${{totalSections}}`;
if (currentScene + 1 < totalSections) playSectionAudio(currentScene); if (currentScene + 1 < totalSections) playCurrentAudio();
}} }}
function prev() {{ function prev() {{