another push

Fixed issue with color saving
Redesigned color select section
This commit is contained in:
Jaman Brundage 2022-03-23 08:47:57 -04:00
parent 5f09ceddcf
commit 12a3283790
19 changed files with 281 additions and 117 deletions

View File

@ -85,9 +85,9 @@
#canvas-view { #canvas-view {
bottom: 0px; bottom: 0px;
left: 48px; left: var(--top-nav-height);
right: 48px; right: var(--top-nav-height);
top: 48px; top: var(--top-nav-height);
cursor: default; cursor: default;
position: fixed; position: fixed;
display: block; display: block;
@ -97,9 +97,9 @@
box-shadow: inset 0px 0px 4px 0px rgba(0, 0, 0, 0.4); box-shadow: inset 0px 0px 4px 0px rgba(0, 0, 0, 0.4);
position: fixed; position: fixed;
bottom: 0px; bottom: 0px;
left: 48px; left: var(--top-nav-height);
right: 48px; right: var(--top-nav-height);
top: 48px; top: var(--top-nav-height);
display: block; display: block;
pointer-events: none; pointer-events: none;
} }

View File

@ -1,36 +1,57 @@
#colors-menu { #colors-menu {
right: 200px; width:var(--layers-width);
width: 48px;
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
flex-direction: column; flex-direction: row;
list-style-type: none; list-style-type: none;
top: 48px; display: flex;
bottom: 0; flex-wrap: wrap;
align-content: flex-start;
height: var(--palette-height);
padding: 0; padding: 0;
margin: 0; margin: 0;
background-color: $basecolor; background-color: $basecolor;
box-sizing: border-box; box-sizing: border-box;
position: fixed; align-items: flex-start;
z-index: 1120; z-index: 1120;
overflow-y: scroll;
resize: vertical;
li { li {
width: 48px; width: var(--top-nav-height);
flex-basis: 48px; height: var(--top-nav-height);
flex-basis: var(--top-nav-height);
&:not(.noshrink) {
flex-grow: 1;
}
&.noshrink { &.noshrink {
flex-grow: 0; flex-grow: 0;
flex-shrink: 0; flex-shrink: 0;
} }
} }
svg {
margin-top: 4px;
}
&::-webkit-scrollbar {
background: #232125;
width: 1em;
}
&::-webkit-scrollbar-track {
margin-top: -0.125em;
width: 1em;
}
&::-webkit-scrollbar-thumb {
background: #332f35;
border-radius: 0.25em;
border: solid 0.125em #232125; //same color as scrollbar back to fake padding
}
&::-webkit-scrollbar-corner {
background: #232125;
}
scrollbar-color: #332f35 #232125;
scroll-behavior: smooth;
} }
//added when the color is a duplicate of another //added when the color is a duplicate of another
#duplicate-color-warning { #duplicate-color-warning {
display: inline-block; display: inline-block;
@ -118,14 +139,14 @@
content: ""; content: "";
display: block; display: block;
position: absolute; position: absolute;
top: -3px; top: 0px;
left: -3px; left: 0px;
border: solid 3px #fff; border: solid 3px #fff;
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 4px; box-shadow: 0px 0px 0px 3px rgba(0, 0, 0, 0.15) inset;
box-shadow: 0px 0px 0px 3px rgba(0, 0, 0, 0.15);
z-index: 10; z-index: 10;
box-sizing: border-box;
} //inner outline } //inner outline
&.selected button::after { &.selected button::after {
content: ""; content: "";
@ -149,7 +170,9 @@
background: $basehover; background: $basehover;
} }
.jscolor-wrap {
z-index: 10000 !important;
}
.jscolor-picker-bottom { .jscolor-picker-bottom {
display: none; display: none;
@ -173,7 +196,6 @@
} }
} }
.delete-color-button { .delete-color-button {
background: none; background: none;
padding: 0px; padding: 0px;

24
css/_containers.scss Normal file
View File

@ -0,0 +1,24 @@
#right-container{
display: flex;
flex-direction: column;
position: fixed;
top: var(--top-nav-height);
right: var(--top-nav-height);
bottom: 0;
}
#bottom-container{
display: flex;
flex-direction: column;
position: fixed;
left: 0;
right: 0;
bottom: 0;
}
#left-container{
display: flex;
flex-direction: column;
position: fixed;
top: var(--top-nav-height);
bottom: 0;
left: var(--top-nav-height);
}

View File

@ -43,4 +43,15 @@ svg {
#data-holders, .preload { #data-holders, .preload {
display: none; display: none;
} }
#right-nav {
position: fixed;
top: var(--top-nav-height);
right: 0;
bottom: 0;
width: var(--layers-width);
z-index: 9000;
display: flex;
flex-direction: column;
}

View File

