mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-20 14:43:48 +01:00
Merge pull request #3338 from phyzical/feature/add-more-hotkeys-for-zoom
Add more hotkeys for zoom
This commit is contained in:
commit
c7702d8511
@ -22,6 +22,7 @@ function error_process(err, error_callback) {
|
||||
if (err && error_callback) error_callback(err);
|
||||
}
|
||||
|
||||
if (greenworks) {
|
||||
greenworks.ugcGetItems = function (options, ugc_matching_type, ugc_query_type, success_callback, error_callback) {
|
||||
if (typeof options !== "object") {
|
||||
error_callback = success_callback;
|
||||
@ -99,7 +100,15 @@ greenworks.publishWorkshopFile = function (
|
||||
tags: [],
|
||||
};
|
||||
}
|
||||
greenworks._publishWorkshopFile(options, file_path, image_path, title, description, success_callback, error_callback);
|
||||
greenworks._publishWorkshopFile(
|
||||
options,
|
||||
file_path,
|
||||
image_path,
|
||||
title,
|
||||
description,
|
||||
success_callback,
|
||||
error_callback,
|
||||
);
|
||||
};
|
||||
|
||||
greenworks.updatePublishedWorkshopFile = function (
|
||||
@ -289,5 +298,6 @@ greenworks._steam_events.on = function () {
|
||||
};
|
||||
|
||||
process.versions["greenworks"] = greenworks._version;
|
||||
}
|
||||
|
||||
module.exports = greenworks;
|
||||
|
@ -25,7 +25,7 @@ process.on("uncaughtException", function () {
|
||||
|
||||
// We want to fail gracefully if we cannot connect to Steam
|
||||
try {
|
||||
if (greenworks.init()) {
|
||||
if (greenworks && greenworks.init()) {
|
||||
log.info("Steam API has been initialized.");
|
||||
} else {
|
||||
const error = "Steam API has failed to initialize.";
|
||||
|
@ -8,6 +8,39 @@ const storage = require("./storage");
|
||||
const config = new Config();
|
||||
|
||||
function getMenu(window) {
|
||||
const canZoomIn = utils.getZoomFactor() <= 2;
|
||||
const zoomIn = () => {
|
||||
const currentZoom = utils.getZoomFactor();
|
||||
const newZoom = currentZoom + 0.1;
|
||||
if (newZoom <= 2.0) {
|
||||
utils.setZoomFactor(window, newZoom);
|
||||
refreshMenu(window);
|
||||
} else {
|
||||
log.log("Max zoom out");
|
||||
utils.writeToast(window, "Cannot zoom in anymore", "warning");
|
||||
}
|
||||
};
|
||||
|
||||
const canZoomOut = utils.getZoomFactor() >= 0.5;
|
||||
const zoomOut = () => {
|
||||
const currentZoom = utils.getZoomFactor();
|
||||
const newZoom = currentZoom - 0.1;
|
||||
if (newZoom >= 0.5) {
|
||||
utils.setZoomFactor(window, newZoom);
|
||||
refreshMenu(window);
|
||||
} else {
|
||||
log.log("Max zoom in");
|
||||
utils.writeToast(window, "Cannot zoom out anymore", "warning");
|
||||
}
|
||||
};
|
||||
|
||||
const canResetZoom = utils.getZoomFactor() !== 1;
|
||||
const resetZoom = () => {
|
||||
utils.setZoomFactor(window, 1);
|
||||
refreshMenu(window);
|
||||
log.log("Reset zoom");
|
||||
};
|
||||
|
||||
return Menu.buildFromTemplate([
|
||||
{
|
||||
label: "File",
|
||||
@ -289,45 +322,45 @@ function getMenu(window) {
|
||||
submenu: [
|
||||
{
|
||||
label: "Zoom In",
|
||||
enabled: utils.getZoomFactor() <= 2,
|
||||
enabled: canZoomIn,
|
||||
accelerator: "CommandOrControl+numadd",
|
||||
click: () => {
|
||||
const currentZoom = utils.getZoomFactor();
|
||||
const newZoom = currentZoom + 0.1;
|
||||
if (newZoom <= 2.0) {
|
||||
utils.setZoomFactor(window, newZoom);
|
||||
refreshMenu(window);
|
||||
} else {
|
||||
log.log("Max zoom out");
|
||||
utils.writeToast(window, "Cannot zoom in anymore", "warning");
|
||||
}
|
||||
click: zoomIn,
|
||||
},
|
||||
{
|
||||
label: "Zoom In (non numpad)",
|
||||
enabled: canZoomIn,
|
||||
visible: false,
|
||||
accelerator: "CommandOrControl+Plus",
|
||||
acceleratorWorksWhenHidden: true,
|
||||
click: zoomIn,
|
||||
},
|
||||
{
|
||||
label: "Zoom Out",
|
||||
enabled: utils.getZoomFactor() >= 0.5,
|
||||
enabled: canZoomOut,
|
||||
accelerator: "CommandOrControl+numsub",
|
||||
click: () => {
|
||||
const currentZoom = utils.getZoomFactor();
|
||||
const newZoom = currentZoom - 0.1;
|
||||
if (newZoom >= 0.5) {
|
||||
utils.setZoomFactor(window, newZoom);
|
||||
refreshMenu(window);
|
||||
} else {
|
||||
log.log("Max zoom in");
|
||||
utils.writeToast(window, "Cannot zoom out anymore", "warning");
|
||||
}
|
||||
click: zoomOut,
|
||||
},
|
||||
{
|
||||
label: "Zoom Out (non numpad)",
|
||||
enabled: canZoomOut,
|
||||
accelerator: "CommandOrControl+-",
|
||||
visible: false,
|
||||
acceleratorWorksWhenHidden: true,
|
||||
click: zoomOut,
|
||||
},
|
||||
{
|
||||
label: "Reset Zoom",
|
||||
enabled: utils.getZoomFactor() !== 1,
|
||||
enabled: canResetZoom,
|
||||
accelerator: "CommandOrControl+num0",
|
||||
click: () => {
|
||||
utils.setZoomFactor(window, 1);
|
||||
refreshMenu(window);
|
||||
log.log("Reset zoom");
|
||||
click: resetZoom,
|
||||
},
|
||||
{
|
||||
label: "Reset Zoom (non numpad)",
|
||||
enabled: canResetZoom,
|
||||
accelerator: "CommandOrControl+0",
|
||||
visible: false,
|
||||
acceleratorWorksWhenHidden: true,
|
||||
click: resetZoom,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user