Fix texture template generator issues

This commit is contained in:
JannisX11 2020-07-18 13:31:46 +02:00
parent 0c7a9c3a67
commit 49da439264
4 changed files with 25 additions and 9 deletions

View File

@ -172,7 +172,7 @@ const Painter = {
Painter.colorPicker(texture, x, y)
} else if (Toolbox.selected.id === 'draw_shape_tool') {
Undo.initEdit({textures: [texture], bitmap: true});
Undo.initEdit({textures: [texture], selected_texture: true, bitmap: true});
Painter.brushChanges = false;
Painter.painting = true;
Painter.current = {
@ -187,7 +187,7 @@ const Painter = {
Painter.current.clear.getContext('2d').drawImage(texture.img, 0, 0);
} else {
Undo.initEdit({textures: [texture], bitmap: true});
Undo.initEdit({textures: [texture], selected_texture: true, bitmap: true});
Painter.brushChanges = false;
Painter.painting = true;

View File

@ -106,15 +106,16 @@ const TextureGenerator = {
after(texture)
}
if (!options.template) {
Undo.finishEdit('create blank texture', {textures: [texture], bitmap: true})
Undo.finishEdit('create blank texture', {textures: [texture], selected_texture: true, bitmap: true})
}
return texture;
}
if (options.template === true) {
Undo.initEdit({
textures: Format.single_texture ? textures : [],
textures: [],
elements: Format.single_texture ? Cube.all : Cube.selected,
uv_only: true,
selected_texture: true,
uv_mode: true
})
if (Project.box_uv || options.box_uv) {
@ -123,7 +124,7 @@ const TextureGenerator = {
TextureGenerator.generateFaceTemplate(options, makeTexture)
}
} else {
Undo.initEdit({textures: []})
Undo.initEdit({textures: [], selected_texture: true})
TextureGenerator.generateBlank(options.resolution, options.resolution, options.color, makeTexture)
}
},
@ -356,6 +357,7 @@ const TextureGenerator = {
textures: [texture],
bitmap: true,
elements: cubes,
selected_texture: true,
uv_only: true,
uv_mode: true
})
@ -455,7 +457,7 @@ const TextureGenerator = {
for (var face in TextureGenerator.face_data) {
let d = TextureGenerator.face_data[face]
if (!cube.faces[face].texture ||
if (!cube.faces[face].getTexture() ||
!TextureGenerator.boxUVdrawTexture(cube.faces[face], d.place(template), texture, canvas)
) {
TextureGenerator.boxUVdrawTemplateRectangle(d.c1, transparent ? null : d.c2, cube.faces[face], d.place(template), texture, canvas)
@ -744,6 +746,7 @@ const TextureGenerator = {
textures: [texture],
bitmap: true,
elements: cube_array,
selected_texture: true,
uv_only: true,
uv_mode: true
})

View File

@ -685,7 +685,7 @@ class Texture {
return;
}
Undo.initEdit({textures: [scope]})
Undo.initEdit({textures: [scope], selected_texture: true})
scope.name = results.name;
if (results.variable !== undefined) scope.id = results.variable;
@ -981,9 +981,9 @@ class Texture {
icon: 'delete',
name: 'generic.delete',
click: function(texture) {
Undo.initEdit({textures: [texture], bitmap: true})
Undo.initEdit({textures: [texture], selected_texture: true, bitmap: true})
texture.remove()
Undo.initEdit({textures: [], bitmap: true})
Undo.finishEdit('delete texture', {textures: [], selected_texture: true, bitmap: true})
}},
'_',
{

View File

@ -130,6 +130,8 @@ var Undo = {
var scope = this;
this.aspects = aspects;
templog(aspects)
if (aspects.selection) {
this.selection = []
selected.forEach(function(obj) {
@ -170,6 +172,10 @@ var Undo = {
})
}
if (aspects.selected_texture && Texture.all.length) {
this.selected_texture = Texture.selected ? Texture.selected.uuid : null;
}
if (aspects.settings) {
this.settings = aspects.settings
}
@ -343,6 +349,13 @@ var Undo = {
Canvas.updateLayeredTextures()
}
if (save.selected_texture) {
let tex = Texture.all.find(tex => tex.uuid == save.selected_texture);
if (tex instanceof Texture) tex.select()
} else if (save.selected_texture == null) {
unselectTextures()
}
if (save.settings) {
for (var key in save.settings) {
settings[key].value = save.settings[key]