Skip to content

Commit

Permalink
Add separate snapping setting for ctrl + shift
Browse files Browse the repository at this point in the history
Closes #657
  • Loading branch information
JannisX11 committed Jan 10, 2021
1 parent a19c1a5 commit 612eb25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
12 changes: 4 additions & 8 deletions js/blockbench.js
Expand Up @@ -43,17 +43,13 @@ function onVueSetup(func) {
}
function canvasGridSize(shift, ctrl) {
if (!shift && !ctrl) {
return 16 / limitNumber(settings.edit_size.value, 1, 512)
return 16 / Math.clamp(settings.edit_size.value, 1, 512)
} else if (ctrl && shift) {
var basic = 16 / limitNumber(settings.edit_size.value, 1, 512)
var control = 16 / limitNumber(settings.ctrl_size.value, 1, 4096)
var shift = 16 / limitNumber(settings.shift_size.value, 1, 4096)
control = basic / control
return shift / control
return 16 / Math.clamp(settings.ctrl_shift_size.value, 1, 4096)
} else if (ctrl) {
return 16 / limitNumber(settings.ctrl_size.value, 1, 4096)
return 16 / Math.clamp(settings.ctrl_size.value, 1, 4096)
} else {
return 16 / limitNumber(settings.shift_size.value, 1, 4096)
return 16 / Math.clamp(settings.shift_size.value, 1, 4096)
}
}
function updateNslideValues() {
Expand Down
1 change: 1 addition & 0 deletions js/interface/settings.js
Expand Up @@ -165,6 +165,7 @@ const Settings = {
new Setting('edit_size', {category: 'snapping', value: 16, type: 'number'});
new Setting('shift_size', {category: 'snapping', value: 64, type: 'number'});
new Setting('ctrl_size', {category: 'snapping', value: 160, type: 'number'});
new Setting('ctrl_shift_size', {category: 'snapping', value: 640, type: 'number'});
new Setting('negative_size',{category: 'snapping', value: false});
new Setting('animation_snap',{category: 'snapping', value: 24, type: 'number'});

Expand Down
2 changes: 2 additions & 0 deletions lang/en.json
Expand Up @@ -542,6 +542,8 @@
"settings.shift_size.desc": "Resolution of the grid while holding shift",
"settings.ctrl_size": "Control Resolution",
"settings.ctrl_size.desc": "Resolution of the grid while holding control",
"settings.ctrl_shift_size": "Control + Shift Resolution",
"settings.ctrl_shift_size.desc": "Resolution of the grid while holding control and shift",
"settings.negative_size": "Negative Size",
"settings.negative_size.desc": "Allow the resize tool to use negative sizes",
"settings.animation_snap": "Animation Snap",
Expand Down

0 comments on commit 612eb25

Please sign in to comment.