Save selected tool when switching modes

This commit is contained in:
JannisX11 2022-10-29 17:25:33 +02:00
parent 8af0c8e3d4
commit 7a3f948a3d
5 changed files with 11 additions and 7 deletions

View File

@ -390,6 +390,9 @@ class Tool extends Action {
Toolbox.selected = this;
delete Toolbox.original;
this.uses++;
if (Project) {
Project.tool = Mode.selected.tool = this.id;
}
if (this.transformerMode) {
Transformer.setMode(this.transformerMode)

View File

@ -143,8 +143,6 @@ class ModelProject {
}
}
saveEditorState() {
this.tool = Toolbox.selected.id;
UVEditor.saveViewportOffset();
Preview.all.forEach(preview => {

View File

@ -67,10 +67,12 @@ class Mode extends KeybindItem {
}
Canvas.updateRenderSides()
if (BarItems[this.default_tool]) {
if (!BarItems[this.default_tool].selected) BarItems[this.default_tool].select()
if (BarItems[this.tool] && Condition(BarItems[this.tool])) {
BarItems[this.tool].select();
} else if (BarItems[this.default_tool]) {
if (!BarItems[this.default_tool].selected) BarItems[this.default_tool].select();
} else {
if (!BarItems.move_tool.selected) BarItems.move_tool.select()
if (!BarItems.move_tool.selected) BarItems.move_tool.select();
}
TickUpdates.interface = true;
TickUpdates.selection = true;

View File

@ -184,7 +184,7 @@ class Plugin {
}).fail(reject)
} else {
try {
eval(file.content);
new Function(file.content)();
} catch (err) {
reject(err)
}

View File

@ -205,6 +205,7 @@ ipcMain.on('new-window', (event, data, position) => {
})
if (place_in_window) {
place_in_window.send('load-tab', load_project_data);
place_in_window.focus();
load_project_data = null;
} else {
createWindow(true, {
@ -246,7 +247,7 @@ app.on('ready', () => {
}
if (app_was_loaded) {
console.log('[Blockbench] App reloaded')
console.log('[Blockbench] App reloaded or new window opened')
return;
}