From 45a58ef7450c688a8615e0662409b15b85ad168a Mon Sep 17 00:00:00 2001 From: Cailean Date: Tue, 22 Jul 2025 16:58:59 +0100 Subject: [PATCH] Pause function added --- src/ofTeleprompter.cpp | 30 +++++++++++++++++++++++++++--- src/ofTeleprompter.h | 3 +++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/ofTeleprompter.cpp b/src/ofTeleprompter.cpp index 6f82438..b5530af 100644 --- a/src/ofTeleprompter.cpp +++ b/src/ofTeleprompter.cpp @@ -104,6 +104,7 @@ void ofTeleprompter::setupGUI() { gui.add(useLLMOnly.setup("Use LLM Only", false)); gui.add(useTextOnly.setup("Use Text Only", false)); gui.add(useContempTextOnly.setup("Use Contept Text Only", false)); + gui.add(usePauseFunction.setup("Toggle Pause (Fn)", true)); gui.add(useGeneratedFeedback.setup("Use LLM Feedback", false)); gui.add(nextLine.setup("Next Line")); gui.add(reset.setup("Reset Script")); @@ -287,10 +288,33 @@ void ofTeleprompter::toggleOffText(bool & val) { } void ofTeleprompter::toggleContempScript(bool & val) { - if (val) { - activeScript = &scriptContemporary; + + // Only save/restore line if pauseOnSwitch is enabled + if (usePauseFunction) { + if (activeScript == &script) { + currentLineScript = currentLine; + } else { + currentLineContemporary = currentLine; + } + + if (val) { + activeScript = &scriptContemporary; + currentLine = currentLineContemporary; + } else { + activeScript = &script; + currentLine = currentLineScript; + } } else { - activeScript = &script; + // Always start from line 0 if not pausing + if (val) { + activeScript = &scriptContemporary; + } else { + activeScript = &script; + } + // Set both script line trackers to the same value + currentLine = 0; + currentLineScript = currentLine; + currentLineContemporary = currentLine; } ofLog() << "Script Size:" + (*activeScript).size(); diff --git a/src/ofTeleprompter.h b/src/ofTeleprompter.h index abd0126..9d2a5c7 100644 --- a/src/ofTeleprompter.h +++ b/src/ofTeleprompter.h @@ -41,6 +41,7 @@ class ofTeleprompter: public ofBaseApp{ ofxToggle useTextOnly; ofxToggle useContempTextOnly; ofxToggle useGeneratedFeedback; + ofxToggle usePauseFunction; ofxButton reset; ofxLabel currentLineIndex; @@ -63,6 +64,8 @@ class ofTeleprompter: public ofBaseApp{ /* scrolling text */ int currentLetterIndex = 0; + int currentLineScript = 0; + int currentLineContemporary = 0; std::string currentSentence; uint64_t lastWordTime = 0; uint64_t wordDelay = 20;