Revert "LPE Loading Improvements"

This reverts commit 94add8f3f7.
This commit is contained in:
unsettledgames 2021-07-20 21:58:00 +02:00
parent 94add8f3f7
commit 3b8dbb5151

View File

@ -67,7 +67,7 @@ const Startup = (() => {
if (fileContent != null) { if (fileContent != null) {
loadFromLPE(fileContent); loadFromLPE(fileContent);
// Deleting the default layer // Deleting the default layer
//deleteLayer(false); deleteLayer(false);
} }
} }
@ -80,54 +80,69 @@ const Startup = (() => {
// Creating the first layer // Creating the first layer
currentLayer = new Layer(width, height, canvas, layerListEntry); currentLayer = new Layer(width, height, canvas, layerListEntry);
currentLayer.canvas.style.zIndex = 2; currentLayer.canvas.style.zIndex = 2;
// Adding the checkerboard behind it
checkerBoard = new Layer(width, height, checkerBoardCanvas);
VFXLayer = new Layer(width, height, VFXCanvas);
TMPLayer = new Layer(width, height, TMPCanvas);
pixelGrid = new Layer(width, height, pixelGridCanvas);
// Setting the general canvasSize
canvasSize = currentLayer.canvasSize;
// Cloning the entry so that when I change something on the first layer, those changes aren't propagated to the other ones
layerListEntry = layerListEntry.cloneNode(true);
// Adding the first layer and the checkerboard to the list of layers
layers.push(checkerBoard);
layers.push(currentLayer);
layers.push(VFXLayer);
layers.push(TMPLayer);
layers.push(pixelGrid);
} }
else { else {
// Deleting all the extra layers and canvases, leaving only one, (nAppLayers=3) // Deleting all the extra layers and canvases, leaving only one
const nLayers = layers.length; let nLayers = layers.length;
for (let i=2; i < nLayers - nAppLayers; i++) { for (let i=2; i < layers.length - nAppLayers; i++) {
const currentEntry = layers[i].menuEntry; let currentEntry = layers[i].menuEntry;
let associatedLayer; let associatedLayer;
if (currentEntry != null) { if (currentEntry != null) {
// Getting the associated layer // Getting the associated layer
associatedLayer = getLayerByID(currentEntry.id); associatedLayer = getLayerByID(currentEntry.id);
// Deleting its canvas // Deleting its canvas
associatedLayer.canvas.remove(); associatedLayer.canvas.remove();
// Adding the id to the unused ones // Adding the id to the unused ones
unusedIDs.push(currentEntry.id); unusedIDs.push(currentEntry.id);
// Removing the entry from the menu // Removing the entry from the menu
currentEntry.remove(); currentEntry.remove();
} }
} }
// Removing the old layers from the list
for (let i=2; i<nLayers - nAppLayers; i++) {
layers.splice(2, 1);
}
// Setting up the current layer // Setting up the current layer
layers[1] = new Layer(width, height, canvas, layerListEntry); layers[1] = new Layer(width, height, layers[1].canvas, layers[1].menuEntry);
currentLayer = layers[1]; currentLayer = layers[1];
currentLayer.canvas.style.zIndex = 9; currentLayer.canvas.style.zIndex = 2;
// Updating canvas size to the new size // Updating canvas size to the new size
for (let i=0; i<nLayers; i++) { for (let i=0; i<nLayers; i++) {
layers[i].canvasSize = [width, height]; layers[i].canvasSize = [width, height];
} }
} }
// Adding the checkerboard behind it
checkerBoard = new Layer(width, height, checkerBoardCanvas);
// Creating the vfx layer on top of everything
VFXLayer = new Layer(width, height, VFXCanvas);
// Tmp layer to draw previews on
TMPLayer = new Layer(width, height, TMPCanvas);
// Pixel grid
pixelGrid = new Layer(width, height, pixelGridCanvas);
// Setting the general canvasSize
canvasSize = currentLayer.canvasSize;
if (firstPixel) {
// Cloning the entry so that when I change something on the first layer, those changes aren't
// propagated to the other ones
layerListEntry = layerListEntry.cloneNode(true);
// Adding the first layer and the checkerboard to the list of layers
layers.push(checkerBoard);
layers.push(currentLayer);
layers.push(VFXLayer);
layers.push(TMPLayer);
layers.push(pixelGrid);
}
} }
function initPalette() { function initPalette() {