Dialogue Writing Assistant

Dialogue Writing Assistant

Craft compelling conversations by setting the stage for your characters.

Scene Setup

The Stage is Quiet

Set the scene to get your characters talking.

${data.scene_summary || 'N/A'}

`; case 'analysis': return `

${data.character_analysis || 'N/A'}

`; default: return '

No content available.

'; } } function showTab(index) { const tabs = tabsContainer.querySelectorAll('.tab'); const contents = tabContentsContainer.querySelectorAll('.tab-content'); tabs.forEach(tab => tab.classList.remove('active')); contents.forEach(content => content.classList.remove('active')); if(tabs[index]) tabs[index].classList.add('active'); if(contents[index]) contents[index].classList.add('active'); currentTabIndex = index; updateNavButtons(); } function navigateTabs(direction) { const tabs = tabsContainer.querySelectorAll('.tab'); const newIndex = currentTabIndex + direction; if (newIndex >= 0 && newIndex < tabs.length) showTab(newIndex); } function updateNavButtons() { const tabs = tabsContainer.querySelectorAll('.tab'); prevTabBtn.disabled = currentTabIndex === 0; nextTabBtn.disabled = currentTabIndex === tabs.length - 1; } function generatePdf() { if (!window.jspdf || !latestGeneratedData) { alert("Please generate dialogue before downloading."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'letter' }); const pageHeight = doc.internal.pageSize.getHeight(); const pageWidth = doc.internal.pageSize.getWidth(); const leftMargin = 72; // 1 inch const rightMargin = pageWidth - 72; const topMargin = 72; const bottomMargin = pageHeight - 72; const charMargin = pageWidth * 0.4; const dialogueLeftMargin = pageWidth * 0.25; const dialogueRightMargin = pageWidth * 0.75; let cursorY = topMargin; doc.addFont('courier', 'normal', 'normal'); doc.addFont('courier', 'bold', 'bold'); doc.setFont('courier', 'normal'); doc.setFontSize(12); const checkPageBreak = (neededHeight) => { if (cursorY + neededHeight > bottomMargin) { doc.addPage(); cursorY = topMargin; } }; // Scene Heading doc.setFont('courier', 'bold'); checkPageBreak(14); doc.text((latestGeneratedData.scene_heading || "INT. LOCATION - DAY").toUpperCase(), leftMargin, cursorY); cursorY += 28; // Double space after heading doc.setFont('courier', 'normal'); latestGeneratedData.dialogue_lines.forEach(line => { // Character Name checkPageBreak(28); // Name + one line of dialogue doc.setFont('courier', 'normal'); doc.text(line.character.toUpperCase(), charMargin, cursorY); cursorY += 14; // Dialogue const dialogueLines = doc.splitTextToSize(line.dialogue, dialogueRightMargin - dialogueLeftMargin); checkPageBreak(dialogueLines.length * 14 + 14); // text + space after doc.text(dialogueLines, dialogueLeftMargin, cursorY); cursorY += (dialogueLines.length * 14) + 14; }); doc.save(`dialogue_scene.pdf`); } setUIState('placeholder'); });
Scroll to Top