@ -1,4 +1,3 @@
#layer-properties-menu { #layer-properties-menu {
visibility: hidden; visibility: hidden;
margin: 0; margin: 0;
@ -8,7 +7,7 @@
width: 120px; width: 120px;
text-align: center; text-align: center;
margin-right: 200px; margin-right: var(--layers-width);
/*border:1px solid $basetext;*/ /*border:1px solid $basetext;*/
list-style: none; list-style: none;
position: relative; position: relative;
@ -72,19 +71,16 @@
} }
scrollbar-color: #332f35 #232125; scrollbar-color: #332f35 #232125;
scroll-behavior: smooth; scroll-behavior: smooth;
width:200px; width:var(--layers-width);
top: 48px;
bottom: 0;
right:0;
padding: 0; padding: 0;
margin: 0; margin: 0;
background-color: $basecolor; background-color: $basecolor;
box-sizing: border-box; box-sizing: border-box;
position: fixed;
z-index: 1120; z-index: 1120;
list-style-type: none; list-style-type: none;
overflow-y:scroll; overflow-y:scroll;
overflow-x:hidden; overflow-x:hidden;
flex: 1;
#add-layer-button { #add-layer-button {
path { path {
fill: $baseicon; fill: $baseicon;
@ -112,6 +108,33 @@
color: $basehovertext; color: $basehovertext;
background-color: $basehover; background-color: $basehover;
} }
#add-reference-button {
path {
fill: $baseicon;
}
svg {
position: relative;
margin-right: 10px;
}
position:relative;
justify-content: center;
display:none;
align-items:center;
margin-top:2px;
font-size: 1.2em;
color: $basetext;
height: 100%;
width: 100%;
padding: 17px;
background: none;
border: none;
cursor: pointer;
}
#add-reference-button:hover {
color: $basehovertext;
background-color: $basehover;
}
} }
.selected-layer { .selected-layer {

View File

@ -1,6 +1,6 @@
#main-menu { #main-menu {
height: 48px; height: var(--top-nav-height);
left: 0; left: 0;
right: 0; right: 0;
list-style-type: none; list-style-type: none;
@ -35,7 +35,7 @@
li ul { li ul {
display: none; display: none;
position: absolute; position: absolute;
top: 48px; top: var(--top-nav-height);
list-style-type: none; list-style-type: none;
padding: 0; padding: 0;
margin: 0; margin: 0;

View File

@ -6,6 +6,18 @@
font-style: italic; font-style: italic;
} }
#new-pixel-inventory {
display: none;
}
#new-pixel-map {
display: none;
}
#new-voxel-world {
display: none;
}
.dimentions-x { .dimentions-x {
margin: -2px 7px; margin: -2px 7px;
path { path {
@ -13,12 +25,10 @@
} }
} }
#no-palette-button { #no-palette-button {
display: none; display: none;
} }
#editor-mode-info { #editor-mode-info {
font-style: italic; font-style: italic;
} }

View File

@ -1,9 +1,9 @@
#tools-menu { #tools-menu {
left: 0; left: 0;
width: 48px; width: var(--top-nav-height);
list-style-type: none; list-style-type: none;
top: 48px; top: var(--top-nav-height);
bottom: 0; bottom: 0;
padding: 0; padding: 0;
margin: 0; margin: 0;
@ -24,7 +24,7 @@
width: 100%; width: 100%;
padding: 0; padding: 0;
cursor: pointer; cursor: pointer;
height: 48px; height: var(--top-nav-height);
z-index:0; z-index:0;
} }
@ -73,7 +73,7 @@
#tools-menu .size-buttons { #tools-menu .size-buttons {
position:absolute; position:absolute;
display: none; display: none;
height:48px; height:var(--top-nav-height);
left:8px; left:8px;
z-index:-1; z-index:-1;
background-color: $basecolor !important; background-color: $basecolor !important;
@ -140,8 +140,8 @@
#tool-tutorial { #tool-tutorial {
display:inline-block; display:inline-block;
position:absolute; position:absolute;
margin-left:48px; margin-left:var(--top-nav-height);
margin-top:48px; margin-top:var(--top-nav-height);
background-color: $basehover; background-color: $basehover;
color:$basetext; color:$basetext;
font-size:14px; font-size:14px;

View File

@ -13,4 +13,12 @@ $baseselected: lighten($basecolor, 15%); //color(selectedTool, background),
$baseselectediconhover: lighten($basecolor, 70%); //color(subbutton, foreground, hover) $baseselectediconhover: lighten($basecolor, 70%); //color(subbutton, foreground, hover)
$baseselectedhover: lighten($basecolor, 25%); //color(subbutton, background, hover) $baseselectedhover: lighten($basecolor, 25%); //color(subbutton, background, hover)
$indent: darken($basecolor, 5%); //color(indent) $indent: darken($basecolor, 5%); //color(indent)
$indenttext: lighten($basecolor, 50%); //color(indent, foreground) $indenttext: lighten($basecolor, 50%); //color(indent, foreground)
:root{
--layers-width: 206px;
--palette-height: 38%;
--top-nav-height: 48px;
--drag-bar-size: var(--top-nav-height);
}

View File

