pixel-editor/js/_editorMode.js

75 lines
2.3 KiB
JavaScript
Raw Normal View History

let modes = {
'Basic' : {
description: 'Basic mode is perfect if you want to create simple sprites or try out palettes.'
},
'Advanced' : {
description: 'Choose advanced mode to gain access to more advanced features such as layers.'
}
}
on('click', 'switch-editor-mode-splash', function (e) {
console.log('switching mode')
switchMode();
});
function switchMode(mustConfirm = true) {
console.log('switching mode', 'current:',pixelEditorMode)
//switch to advanced mode
if (pixelEditorMode == 'Basic') {
2020-07-21 00:33:17 +03:00
// Switch to advanced ez pez lemon squez
document.getElementById('switch-mode-button').innerHTML = 'Switch to basic mode';
// Show the layer menus
layerList.style.display = "inline-block";
document.getElementById('layer-button').style.display = 'inline-block';
// Hide the palette menu
document.getElementById('colors-menu').style.right = '200px'
//change splash text
document.querySelector('#sp-quickstart-container .mode-switcher').classList.add('advanced-mode');
2020-07-21 00:33:17 +03:00
pixelEditorMode = 'Advanced';
//turn pixel grid off
togglePixelGrid('off');
2020-07-21 00:33:17 +03:00
}
//switch to basic mode
2020-07-21 00:33:17 +03:00
else {
//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;
}
}
// Selecting the current layer
currentLayer.selectLayer();
// Flatten the layers
flatten(true);
2020-07-21 00:33:17 +03:00
}
//change menu text
2020-07-21 00:33:17 +03:00
document.getElementById('switch-mode-button').innerHTML = 'Switch to advanced mode';
2020-07-21 00:33:17 +03:00
// Hide the layer menus
layerList.style.display = 'none';
document.getElementById('layer-button').style.display = 'none';
// Show the palette menu
document.getElementById('colors-menu').style.display = 'flex';
// Move the palette menu
document.getElementById('colors-menu').style.right = '0px';
2020-07-21 00:33:17 +03:00
//change splash text
document.querySelector('#sp-quickstart-container .mode-switcher').classList.remove('advanced-mode');
2020-07-21 00:33:17 +03:00
pixelEditorMode = 'Basic';
togglePixelGrid('on');
2020-07-21 00:33:17 +03:00
}
}
on('click', 'switch-mode-button', function (e) {
switchMode();
2020-07-21 00:33:17 +03:00
});