You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.1 KiB
73 lines
2.1 KiB
"use strict"
|
|
|
|
function prepareInterface(){
|
|
globalCursor = {
|
|
isActive: true,
|
|
standStillTime: 0,
|
|
|
|
//seconds not moving cursor -> it disappears
|
|
timeLimit: int(values.cursorTimeLimit) / 1000
|
|
}
|
|
$("#messageWrapper").hide();
|
|
$("#menuOpener").click(function(){
|
|
toggleMenu($(this));
|
|
});
|
|
$("button, input").click(function(){
|
|
$(this).blur();
|
|
updateMenu();
|
|
});
|
|
}
|
|
|
|
function toggleMenu(opener){
|
|
menuOpen = !menuOpen;
|
|
let menuAnimationTime = int(values.menuAnimationTime),
|
|
openerAnimationTime = int(values.openerAnimationTime);
|
|
let menuLeft;
|
|
if ($("#menu").css("left") == "0px") menuLeft = -$("#menu").outerWidth();
|
|
else menuLeft = 0;
|
|
let menuBorder = abs(menuLeft);
|
|
opener.animate({"left": menuBorder - opener.outerWidth()}, openerAnimationTime, function(){
|
|
opener.hide();
|
|
$("#menu").show();
|
|
$("#menu").animate({"left": menuLeft}, menuAnimationTime, function(){
|
|
menuBorder = int($(this).css("left").substring(0, $(this).css("left").length - 2)) + $(this).outerWidth();
|
|
opener.show();
|
|
opener.css("left", menuBorder - opener.outerWidth());
|
|
opener.animate({"left": menuBorder}, openerAnimationTime, function(){
|
|
//Animation ended successfully
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
function toggleFullscreen(htmlElement){
|
|
let fs = fullscreen();
|
|
fullscreen(!fs);
|
|
$(htmlElement).html(fs ? "Fullscreen: Off" : "Fullscreen: On");
|
|
}
|
|
|
|
function checkCursor(){
|
|
globalCursor.standStillTime += 1 / frameRate();
|
|
if (globalCursor.isActive && globalCursor.standStillTime > globalCursor.timeLimit){
|
|
globalCursor.isActive = false;
|
|
noCursor();
|
|
}
|
|
if (!globalCursor.isActive && globalCursor.standStillTime < globalCursor.timeLimit){
|
|
globalCursor.isActive = true;
|
|
cursor(ARROW);
|
|
}
|
|
}
|
|
|
|
function updateMenu(){
|
|
let val = [
|
|
["run", game.paused ? "Resume" : "Pause"],
|
|
["restart", "Restart"],
|
|
["new", "New Game"],
|
|
["map", game.showMap ? "Map: On" : "Map: Off"],
|
|
["hint", game.showHint ? "Hint: On" : "Hint: Off"],
|
|
["sound", audioOptions.sound ? "Sound: On" : "Sound: Off"],
|
|
["music", audioOptions.music ? "Music: On" : "Music: Off"]
|
|
];
|
|
|
|
for (let v of val) $("#" + v[0]).html(v[1]);
|
|
} |