mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-01-18 15:26:19 +08:00
Reference image web search and improvements
Auto enable template generator padding on meshes
This commit is contained in:
parent
a772b10e93
commit
88a23577ac
@ -992,12 +992,12 @@
|
||||
margin: auto;
|
||||
height: auto;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
right: -150px;
|
||||
left: -150px;
|
||||
background-color: var(--color-ui);
|
||||
max-width: fit-content;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.toolbar[toolbar_id=reference_images] {
|
||||
|
@ -887,6 +887,98 @@ BARS.defineActions(function() {
|
||||
return list;
|
||||
}
|
||||
});
|
||||
new Action('search_reference_image', {
|
||||
icon: 'image_search',
|
||||
category: 'view',
|
||||
condition: isApp,
|
||||
async click() {
|
||||
if (!ReferenceImageMode.active) {
|
||||
ReferenceImageMode.activate()
|
||||
}
|
||||
|
||||
let win = new electron.BrowserWindow({
|
||||
icon: 'icon.ico',
|
||||
modal: true,
|
||||
parent: currentwindow,
|
||||
width: 1080,
|
||||
height: 720,
|
||||
menuBarVisible: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true
|
||||
}
|
||||
})
|
||||
if (process.platform !== 'darwin') {
|
||||
win.setMenu(null);
|
||||
}
|
||||
let { getCursorScreenPoint, getDisplayNearestPoint } = electron.screen;
|
||||
let currentScreen = getDisplayNearestPoint(getCursorScreenPoint());
|
||||
win.setBounds(currentScreen.workArea);
|
||||
|
||||
win.loadURL('https://google.com/images');
|
||||
|
||||
win.webContents.setWindowOpenHandler(details => ({action: 'deny'}));
|
||||
win.webContents.openDevTools()
|
||||
|
||||
function addButton() {
|
||||
win.webContents.insertCSS(`
|
||||
#blockbench_load_reference {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: auto;
|
||||
appearance: none;
|
||||
border: none;
|
||||
background-color: #3e90ff;
|
||||
color: black;
|
||||
width: 160px;
|
||||
font-family: "segoe ui", roboto, sans-serif;
|
||||
font-weight: normal;
|
||||
height: 40px;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
box-shadow: 2px 2px 20px rgba(0, 0, 0, 60%);
|
||||
}
|
||||
#blockbench_load_reference:hover {
|
||||
color: #ffffff;
|
||||
}
|
||||
`)
|
||||
win.webContents.executeJavaScript(`
|
||||
let button = document.createElement('button');
|
||||
button.id = 'blockbench_load_reference';
|
||||
button.textContent = 'Load Image';
|
||||
button.onclick = event => {
|
||||
let img;
|
||||
document.querySelectorAll('c-wiz > div > div > div > div > div > a > img').forEach(node => {
|
||||
if (node.checkVisibility()) img = node;
|
||||
});
|
||||
if (img && img.src) {
|
||||
location.assign(img.src);
|
||||
}
|
||||
};
|
||||
document.body.append(button);
|
||||
`);
|
||||
}
|
||||
|
||||
win.webContents.on('did-stop-loading', () => {
|
||||
try {
|
||||
addButton();
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
})
|
||||
win.webContents.on('did-navigate', (event, url) => {
|
||||
|
||||
if (url.match(/\.(png|gif|jpg|jpeg|tif|tiff)($|\?|\/)/i)) {
|
||||
ReferenceImageMode.importReferences([{content: url, name: win.webContents.getTitle().substring(0, 24)}]);
|
||||
win.close();
|
||||
} else if (!url.includes('google.com/')) {
|
||||
win.close();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
Interface.definePanels(function() {
|
||||
|
@ -54,7 +54,7 @@ const TextureGenerator = {
|
||||
combine_polys: {label: 'dialog.create_texture.combine_polys', description: 'dialog.create_texture.combine_polys.desc', type: 'checkbox', value: true, condition: (form) => (form.type == 'template' && form.rearrange_uv && Mesh.selected.length)},
|
||||
max_edge_angle: {label: 'dialog.create_texture.max_edge_angle', description: 'dialog.create_texture.max_edge_angle.desc', type: 'number', value: 36, condition: (form) => (form.type == 'template' && form.rearrange_uv && Mesh.selected.length)},
|
||||
max_island_angle: {label: 'dialog.create_texture.max_island_angle', description: 'dialog.create_texture.max_island_angle.desc', type: 'number', value: 45, condition: (form) => (form.type == 'template' && form.rearrange_uv && Mesh.selected.length)},
|
||||
padding: {label: 'dialog.create_texture.padding', description: 'dialog.create_texture.padding.desc', type: 'checkbox', value: false, condition: (form) => (form.type == 'template' && form.rearrange_uv)},
|
||||
padding: {label: 'dialog.create_texture.padding', description: 'dialog.create_texture.padding.desc', type: 'checkbox', value: Mesh.selected.length > 0, condition: (form) => (form.type == 'template' && form.rearrange_uv)},
|
||||
|
||||
},
|
||||
onFormChange(form) {
|
||||
|
Loading…
Reference in New Issue
Block a user