bitburner-src/utils/GameOptions.js

51 lines
1.4 KiB
JavaScript
Raw Normal View History

/* GameOptions.js */
import { Player } from "../src/Player";
//Close box when clicking outside
2021-09-05 01:09:30 +02:00
$(document).click(function (event) {
if (gameOptionsOpened) {
if ($(event.target).closest(".game-options-box").get(0) == null) {
gameOptionsBoxClose();
}
2021-09-05 01:09:30 +02:00
}
});
var gameOptionsOpened = false;
function gameOptionsBoxInit() {
2021-09-11 07:54:19 +02:00
return;
2021-09-05 01:09:30 +02:00
//Menu link button
2021-09-09 05:47:34 +02:00
document.getElementById("options-menu-link").addEventListener("click", function () {
gameOptionsBoxOpen();
return false;
});
2021-09-05 01:09:30 +02:00
//Close button
var closeButton = document.getElementById("game-options-close-button");
closeButton.addEventListener("click", function () {
gameOptionsBoxClose();
return false;
});
2021-04-30 05:52:56 +02:00
}
document.addEventListener("DOMContentLoaded", gameOptionsBoxInit, false);
function gameOptionsBoxClose() {
2021-09-05 01:09:30 +02:00
gameOptionsOpened = false;
var box = document.getElementById("game-options-container");
box.style.display = "none";
}
function gameOptionsBoxOpen() {
2021-09-05 01:09:30 +02:00
var box = document.getElementById("game-options-container");
box.style.display = "flex";
// special exception for bladeburner popup because it's only visible later.
2021-09-09 05:47:34 +02:00
document.getElementById("settingsSuppressBladeburnerPopup").closest("fieldset").style.display =
Player.canAccessBladeburner() ? "block" : "none";
2021-09-05 01:09:30 +02:00
setTimeout(function () {
gameOptionsOpened = true;
}, 500);
}
2021-09-05 01:09:30 +02:00
export { gameOptionsBoxOpen, gameOptionsBoxClose };