diff --git a/app/assets/css/index.css b/app/assets/css/index.css index c081e4b..418e668 100644 --- a/app/assets/css/index.css +++ b/app/assets/css/index.css @@ -116,10 +116,11 @@ button.classic { border: none; cursor: pointer; outline: none; - margin-left: 2%; - margin-top: 5px; transition: .3s; + margin-top: 5px; + font-weight: 900; border-radius: 5px; + z-index: 9; background-color: #39aa6d; } @@ -247,6 +248,130 @@ main > section.twitch { right: 60px; } +input[type="range"] { + width: 100%; + border: none; + accent-color: #2E8B57; + background-color: #2E8B57; +} + +input[type="range"]#audioVolume { + width: 83%; +} + +input[type="text"], +input[type="password"] { + width: 90%; + border: 0px; + color: #ffffff; + outline: 0px; + height: 30px; + padding-left: 10px; + margin-top: 4px; + margin-bottom: 4px; + border-radius: 5px; + background-color: #292929; +} + +main > article.loginchoice { + position: absolute; + top: 50%; + left: 50%; + width: 25%; + height: 25%; + color: #ffffff; + text-align: center; + border-radius: 10px; + padding-top: 20px; + transform: translate(-50%, -50%); + background-color: #343434; +} + +main > article.loginchoice > input:nth-of-type(1) { + margin-top: 10px; +} + +button { + text-align: center; +} + +button.login { + width: 90%; + height: 60px; + border: none; + outline: none; + color: #ffffff; + cursor: pointer; + font-size: larger; + font-weight: 900; + border-radius: 10px; + background-color: #292929; + border: 3px #292929 solid; + transition: .23s; + margin-top: 13px; + line-height: 40px; +} + +button.login:hover { + border-color: #12865c; +} + +button.login > img { + width: 40px; + margin-right: 10px; + vertical-align: middle; +} + +div[frame="mojang"] > p { + width: 90%; + margin-left: 5%; + text-align: left; + font-size: small; + margin-top: 4px; + margin-bottom: 4px; +} + +a { + text-decoration: underline; + color: #12865c; +} + +article.game { + text-align: center; +} + +article.game > label { + font-size: small; + margin-top: 7px; +} + +article.game > div.ranges { + display: flex; + flex-wrap: wrap; + justify-content: space-evenly; +} + +article.game > div.ranges > span { + font-size: small; +} + +article.game > div.ranges > input { + width: 60%; +} + +div.checkboxes { + width: 100%; + text-align: left; +} + +input[type="checkbox"] { + accent-color: #12865c; +} + +div.checkboxes > input[type="checkbox"] { + font-size: small; +} + [hidden] { display: none; visibility: hidden; diff --git a/app/assets/img/login_wallpaper.gif b/app/assets/img/login_wallpaper.gif new file mode 100644 index 0000000..b393239 Binary files /dev/null and b/app/assets/img/login_wallpaper.gif differ diff --git a/app/assets/img/microsoft.png b/app/assets/img/microsoft.png new file mode 100644 index 0000000..11e09dc Binary files /dev/null and b/app/assets/img/microsoft.png differ diff --git a/app/assets/img/mojang.png b/app/assets/img/mojang.png new file mode 100644 index 0000000..cff9d45 Binary files /dev/null and b/app/assets/img/mojang.png differ diff --git a/app/assets/js/index.js b/app/assets/js/index.js index 36b8650..a247827 100644 --- a/app/assets/js/index.js +++ b/app/assets/js/index.js @@ -1,15 +1,20 @@ const navBar = document.querySelector("nav") -const uiButton = document.querySelector("footer>section.left") +const uiButtons = document.querySelector("footer>section.left") +const footer = document.querySelector("footer") +const leftSection = document.querySelector("section.left") +const audioPourcentageLabel = document.querySelector("label[for='audioVolume']") const audio = new Audio() function startAudio() { - audio.src = "/app/assets/audio/Golden Hill (Radio Edit).mp3" + audio.src = "./assets/audio/Golden Hill (Radio Edit).mp3" audio.loop = true + audio.play() audio.onended = () => { if (!audio.paused) { audio.play() } } + updateVolume(audio.volume) } function muteAudio() { @@ -21,23 +26,71 @@ function unmuteAudio() { } function showNavBar() { + footer.style.zIndex = "-1" + leftSection.style.zIndex = "-1" navBar.removeAttribute("hidden") - for (const button of uiButton.children) { + for (const button of uiButtons.children) { button.setAttribute("hidden", "") } } function hideNavBar() { + footer.style.zIndex = "9" + leftSection.style.zIndex = "9" navBar.setAttribute("hidden", "") - for (const button of uiButton.children) { + for (const button of uiButtons.children) { button.removeAttribute("hidden") } } +function toggleAudio(element) { + if (element.getAttribute("state") == 0) { + system.call("audio::mute") + element.setAttribute("state", 1) + element.children[0].classList.replace("fa-music", "fa-music-slash") + } else { + system.call("audio::unmute") + element.setAttribute("state", 0) + element.children[0].classList.replace("fa-music-slash", "fa-music") + } +} + +function toggleMusic(element) { + if (element.getAttribute("state") == 0) { + system.call("audio::mute") + element.setAttribute("state", 1) + element.children[0].classList.replace("fa-pause", "fa-play") + element.children[1].innerText = "Reprendre" + } else { + system.call("audio::unmute") + element.setAttribute("state", 0) + element.children[0].classList.replace("fa-play", "fa-pause") + element.children[1].innerText = "Pause" + } +} + +function updateVolume(value) { + audio.volume = value / 100 + audioPourcentageLabel.innerText = `${value}%` +} + +function logout() { + localStorage.removeItem("user") + document.location.href = './login.html' +} + window.onload = () => { system.call("server::ping") + system.call("player::profile") + startAudio() } system.result("server::ping", (data) => { playersStatus.innerText = `${data.players.online}/${data.players.max}` +}) + +system.result("player::profile", (data) => { + if (!localStorage.getItem("user")) { + localStorage.setItem("user", JSON.stringify(data)) + } }) \ No newline at end of file diff --git a/app/assets/js/login.js b/app/assets/js/login.js new file mode 100644 index 0000000..7f2b9d8 --- /dev/null +++ b/app/assets/js/login.js @@ -0,0 +1,30 @@ +const loginchoice = document.querySelector("main > article.loginchoice") + +function selectLoginType(type) { + for (const frame of loginchoice.children) { + frame.setAttribute("hidden", "") + if (frame.getAttribute("frame") == type) { + frame.removeAttribute("hidden") + } + } + if (type == "microsoft") { + system.call(`auth::${type}`) + } +} + +system.result("auth::microsoft", () => { + selectLoginType("select") +}) + +system.result("auth::refresh", () => { + selectLoginType("select") +}) + +window.onload = () => { + if (localStorage.getItem("user")) { + system.call("auth::refresh", { + user: JSON.parse(localStorage.getItem("user")) + }) + selectLoginType("token") + } +} \ No newline at end of file diff --git a/app/logged.html b/app/logged.html index 7890633..90a47bc 100644 --- a/app/logged.html +++ b/app/logged.html @@ -27,9 +27,9 @@
-

- a -

+
@@ -41,10 +41,72 @@ -
-

- a -

+
+ +
+ + 0.5GB + + + + MAX + +
+
+ +
+ + 4 + + + + 32 + +
+
+ +
+ + 1 + + + + 4 + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
@@ -57,12 +119,20 @@
-

- a -

+
+ + +
+
- @@ -109,12 +179,6 @@ Wiki -
@@ -134,7 +198,7 @@ -
diff --git a/app/login.html b/app/login.html new file mode 100644 index 0000000..ed02a14 --- /dev/null +++ b/app/login.html @@ -0,0 +1,70 @@ + + + + + + + Connexion + + + +
+ +
+
+

+ Se connecter avec +

+ + +
+ + + +
+ +
+ + + \ No newline at end of file diff --git a/main.js b/main.js index 05278ab..3d7d1ae 100644 --- a/main.js +++ b/main.js @@ -35,7 +35,7 @@ async function createLauncherWindow() { } launcherWindow.setIcon(path.join(__dirname, "app", "assets", "img", "icon.png")) if (isLauncherNotBanned.success) { - launcherWindow.loadFile(path.join(__dirname, "app", "logged.html")) + launcherWindow.loadFile(path.join(__dirname, "app", "login.html")) session.defaultSession.webRequest.onBeforeRequest({ urls: [ "https://embed.twitch.tv/*channel=*" @@ -160,13 +160,52 @@ ipcMain.on("call", async (event, data) => { } break case "auth::mojang": - auth = Authenticator.getAuth(data.args.username, data.args.password) + if (data.args.trim() != "") { + auth = Authenticator.getAuth(data.args.username, data.args.password) + await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html")) + } else { + dialog.showErrorBox("Erreur", "Le mot de passe n'est pas défini. Les comptes crackés ne sont pas supporté par le launcher.") + } break - case "auth::msmc": + case "auth::microsoft": const authManager = new msmc.Auth("select_account") - const xboxManager = await authManager.launch("raw") - const token = await xboxManager.getMinecraft() - auth = token.mclc() + try { + const xboxManager = await authManager.launch("raw") + const token = await xboxManager.getMinecraft() + auth = token.mclc() + console.log(auth) + await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html")) + } catch (error) { + console.log(error) + if (error == "error.gui.closed") { + launcherWindow.webContents.send("Response") + } + } + break + case "auth::refresh": + const user = data.args.user + if (user.meta?.type == "msa") { + try { + const authManager = new msmc.Auth("none") + const xboxManager = await authManager.refresh(user.meta.refresh) + const minecraft = await xboxManager.getMinecraft() + auth = minecraft.mclc() + await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html")) + } catch (error) { + dialog.showErrorBox("Erreur lors de la connexion via token", error) + console.log(error) + launcherWindow.webContents.send("Response") + } + } else { + try { + auth = Authenticator.refreshAuth(user.access_token, user.client_token) + await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html")) + } catch (error) { + dialog.showErrorBox("Erreur lors de la connexion via token", error) + console.log(error) + launcherWindow.webContents.send("Response") + } + } break case "shell::openExternal": shell.openExternal(data.args.url) @@ -177,5 +216,8 @@ ipcMain.on("call", async (event, data) => { case "audio::unmute": launcherWindow.webContents.setAudioMuted(false) break + case "player::profile": + await launcherWindow.webContents.send("Response", auth) + break } }) \ No newline at end of file diff --git a/modules/serverPing.js b/modules/serverPing.js index da6e8e0..04c92d8 100644 --- a/modules/serverPing.js +++ b/modules/serverPing.js @@ -6,8 +6,8 @@ async function fetchServerStatus() { return { online: json.online, players: { - online: json.players.online || 0, - max: json.players.max || 0 + online: json.players?.online || 0, + max: json.players?.max || 0 } }