JSON indentation setting

Closes #1407
This commit is contained in:
JannisX11 2023-05-31 21:36:50 +02:00
parent e90771e39f
commit 78c27ebdf8
4 changed files with 21 additions and 4 deletions

View File

@ -530,6 +530,11 @@ const Settings = {
new Setting('hardware_acceleration', {category: 'application', value: true, condition: isApp, launch_setting: true});
//Export
new Setting('json_indentation', {category: 'export', value: 'tabs', type: 'select', options: {
tabs: tl('settings.json_indentation.tabs'),
spaces_4: tl('settings.json_indentation.spaces_4'),
spaces_2: tl('settings.json_indentation.spaces_2'),
}});
new Setting('minifiedout', {category: 'export', value: false});
new Setting('embed_textures', {category: 'export', value: true});
new Setting('minify_bbmodel', {category: 'export', value: true});

View File

@ -426,13 +426,20 @@ const Extruder = {
}
}
//Json
function compileJSON(object, options) {
if (typeof options !== 'object') options = {}
function compileJSON(object, options = {}) {
let indentation = options.indentation;
if (typeof indentation !== 'string') {
switch (settings.json_indentation.value) {
case 'spaces_4': indentation = ' '; break;
case 'spaces_2': indentation = ' '; break;
case 'tabs': default: indentation = '\t'; break;
}
}
function newLine(tabs) {
if (options.small === true) {return '';}
var s = '\n'
for (var i = 0; i < tabs; i++) {
s += '\t'
s += indentation;
}
return s;
}

File diff suppressed because one or more lines are too long

View File

@ -918,6 +918,11 @@
"settings.dialog.desc": "Show the \"%0\" dialog",
"settings.json_indentation": "JSON Indentation",
"settings.json_indentation.desc": "Indentation style for exported JSON files",
"settings.json_indentation.tabs": "Tabs",
"settings.json_indentation.spaces_4": "Spaces: 4",
"settings.json_indentation.spaces_2": "Spaces: 2",
"settings.minifiedout": "Minified Export",
"settings.minifiedout.desc": "Write JSON file in one line",
"settings.minify_bbmodel": "Minified Project Files",