mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 14:59:16 +02:00
ELECTRON: Allow automatically hiding the top menu in Electron (#2325)
This commit is contained in:
@@ -5,6 +5,7 @@ const achievements = require("./achievements");
|
||||
const menu = require("./menu");
|
||||
const path = require("path");
|
||||
const { windowTracker } = require("./windowTracker");
|
||||
const storage = require("./storage");
|
||||
|
||||
const debug = process.argv.includes("--debug");
|
||||
|
||||
@@ -18,12 +19,14 @@ async function createWindow(killall) {
|
||||
}
|
||||
|
||||
const tracker = windowTracker("main");
|
||||
|
||||
const window = new BrowserWindow({
|
||||
icon,
|
||||
show: false,
|
||||
backgroundThrottling: false,
|
||||
backgroundColor: "#000000",
|
||||
title: "Bitburner",
|
||||
autoHideMenuBar: storage.isMenuHideEnabled(),
|
||||
x: tracker.state.x,
|
||||
y: tracker.state.y,
|
||||
width: tracker.state.width,
|
||||
|
||||
@@ -204,24 +204,10 @@ function getMenu(window) {
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Reloads",
|
||||
label: "View",
|
||||
submenu: [
|
||||
{
|
||||
label: "Reload",
|
||||
accelerator: "f5",
|
||||
click: () => window.loadFile("index.html"),
|
||||
},
|
||||
{
|
||||
label: "Reload && Kill All Scripts",
|
||||
click: () => utils.reloadAndKill(window, true),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Fullscreen",
|
||||
submenu: [
|
||||
{
|
||||
label: "Toggle",
|
||||
label: "Fullscreen",
|
||||
accelerator: "f9",
|
||||
click: (() => {
|
||||
let full = false;
|
||||
@@ -231,11 +217,9 @@ function getMenu(window) {
|
||||
};
|
||||
})(),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Zoom",
|
||||
submenu: [
|
||||
{
|
||||
type: "separator",
|
||||
},
|
||||
{
|
||||
label: "Zoom In",
|
||||
enabled: canZoomIn,
|
||||
@@ -278,6 +262,38 @@ function getMenu(window) {
|
||||
acceleratorWorksWhenHidden: true,
|
||||
click: resetZoom,
|
||||
},
|
||||
{
|
||||
type: "separator",
|
||||
},
|
||||
{
|
||||
label: "Autohide top menu",
|
||||
type: "checkbox",
|
||||
checked: storage.isMenuHideEnabled(),
|
||||
click: (menuItem) => {
|
||||
storage.setMenuHideConfig(menuItem.checked);
|
||||
window.setAutoHideMenuBar(menuItem.checked);
|
||||
if (menuItem.checked) {
|
||||
window.setMenuBarVisibility(false);
|
||||
} else {
|
||||
window.setMenuBarVisibility(true);
|
||||
}
|
||||
refreshMenu(window);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Reloads",
|
||||
submenu: [
|
||||
{
|
||||
label: "Reload",
|
||||
accelerator: "f5",
|
||||
click: () => window.loadFile("index.html"),
|
||||
},
|
||||
{
|
||||
label: "Reload && Kill All Scripts",
|
||||
click: () => utils.reloadAndKill(window, true),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -87,6 +87,14 @@ function setCloudEnabledConfig(value) {
|
||||
store.set("cloud-enabled", value);
|
||||
}
|
||||
|
||||
function isMenuHideEnabled() {
|
||||
return store.get("autoHideMenuBar", false);
|
||||
}
|
||||
|
||||
function setMenuHideConfig(value) {
|
||||
return store.set("autoHideMenuBar", value);
|
||||
}
|
||||
|
||||
function getSaveFolder(window, root = false) {
|
||||
if (root) {
|
||||
return path.join(app.getPath("userData"), "/saves");
|
||||
@@ -388,4 +396,6 @@ module.exports = {
|
||||
setCloudEnabledConfig,
|
||||
isAutosaveEnabled,
|
||||
setAutosaveConfig,
|
||||
isMenuHideEnabled,
|
||||
setMenuHideConfig,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user