diff --git a/js/interface/interface.js b/js/interface/interface.js index f6fd46b1..db9dbbab 100644 --- a/js/interface/interface.js +++ b/js/interface/interface.js @@ -919,3 +919,37 @@ onVueSetup(function() { Interface.status_bar.vue.modifier_keys[key].remove(text); }; }) + + +BARS.defineActions(function() { + + new Action('reset_layout', { + icon: 'replay', + category: 'blockbench', + click: function () { + Interface.data = $.extend(true, {}, Interface.default_data); + + for (let id in Panels) { + let panel = Panels[id]; + + if (!Interface.data.panels[id]) Interface.data.panels[id] = {}; + panel.position_data = Interface.data.panels[id]; + + let defaultp = panel.default_position || 0; + if (!panel.position_data.slot) panel.position_data.slot = defaultp.slot || 'left_bar'; + if (!panel.position_data.float_position)panel.position_data.float_position = defaultp.float_position || [0, 0]; + if (!panel.position_data.float_size) panel.position_data.float_size = defaultp.float_size || [300, 300]; + if (!panel.position_data.height) panel.position_data.height = defaultp.height || 300; + if (panel.position_data.folded == undefined) panel.position_data.folded = defaultp.folded || false; + + console.log(id, panel.slot) + panel.moveTo(panel.slot); + } + + Blockbench.dispatchEvent('reset_layout', {}); + + updateInterface(); + updateSidebarOrder(); + } + }) +}) diff --git a/js/interface/panels.js b/js/interface/panels.js index 0ac9736d..dc59127e 100644 --- a/js/interface/panels.js +++ b/js/interface/panels.js @@ -21,7 +21,7 @@ class Panel extends EventSystem { if (!Interface.data.panels[this.id]) Interface.data.panels[this.id] = {}; this.position_data = Interface.data.panels[this.id]; - let defaultp = data.default_position || 0; + let defaultp = this.default_position = data.default_position || 0; if (defaultp && defaultp.slot) this.previous_slot = defaultp.slot; if (!this.position_data.slot) this.position_data.slot = defaultp.slot || (data.default_side ? (data.default_side+'_bar') : 'left_bar'); if (!this.position_data.float_position) this.position_data.float_position = defaultp.float_position || [0, 0]; @@ -331,6 +331,9 @@ class Panel extends EventSystem { } set folded(state) { this.position_data.folded = !!state; + } + resetCustomLayout() { + } addToolbar(toolbar, position = this.toolbars.length) { let nodes = []; diff --git a/js/interface/themes.js b/js/interface/themes.js index 0e9fc3c1..0ae68155 100644 --- a/js/interface/themes.js +++ b/js/interface/themes.js @@ -513,21 +513,6 @@ BARS.defineActions(function() { }) } }) - //Only interface - new Action('reset_layout', { - icon: 'replay', - category: 'blockbench', - click: function () { - Interface.data = $.extend(true, {}, Interface.default_data) - Interface.data.left_bar.forEach((id) => { - $('#left_bar').append(Interface.Panels[id].node) - }) - Interface.data.right_bar.forEach((id) => { - $('#right_bar').append(Interface.Panels[id].node) - }) - updateInterface() - } - }) BarItems.import_theme.toElement('#layout_title_bar') BarItems.export_theme.toElement('#layout_title_bar') })