Tried fixing pan bug

If you load an LPE file, the pan tool screws up
This commit is contained in:
unsettledgames 2021-07-15 23:30:55 +02:00
parent 06d9536895
commit 68dbbdc4c3
3 changed files with 5 additions and 15 deletions

View File

@ -153,7 +153,6 @@ const FileManager = (() => {
// Converting the data to a json object and creating a new pixel (see _newPixel.js for more)
reader.onload = function (e) {
let dictionary = JSON.parse(e.target.result);
let mode = dictionary['editorMode'];
Startup.newPixel(dictionary['canvasWidth'], dictionary['canvasHeight'], dictionary);
}
}

View File

@ -6,7 +6,7 @@ const Startup = (() => {
Input.on('click', 'create-button', create, false);
Input.on('click', 'create-button-splash', create, true);
function create(e, isSplash) {
function create(isSplash) {
// If I'm creating from the splash menu, I append '-splash' so I get the corresponding values
if (isSplash) {
splashPostfix = '-splash';
@ -34,14 +34,6 @@ const Startup = (() => {
ga('send', 'event', 'Pixel Editor New', selectedPalette, width+'/'+height); /*global ga*/
}
/** TODO:
* - Remove firstPixel: it's enough to pass to newPixel whether it's been called from the splash page or not
* - Divide functions depending on their purpose:
* - initLayers()
* - initPalette()
* - openLPE()
*/
/** Creates a new, empty file
*
* @param {*} width Start width of the canvas
@ -73,7 +65,7 @@ const Startup = (() => {
// Now, if I opened an LPE file
if (fileContent != null) {
loadLPE(fileContent);
loadFromLPE(fileContent);
// Deleting the default layer
deleteLayer(false);
}
@ -196,8 +188,7 @@ const Startup = (() => {
}
}
// REFACTOR: should probably moved to a FileManagement class or something
function loadLPE(fileContent) {
function loadFromLPE(fileContent) {
// I add every layer the file had in it
for (let i=0; i<fileContent['nLayers']; i++) {
let layerData = fileContent['layer' + i];
@ -247,7 +238,7 @@ const Startup = (() => {
const presetProperties = PresetModule.propertiesOf(preset);
Util.setText('palette-button-splash', presetProperties.palette);
Util.setText('palette-button', presetProperties.palette);
x = presetProperties.width;
y = presetProperties.height;
}

View File

@ -397,7 +397,7 @@ function deleteLayer(saveHistory = true) {
layers[layerIndex + 1].selectLayer();
}
// or the previous one if the next one doesn't exist
else if (layerIndex != 1) {
else {
layers[layerIndex - 1].selectLayer();
}