@ -13,6 +13,16 @@ const ColorModule = (() => {
document.getElementById('jscolor-hex-input').addEventListener('change',colorChanged, false); document.getElementById('jscolor-hex-input').addEventListener('change',colorChanged, false);
document.getElementById('jscolor-hex-input').addEventListener('input', colorChanged, false); document.getElementById('jscolor-hex-input').addEventListener('input', colorChanged, false);
document.getElementById('add-color-button').addEventListener('click', addColorButtonEvent, false); document.getElementById('add-color-button').addEventListener('click', addColorButtonEvent, false);
// const resizeObserver = new ResizeObserver(function(mutations) {
// console.log('mutations:', mutations);
// const h = mutations[0].contentRect.height;
// colorMenuResized(h);
// });
// resizeObserver.observe(document.getElementById('colors-menu'), {attributes:true});
// function colorMenuResized(h) {
// document.getElementById('layers-menu').style.height = `calc(100% + ${h}px - var(--top-nav-height))`;
// }
// Making the colours in the HTML menu sortable // Making the colours in the HTML menu sortable
new Sortable(document.getElementById("colors-menu"), { new Sortable(document.getElementById("colors-menu"), {
@ -21,7 +31,6 @@ const ColorModule = (() => {
draggable: ".draggable-colour", draggable: ".draggable-colour",
onEnd: function() {Events.simulateMouseEvent(window, "mouseup");} onEnd: function() {Events.simulateMouseEvent(window, "mouseup");}
}); });
/** Changes all of one color to another after being changed from the color picker /** Changes all of one color to another after being changed from the color picker
* *
* @param {*} colorHexElement The element that has been changed * @param {*} colorHexElement The element that has been changed
@ -94,18 +103,25 @@ const ColorModule = (() => {
* *
* @param {*} e The event that triggered the callback * @param {*} e The event that triggered the callback
*/ */
function clickedColor (e){ function clickedColor (e) {
//left clicked color //left clicked color
if (e.which == 1) { if (e.which == 1) {
// remove current color selection // remove current color selection
const currentSelectedColorButton = document.querySelector('#colors-menu li.selected .color-button');
const selectedColor = currentSelectedColorButton.style.backgroundColor;
const clickedColor = e.target.style.backgroundColor;
document.querySelector('#colors-menu li.selected')?.classList.remove('selected'); document.querySelector('#colors-menu li.selected')?.classList.remove('selected');
//set current color //set current color
updateCurrentColor(Color.cssToHex(e.target.style.backgroundColor)); updateCurrentColor(Color.cssToHex(clickedColor));
//make color selected //make color selected
e.target.parentElement.classList.add('selected'); e.target.parentElement.classList.add('selected');
if(selectedColor === clickedColor) {
e.target.parentElement.lastChild.classList.add('hidden');
e.target.jscolor.show();
}
} }
//right clicked color //right clicked color
else if (e.which == 3) { else if (e.which == 3) {
@ -251,7 +267,6 @@ const ColorModule = (() => {
//loop through colors //loop through colors
for (var i = 0; i < colors.length; i++) { for (var i = 0; i < colors.length; i++) {
//////console.log(color,'=',colors[i].jscolor.toString());
if (color == colors[i].jscolor.toString()) { if (color == colors[i].jscolor.toString()) {
//set color to the color button //set color to the color button
@ -334,7 +349,11 @@ const ColorModule = (() => {
} }
function getCurrentPalette() { function getCurrentPalette() {
return currentPalette; let ret = [...currentPalette];
if(ret.length === 0) {
ret = [...document.querySelectorAll(".color-button")].map(n=>n.style.backgroundColor);
}
return ret;
} }
function resetPalette() { function resetPalette() {
@ -346,7 +365,6 @@ const ColorModule = (() => {
* @param {*} paletteColors The colours of the palette * @param {*} paletteColors The colours of the palette
*/ */
function createColorPalette(paletteColors) { function createColorPalette(paletteColors) {
////console.log("creating palette");
//remove current palette //remove current palette
while (colorsMenu.childElementCount > 1) while (colorsMenu.childElementCount > 1)
colorsMenu.children[0].remove(); colorsMenu.children[0].remove();
@ -358,7 +376,6 @@ const ColorModule = (() => {
for (var i = 0; i < paletteColors.length; i++) { for (var i = 0; i < paletteColors.length; i++) {
var newColor = new Color("hex", paletteColors[i]); var newColor = new Color("hex", paletteColors[i]);
var newColorElement = ColorModule.addColor(newColor.hex); var newColorElement = ColorModule.addColor(newColor.hex);
////console.log('newColor.hex === ',newColor.hex);
var newColRgb = newColor.rgb; var newColRgb = newColor.rgb;
var lightestColorRgb = lightestColor.rgb; var lightestColorRgb = lightestColor.rgb;
@ -383,7 +400,6 @@ const ColorModule = (() => {
//set as current color //set as current color
updateCurrentColor(darkestColor.hex); updateCurrentColor(darkestColor.hex);
////console.log('getCurrentPalette() === ',getCurrentPalette());
} }
/** Creates the palette with the colours used in all the layers /** Creates the palette with the colours used in all the layers
@ -423,7 +439,6 @@ const ColorModule = (() => {
//create palette from colors array //create palette from colors array
createColorPalette(colorPaletteArray); createColorPalette(colorPaletteArray);
////console.log("Done 2");
} }
function updateCurrentColor(color, refLayer) { function updateCurrentColor(color, refLayer) {

View File

@ -18,8 +18,6 @@ const EditorState = (() => {
//switch to advanced mode //switch to advanced mode
if (newMode == 'Advanced') { if (newMode == 'Advanced') {
Events.emit("switchedToAdvanced"); Events.emit("switchedToAdvanced");
// Hide the palette menu
document.getElementById('colors-menu').style.right = '200px'
pixelEditorMode = 'Advanced'; pixelEditorMode = 'Advanced';
document.getElementById("switch-mode-button").innerHTML = 'Switch to basic mode'; document.getElementById("switch-mode-button").innerHTML = 'Switch to basic mode';

View File

@ -128,10 +128,14 @@ const FileManager = (() => {
function localStorageSave() { function localStorageSave() {
const lpeStr = getProjectData(); const lpeStr = getProjectData();
const lpe = JSON.parse(lpeStr); const lpe = JSON.parse(lpeStr);
//console.log('LPE saved === ',lpe); console.log('BEFORE JSON.stringify(lpe.colors,null,4) === ',JSON.stringify(lpe.colors,null,4));
console.log([...ColorModule.getCurrentPalette()]);
if(lpe.colors.length < 1)lpe.colors = [...ColorModule.getCurrentPalette()];
if(lpe.colors.length < 1)lpe.colors.push("#000000"); if(lpe.colors.length < 1)lpe.colors.push("#000000");
console.log('AFTER JSON.stringify(lpe.colors,null,4) === ',JSON.stringify(lpe.colors,null,4));
if(!lpe.canvasWidth)lpe.canvasWidth = 16; if(!lpe.canvasWidth)lpe.canvasWidth = 16;
if(!lpe.canvasHeight)lpe.canvasHeight = 16; if(!lpe.canvasHeight)lpe.canvasHeight = 16;
console.log('LPE saved === ',lpe);
localStorage.setItem("lpe-cache", JSON.stringify(lpe)); localStorage.setItem("lpe-cache", JSON.stringify(lpe));
} }
function localStorageReset() { function localStorageReset() {
@ -185,6 +189,7 @@ const FileManager = (() => {
// If it's a Lospec Pixel Editor tm file, I load the project // If it's a Lospec Pixel Editor tm file, I load the project
if (extension == 'lpe') { if (extension == 'lpe') {
openProject(); openProject();
// openFile();
} }
else { else {
openFile(); openFile();
@ -204,6 +209,7 @@ const FileManager = (() => {
img.onload = function() { img.onload = function() {
//create a new pixel with the images dimentions //create a new pixel with the images dimentions
console.log('this === ',this);
Startup.newPixel({ Startup.newPixel({
canvasWidth: this.width, canvasWidth: this.width,
canvasHeight: this.height canvasHeight: this.height
@ -224,23 +230,26 @@ const FileManager = (() => {
fileReader.readAsDataURL(browseHolder.files[0]); fileReader.readAsDataURL(browseHolder.files[0]);
} }
function openProject(lpeData) { function openProject(lpeData) {
console.log('lpeData === ',lpeData);
// Getting all the data // Getting all the data
if(lpeData){ if(lpeData){
_parseLPE(lpeData); _parseLPE(lpeData);
} else { } else {
let file = uri ?? browseHolder.files[0]; let file = browseHolder.files[0];
let reader = new FileReader(); let reader = new FileReader();
reader.readAsText(file, "UTF-8");
// Converting the data to a json object and creating a new pixel (see _newPixel.js for more) // Converting the data to a json object and creating a new pixel (see _newPixel.js for more)
reader.onload = function (e) { reader.onload = function (e) {
console.log('this === ',this);
console.log('e === ',e);
let dictionary = JSON.parse(e.target.result); let dictionary = JSON.parse(e.target.result);
console.log('FileManager.js => openProject => loaded lpe dictionary === ',dictionary);
_parseLPE(dictionary); _parseLPE(dictionary);
} }
reader.readAsText(file, "UTF-8");
} }
function _parseLPE(dictionary) { function _parseLPE(dictionary) {
Startup.newPixel(dictionary, true); Startup.newPixel(dictionary);
} }
} }
function loadFromLPE(dictionary) { function loadFromLPE(dictionary) {
@ -248,38 +257,11 @@ const FileManager = (() => {
//console.log('dictionary === ',dictionary); //console.log('dictionary === ',dictionary);
dictionary = FileManager.upgradeLPE(dictionary);
EditorState.switchMode(dictionary.editorMode ?? 'Advanced'); EditorState.switchMode(dictionary.editorMode ?? 'Advanced');
// I add every layer the file had in it
// dictionary.layers.forEach((layerData,i)=>{
// let layerImage = layerData.src;
// if (layerData != null) {
// // Setting id
// let createdLayer = LayerList.addLayer(layerData.id, false, layerData.name);
// // Setting name
// createdLayer.menuEntry.getElementsByTagName("p")[0].innerHTML = layerData.name;
// // Adding the image (I can do that because they're sorted by increasing z-index)
// let img = new Image();
// img.onload = function() {
// createdLayer.context.drawImage(img, 0, 0);
// createdLayer.updateLayerPreview();
// };
// img.src = layerImage;
// // Setting visibility and lock options
// if (!layerData.isVisible) {
// createdLayer.hide();
// }
// if (layerData.isLocked) {
// createdLayer.lock();
// }
// }
// })
if(dictionary.colors)ColorModule.createColorPalette(dictionary.colors); if(dictionary.colors)ColorModule.createColorPalette(dictionary.colors);
// Startup.newPixel(dictionary);
} }
function getProjectData() { function getProjectData() {
// use a dictionary // use a dictionary
@ -355,7 +337,7 @@ const FileManager = (() => {
browsePaletteHolder.value = null; browsePaletteHolder.value = null;
} }
function upgradeLPE(dictionary) { function upgradeLPE(dictionary) {
////console.log('dictionary === ',dictionary); console.log('dictionary === ',dictionary);
if(dictionary.color0 && !dictionary.colors) { if(dictionary.color0 && !dictionary.colors) {
dictionary.colors = []; dictionary.colors = [];
let colorIdx = 0; let colorIdx = 0;
@ -364,8 +346,9 @@ const FileManager = (() => {
delete dictionary[`color${colorIdx}`]; delete dictionary[`color${colorIdx}`];
colorIdx++; colorIdx++;
} }
console.log('Object.keys(dictionary) === ',Object.keys(dictionary));
dictionary.layers = Object.keys(dictionary).reduce((r,k,i)=>{ dictionary.layers = Object.keys(dictionary).reduce((r,k,i)=>{
if(k.slice(0,5) === "layer"){ if(k.slice(0,5) === "layer" && dictionary[k]){
if(dictionary[k].isSelected){ if(dictionary[k].isSelected){
dictionary.selectedLayer = r.length; dictionary.selectedLayer = r.length;
} }
@ -379,7 +362,9 @@ const FileManager = (() => {
} }
return r; return r;
},[]); },[]);
console.log('dictionary.layers === ',dictionary.layers);
} }
console.log('dictionary === ',dictionary);
return dictionary; return dictionary;
} }
function toggleCache(elm){ function toggleCache(elm){
@ -395,7 +380,7 @@ const FileManager = (() => {
const cacheEnabled = !!Number(localStorage.getItem("lpe-cache-enabled")); const cacheEnabled = !!Number(localStorage.getItem("lpe-cache-enabled"));
document.getElementById("auto-cache-button").textContent = cacheBtnText(cacheEnabled); document.getElementById("auto-cache-button").textContent = cacheBtnText(cacheEnabled);
return { const ret = {
cacheEnabled, cacheEnabled,
loadFromLPE, loadFromLPE,
toggleCache, toggleCache,
@ -413,4 +398,14 @@ const FileManager = (() => {
openSaveProjectWindow, openSaveProjectWindow,
open open
}; };
Object.keys(ret).forEach(k=>{
if(typeof ret[k] === "function"){
const orig = ret[k];
ret[k] = function() {
DEBUG_ARR.push(`called FileManager -> ${k}`);
return orig.call(this,...arguments);
}
}
})
return ret;
})(); })();

View File

@ -6,6 +6,7 @@ const LayerList = (() => {
let dragStartLayer; let dragStartLayer;
Events.on("mousedown", layerList, openOptionsMenu); Events.on("mousedown", layerList, openOptionsMenu);
Events.on('click',"add-layer-button", addLayerClick, false); Events.on('click',"add-layer-button", addLayerClick, false);
Events.on('click',"add-reference-button", addReferenceClick, false);
Events.onCustom("switchedToAdvanced", showLayerList); Events.onCustom("switchedToAdvanced", showLayerList);
Events.onCustom("switchedToBasic", hideLayerList); Events.onCustom("switchedToBasic", hideLayerList);
@ -28,6 +29,10 @@ const LayerList = (() => {
layerList.style.display = "none"; layerList.style.display = "none";
document.getElementById('layer-button').style.display = 'none'; document.getElementById('layer-button').style.display = 'none';
} }
function addReferenceClick(id, saveHistory = true, layerName) {
addLayer(...arguments);
currFile.layers[currFile.layers.length-1].selectLayer();
}
function addLayerClick(id, saveHistory = true, layerName) { function addLayerClick(id, saveHistory = true, layerName) {
addLayer(...arguments); addLayer(...arguments);
currFile.layers[currFile.layers.length-1].selectLayer(); currFile.layers[currFile.layers.length-1].selectLayer();
@ -156,14 +161,6 @@ const LayerList = (() => {
dragStartLayer = getLayerByID(layerList.children[event.oldIndex].id); dragStartLayer = getLayerByID(layerList.children[event.oldIndex].id);
} }
function getLayerByID(id) { function getLayerByID(id) {
//console.log(`getLayerByID(${id})`);
// for (let i=0; i<currFile.layers.length; i++) {
// if (currFile.layers[i].hasCanvas()) {
// if (currFile.layers[i].menuEntry.id == id) {
// return currFile.layers[i];
// }
// }
// }
let ret; let ret;
for (let i=0; i<currFile.layers.length; i++) { for (let i=0; i<currFile.layers.length; i++) {
if (currFile.layers[i].hasCanvas()) { if (currFile.layers[i].hasCanvas()) {
@ -172,8 +169,6 @@ const LayerList = (() => {
} }
} }
} }
//console.log('ret === ',ret);
return ret ?? null; return ret ?? null;
} }
function getLayerByName(name) { function getLayerByName(name) {
@ -200,19 +195,9 @@ const LayerList = (() => {
renamingLayer = true; renamingLayer = true;
} }
function duplicateLayer(event, saveHistory = true) { function duplicateLayer(event, saveHistory = true) {
function getMenuEntryIndex(list, entry) {
for (let i=0; i<list.length; i++) {
if (list[i] === entry) {
return i;
}
}
return -1;
}
let layerIndex = currFile.layers.indexOf(currFile.currentLayer); let layerIndex = currFile.layers.indexOf(currFile.currentLayer);
// Creating a new canvas // Creating a new canvas
let newCanvas = document.createElement("canvas"); let newCanvas = document.createElement("canvas");
// Setting up the new canvas // Setting up the new canvas

View File

@ -1,3 +1,4 @@
let DEBUG_ARR = [];
const Startup = (() => { const Startup = (() => {
let splashPostfix = ''; let splashPostfix = '';
@ -31,11 +32,13 @@ const Startup = (() => {
* @param {*} skipModeConfirm If skipModeConfirm == true, then the mode switching confirmation will be skipped * @param {*} skipModeConfirm If skipModeConfirm == true, then the mode switching confirmation will be skipped
*/ */
function newPixel (lpe = null, skipModeConfirm = false) { function newPixel (lpe = null, skipModeConfirm = false) {
console.log('called newPixel'); DEBUG_ARR.push('called Startup -> newPixel');
console.trace(); console.trace();
// The palette is empty, at the beginning // The palette is empty, at the beginning
ColorModule.resetPalette(); ColorModule.resetPalette();
lpe = FileManager.upgradeLPE(lpe);
initLayers(lpe); initLayers(lpe);
initPalette(); initPalette();
@ -60,6 +63,7 @@ const Startup = (() => {
////console.trace(); ////console.trace();
} }
function clearLayers() { function clearLayers() {
DEBUG_ARR.push('called Startup -> clearLayers');
console.dir(currFile.layers); console.dir(currFile.layers);
for(let i = currFile.layers.length-1; i >= 0;i--) { for(let i = currFile.layers.length-1; i >= 0;i--) {
currFile.layers[i].delete(i); currFile.layers[i].delete(i);
@ -70,6 +74,7 @@ const Startup = (() => {
} }
} }
function initLayers(lpe) { function initLayers(lpe) {
DEBUG_ARR.push('called Startup -> initLayers');
//console.group('called initLayers'); //console.group('called initLayers');
//console.log('currFile.layers === ',currFile.layers); //console.log('currFile.layers === ',currFile.layers);
@ -150,6 +155,7 @@ const Startup = (() => {
} }
function initPalette() { function initPalette() {
DEBUG_ARR.push('called Startup -> initPalette');
// Get selected palette // Get selected palette
let selectedPalette = Util.getText('palette-button' + splashPostfix); let selectedPalette = Util.getText('palette-button' + splashPostfix);
@ -197,6 +203,7 @@ const Startup = (() => {
} }
function resetInput() { function resetInput() {
DEBUG_ARR.push('called Startup -> resetInput');
//reset new form //reset new form
Util.setValue('size-width', 64); Util.setValue('size-width', 64);
Util.setValue('size-height', 64); Util.setValue('size-height', 64);
@ -206,6 +213,7 @@ const Startup = (() => {
} }
function newFromTemplate(preset, x, y) { function newFromTemplate(preset, x, y) {
DEBUG_ARR.push('called Startup -> newFromTemplate');
if (preset != '') { if (preset != '') {
const presetProperties = PresetModule.propertiesOf(preset); const presetProperties = PresetModule.propertiesOf(preset);
Util.setText('palette-button-splash', presetProperties.palette); Util.setText('palette-button-splash', presetProperties.palette);
@ -219,6 +227,7 @@ const Startup = (() => {
} }
function splashEditorMode(mode) { function splashEditorMode(mode) {
DEBUG_ARR.push('called Startup -> splashEditorMode');
editorMode = mode; editorMode = mode;
} }

View File

@ -47,6 +47,9 @@ const ToolManager = (() => {
if (!EditorState.documentCreated || Dialogue.isOpen()) if (!EditorState.documentCreated || Dialogue.isOpen())
return; return;
const isHoveringMenuElement = !!mouseEvent.path.find(n=>n.id && n.id.includes("-menu"));
if(isHoveringMenuElement)return;
let mousePos = Input.getCursorPosition(mouseEvent); let mousePos = Input.getCursorPosition(mouseEvent);
tools["zoom"].onMouseWheel(mousePos, mouseEvent.deltaY < 0 ? 'in' : 'out'); tools["zoom"].onMouseWheel(mousePos, mouseEvent.deltaY < 0 ? 'in' : 'out');
} }

View File

@ -5,7 +5,9 @@
//=include data/consts.js //=include data/consts.js
//=include data/palettes.js //=include data/palettes.js
// str.split(`//=include `).slice(1).map(n=>{
// return `<script src="${jsPath}/${n.split('\n')[0]}"></script>`;
// });
/** UTILITY AND INPUT **/ /** UTILITY AND INPUT **/
//=include Util.js //=include Util.js
//=include Events.js //=include Events.js

53
old_lpe1.json Normal file
View File

@ -0,0 +1,53 @@
{
"canvasWidth": 128,
"canvasHeight": 128,
"editorMode": "Advanced",
"color0": "#798040",
"color1": "#33ff69",
"color2": "#2f748a",
"nLayers": 7,
"layer4": {
"canvas": {},
"context": {
"mozImageSmoothingEnabled": false
},
"isSelected": false,
"isVisible": true,
"isLocked": false,
"oldLayerName": null,
"menuEntry": {},
"id": "layer1",
"name": "Layer 0"
},
"layer4ImageData": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAABCRJREFUeF7tmrFx3DAQRXXlOFYDjtyLS3BkOXIJ7sWRG1DscuShZjADcwgSBD4ofO5TouCIvd3 / H3ZB8h5P / IVW4BG6eop / AoDgEAAAAARXIHj5dAAACK5A8PLpAAAQXIHg5dMBACC4AsHLpwMAQHAFgpdPBwCA4AoEL58OAADBFQhePh0AAIIrELx8OgAABFcgePl0AAAIrkDw8ukAABBcgeDl0wEAILgCwcunAwBAcAWCl08HAIDgCgQvnw4AAPEU + Pby + W2v6t / fP21 + /Pr4dbsNc7uCjnDeMz8Z/ + XH380wP1 / +3E6 vqQp6fvv6vjNH7bSS + UfGJxoA4Gh7dX4 + CoBe4wGg09ja5SMAWJufz / dSqy / lSweodbLxOjUAufm1bX4vdQBoNLZm2WL + MvvT / 5 o1e9ck8xXGMwJ63ahYrwYgdZOzbZ4OUGHWiEuUACyxlMbTAUY4voqpAmCU + Uu6nAEGgtALwIiWvy4XAAYBkB / 8 Wg6Bac3RI97e9AGgV8HC + h4ArjKfETDI / CVsS / vPnxmM3vkcAgea3wLAekxcBUCrDDOPjileBp3pAG7mzz46rABwNH / 28 TENAItQpdfApXcEs7f + fGTMOgamB6B0W + hk / sxjYBoAtnb / 3 jMBAGg9kv6 / bloAjh4IAcBNANia70fmL6UDwE0BqDFfAYDydwI1VnAI3FBpff9fa34PAFcbz23gzvbIAdi7DdwKcXYEfJTxAHDwAqj1d4C1AHy08QCwA0Da9Wdafwp3BMAsxgNAYfbnLV8JwGzGA8DO4S991AtAz2 / 9 a07wimu4C6g4DJ4ROp0dljUjfgB6JpeaawFAAICb6XnJANAIQG56 / r7g6BBYsyuvvAYADtTOjc4vLb0iBgANvlO8DGop5WoA0g7u + d4ZuwAAFOgrmQUALdv1RmsA4EZmtpTSA8D6 + 2 YYCbYjoMU8xRoAUKhoHAMAjM1TpA4AChWNYwCAsXmK1AFAoaJxDAAwNk + ROgAoVDSOAQDG5ilSBwCFiuYxVBDwJNAUBAAwNU6VNgColDSNAwCmxinT7oVghvm / 6 MHbwA4qeiAAgA7hWapTgA6g09IyEgBY2qZLGgB0WlpGAgBL23RJA4BOS8tIAGBpmy5pANBpaRkJACxt0yUNADotLSMBgKVtuqQBQKelZSQAsLRNlzQA6LS0jAQAlrbpkgYAnZaWkQDA0jZd0gCg09IyEgBY2qZLGgB0WlpGAgBL23RJA4BOS8tIAGBpmy5pANBpaRkJACxt0yUNADotLSMBgKVtuqQBQKelZSQAsLRNlzQA6LS0jAQAlrbpkgYAnZaWkQDA0jZd0gCg09IyEgBY2qZLGgB0WlpGAgBL23RJA4BOS8tIAGBpmy5pANBpaRkJACxt0yUNADotLSMBgKVtuqQBQKelZaR / PIgEn3reoTUAAAAASUVORK5CYII = ",
"layer5": {
"canvas": {},
"context": {
"mozImageSmoothingEnabled": false
},
"isSelected": false,
"isVisible": true,
"isLocked": false,
"oldLayerName": null,
"menuEntry": {},
"id": "layer6",
"name": "Layer 1"
},
"layer5ImageData": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAA7ZJREFUeF7tnFFyo0AQQ + Mz7an2RDnVnilbqYqrHMo2aNBgLL380gMj6XUDdpLLBz / VDlyq1SP + AwDKIQAAACh3oFw + EwAAyh0ol88EAIByB8rlMwEAoNyBcvlMAAAod6BcPhMAAModKJfPBACAcgfK5TMBAKDcgXL5TAAAKHegXD4TAADKHSiXzwQAgHIHyuUzAQCg3IFy + UwAACh3oFw + EwAAyh0ol88EAIByB8rlMwEAoNyBcvlMAAAod6BcPhMAAModKJfPBPgB4M / X3y + FhX + XzwjvIkQowS1r1eCv6wFgj + snWTsa / vf2AeAkIY5uY0 / 4 ADDq + knW7Q0fAE4S5Mg2HOEDwIjzJ1jjCh8AThCmugVn + G4ARvfmeBCteA0cNfgZZHvNd + xp7x6 + 9 QGAOkp + 6 lXzHYEvt6ru4Z7UeABmGL / 1 FjDr2s4Po6IBmBnAo + 6 beU0mgDiuZ4WxDH / Wddbkcgt44tCMUK6Gzzj3Wtj3jgPAA9fOEtBIqMoaALjjVkv4Wx9E14CKewgEgLXIfx + PAqApfCbAAvS28AEAACy / lBJzC2ACaPf + azUAjPn28lWOV8CoL4PaJgAAlD8DAEAxAK7wuQUccCef8cURAJz8I + DZXxUDwAkB2BKK40F1y3WUwcZroOLWTa0ahCN816d / t5IBQABADf321A4A9lz / kUwAeAKAy3BH + DO6n7eARfiuwJdMOQCYtbeYCSBM8kNLHeHP6v6oCXBoqsLFHADM6n4AEIIcKXWEP7P7AWAkVWGNA4CZ3Q8AQphqqSP82d0PAGqqQr0DgNndDwBCoEqpI / wjuh8AlFSFWgcAR3Q / AAihbi11hH9U9wPA1lSFOgcAR3U / AAjBbil1hH9k9wPAllSFGgcAR3Y / AAjhrpU6wj + 6 + wFgLVXhuAOAo7sfAISA10oBYM2h8ON7AXhF9zMBjFACgNHMdzzVHgBe1f1MACNpAGA08x1PNQrAK7ufCWAkDQCMZr7jqQDgHVMz7nkEgFePf24BANDx7 + KNOcedij8MiYtUEwQAml9x1QAQF6kmCAA0v + KqASAuUk0QAGh + xVUDQFykmiAA0PyKqwaAuEg1QQCg + RVXDQBxkWqCAEDzK64aAOIi1QQBgOZXXDUAxEWqCQIAza + 4 agCIi1QTBACaX3HVABAXqSYIADS / 4 qoBIC5STRAAaH7FVQNAXKSaIADQ / IqrBoC4SDVBAKD5FVcNAHGRaoIAQPMrrhoA4iLVBAGA5ldcNQDERaoJAgDNr7jq / yPDGJDPZGMlAAAAAElFTkSuQmCC ",
"layer6": {
"canvas": {},
"context": {
"mozImageSmoothingEnabled": false
},
"isSelected": true,
"isVisible": true,
"isLocked": false,
"oldLayerName": null,
"menuEntry": {},
"id": "layer7",
"name": "Layer 2"
},
"layer6ImageData": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAA9VJREFUeF7tnFuO1TAQRGdWxOYQi0BsjhWBrsQVmSgPt92VVNxnfse4y1UnZQshPj / 4 Ke3AZ + nTc / gPACgOAQAAQHEHih + fBgCA4g4UPz4NAADFHSh + fBoAAIo7UPz4NAAAFHeg + PFpAAAo7kDx49MAAFDcgeLHpwEAoLgDxY9PAwBAcQeKH58GAIDiDhQ / fqkG + Pb9559o3r9 //Zjao6kPtw67B4DlHjPCUAaA0fC3mmMGIAAgeiccrH8iECUAUHz9R9w8CQQASGyA9VZPAGF6AK7++p/2VgAAYQNEGiEKala7AMCFALxG7QUHAIIgoqYKJOxuuQYhqpUGaEgramrDlqlLliFGtQJAQxRRUxu2TF/yDrJHawYEU78BekxNT1i4IQAcmDt7+EcPyghz0zYAALRhAAAbPo08ztpsz1nFFSC6AraMdWwUANgBYCSsM1NH9s757v/vcqa1Zd6UV8BISK2mjsxoCaZlTavWo70AYOVO1NQ7QYhq3QIBABau9Bp6FwS9epcgAEACAO8trgYBAJIfgRmGXglBht7pGmAkgAxDX0yOaGh5/L3XZOgFgH9uZpi5Dk8NQoZmABACoG4DANjoy96vLsPMvfru1XR2HWRopgHEDaBsAQBIaoAMI8++VkULZOimAQ7+oeZZqNHfZ0MAAA9qAMVfFgEAAAw3+PAG0RpUr++p2YwvKXKuHo1b+2foBoAL3wDLEEchyAj/pac8AFlGRhog4z2QpRsAbv4vYHqaICt8GuCm+u9pC9WfoQFubgBVsK37AgAAtLLyjHXROzXzPn2GQ19V0gA0wBO53ddMA8TypAFogBgx7qtpgFhCNAANECPGfTUNEEuIBqABYsS4r6YBYgnRADRAjBj31TRALCEagAaIEeO+mgaIJUQD0AAxYtxX0wCxhGgAGiBGDKvncmC6BpgrHv1pAEDvsfUEALCORy8OAPQeW08AAOt49OIAQO+x9QQAsI5HLw4A9B5bTwAA63j04gBA77H1BACwjkcvDgD0HltPAADrePTiAEDvsfUEALCORy8OAPQeW08AAOt49OIAQO+x9QQAsI5HLw4A9B5bTwAA63j04gBA77H1BACwjkcvDgD0HltPAADrePTiAEDvsfUEALCORy8OAPQeW08AAOt49OIAQO+x9QQAsI5HLw4A9B5bTwAA63j04gBA77H1BACwjkcvDgD0HltPAADrePTiAEDvsfUEALCORy8OAPQeW08AAOt49OIAQO+x9QQAsI5HLw4A9B5bTwAA63j04gBA77H1BACwjkcvDgD0HltPAADrePTi/gKPB0SQMNaI5gAAAABJRU5ErkJggg=="
}

View File

@ -18,8 +18,11 @@
{{> main-menu}} {{> main-menu}}
{{> tools-menu}} {{> tools-menu}}
{{> colors-menu}}
{{> layers-menu}} <div id="right-nav">
{{> colors-menu}}
{{> layers-menu}}
</div>
{{> tool-previews}} {{> tool-previews}}
{{> canvases}} {{> canvases}}

View File

@ -24,6 +24,9 @@
<button id="add-layer-button"> <button id="add-layer-button">
{{svg "plus.svg" width="20" height="20"}} Add layer {{svg "plus.svg" width="20" height="20"}} Add layer
</button> </button>
<button id="add-reference-button">
{{svg "plus.svg" width="20" height="20"}} Add reference
</button>
</li> </li>
</ul> </ul>