mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
fixed a few bugs on layers before first document is created
This commit is contained in:
parent
8a769557db
commit
43f5fa8d5c
@ -10,6 +10,8 @@ let modes = {
|
||||
let infoBox = document.getElementById('editor-mode-info');
|
||||
|
||||
function switchMode(currentMode, mustConfirm = true) {
|
||||
|
||||
//switch to advanced mode
|
||||
if (currentMode == 'Basic') {
|
||||
// Switch to advanced ez pez lemon squez
|
||||
document.getElementById('switch-mode-button').innerHTML = 'Switch to basic mode';
|
||||
@ -21,19 +23,30 @@ function switchMode(currentMode, mustConfirm = true) {
|
||||
|
||||
pixelEditorMode = 'Advanced';
|
||||
}
|
||||
|
||||
//switch to basic mode
|
||||
else {
|
||||
// Switch to basic
|
||||
if (mustConfirm) {
|
||||
|
||||
|
||||
//if there is a current layer (a document is active)
|
||||
if (currentLayer) {
|
||||
|
||||
//confirm with user before flattening image
|
||||
if (mustConfirm ) {
|
||||
if (!confirm('Switching to basic mode will flatten all the visible layers. Are you sure you want to continue?')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('switch-mode-button').innerHTML = 'Switch to advanced mode';
|
||||
// Selecting the current layer
|
||||
currentLayer.selectLayer();
|
||||
// Flatten the layers
|
||||
flatten(true);
|
||||
}
|
||||
|
||||
//change menu text
|
||||
document.getElementById('switch-mode-button').innerHTML = 'Switch to advanced mode';
|
||||
|
||||
// Hide the layer menus
|
||||
layerList.style.display = 'none';
|
||||
document.getElementById('layer-button').style.display = 'none';
|
||||
|
@ -560,6 +560,8 @@ function addLayer(id, saveHistory = true) {
|
||||
|
||||
console.log("Tela creata: " + newCanvas);
|
||||
|
||||
if (!layerListEntry) return console.warn('skipping adding layer because no document');
|
||||
|
||||
// Clone the default layer
|
||||
let toAppend = layerListEntry.cloneNode(true);
|
||||
// Setting the default name for the layer
|
||||
@ -588,3 +590,5 @@ function addLayer(id, saveHistory = true) {
|
||||
|
||||
return newLayer;
|
||||
}
|
||||
|
||||
layerList = document.getElementById("layers-menu");
|
@ -5,7 +5,6 @@ function newPixel (width, height, editorMode, fileContent = null) {
|
||||
|
||||
currentPalette = [];
|
||||
if (firstPixel) {
|
||||
layerList = document.getElementById("layers-menu");
|
||||
layerListEntry = layerList.firstElementChild;
|
||||
|
||||
// Setting up the current layer
|
||||
|
Loading…
Reference in New Issue
Block a user