Fixed exception. Added candleflicker.

This commit is contained in:
2025-04-04 19:33:14 +00:00
parent 49a5af252c
commit c27ba8be6b
3 changed files with 807 additions and 727 deletions
+32
View File
@@ -721,3 +721,35 @@ ol.choice {
vertical-align: middle; vertical-align: middle;
margin: 0 5px; margin: 0 5px;
} }
/* UI Effects */
.effects-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none; /* Allow clicks to pass through */
z-index: 998; /* Below lighting but above other elements */
}
.candle-effect {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.3;
pointer-events: none;
mix-blend-mode: screen;
background: radial-gradient(circle at center, rgba(255,230,150,0.2) 0%, rgba(0,0,0,0) 70%);
animation: candle-flicker 4s infinite alternate;
}
@keyframes candle-flicker {
0% { opacity: 0.2; transform: scale(1.02); }
25% { opacity: 0.3; }
50% { opacity: 0.25; transform: scale(0.98); }
75% { opacity: 0.3; }
100% { opacity: 0.35; transform: scale(1); }
}
+19 -1
View File
@@ -44,7 +44,8 @@ class TTSFactoryModule extends BaseModule {
'pause', 'pause',
'resume', 'resume',
'getVoices', 'getVoices',
'getPreference' 'getPreference',
'isSpeaking'
]); ]);
// Add dependencies // Add dependencies
@@ -369,6 +370,23 @@ class TTSFactoryModule extends BaseModule {
return defaultValue; return defaultValue;
} }
/**
* Check if any TTS handler is currently speaking
* @returns {boolean} - True if speaking, false otherwise
*/
isSpeaking() {
if (!this.activeHandler || !this.handlers[this.activeHandler]) {
return false;
}
try {
return this.handlers[this.activeHandler].isSpeaking();
} catch (error) {
console.error("Error checking speaking status:", error);
return false;
}
}
/** /**
* Clean up when module is disposed * Clean up when module is disposed
*/ */
+33 -3
View File
@@ -42,7 +42,8 @@ class UIEffects extends BaseModule {
'applyShakeEffect', 'applyShakeEffect',
'applyFlashEffect', 'applyFlashEffect',
'applyTextEmphasis', 'applyTextEmphasis',
'processCommand' 'processCommand',
'handleLightingAnimationEnd'
]); ]);
console.log('UIEffects: Constructor initialized'); console.log('UIEffects: Constructor initialized');
@@ -62,6 +63,9 @@ class UIEffects extends BaseModule {
// Set up ambient effect animations // Set up ambient effect animations
this.setupAmbientEffects(); this.setupAmbientEffects();
// Start ambient effects immediately after initialization
this.startAmbientEffects();
this.reportProgress(100, 'UI Effects ready'); this.reportProgress(100, 'UI Effects ready');
// Use the parent's dispatchEvent method // Use the parent's dispatchEvent method
@@ -124,6 +128,31 @@ class UIEffects extends BaseModule {
setupCandleFlickerEffect() { setupCandleFlickerEffect() {
// Store the animation frame ID for later cancellation // Store the animation frame ID for later cancellation
this.candleAnimationId = null; this.candleAnimationId = null;
// Add animation end event listener to create continuous random animations
if (this.lightingElement) {
this.lightingElement.addEventListener('animationend', this.handleLightingAnimationEnd.bind(this));
}
}
/**
* Handle the end of a lighting animation by setting a new random duration
* @param {AnimationEvent} event - The animation end event
*/
handleLightingAnimationEnd(event) {
if (!this.lightingElement || !this.ambientEffectsActive) return;
// Generate a random duration between 0.5 and 4 seconds
const randomDuration = Math.random() * 3.5 + 0.5;
// Toggle between grow and shrink animations
const previousAnimation = event.animationName;
if (previousAnimation === 'gradient-animation-grow') {
this.lightingElement.style.animation = `gradient-animation-shrink ${randomDuration}s 1`;
} else {
this.lightingElement.style.animation = `gradient-animation-grow ${randomDuration}s 1`;
}
} }
updateCandleEffect() { updateCandleEffect() {
@@ -153,9 +182,10 @@ class UIEffects extends BaseModule {
this.updateCandleEffect(); this.updateCandleEffect();
} }
// Apply lighting animation // Apply lighting animation with initial random duration
if (this.lightingElement) { if (this.lightingElement) {
this.lightingElement.style.animation = 'gradient-animation-shrink 2s infinite alternate'; const initialDuration = Math.random() * 3.5 + 0.5;
this.lightingElement.style.animation = `gradient-animation-shrink ${initialDuration}s 1`;
} }
} }