mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-27 04:21:46 +08:00
Fix texture template generator issues
This commit is contained in:
parent
0c7a9c3a67
commit
49da439264
@ -172,7 +172,7 @@ const Painter = {
|
|||||||
Painter.colorPicker(texture, x, y)
|
Painter.colorPicker(texture, x, y)
|
||||||
} else if (Toolbox.selected.id === 'draw_shape_tool') {
|
} 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.brushChanges = false;
|
||||||
Painter.painting = true;
|
Painter.painting = true;
|
||||||
Painter.current = {
|
Painter.current = {
|
||||||
@ -187,7 +187,7 @@ const Painter = {
|
|||||||
Painter.current.clear.getContext('2d').drawImage(texture.img, 0, 0);
|
Painter.current.clear.getContext('2d').drawImage(texture.img, 0, 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Undo.initEdit({textures: [texture], bitmap: true});
|
Undo.initEdit({textures: [texture], selected_texture: true, bitmap: true});
|
||||||
Painter.brushChanges = false;
|
Painter.brushChanges = false;
|
||||||
Painter.painting = true;
|
Painter.painting = true;
|
||||||
|
|
||||||
|
@ -106,15 +106,16 @@ const TextureGenerator = {
|
|||||||
after(texture)
|
after(texture)
|
||||||
}
|
}
|
||||||
if (!options.template) {
|
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;
|
return texture;
|
||||||
}
|
}
|
||||||
if (options.template === true) {
|
if (options.template === true) {
|
||||||
Undo.initEdit({
|
Undo.initEdit({
|
||||||
textures: Format.single_texture ? textures : [],
|
textures: [],
|
||||||
elements: Format.single_texture ? Cube.all : Cube.selected,
|
elements: Format.single_texture ? Cube.all : Cube.selected,
|
||||||
uv_only: true,
|
uv_only: true,
|
||||||
|
selected_texture: true,
|
||||||
uv_mode: true
|
uv_mode: true
|
||||||
})
|
})
|
||||||
if (Project.box_uv || options.box_uv) {
|
if (Project.box_uv || options.box_uv) {
|
||||||
@ -123,7 +124,7 @@ const TextureGenerator = {
|
|||||||
TextureGenerator.generateFaceTemplate(options, makeTexture)
|
TextureGenerator.generateFaceTemplate(options, makeTexture)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Undo.initEdit({textures: []})
|
Undo.initEdit({textures: [], selected_texture: true})
|
||||||
TextureGenerator.generateBlank(options.resolution, options.resolution, options.color, makeTexture)
|
TextureGenerator.generateBlank(options.resolution, options.resolution, options.color, makeTexture)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -356,6 +357,7 @@ const TextureGenerator = {
|
|||||||
textures: [texture],
|
textures: [texture],
|
||||||
bitmap: true,
|
bitmap: true,
|
||||||
elements: cubes,
|
elements: cubes,
|
||||||
|
selected_texture: true,
|
||||||
uv_only: true,
|
uv_only: true,
|
||||||
uv_mode: true
|
uv_mode: true
|
||||||
})
|
})
|
||||||
@ -455,7 +457,7 @@ const TextureGenerator = {
|
|||||||
for (var face in TextureGenerator.face_data) {
|
for (var face in TextureGenerator.face_data) {
|
||||||
let d = TextureGenerator.face_data[face]
|
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.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)
|
TextureGenerator.boxUVdrawTemplateRectangle(d.c1, transparent ? null : d.c2, cube.faces[face], d.place(template), texture, canvas)
|
||||||
@ -744,6 +746,7 @@ const TextureGenerator = {
|
|||||||
textures: [texture],
|
textures: [texture],
|
||||||
bitmap: true,
|
bitmap: true,
|
||||||
elements: cube_array,
|
elements: cube_array,
|
||||||
|
selected_texture: true,
|
||||||
uv_only: true,
|
uv_only: true,
|
||||||
uv_mode: true
|
uv_mode: true
|
||||||
})
|
})
|
||||||
|
@ -685,7 +685,7 @@ class Texture {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Undo.initEdit({textures: [scope]})
|
Undo.initEdit({textures: [scope], selected_texture: true})
|
||||||
|
|
||||||
scope.name = results.name;
|
scope.name = results.name;
|
||||||
if (results.variable !== undefined) scope.id = results.variable;
|
if (results.variable !== undefined) scope.id = results.variable;
|
||||||
@ -981,9 +981,9 @@ class Texture {
|
|||||||
icon: 'delete',
|
icon: 'delete',
|
||||||
name: 'generic.delete',
|
name: 'generic.delete',
|
||||||
click: function(texture) {
|
click: function(texture) {
|
||||||
Undo.initEdit({textures: [texture], bitmap: true})
|
Undo.initEdit({textures: [texture], selected_texture: true, bitmap: true})
|
||||||
texture.remove()
|
texture.remove()
|
||||||
Undo.initEdit({textures: [], bitmap: true})
|
Undo.finishEdit('delete texture', {textures: [], selected_texture: true, bitmap: true})
|
||||||
}},
|
}},
|
||||||
'_',
|
'_',
|
||||||
{
|
{
|
||||||
|
13
js/undo.js
13
js/undo.js
@ -130,6 +130,8 @@ var Undo = {
|
|||||||
var scope = this;
|
var scope = this;
|
||||||
this.aspects = aspects;
|
this.aspects = aspects;
|
||||||
|
|
||||||
|
templog(aspects)
|
||||||
|
|
||||||
if (aspects.selection) {
|
if (aspects.selection) {
|
||||||
this.selection = []
|
this.selection = []
|
||||||
selected.forEach(function(obj) {
|
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) {
|
if (aspects.settings) {
|
||||||
this.settings = aspects.settings
|
this.settings = aspects.settings
|
||||||
}
|
}
|
||||||
@ -343,6 +349,13 @@ var Undo = {
|
|||||||
Canvas.updateLayeredTextures()
|
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) {
|
if (save.settings) {
|
||||||
for (var key in save.settings) {
|
for (var key in save.settings) {
|
||||||
settings[key].value = save.settings[key]
|
settings[key].value = save.settings[key]
|
||||||
|
Loading…
Reference in New Issue
Block a user