Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
add stop button
Browse files Browse the repository at this point in the history
  • Loading branch information
zeankundev committed Nov 5, 2022
1 parent e0d0c3c commit 6c105fd
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 33 deletions.
1 change: 1 addition & 0 deletions language/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"downloads": "ውርዶች",
"noDownloads": "ምንም ውርዶች የሉም። በቅርቡ ተመልሰው ይመልከቱ።",
"play": "ይጫወቱ",
"stop": "ጨዋታ አቁም",
"downloadAndInstall": "አውርድና ጫን",
"refreshStore": "ሱቅ አድስ",
"wineConfig": "የወይን ውቅር",
Expand Down
1 change: 1 addition & 0 deletions language/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"downloads": "Download",
"noDownloads": "Keine Downloads. Schau bald wieder vorbei!",
"play": "Spielen",
"stop": "Spiel beenden",
"downloadAndInstall": "Herunterladen und installieren",
"refreshStore": "Geschäft aktualisieren",
"wineConfig": "Wine-Konfiguration",
Expand Down
1 change: 1 addition & 0 deletions language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"downloads": "Downloads",
"noDownloads": "No downloads. Check back soon!",
"play": "Play",
"stop": "Stop Game",
"downloadAndInstall": "Download and Install",
"refreshStore": "Refresh Store",
"wineConfig": "Wine Configuration",
Expand Down
1 change: 1 addition & 0 deletions language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"downloads": "Descargas",
"noDownloads": "Sin descargas. ¡Vuelve a consultar pronto!",
"play": "Tocar",
"stop": "Detener el juego",
"downloadAndInstall": "Descargar e instalar",
"refreshStore": "Actualizar tienda",
"wineConfig": "Configuración del Wine",
Expand Down
1 change: 1 addition & 0 deletions language/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"downloads": "Unduhan",
"noDownloads": "Tidak ada unduhan. Coba lagi nanti.",
"play": "Mainkan",
"stop": "Hentikan permainan",
"downloadAndInstall": "Unduh dan pasang",
"refreshStore": "Segarkan Toko",
"wineConfig": "Konfigurasi Wine",
Expand Down
1 change: 1 addition & 0 deletions language/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"downloads": "ダウンロード",
"noDownloads": "ダウンロードはありません。 すぐにもう一度確認してください",
"play": "遊ぶ",
"stop": "ゲームを停止",
"downloadAndInstall": "ダウンロードとインストール",
"refreshStore": "リフレッシュショップ",
"wineConfig": "ワイン構成",
Expand Down
1 change: 1 addition & 0 deletions language/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"downloads": "Downloads",
"noDownloads": "Geen downloads. Kom snel terug.",
"play": "Spelen",
"stop": "Spel stoppen",
"downloadAndInstall": "Download en installeer",
"refreshStore": "Winkel vernieuwen",
"wineConfig": "Wine configuratie",
Expand Down
1 change: 1 addition & 0 deletions language/sw.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"downloads": "Vipakuliwa",
"noDownloads": "Hakuna vipakuliwa. Angalia tena hivi karibuni!",
"play": "Cheza",
"stop": "Acha Mchezo",
"downloadAndInstall": "Pakua na usakinishe",
"refreshStore": "Onyesha upya duka",
"wineConfig": "Mpangilio wa Wine",
Expand Down
83 changes: 50 additions & 33 deletions script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let cus;
let downAndI;
let libText;
let language;
let stop;
fetch(app.getPath('userData') + '/config.json')
.then(response => response.json())
.then(data => {
Expand Down Expand Up @@ -68,6 +69,7 @@ fetch(app.getPath('userData') + '/config.json')
document.getElementById('ref-internet').innerHTML = data.translations.refInternet
document.getElementById('rec-for-u').innerHTML = data.translations.recForU
play = data.translations.play;
stop = data.translations.stop;
downAndI = data.translations.downloadAndInstall
fetchStores();
getGames();
Expand Down Expand Up @@ -235,6 +237,7 @@ openMenu(event, 'home')
});
});
}*/
var proc;
function getGames() {
fetch(app.getPath('userData') + '/games.json')
.then(response => response.json())
Expand All @@ -260,41 +263,55 @@ openMenu(event, 'home')
gameButton.className = "play";
gameButton.innerHTML = `<span>${play}</span>`;
gameButton.onclick = function() {
seconds = 0;
secElapsed.style.display = 'block';
const timer = setInterval(function() {
seconds++
secElapsed.innerHTML = `${seconds} seconds elapsed. <br>`
if (seconds > 59) notifDisplay('You have exceeded the maximum time of 1 minute.', 'Please take a rest')
}, 1000)
// downgraded to electron v4, now we can require child_process.
const { spawn } = require('child_process');
if (game.enableWine != true) {
const process = spawn(game.exec, game.args);
process.on('error', (err) => {
console.log(err)
notifDisplay(err, 'Failed to launch!')
});
process.on('exit', () => {
clearInterval(timer)
})
} else {
if (platform == 'win32') notifDisplay('Wine is only available for Mac or Linux', 'Your OS is unsupported');
else {
var cmdExist = require('command-exists');
if (cmdExist('wine')) {
const process = spawn('wine', [game.exec]);
process.on('error', (err) => {
console.log(err)
notifDisplay(err, 'Failed to launch!')
});
process.on('exit', () => {
clearInterval(timer)
})
} else {
notifDisplay('Wine cannot be searched. Close Graycrown, install wine, then try again.', 'Unsupported!')
if (gameButton.className == "play") {
seconds = 0;
secElapsed.style.display = 'block';
const timer = setInterval(function() {
seconds++
secElapsed.innerHTML = `${seconds} seconds elapsed. <br>`
if (seconds > 59) notifDisplay('You have exceeded the maximum time of 1 minute.', 'Please take a rest')
}, 1000)
// downgraded to electron v4, now we can require child_process.
const { spawn } = require('child_process');
if (game.enableWine != true) {
proc = spawn(game.exec, game.args);
gameButton.className = "stop";
gameButton.innerHTML = stop;
proc.on('error', (err) => {
console.log(err)
notifDisplay(err, 'Failed to launch!')
});
proc.on('exit', () => {
clearInterval(timer)
gameButton.className = "play";
gameButton.innerHTML = play;
})
} else {
if (platform == 'win32') notifDisplay('Wine is only available for Mac or Linux', 'Your OS is unsupported');
else {
var cmdExist = require('command-exists');
if (cmdExist('wine')) {
proc = spawn('wine', [game.exec]);
gameButton.className = "stop";
gameButton.innerHTML = stop;
proc.on('error', (err) => {
console.log(err)
notifDisplay(err, 'Failed to launch!')
});
proc.on('exit', () => {
clearInterval(timer)
gameButton.className = "play";
gameButton.innerHTML = play;
})
} else {
notifDisplay('Wine cannot be searched. Close Graycrown, install wine, then try again.', 'Unsupported!')
}
}
}
} else {
const { spawn } = require('child_process');
console.log("KILLING PROCESS")
proc.kill()
}
}
gameDisplay.appendChild(secElapsed)
Expand Down
20 changes: 20 additions & 0 deletions views/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ h1 {
border-radius: 15px;
color: var(--main-text);
width: 240px;
transition: all 0.2s ease;
cursor: url('../../assets/pointer.png'), auto;
-webkit-animation: scale-down-center 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: scale-down-center 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
Expand All @@ -324,6 +325,25 @@ h1 {
-webkit-animation: scale-up-center 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: scale-up-center 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
.stop {
background-color: var(--stop-color);
border: none;
display: inline-block;
font-family: system-ui;
padding: 10px;
border-radius: 15px;
color: var(--main-text);
width: 240px;
cursor: url('../../assets/pointer.png'), auto;
transition: all 0.2s ease;
-webkit-animation: scale-down-center 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: scale-down-center 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
.stop:hover {
background-color: var(--stop-color-hover);
-webkit-animation: scale-up-center 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: scale-up-center 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
.store-display {
background: var(--main-color);
margin: 10px;
Expand Down
2 changes: 2 additions & 0 deletions views/css/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
--main-text: #fff;
--play-color: #16c716;
--play-color-hover: #2ae42a;
--stop-color: #ff0b0b;
--stop-color-hover: #ff2323;
--download-color: #0362fc;
--download-color-hover: #1e71f7;
}

0 comments on commit 6c105fd

Please sign in to comment.