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