2021-07-19 00:17:41 +03:00
|
|
|
// REFACTOR: move everything in EditorState?
|
|
|
|
|
2021-07-15 17:33:26 +03:00
|
|
|
var pixelEditorMode = "Basic";
|
|
|
|
switchMode(pixelEditorMode);
|
|
|
|
|
2020-07-20 13:59:04 +03:00
|
|
|
let modes = {
|
|
|
|
'Basic' : {
|
|
|
|
description: 'Basic mode is perfect if you want to create simple sprites or try out palettes.'
|
|
|
|
},
|
|
|
|
'Advanced' : {
|
2021-07-14 23:48:53 +03:00
|
|
|
description: 'Choose advanced mode to gain access to more advanced features such as layers and advanced palette editing.'
|
2020-07-20 13:59:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-20 23:52:51 +03:00
|
|
|
Events.on('click', 'switch-editor-mode-splash', function (e) {
|
2021-07-14 23:48:53 +03:00
|
|
|
toggleMode();
|
2021-07-07 03:37:47 +03:00
|
|
|
});
|
2021-02-19 00:28:52 +03:00
|
|
|
|
2021-07-14 23:48:53 +03:00
|
|
|
function switchMode(newMode) {
|
2020-09-09 07:15:22 +03:00
|
|
|
//switch to advanced mode
|
2021-07-15 17:33:26 +03:00
|
|
|
if (newMode == 'Advanced' && 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';
|
2021-01-04 01:59:11 +03:00
|
|
|
// Hide the palette menu
|
|
|
|
document.getElementById('colors-menu').style.right = '200px'
|
2020-09-09 07:15:22 +03:00
|
|
|
|
2021-07-07 03:37:47 +03:00
|
|
|
//change splash text
|
|
|
|
document.querySelector('#sp-quickstart-container .mode-switcher').classList.add('advanced-mode');
|
|
|
|
|
2020-07-21 00:33:17 +03:00
|
|
|
pixelEditorMode = 'Advanced';
|
2021-07-07 03:51:20 +03:00
|
|
|
|
|
|
|
//turn pixel grid off
|
|
|
|
togglePixelGrid('off');
|
2020-07-21 00:33:17 +03:00
|
|
|
}
|
2020-09-09 07:15:22 +03:00
|
|
|
//switch to basic mode
|
2020-07-21 00:33:17 +03:00
|
|
|
else {
|
2020-09-09 07:15:22 +03:00
|
|
|
//if there is a current layer (a document is active)
|
|
|
|
if (currentLayer) {
|
2021-07-14 23:48:53 +03:00
|
|
|
if (!confirm('Switching to basic mode will flatten all the visible layers. Are you sure you want to continue?')) {
|
|
|
|
return;
|
|
|
|
}
|
2020-09-09 07:15:22 +03:00
|
|
|
|
|
|
|
// Selecting the current layer
|
|
|
|
currentLayer.selectLayer();
|
|
|
|
// Flatten the layers
|
|
|
|
flatten(true);
|
2020-07-21 00:33:17 +03:00
|
|
|
}
|
|
|
|
|
2020-09-09 07:15:22 +03:00
|
|
|
//change menu text
|
2020-07-21 00:33:17 +03:00
|
|
|
document.getElementById('switch-mode-button').innerHTML = 'Switch to advanced mode';
|
2020-09-09 07:15:22 +03:00
|
|
|
|
2020-07-21 00:33:17 +03:00
|
|
|
// Hide the layer menus
|
|
|
|
layerList.style.display = 'none';
|
|
|
|
document.getElementById('layer-button').style.display = 'none';
|
2021-01-04 01:59:11 +03:00
|
|
|
// 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
|
|
|
|
2021-07-07 03:37:47 +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';
|
2021-07-07 03:51:20 +03:00
|
|
|
togglePixelGrid('on');
|
2020-07-21 00:33:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-14 23:48:53 +03:00
|
|
|
function toggleMode() {
|
|
|
|
if (pixelEditorMode == 'Advanced')
|
|
|
|
switchMode('Basic');
|
|
|
|
else
|
|
|
|
switchMode('Advanced');
|
|
|
|
}
|
|
|
|
|
2021-07-20 23:52:51 +03:00
|
|
|
Events.on('click', 'switch-mode-button', function (e) {
|
2021-07-14 23:48:53 +03:00
|
|
|
toggleMode();
|
2020-07-21 00:33:17 +03:00
|
|
|
});
|