mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-22 11:48:18 +00:00
- Created SoundManager class for handling audio playback using Phaser's sound system. - Added methods for preloading, initializing, and playing sounds with volume control. - Integrated UI sound helpers for easier sound attachment to DOM elements. - Updated game.js to initialize sound manager and preload sounds. - Modified interactions.js, unlock-system.js, and panels.js to play appropriate sounds on interactions. - Created SOUND_SYSTEM_QUICK_REFERENCE.md for documentation on sound system usage. - Optimized NPCBarkSystem and NPCManager with caching and event listener cleanup.
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
// UI Panels System
|
|
// Handles generic panel utilities - specific panel functionality is handled by individual systems
|
|
import { playUISound } from '../systems/ui-sounds.js?v=1';
|
|
|
|
// Initialize UI panels (generic setup only)
|
|
export function initializeUI() {
|
|
console.log('UI panels system initialized');
|
|
|
|
// Note: Individual systems (notes.js, biometrics.js) handle their own panel setup
|
|
// This file only provides utility functions for generic panel operations
|
|
}
|
|
|
|
// Generic panel utility functions
|
|
export function togglePanel(panel) {
|
|
if (!panel) {
|
|
console.warn('togglePanel: panel is null or undefined');
|
|
return;
|
|
}
|
|
|
|
console.log('Toggling panel:', panel.id);
|
|
const isVisible = panel.style.display === 'block';
|
|
panel.style.display = isVisible ? 'none' : 'block';
|
|
|
|
// Play sound
|
|
if (!isVisible) {
|
|
playUISound('notification');
|
|
}
|
|
|
|
// Add animation class for smooth transitions
|
|
if (!isVisible) {
|
|
panel.classList.add('panel-show');
|
|
setTimeout(() => panel.classList.remove('panel-show'), 300);
|
|
}
|
|
}
|
|
|
|
export function showPanel(panel) {
|
|
if (!panel) return;
|
|
console.log('Showing panel:', panel.id);
|
|
playUISound('notification');
|
|
panel.style.display = 'block';
|
|
panel.classList.add('panel-show');
|
|
setTimeout(() => panel.classList.remove('panel-show'), 300);
|
|
}
|
|
|
|
export function hidePanel(panel) {
|
|
if (!panel) return;
|
|
console.log('Hiding panel:', panel.id);
|
|
panel.style.display = 'none';
|
|
}
|
|
|
|
export function hidePanelById(panelId) {
|
|
const panel = document.getElementById(panelId);
|
|
if (panel) {
|
|
hidePanel(panel);
|
|
}
|
|
}
|
|
|
|
// Export for global access (utility functions only)
|
|
window.togglePanel = togglePanel;
|
|
window.showPanel = showPanel;
|
|
window.hidePanel = hidePanel;
|
|
window.hidePanelById = hidePanelById;
|