Skip to content

Commit

Permalink
viliusle#61 - layers fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
viliusle committed Aug 14, 2017
1 parent d44a996 commit f3d7d61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion js/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function EDIT_CLASS() {
}
return false;
}

LAYER.layer_max_index++;
tmp = new Array();
var new_name = LAYER.generate_layer_name();
LAYER.create_canvas(new_name);
Expand Down Expand Up @@ -150,6 +150,7 @@ function EDIT_CLASS() {
return false;
}

EDIT.edit_clear();
LAYER.remove_all_layers();

if (WIDTH != layers_archive[j].width || HEIGHT != layers_archive[j].height) {
Expand Down
11 changes: 6 additions & 5 deletions js/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function LAYER_CLASS() {
/**
* latest layer index
*/
var layer_max_index = 0;
this.layer_max_index = 0;

//new layer
this.layer_new = function () {
Expand Down Expand Up @@ -56,7 +56,7 @@ function LAYER_CLASS() {
for (var i = LAYER.layers.length-1; i >= 0; i--) {
LAYER.layer_remove(i, true);
}
layer_max_index = 0;
this.layer_max_index = 0;
this.layer_renew();
};

Expand All @@ -65,12 +65,12 @@ function LAYER_CLASS() {
if(prefix == undefined)
prefix = 'Layer';

return prefix + ' #' + (layer_max_index);
return prefix + ' #' + (this.layer_max_index);
};

//create layer
this.layer_add = function (name, data, layer_type, layer_extra_info) {
layer_max_index++;
this.layer_max_index++;

if(layer_type == undefined)
layer_type = 'default';
Expand Down Expand Up @@ -182,6 +182,7 @@ function LAYER_CLASS() {
if (this.layers.length == 1 && force == undefined){
//only 1 layer left
canvas_active().clearRect(0, 0, WIDTH, HEIGHT);
GUI.redraw_preview();
return false;
}
element = document.getElementById(this.layers[i].name);
Expand All @@ -208,7 +209,7 @@ function LAYER_CLASS() {
LAYER.layer_renew();
}
else {
layer_max_index++;
this.layer_max_index++;
//copy all layer
tmp_data = document.createElement("canvas");
tmp_data.width = WIDTH;
Expand Down

0 comments on commit f3d7d61

Please sign in to comment.