diff options
author | Minteck <nekostarfan@gmail.com> | 2021-06-05 19:27:48 +0200 |
---|---|---|
committer | Minteck <nekostarfan@gmail.com> | 2021-06-05 19:27:48 +0200 |
commit | 8cf5cefe6e91a5a1ed6eeaae4d94760d84c304a6 (patch) | |
tree | 7096b67b189c0220826123c7d5b121752545d140 /race/pause.js | |
download | kartik-client-8cf5cefe6e91a5a1ed6eeaae4d94760d84c304a6.tar.gz kartik-client-8cf5cefe6e91a5a1ed6eeaae4d94760d84c304a6.tar.bz2 kartik-client-8cf5cefe6e91a5a1ed6eeaae4d94760d84c304a6.zip |
Presque sortie du jeu
Diffstat (limited to 'race/pause.js')
-rw-r--r-- | race/pause.js | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/race/pause.js b/race/pause.js new file mode 100644 index 0000000..d1ee002 --- /dev/null +++ b/race/pause.js @@ -0,0 +1,102 @@ +global.quitting = false; + +startHooks.push(() => { + global.pause = (stat) => { + if (stat) { + if (location.search === "?sp") { + require('@electron/remote').getCurrentWindow().dstate = lang.discord.game[3]; + require('@electron/remote').getCurrentWindow().ddetails = lang.discord.game[1]; + } else { + require('@electron/remote').getCurrentWindow().dstate = lang.discord.game[3]; + require('@electron/remote').getCurrentWindow().ddetails = lang.discord.game[2]; + } + warn("Suspend", "Game paused"); + Sound.pause(); + if (require('@electron/remote').getCurrentWindow().music) { + shouldMusicPlay = false; + require('electron').ipcRenderer.send('prefademusic', ""); + } + 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(); + $("#credits").show(); + } else { + if (location.search === "?sp") { + require('@electron/remote').getCurrentWindow().dstate = lang.discord.game[0]; + require('@electron/remote').getCurrentWindow().ddetails = lang.discord.game[1]; + } else { + require('@electron/remote').getCurrentWindow().dstate = lang.discord.game[0]; + require('@electron/remote').getCurrentWindow().ddetails = lang.discord.game[2]; + } + warn("Suspend", "Game resumed"); + Sound.pause(); + if (require('@electron/remote').getCurrentWindow().music) { + shouldMusicPlay = true; + require('electron').ipcRenderer.send('preunfademusic', ""); + } + 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(); + $("#credits").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; + require('electron').ipcRenderer.send('prefademusic', ""); + $("#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 |