Add description for using numeration in multi rename

This commit is contained in:
JannisX11 2024-10-11 23:12:11 +02:00
parent bec1558be1
commit 8d7f444a7b
4 changed files with 34 additions and 7 deletions

View File

@ -209,14 +209,35 @@ const Blockbench = {
showMessageBox(options = 0, cb) {
return new MessageBox(options, cb).show();
},
async textPrompt(title, value, callback, placeholder = null) {
/**
*
* @param {*} title
* @param {*} value
* @param {*} callback
* @param {object} options Options
* @param {string} options.info Info text
* @param {string} options.description Description for the text input
* @returns {Promise<string>} Input value
*/
async textPrompt(title, value, callback, options = 0) {
if (typeof options == 'string') {
options = {placeholder: options};
console.warn('textPrompt: 4th argument is expected to be a string');
}
let answer = await new Promise((resolve) => {
let form = {
text: {full_width: true, placeholder: options.placeholder, value, description: options.description}
};
if (options.info) {
form.description = {
type: 'info',
text: tl(options.info)
}
}
new Dialog({
id: 'text_input',
title: title || 'dialog.input.title',
form: {
text: {full_width: true, placeholder, value}
},
form,
onConfirm({text}) {
if (callback) callback(text);
resolve(text);

View File

@ -676,7 +676,7 @@ BARS.defineActions(function() {
Blockbench.showQuickMessage('message.invalid_link')
})
}
}, 'https://blckbn.ch/123abc')
}, {placeholder: 'https://blckbn.ch/123abc'});
}
})
new Action('extrude_texture', {

View File

@ -952,11 +952,15 @@ function renameOutliner(element) {
if (name) {
Undo.initEdit({elements: selected})
selected.forEach(function(obj, i) {
obj.name = name.replace(/%/g, obj.index).replace(/\$/g, i)
obj.name = name.replace(/%+/g, val => {
return (obj.getParentArray().indexOf(obj)+1).toDigitString(val.length)
}).replace(/\$+/g, val => {
return (i+1).toDigitString(val.length)
});
})
Undo.finishEdit('Rename')
}
})
}, {description: tl('message.rename_elements.numbering')})
}
}
}

View File

@ -420,6 +420,8 @@
"message.invalid_session.title": "Invalid Session Token",
"message.invalid_session.message": "The session you are trying to join has expired or the token provided is invalid.",
"message.rename_elements.numbering": "You can use special characters to generate sequential numbers: % to get the index of the element within its group, $ to get the index within the selection.",
"dialog.project.title": "Project",
"dialog.project.name": "File Name",
"dialog.project.parent": "Parent Model",