bitburner-src/utils/GameOptions.js

52 lines
1.5 KiB
JavaScript
Raw Normal View History

/* GameOptions.js */
import { Player } from "../src/Player";
//Close box when clicking outside
$(document).click(function(event) {
if (gameOptionsOpened) {
if ( $(event.target).closest(".game-options-box").get(0) == null ) {
gameOptionsBoxClose();
}
}
});
var gameOptionsOpened = false;
function gameOptionsBoxInit() {
//Menu link button
document.getElementById("options-menu-link").addEventListener("click", function() {
gameOptionsBoxOpen();
return false;
});
//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() {
gameOptionsOpened = false;
var box = document.getElementById("game-options-container");
box.style.display = "none";
}
function gameOptionsBoxOpen() {
var box = document.getElementById("game-options-container");
2018-08-12 21:45:35 +02:00
box.style.display = "flex";
// special exception for bladeburner popup because it's only visible later.
document.getElementById("settingsSuppressBladeburnerPopup")
.closest('fieldset').style.display =
Player.canAccessBladeburner() ? 'block' : 'none';
setTimeout(function() {
gameOptionsOpened = true;
}, 500);
}
export {gameOptionsBoxOpen, gameOptionsBoxClose};