summaryrefslogtreecommitdiff
path: root/kartik/race/pause.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-05-18 18:50:12 +0200
committerMinteck <contact@minteck.org>2022-05-18 18:50:12 +0200
commit0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0 (patch)
tree97a7e15187fe7fcb5b8775e03a62f62ac8fc5c61 /kartik/race/pause.js
parentd4805039b8ea7b30f5e78cf53caf8fd3f267256a (diff)
downloadarcade-trunk.tar.gz
arcade-trunk.tar.bz2
arcade-trunk.zip
Add KartikHEADtrunk
Diffstat (limited to 'kartik/race/pause.js')
-rwxr-xr-xkartik/race/pause.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/kartik/race/pause.js b/kartik/race/pause.js
new file mode 100755
index 0000000..8cf46ea
--- /dev/null
+++ b/kartik/race/pause.js
@@ -0,0 +1,82 @@
+global.quitting = false;
+
+startHooks.push(() => {
+ global.pause = (stat) => {
+ if (stat) {
+ warn("Suspend", "Game paused");
+ Sound.pause();
+ shouldMusicPlay = false;
+ window.parent.musicManager.fadeMusic();
+ if (typeof e !== "undefined") {
+ if (e.currentTime < e.duration) {
+ e.pause();
+ }
+ }
+ if (typeof b !== "undefined") {
+ b.pause();
+ }
+ paused = true;
+ document.getElementById('box').classList.add('paused');
+ $("#paused").show();
+ } else {
+ warn("Suspend", "Game resumed");
+ Sound.pause();
+ shouldMusicPlay = true;
+ window.parent.musicManager.unfadeMusic();
+ if (typeof me !== "undefined") {
+ if (me.currentTime < me.duration) {
+ me.play();
+ }
+ }
+ if (typeof b !== "undefined") {
+ b.play();
+ }
+ paused = false;
+ document.getElementById('box').classList.remove('paused');
+ $("#paused").hide();
+ }
+ }
+
+ global.selectOption = () => {
+ item = document.querySelector(".selected a").id;
+ Sound.click();
+
+ switch (item) {
+ case 'continue':
+ pause(false);
+ break;
+ case 'hitboxes':
+ if (hitshow) {
+ hitshow = false;
+ document.getElementById("circuit").classList.remove("hitboxes");
+ document.getElementById('hitboxes').innerText = lang.game.gpause.showhb;
+ info("GameWindow", "Hitboxes hidden");
+ } else {
+ hitshow = true;
+ document.getElementById("circuit").classList.add("hitboxes");
+ document.getElementById('hitboxes').innerText = lang.game.gpause.hidehb;
+ info("GameWindow", "Hitboxes shown");
+ }
+ break;
+ case 'quit':
+ if (online) {
+ global.quitting = true;
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "abort",
+ message: null
+ }) + "|")
+ }
+ keysEnabled = false;
+ window.parent.musicManager.fadeMusic();
+ $("#box").fadeOut(500);
+ $("#bg").fadeOut(500);
+ $("#paused").fadeOut(500);
+ setTimeout(() => {
+ info("GameWindow", "Switching control to MenuWindow");
+ location.href = "menu.html?back";
+ }, 1000)
+ break;
+ }
+ }
+}) \ No newline at end of file