mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-03-19 17:01:55 +08:00
Option to restore default preview backgrounds
This commit is contained in:
parent
3ebf9efff7
commit
300f191f8e
@ -175,6 +175,7 @@ const Settings = {
|
||||
|
||||
//Dialogs
|
||||
new Setting('dialog_larger_cubes', {category: 'dialogs', value: true});
|
||||
new Setting('dialog_drag_background', {category: 'dialogs', value: true});
|
||||
new Setting('dialog_rotation_limit', {category: 'dialogs', value: true});
|
||||
|
||||
//Application
|
||||
|
@ -854,6 +854,19 @@ class Preview {
|
||||
this.background.x = limitNumber(this.background.x, 0, this.width-30)
|
||||
this.background.y = limitNumber(this.background.y, 0, this.height-30)
|
||||
this.loadBackground()
|
||||
Settings.saveLocalStorages()
|
||||
return this;
|
||||
}
|
||||
restoreBackground() {
|
||||
this.loadBackground()
|
||||
if (this.background && this.background.defaults) {
|
||||
this.background.image = this.background.defaults.image || false;
|
||||
this.background.size = this.background.defaults.size || 1000
|
||||
this.background.x = this.background.defaults.x || 0
|
||||
this.background.y = this.background.defaults.y || 0
|
||||
}
|
||||
this.loadBackground()
|
||||
Settings.saveLocalStorages()
|
||||
return this;
|
||||
}
|
||||
startMovingBackground() {
|
||||
@ -863,15 +876,26 @@ class Preview {
|
||||
this.movingBackground = true;
|
||||
this.controls.enabled_before = this.controls.enabled
|
||||
this.controls.enabled = false
|
||||
Blockbench.showMessageBox({
|
||||
translateKey: 'drag_background',
|
||||
icon: 'open_with'
|
||||
})
|
||||
|
||||
if (settings.dialog_drag_background.value) {
|
||||
Blockbench.showMessageBox({
|
||||
translateKey: 'drag_background',
|
||||
icon: 'open_with',
|
||||
buttons: ['dialog.ok', 'dialog.dontshowagain']
|
||||
}, function(r) {
|
||||
if (r === 1) {
|
||||
settings.dialog_drag_background.value = false
|
||||
Settings.save()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
stopMovingBackground() {
|
||||
this.movingBackground = false;
|
||||
this.controls.enabled = this.controls.enabled_before
|
||||
delete this.controls.enabled_before
|
||||
Settings.saveLocalStorages()
|
||||
return this;
|
||||
}
|
||||
backgroundPositionDialog() {
|
||||
var scope = this;
|
||||
@ -902,6 +926,7 @@ class Preview {
|
||||
if (!isNaN(coords[2])) { scope.background.size = coords[2] }
|
||||
|
||||
scope.updateBackground()
|
||||
Settings.saveLocalStorages()
|
||||
}
|
||||
})
|
||||
dialog.show()
|
||||
@ -1005,6 +1030,7 @@ class Preview {
|
||||
if (files) {
|
||||
preview.background.image = isApp ? files[0].path : files[0].content
|
||||
preview.loadBackground()
|
||||
Settings.saveLocalStorages()
|
||||
}
|
||||
}, 'image', false)
|
||||
}},
|
||||
@ -1013,6 +1039,7 @@ class Preview {
|
||||
if (image.length > 32) {
|
||||
preview.background.image = image;
|
||||
preview.loadBackground();
|
||||
Settings.saveLocalStorages()
|
||||
}
|
||||
}},
|
||||
{icon: 'photo_size_select_large', name: 'menu.preview.background.position', condition: has_background, click: function(preview) {
|
||||
@ -1031,6 +1058,10 @@ class Preview {
|
||||
}},
|
||||
{icon: 'clear', name: 'generic.remove', condition: has_background, click: function(preview) {
|
||||
preview.clearBackground()
|
||||
}},
|
||||
{icon: 'restore', name: 'generic.restore', condition: (preview) => (preview.background && preview.background.defaults.image), click: function(preview) {
|
||||
// ToDo: condition, save local storage, name and icon
|
||||
preview.restoreBackground()
|
||||
}}
|
||||
]
|
||||
}},
|
||||
@ -1387,6 +1418,7 @@ function initCanvas() {
|
||||
this.x = data.x||0
|
||||
this.y = data.y||0
|
||||
this.lock = data.lock||false
|
||||
this.defaults = Object.assign({}, this);
|
||||
}
|
||||
|
||||
canvas_scenes = {
|
||||
|
@ -42,6 +42,8 @@
|
||||
"generic.enable": "Enable",
|
||||
"generic.disable": "Disable",
|
||||
"generic.redacted": "Redacted",
|
||||
"generic.reset": "Reset",
|
||||
"generic.restore": "Restore",
|
||||
|
||||
"dates.today": "Today",
|
||||
"dates.yesterday": "Yesterday",
|
||||
@ -534,6 +536,8 @@
|
||||
|
||||
"settings.dialog_larger_cubes": "Model Too Large",
|
||||
"settings.dialog_larger_cubes.desc": "Show \"Model Too Large\" dialog",
|
||||
"settings.dialog_drag_background": "Position Background",
|
||||
"settings.dialog_drag_background.desc": "Show \"Position Background\" dialog",
|
||||
"settings.dialog_rotation_limit": "Rotation Limits",
|
||||
"settings.dialog_rotation_limit.desc": "Show \"Rotation Limits\" dialog",
|
||||
|
||||
|
@ -200,8 +200,6 @@ THREE.GridHelper = class GridHelper extends THREE.LineSegments {
|
||||
|
||||
constructor( size, divisions, color1, color2 ) {
|
||||
|
||||
console.log({size, divisions, color1, color2})
|
||||
|
||||
size = size || 10;
|
||||
divisions = divisions || 10;
|
||||
color1 = new THREE.Color( color1 !== undefined ? color1 : 0x444444 );
|
||||
@ -241,8 +239,6 @@ THREE.GridHelper = class GridHelper extends THREE.LineSegments {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
THREE.NormalX = new THREE.Vector3(1, 0, 0);
|
||||
THREE.NormalY = new THREE.Vector3(0, 1, 0);
|
||||
THREE.NormalZ = new THREE.Vector3(0, 0, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user