Skip to content

Commit

Permalink
Outliner Group Exporter: Make export action not global
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisX11 committed May 30, 2024
1 parent fa57525 commit 5ee2355
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions plugins/outliner_group_exporter/outliner_group_exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@
min_version: '4.10.1',
variant: 'both',
onload() {
// Add translations
window.Language.addTranslations('en', {
'action.export_outliner_group': "Export"
});

// Setup action and separator
separator = new MenuSeparator('export');
actionExportGroup = new Action('export_outliner_group', {
actionExportGroup = {
name: "Export",
id: 'export_outliner_group',
icon: 'insert_drive_file',
category: 'export',
// Only allow on java_block format or custom formats that can support it (e.g. ones that use Cubes)
condition: () => Format.id === 'java_block' || Format.allowOutlinerGroupExporting,
children() {
return MenuBar.menus.file.structure.find(menu => menu.id === 'export')?.children;
}
});
};

// Append the separator and action to group menu
Group.prototype.menu.addAction(separator);
Expand Down Expand Up @@ -70,7 +67,7 @@
originalExportFunction = Codec.prototype.export;
Codec.prototype.export = async function () {
// Check if the menu is open. Is this okay for web/mobile app?
let restrict = actionExportGroup.menu_node.classList.contains("opened");
let restrict = Group.prototype.menu == Menu.open;
restrictCubes(restrict);
originalExportFunction.call(this);
resetCubes(restrict);
Expand All @@ -80,8 +77,7 @@
// Clean up
Codec.prototype.export = originalExportFunction;
Group.prototype.menu.removeAction(separator);
Group.prototype.menu.removeAction(actionExportGroup);
actionExportGroup.delete();
Group.prototype.menu.removeAction('export_outliner_group');
}
});
})()

0 comments on commit 5ee2355

Please sign in to comment.