mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
LPE Loading Improvements
This commit is contained in:
parent
f5fc762c5c
commit
94add8f3f7
@ -67,7 +67,7 @@ const Startup = (() => {
|
||||
if (fileContent != null) {
|
||||
loadFromLPE(fileContent);
|
||||
// Deleting the default layer
|
||||
deleteLayer(false);
|
||||
//deleteLayer(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,62 +80,19 @@ const Startup = (() => {
|
||||
// Creating the first layer
|
||||
currentLayer = new Layer(width, height, canvas, layerListEntry);
|
||||
currentLayer.canvas.style.zIndex = 2;
|
||||
}
|
||||
else {
|
||||
// Deleting all the extra layers and canvases, leaving only one
|
||||
let nLayers = layers.length;
|
||||
for (let i=2; i < layers.length - nAppLayers; i++) {
|
||||
let currentEntry = layers[i].menuEntry;
|
||||
let associatedLayer;
|
||||
|
||||
if (currentEntry != null) {
|
||||
// Getting the associated layer
|
||||
associatedLayer = getLayerByID(currentEntry.id);
|
||||
// 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);
|
||||
|
||||
// Deleting its canvas
|
||||
associatedLayer.canvas.remove();
|
||||
// Setting the general canvasSize
|
||||
canvasSize = currentLayer.canvasSize;
|
||||
|
||||
// Adding the id to the unused ones
|
||||
unusedIDs.push(currentEntry.id);
|
||||
// Removing the entry from the menu
|
||||
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
|
||||
layers[1] = new Layer(width, height, layers[1].canvas, layers[1].menuEntry);
|
||||
currentLayer = layers[1];
|
||||
currentLayer.canvas.style.zIndex = 2;
|
||||
|
||||
// Updating canvas size to the new size
|
||||
for (let i=0; i<nLayers; i++) {
|
||||
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
|
||||
// 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);
|
||||
@ -143,6 +100,34 @@ const Startup = (() => {
|
||||
layers.push(TMPLayer);
|
||||
layers.push(pixelGrid);
|
||||
}
|
||||
else {
|
||||
// Deleting all the extra layers and canvases, leaving only one, (nAppLayers=3)
|
||||
const nLayers = layers.length;
|
||||
for (let i=2; i < nLayers - nAppLayers; i++) {
|
||||
const currentEntry = layers[i].menuEntry;
|
||||
let associatedLayer;
|
||||
|
||||
if (currentEntry != null) {
|
||||
// Getting the associated layer
|
||||
associatedLayer = getLayerByID(currentEntry.id);
|
||||
// Deleting its canvas
|
||||
associatedLayer.canvas.remove();
|
||||
// Adding the id to the unused ones
|
||||
unusedIDs.push(currentEntry.id);
|
||||
// Removing the entry from the menu
|
||||
currentEntry.remove();
|
||||
}
|
||||
}
|
||||
// Setting up the current layer
|
||||
layers[1] = new Layer(width, height, canvas, layerListEntry);
|
||||
currentLayer = layers[1];
|
||||
currentLayer.canvas.style.zIndex = 9;
|
||||
|
||||
// Updating canvas size to the new size
|
||||
for (let i=0; i<nLayers; i++) {
|
||||
layers[i].canvasSize = [width, height];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initPalette() {
|
||||
|
Loading…
Reference in New Issue
Block a user