Message
Message
function ImportTheGameClicked() {
ScriptEditorClicked();
SceneEditorClicked();
dialog.showOpenDialog({
filters: [
{ name: 'LFE or ZIP Files', extensions: ['LFE', 'zip'] }
],
properties: ['openFile']
}).then(result => {
if (!result.canceled && result.filePaths.length > 0) {
const filePath = result.filePaths[0];
console.log('Selected file in Electron:', filePath);
initializeEditor(); // Ensure CodeMirror is initialized
processLFEFile(filePath);
} else {
console.log('No file selected or cancelled in Electron.');
}
}).catch(err => {
console.error('Error opening file in Electron:', err);
});
} else {
// Running in a web browser
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.accept = '.LFE, .zip';
fileInput.addEventListener('change', function(event) {
const file = event.target.files[0];
if (file && (file.name.endsWith('.LFE') || file.name.endsWith('.zip')))
{
initializeEditor(); // Ensure CodeMirror is initialized
const reader = new FileReader();
reader.onload = function(e) {
const fileContent = e.target.result;
processLFEFileContent(fileContent); // Call the function here
};
reader.readAsArrayBuffer(file); // Read as ArrayBuffer for ZIP
extraction
} else {
alert('Please select a .LFE or a .zip file.');
}
});
fileInput.click();
}
}
canvas.appendChild(img);
objectPanel.appendChild(box);
} else {
console.error('Invalid image data in JSON.');
}
}
} else {
console.error('Object panel element not found.');
}
}