mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-27 04:21:46 +08:00
Fix Reset Layout not working with new panel system
This commit is contained in:
parent
2d792137e1
commit
8cd1ec1e07
@ -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();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -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 = [];
|
||||
|
@ -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')
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user