Add recent thumbnails for image projects

Open new image project when selecting Texture skin preset
DIsable brush outline while zooming in UV editor
Add attachables to description of bedrock enttiy format
This commit is contained in:
JannisX11 2022-10-09 19:39:58 +02:00
parent d935198fc2
commit 6debfd32db
4 changed files with 68 additions and 27 deletions

View File

@ -175,10 +175,40 @@ function updateRecentProjectData() {
updateRecentProjects()
}
async function updateRecentProjectThumbnail() {
if (Outliner.elements.length == 0) return;
let project = Project.getProjectMemory();
if (!project) return;
let thumbnail;
if (Format.id == 'image' && Texture.all.length) {
await new Promise((resolve, reject) => {
let tex = Texture.getDefault();
let frame = new CanvasFrame(180, 100);
frame.ctx.imageSmoothingEnabled = false;
let {width, height} = tex;
if (width > 180) {height /= width / 180; width = 180;}
if (height > 100) {width /= height / 100; height = 100;}
if (width < 180 && height < 100) {
let factor = Math.min(180 / width, 100 / height);
factor *= 0.92;
height *= factor; width *= factor;
}
frame.ctx.drawImage(tex.img, (180 - width)/2, (100 - height)/2, width, height)
let url = frame.canvas.toDataURL();
let hash = project.path.hashCode().toString().replace(/^-/, '0');
let path = PathModule.join(app.getPath('userData'), 'thumbnails', `${hash}.png`)
thumbnail = url;
Blockbench.writeFile(path, {
savetype: 'image',
content: url
}, resolve)
})
} else {
if (Outliner.elements.length == 0) return;
MediaPreview.resize(180, 100)
MediaPreview.loadAnglePreset(DefaultCameraPresets[0])
MediaPreview.setFOV(30);
@ -190,7 +220,6 @@ async function updateRecentProjectThumbnail() {
let size = Math.max(box[0], box[1]*2)
MediaPreview.camera.position.multiplyScalar(size/50)
let thumbnail;
await new Promise((resolve, reject) => {
MediaPreview.screenshot({crop: false}, url => {
let hash = project.path.hashCode().toString().replace(/^-/, '0');
@ -205,6 +234,7 @@ async function updateRecentProjectThumbnail() {
project.path = store_path;
})
})
}
Blockbench.dispatchEvent('update_recent_project_thumbnail', {data: project, thumbnail});
StartScreen.vue.updateThumbnails([project.path]);

View File

@ -271,15 +271,24 @@ const skin_dialog = new Dialog({
},
draggable: true,
onConfirm(result) {
if (result.model == 'flat_texture') {
if (newProject(Formats.image)) {
if (result.texture) {
new Texture().fromPath(result.texture).add(false);
} else {
TextureGenerator.addBitmapDialog();
}
}
} else {
if (newProject(format)) {
let preset = skin_presets[result.model];
let model = JSON.parse(preset.model || (result.variant == 'java_edition' ? preset.model_java : preset.model_bedrock));
codec.parse(model, result.resolution/16, result.texture, result.pose, result.layer_template);
}
this.hide();
}
},
onCancel() {
this.hide();
Format = 0;
}
});

View File

@ -1969,8 +1969,10 @@ Interface.definePanels(function() {
if (this.zoom == 1 && Panels.uv.isInSidebar() && diagonal_offset/UVEditor.width < 0.12) {
this.centerView();
}
this.updateMouseCoords(event)
//if (Painter.selection.overlay) UVEditor.updatePastingOverlay()
if (this.mode == 'paint') {
this.mouse_coords.x = -1;
}
}
if (n > 0) {
Vue.nextTick(updateScroll);

View File

@ -118,7 +118,7 @@
"format.java_block.info.animation": "This format does not support animations in vanilla Minecraft. If you are creating a mod, you can use GeckoLib to animate models. If not, the only way to animate is to switch out the model using commands or animated textures.",
"format.bedrock": "Bedrock Entity",
"format.bedrock.desc": "Entity model for Minecraft Bedrock Edition",
"format.bedrock.desc": "Minecraft Bedrock Edition model for entities and item attachables",
"format.bedrock.info.textures": "Each model can only have one texture",
"format.bedrock_block": "Bedrock Block",