Deep codebase cleanup and optimization
- Removed obsolete emergency image-discovery-fix.js file - Cleaned excessive debug console.log statements throughout codebase - Removed Visual Studio .vs/ directory and added to .gitignore - Removed duplicate programmatic mirror task addition from gameData.js - Optimized debug logging in VideoLibrary and QuadVideoPlayer - Removed redundant old image scanning methods (fallback, pattern-based discovery) - Streamlined PopupImageManager getLinkedImages method - Updated .gitignore to prevent future IDE file commits Codebase is now cleaner with minimal debugging noise and no duplicate/obsolete code.
This commit is contained in:
parent
8a25b51168
commit
6509ae5868
|
|
@ -10,6 +10,7 @@ desktop.ini
|
|||
# IDE files
|
||||
.vscode/
|
||||
.idea/
|
||||
.vs/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"ExpandedNodes": [
|
||||
""
|
||||
],
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
||||
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\drew\\webGame\\",
|
||||
"Documents": [],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\drew\\webGame\\",
|
||||
"Documents": [],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": -1,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{56df62a4-05a3-4e5b-aa1a-99371ccfb997}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1696,71 +1696,6 @@ class TaskChallengeGame {
|
|||
return validImages;
|
||||
}
|
||||
|
||||
async fallbackImageDiscovery() {
|
||||
// Fallback to simplified pattern detection if manifest fails
|
||||
console.log('Using fallback pattern detection...');
|
||||
|
||||
const commonPatterns = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'];
|
||||
|
||||
gameData.discoveredTaskImages = await this.findImagesWithPatterns('images/tasks/', commonPatterns);
|
||||
gameData.discoveredConsequenceImages = await this.findImagesWithPatterns('images/consequences/', commonPatterns);
|
||||
|
||||
// If still no images found, show helpful message but don't use placeholders
|
||||
if (gameData.discoveredTaskImages.length === 0 && gameData.discoveredConsequenceImages.length === 0) {
|
||||
console.log('No images found. Users will need to upload or scan for images.');
|
||||
gameData.discoveredTaskImages = [];
|
||||
gameData.discoveredConsequenceImages = [];
|
||||
}
|
||||
}
|
||||
|
||||
async findImagesWithPatterns(directory, patterns) {
|
||||
const foundImages = [];
|
||||
|
||||
for (const pattern of patterns) {
|
||||
for (const format of gameData.supportedImageFormats) {
|
||||
const imagePath = `${directory}${pattern}${format}`;
|
||||
const exists = await this.checkImageExists(imagePath);
|
||||
if (exists) {
|
||||
foundImages.push(imagePath);
|
||||
console.log('✓ Found image:', imagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return foundImages;
|
||||
}
|
||||
|
||||
setupPlaceholderImages() {
|
||||
gameData.discoveredTaskImages = [this.createPlaceholderImage('Task Image')];
|
||||
gameData.discoveredConsequenceImages = [this.createPlaceholderImage('Consequence Image')];
|
||||
}
|
||||
|
||||
checkImageExists(imagePath) {
|
||||
return new Promise((resolve) => {
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
console.log(`✓ Found image: ${imagePath}`);
|
||||
resolve(true);
|
||||
};
|
||||
img.onerror = () => {
|
||||
console.log(`✗ Missing image: ${imagePath}`);
|
||||
resolve(false);
|
||||
};
|
||||
img.src = imagePath;
|
||||
|
||||
// Timeout after 1 second (faster discovery)
|
||||
setTimeout(() => {
|
||||
console.log(`⏰ Timeout for image: ${imagePath}`);
|
||||
resolve(false);
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
createPlaceholderImage(label = 'Task Image') {
|
||||
const encodedLabel = encodeURIComponent(label);
|
||||
return `data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjBmMGYwIiBzdHJva2U9IiNjY2MiIHN0cm9rZS13aWR0aD0iMiIvPjx0ZXh0IHg9IjUwJSIgeT0iNDAlIiBmb250LXNpemU9IjE2IiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBkeT0iLjNlbSIgZmlsbD0iIzY2NiI+JHtsYWJlbH08L3RleHQ+PHRleHQgeD0iNTAlIiB5PSI2MCUiIGZvbnQtc2l6ZT0iMTIiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGR5PSIuM2VtIiBmaWxsPSIjOTk5Ij5BZGQgaW1hZ2VzIHRvIGZvbGRlcjwvdGV4dD48L3N2Zz4=`;
|
||||
}
|
||||
|
||||
// Audio Discovery Functions
|
||||
async discoverAudio() {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -327,20 +327,3 @@ const gameData = {
|
|||
|
||||
// Make gameData available globally
|
||||
window.gameData = gameData;
|
||||
|
||||
// Add mirror task programmatically to avoid any parsing issues
|
||||
console.log('🔧 Adding mirror task programmatically...');
|
||||
console.log('🔍 gameData.mainTasks before:', gameData.mainTasks.length);
|
||||
|
||||
gameData.mainTasks.push({
|
||||
id: 'mirror-humiliation-task',
|
||||
text: "Webcam Mirror Self-Humiliation",
|
||||
difficulty: "Medium",
|
||||
interactiveType: "mirror-task",
|
||||
story: "Look at yourself through your webcam and repeat degrading phrases: 'I am a pathetic toy', 'I exist for others' pleasure', 'I have no dignity'. Say each phrase 5 times while looking at yourself on camera.",
|
||||
mirrorInstructions: "Look directly at yourself through the webcam while speaking the degrading phrases",
|
||||
mirrorTaskText: "Repeat each phrase 5 times while maintaining eye contact with yourself: 'I am a pathetic toy', 'I exist for others' pleasure', 'I have no dignity'"
|
||||
});
|
||||
|
||||
console.log('🔍 gameData.mainTasks after:', gameData.mainTasks.length);
|
||||
console.log('✅ Mirror task added successfully');
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
// Image Discovery Fix - Force Override Version
|
||||
// This is a complete fix that forcefully overrides the broken discoverImages method
|
||||
|
||||
// Emergency fix to override broken methods
|
||||
function forceFixGame() {
|
||||
console.log('<27> Applying emergency game fix...');
|
||||
|
||||
// Override the broken discoverImages completely
|
||||
if (window.game) {
|
||||
// Force mark image discovery as complete
|
||||
window.game.imageDiscoveryComplete = true;
|
||||
|
||||
// Set basic image arrays
|
||||
if (!gameData.discoveredTaskImages) gameData.discoveredTaskImages = [];
|
||||
if (!gameData.discoveredConsequenceImages) gameData.discoveredConsequenceImages = [];
|
||||
|
||||
// Try to get images from desktop file manager if available
|
||||
if (window.game.dataManager) {
|
||||
const customImages = window.game.dataManager.get('customImages') || { task: [], consequence: [] };
|
||||
let taskImages = [];
|
||||
let consequenceImages = [];
|
||||
|
||||
if (Array.isArray(customImages)) {
|
||||
taskImages = customImages;
|
||||
} else {
|
||||
taskImages = customImages.task || [];
|
||||
consequenceImages = customImages.consequence || [];
|
||||
}
|
||||
|
||||
if (taskImages.length > 0 || consequenceImages.length > 0) {
|
||||
gameData.discoveredTaskImages = taskImages.map(img => typeof img === 'string' ? img : img.name);
|
||||
gameData.discoveredConsequenceImages = consequenceImages.map(img => typeof img === 'string' ? img : img.name);
|
||||
console.log(`<EFBFBD> Emergency fix - Found ${gameData.discoveredTaskImages.length} task images, ${gameData.discoveredConsequenceImages.length} consequence images`);
|
||||
}
|
||||
}
|
||||
|
||||
// Override the broken discoverImages method
|
||||
window.game.discoverImages = async function() {
|
||||
console.log('<27> Using emergency fixed discoverImages method');
|
||||
this.imageDiscoveryComplete = true;
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
console.log('✅ Emergency fix applied successfully');
|
||||
}
|
||||
}
|
||||
|
||||
// Apply fix immediately if game exists
|
||||
if (typeof window !== 'undefined') {
|
||||
// Try to apply fix multiple times until it works
|
||||
const tryFix = () => {
|
||||
if (window.game) {
|
||||
forceFixGame();
|
||||
} else {
|
||||
setTimeout(tryFix, 100);
|
||||
}
|
||||
};
|
||||
|
||||
// Start trying to fix
|
||||
setTimeout(tryFix, 500);
|
||||
|
||||
// Also expose for manual use
|
||||
window.forceFixGame = forceFixGame;
|
||||
}
|
||||
|
|
@ -178,8 +178,6 @@ class PopupImageManager {
|
|||
linkedIndividualImages = [];
|
||||
}
|
||||
|
||||
console.log(`📸 PopupImageManager found ${linkedDirs.length} linked directories and ${linkedIndividualImages.length} individual images`);
|
||||
|
||||
// Load images from linked directories using Electron API
|
||||
if (window.electronAPI && linkedDirs.length > 0) {
|
||||
const imageExtensions = /\.(jpg|jpeg|png|gif|webp|bmp)$/i;
|
||||
|
|
@ -215,8 +213,6 @@ class PopupImageManager {
|
|||
});
|
||||
});
|
||||
|
||||
console.log(`📸 PopupImageManager loaded ${allImages.length} total images for popups`);
|
||||
|
||||
} catch (error) {
|
||||
console.error('📸 Error loading linked images:', error);
|
||||
}
|
||||
|
|
@ -263,9 +259,6 @@ class PopupImageManager {
|
|||
this.hidePeriodicPopup(popup);
|
||||
}, this.periodicSystem.displayDuration);
|
||||
|
||||
console.log(`🖼️ Showing periodic popup: ${imageName}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide periodic popup
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ class QuadVideoPlayer {
|
|||
* Initialize the quad video player system
|
||||
*/
|
||||
async initialize() {
|
||||
console.log('🎬 Initializing QuadVideoPlayer...');
|
||||
|
||||
// Get video library using the same pattern as OverlayVideoPlayer
|
||||
this.videoLibrary = this.getAvailableVideos();
|
||||
|
||||
|
|
@ -26,11 +24,9 @@ class QuadVideoPlayer {
|
|||
return false;
|
||||
}
|
||||
|
||||
console.log('📹 Found', this.videoLibrary.length, 'videos for quad player');
|
||||
this.createQuadContainer();
|
||||
await this.initializePlayers();
|
||||
|
||||
console.log('✅ QuadVideoPlayer initialized with', this.players.length, 'players');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -40,29 +36,23 @@ class QuadVideoPlayer {
|
|||
getAvailableVideos() {
|
||||
let allVideos = [];
|
||||
|
||||
console.log('📹 Checking video sources...');
|
||||
|
||||
// Try desktop file manager first
|
||||
if (window.desktopFileManager) {
|
||||
allVideos = window.desktopFileManager.getAllVideos();
|
||||
console.log('📹 Desktop file manager videos:', allVideos.length);
|
||||
}
|
||||
|
||||
// Fallback to unified storage
|
||||
if (allVideos.length === 0) {
|
||||
const unifiedData = JSON.parse(localStorage.getItem('unifiedVideoLibrary') || '{}');
|
||||
allVideos = unifiedData.allVideos || [];
|
||||
console.log('📹 Unified storage videos:', allVideos.length);
|
||||
}
|
||||
|
||||
// Fallback to legacy storage
|
||||
if (allVideos.length === 0) {
|
||||
const storedVideos = JSON.parse(localStorage.getItem('videoFiles') || '{}');
|
||||
allVideos = Object.values(storedVideos).flat();
|
||||
console.log('📹 Legacy storage videos:', allVideos.length);
|
||||
}
|
||||
|
||||
console.log('📹 Total videos found:', allVideos.length);
|
||||
return allVideos;
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +412,6 @@ class QuadVideoPlayer {
|
|||
return;
|
||||
}
|
||||
|
||||
console.log('🎬 Showing quad video overlay');
|
||||
this.container.style.display = 'flex';
|
||||
this.isActive = true;
|
||||
|
||||
|
|
@ -440,7 +429,6 @@ class QuadVideoPlayer {
|
|||
hide() {
|
||||
if (!this.container) return;
|
||||
|
||||
console.log('🎬 Hiding quad video overlay');
|
||||
this.container.style.display = 'none';
|
||||
this.isActive = false;
|
||||
this.isMinimized = false; // Reset minimized state when fully hiding
|
||||
|
|
@ -469,15 +457,11 @@ class QuadVideoPlayer {
|
|||
* Stop all videos (separate method for cleanup purposes)
|
||||
*/
|
||||
stopAllVideos() {
|
||||
console.log('🛑 Stopping all quad videos');
|
||||
this.players.forEach((player, index) => {
|
||||
// Use videoElement (BaseVideoPlayer property) instead of video
|
||||
if (player.videoElement) {
|
||||
player.videoElement.pause();
|
||||
player.videoElement.currentTime = 0; // Reset to beginning
|
||||
console.log(`🛑 Stopped video ${index + 1}: ${player.videoElement.src || 'Unknown'}`);
|
||||
} else {
|
||||
console.log(`⚠️ No videoElement found for player ${index + 1}`);
|
||||
}
|
||||
// Also hide the individual players
|
||||
if (player.overlayElement) {
|
||||
|
|
@ -493,7 +477,6 @@ class QuadVideoPlayer {
|
|||
minimize() {
|
||||
if (!this.container) return;
|
||||
|
||||
console.log('🎬 Minimizing quad video overlay');
|
||||
this.container.style.display = 'none';
|
||||
this.isMinimized = true;
|
||||
// Note: Keep isActive = true and videos continue playing
|
||||
|
|
@ -510,7 +493,6 @@ class QuadVideoPlayer {
|
|||
restore() {
|
||||
if (!this.container || !this.isMinimized) return;
|
||||
|
||||
console.log('🎬 Restoring quad video overlay from minimized');
|
||||
this.container.style.display = 'flex';
|
||||
this.isMinimized = false;
|
||||
this.isActive = true;
|
||||
|
|
@ -520,8 +502,6 @@ class QuadVideoPlayer {
|
|||
* Load new random videos in all slots
|
||||
*/
|
||||
shuffleAllVideos() {
|
||||
console.log('🔄 Shuffling all quad videos');
|
||||
|
||||
// Refresh video library in case new videos were added
|
||||
this.videoLibrary = this.getAvailableVideos();
|
||||
|
||||
|
|
@ -858,15 +838,11 @@ class QuadVideoPlayer {
|
|||
* Cleanup resources
|
||||
*/
|
||||
destroy() {
|
||||
console.log('🧹 Destroying QuadVideoPlayer...');
|
||||
|
||||
// Stop all videos first
|
||||
this.stopAllVideos();
|
||||
|
||||
// Destroy individual players
|
||||
this.players.forEach((player, index) => {
|
||||
console.log(`🧹 Destroying player ${index + 1}`);
|
||||
|
||||
// Remove event listeners and clean up player
|
||||
if (player.overlayElement) {
|
||||
// Remove from DOM
|
||||
|
|
@ -897,8 +873,6 @@ class QuadVideoPlayer {
|
|||
if (styles) {
|
||||
styles.remove();
|
||||
}
|
||||
|
||||
console.log('✅ QuadVideoPlayer destroyed');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,6 @@ class VideoLibrary {
|
|||
|
||||
async loadVideoLibrary() {
|
||||
try {
|
||||
console.log('📁 Loading video library for Porn Cinema...');
|
||||
|
||||
// Use the same video loading logic as the main library interface
|
||||
let linkedDirs;
|
||||
try {
|
||||
|
|
@ -103,8 +101,6 @@ class VideoLibrary {
|
|||
linkedIndividualVideos = [];
|
||||
}
|
||||
|
||||
console.log(`📁 Found ${linkedDirs.length} linked directories and ${linkedIndividualVideos.length} individual videos in localStorage`);
|
||||
|
||||
const allVideos = [];
|
||||
|
||||
// Load videos from linked directories using Electron API
|
||||
|
|
@ -113,24 +109,17 @@ class VideoLibrary {
|
|||
|
||||
for (const dir of linkedDirs) {
|
||||
try {
|
||||
console.log(`🎬 Scanning directory: ${dir.path}`);
|
||||
|
||||
// Use video-specific directory reading for better results
|
||||
let files = [];
|
||||
if (window.electronAPI.readVideoDirectory) {
|
||||
console.log(`🎬 Using readVideoDirectory for ${dir.path}`);
|
||||
files = await window.electronAPI.readVideoDirectory(dir.path);
|
||||
} else if (window.electronAPI.readVideoDirectoryRecursive) {
|
||||
console.log(`🎬 Using readVideoDirectoryRecursive for ${dir.path}`);
|
||||
files = await window.electronAPI.readVideoDirectoryRecursive(dir.path);
|
||||
} else if (window.electronAPI.readDirectory) {
|
||||
console.log(`🎬 Using generic readDirectory for ${dir.path}`);
|
||||
const allFiles = await window.electronAPI.readDirectory(dir.path);
|
||||
files = allFiles.filter(file => videoExtensions.test(file.name));
|
||||
}
|
||||
|
||||
console.log(`🎬 Found ${files ? files.length : 0} videos in ${dir.path}`);
|
||||
|
||||
if (files && files.length > 0) {
|
||||
files.forEach(file => {
|
||||
allVideos.push({
|
||||
|
|
@ -320,16 +309,11 @@ class VideoLibrary {
|
|||
}
|
||||
|
||||
displayLibrary() {
|
||||
console.log(`📁 Displaying library: ${this.filteredVideos.length} videos in ${this.currentView} view`);
|
||||
|
||||
if (this.filteredVideos.length === 0) {
|
||||
console.log(`📁 No videos to display (total videos: ${this.videos.length}, search: "${this.searchQuery}")`);
|
||||
this.displayEmptyLibrary('No videos match your search');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`📁 First few videos being displayed:`, this.filteredVideos.slice(0, 3).map(v => v.name));
|
||||
|
||||
const containerClass = this.currentView === 'grid' ? 'library-grid' : 'library-list';
|
||||
|
||||
this.libraryContent.innerHTML = `
|
||||
|
|
@ -338,22 +322,6 @@ class VideoLibrary {
|
|||
</div>
|
||||
`;
|
||||
|
||||
console.log(`📁 HTML generated for ${this.filteredVideos.length} videos`);
|
||||
|
||||
// Debug: Check if libraryContent element exists and verify HTML
|
||||
console.log(`📁 libraryContent element:`, this.libraryContent);
|
||||
console.log(`📁 libraryContent innerHTML length:`, this.libraryContent ? this.libraryContent.innerHTML.length : 'N/A');
|
||||
|
||||
if (this.libraryContent && this.filteredVideos.length > 0) {
|
||||
// Check if the HTML actually contains video cards
|
||||
const videoCards = this.libraryContent.querySelectorAll('.video-card, .video-list-item');
|
||||
console.log(`📁 Video cards found in DOM:`, videoCards.length);
|
||||
|
||||
if (videoCards.length === 0) {
|
||||
console.log(`📁 No video cards found! Checking generated HTML sample:`, this.libraryContent.innerHTML.substring(0, 500));
|
||||
}
|
||||
}
|
||||
|
||||
// Attach click events to video elements
|
||||
this.attachVideoEvents();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue