ELECTRON: Allow automatically hiding the top menu in Electron (#2325)

This commit is contained in:
Femboy Fireball
2025-10-03 19:45:18 +00:00
committed by GitHub
parent 7225a2b22e
commit 18b062663d
3 changed files with 50 additions and 21 deletions

View File

@@ -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,

View File

@@ -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),
},
],
},
{

View File

@@ -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,
};