Select all + select none buttons when importing anims

Dialog API to set form values
Add alt text to logo graphics
This commit is contained in:
JannisX11 2021-08-18 13:59:01 +02:00
parent 773c6c7986
commit 74f578d3c8
9 changed files with 81 additions and 7 deletions

View File

@ -588,6 +588,16 @@
width: 73px;
border: none;
}
dialog a.button_select_all,
dialog a.button_select_none {
text-decoration: underline;
cursor: pointer;
margin-right: 8px;
}
dialog a.button_select_all:hover,
dialog a.button_select_none:hover {
color: var(--color-accent);
}
/*Scale*/
#model_scale_range {
width: calc(100% - 50px);

View File

@ -357,7 +357,7 @@
<header>
<ul id="mac_window_menu" hidden></ul>
<div id="corner_logo" class="app-drag-region">
<img src="assets/logo_text_white.svg" />
<img src="assets/logo_text_white.svg" alt="Blockbench" />
</div>
<ul id="menu_bar" class="scroll_horizontal"></ul>
<div class="app-drag-region" id="header_free_bar"></div>

View File

@ -1670,8 +1670,14 @@ const Animator = {
id: 'animation_import',
title: 'dialog.animation_import.title',
form,
lines: [
`<div>
<a class="button_select_all">${tl('generic.select_all')}</a>
<a class="button_select_none">${tl('generic.select_none')}</a>
</div>`
],
onConfirm(form_result) {
dialog.hide();
this.hide();
let names = [];
for (var key of keys) {
if (form_result[key.hashCode()]) {
@ -1682,8 +1688,15 @@ const Animator = {
let new_animations = Animator.loadFile(file, names);
Undo.finishEdit('Import animations', {animations: new_animations})
}
})
dialog.show();
}).show();
function setAll(value) {
let values = {};
keys.forEach(key => values[key.hashCode()] = value);
dialog.setFormValues(values);
}
dialog.object.querySelector('a.button_select_all').addEventListener('click', e => setAll(true));
dialog.object.querySelector('a.button_select_none').addEventListener('click', e => setAll(false));
}
},
exportAnimationFile(path) {

View File

@ -274,7 +274,7 @@ BARS.defineActions(() => {
template: `
<div>
<div id="about_page_title">
<img src="assets/logo_text_white.svg" width="240px">
<img src="assets/logo_text_white.svg" alt="Blockbench" width="240px">
</div>
<p><b>${tl('about.version')}</b> <span>{{ version_label }}</span></p>
<p><b>${tl('about.creator')}</b> JannisX11</p>

View File

@ -157,7 +157,7 @@ function addRecentProject(data) {
day: new Date().dayOfYear()
}
recent_projects.splice(0, 0, project)
app.addRecentDocument(data.path)
ipcRenderer.send('add-recent-project', data.path);
if (recent_projects.length > Math.clamp(settings.recent_projects.value, 0, 256)) {
recent_projects.pop()
}

View File

@ -427,6 +427,52 @@ window.Dialog = class Dialog {
this.onFormChange(form_result)
}
}
setFormValues(values) {
for (var form_id in this.form) {
let data = this.form[form_id];
if (values[form_id] != undefined && typeof data == 'object' && data.bar) {
let value = values[form_id];
switch (data.type) {
default:
data.bar.find('input').val(value);
break;
case 'info':
break;
case 'textarea':
data.bar.find('textarea').val(value);
break;
case 'select':
data.bar.find('select').val(value);
break;
case 'radio':
data.bar.find('.form_part_radio input#'+value).prop('checked', value);
break;
case 'number':
data.bar.find('input').val(value);
break;
case 'vector':
for (var i = 0; i < (data.dimensions || 3); i++) {
data.bar.find(`input#${form_id}_${i}`).val(value[i])
}
break;
case 'color':
data.colorpicker.set(value);
break;
case 'checkbox':
data.bar.find('input').prop('checked', value);
break;
case 'file':
if (isApp) {
data.value = value;
} else {
data.content = value;
}
break;
}
}
}
this.updateFormValues();
}
getFormResult() {
var result = {}
if (this.form) {

File diff suppressed because one or more lines are too long

View File

@ -50,6 +50,8 @@
"generic.redacted": "Redacted",
"generic.reset": "Reset",
"generic.restore": "Restore",
"generic.select_all": "Select All",
"generic.select_none": "Select None",
"dates.today": "Today",
"dates.yesterday": "Yesterday",

View File

@ -174,6 +174,9 @@ ipcMain.on('change-main-color', (event, arg) => {
ipcMain.on('edit-launch-setting', (event, arg) => {
LaunchSettings.set(arg.key, arg.value);
})
ipcMain.on('add-recent-project', (event, path) => {
app.addRecentDocument(path);
})
ipcMain.on('request-color-picker', async (event, arg) => {
const color = await getColorHexRGB().catch((error) => {
console.warn('[Error] Failed to pick color', error)