Fix edit sessions not working in webapp

Edit sessions now run over https
Fix issue with toggles and linked settings
Background rendering now respects mouse hovering over preview
This commit is contained in:
JannisX11 2021-02-25 22:18:34 +01:00
parent 5a3e02e8ae
commit 74c8ef8402
5 changed files with 10 additions and 20 deletions

View File

@ -13,7 +13,7 @@ const EditSession = {
host: EditSession.ip,
port: 9000,
path: '/sessions',
secure: false
secure: true
});
EditSession.username = $('#edit_session_username').val() || EditSession.placeholder_names.random();
settings.username.value = EditSession.username;
@ -74,7 +74,7 @@ const EditSession = {
host: EditSession.ip,
port: 9000,
path: '/sessions',
secure: false
secure: true
});
EditSession.peer.on('open', function() {

View File

@ -277,20 +277,6 @@ class Action extends BarItem {
$(n).find('.icon').replaceWith($(scope.icon_node).clone())
})
}
toggleLinkedSetting(change) {
if (this.linked_setting && settings[this.linked_setting]) {
let setting = settings[this.linked_setting];
if (change !== false) {
setting.value = !setting.value
}
if (this.icon_states) {
this.setIcon(setting.value ? this.icon_states[1] : this.icon_states[0]);
} else {
this.setIcon(setting.value ? 'check_box' : 'check_box_outline_blank');
}
if (setting.onChange) setting.onChange(setting.value)
}
}
delete() {
super.delete();
for (var i = this.menus.length-1; i >= 0; i--) {
@ -413,6 +399,7 @@ class Toggle extends Action {
let setting = settings[this.linked_setting];
setting.value = this.value;
if (setting.onChange) setting.onChange(setting.value);
Settings.saveLocalStorages();
}
if (this.onChange) this.onChange(this.value);

View File

@ -265,7 +265,10 @@ const Settings = {
for (var key in BarItems) {
var action = BarItems[key]
if (action.linked_setting) {
action.toggleLinkedSetting(false)
if (settings[action.linked_setting] && action.value != settings[action.linked_setting].value) {
action.value = settings[action.linked_setting].value;
action.updateEnabledState();
}
}
}
if (hasSettingChanged('base_grid') || hasSettingChanged('large_grid') || hasSettingChanged('full_grid') || hasSettingChanged('large_grid_size')
@ -377,7 +380,7 @@ onVueSetup(function() {
},
methods: {
saveSettings() {
localStorage.setItem('settings', JSON.stringify(settings))
Settings.saveLocalStorages();
},
toggleCategory(category) {
if (!category.open) {

View File

@ -1848,7 +1848,7 @@ function initCanvas() {
}
function animate() {
requestAnimationFrame( animate );
if (!settings.background_rendering.value && !document.hasFocus()) return;
if (!settings.background_rendering.value && !document.hasFocus() && !document.querySelector('#preview:hover')) return;
TickUpdates.Run();
if (Animator.open && Timeline.playing) {

View File

@ -501,7 +501,7 @@
"settings.brightness": "Brightness",
"settings.brightness.desc": "Brightness of the preview. Default is 50",
"settings.shading": "Shading",
"settings.shading.desc": "Enable shading",
"settings.shading.desc": "Enable shading in the preview",
"settings.antialiasing": "Anti-aliasing",
"settings.antialiasing.desc": "Toggle anti-aliasing in the preview. Restart Blockbench to apply changes",
"settings.render_sides": "Render Sides",