Improved 3D view and UI

Added random skins
WIP: Skin upload and reset
This commit is contained in:
Arne van Iterson 2020-06-18 19:23:07 +02:00
parent bde532e123
commit 9fdb774b5c
13 changed files with 264 additions and 108 deletions

View File

@ -11,6 +11,15 @@ body header h3 {
margin: 0; margin: 0;
} }
body div.content {
display: -ms-grid;
display: grid;
-ms-grid-columns: 50% 50%;
grid-template-columns: 50% 50%;
grid-template-areas: 'message message' 'left right';
width: 100%;
}
body div.content form label { body div.content form label {
font-size: small; font-size: small;
} }
@ -25,10 +34,14 @@ body div.content button {
} }
body div.content .message { body div.content .message {
min-width: 80%; -ms-grid-row: 1;
-ms-grid-column: 1;
-ms-grid-column-span: 2;
grid-area: message;
width: calc(100% - 22px);
height: auto; height: auto;
margin: 5px auto; margin: 5px auto;
padding: 5px; padding: 5px 10px 5px 10px;
font-size: small; font-size: small;
color: white; color: white;
} }
@ -48,6 +61,18 @@ body div.content .message.success {
background: rgba(0, 255, 0, 0.5); background: rgba(0, 255, 0, 0.5);
} }
body div.content div.left {
-ms-grid-row: 2;
-ms-grid-column: 1;
grid-area: left;
}
body div.content div.right {
-ms-grid-row: 2;
-ms-grid-column: 2;
grid-area: right;
}
body div.content img.skin { body div.content img.skin {
width: 60%; width: 60%;
padding: 0 1em 1em 1em; padding: 0 1em 1em 1em;

View File

@ -1,6 +1,6 @@
{ {
"version": 3, "version": 3,
"mappings": "AAAA,AAAA,IAAI,CAAC;EACD,WAAW,EAAE,4BAA4B;EACzC,UAAU,EAAE,MAAM;CAiErB;;AAnED,AAIQ,IAJJ,CAGA,MAAM,CACF,EAAE,CAAC;EACC,aAAa,EAAE,CAAC;CACnB;;AANT,AAOQ,IAPJ,CAGA,MAAM,CAIF,EAAE,CAAC;EACC,MAAM,EAAE,CAAC;CACZ;;AATT,AAaY,IAbR,CAWA,GAAG,AAAA,QAAQ,CACP,IAAI,CACA,KAAK,CAAC;EACF,SAAS,EAAE,KAAK;CACnB;;AAfb,AAiBQ,IAjBJ,CAWA,GAAG,A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13 @@ body {
} }
} }
div.content { div.content {
display: grid;
grid-template-columns: 50% 50%;
grid-template-areas:
'message message'
'left right'
;
width: 100%;
form { form {
label { label {
font-size: small; font-size: small;
@ -23,10 +30,11 @@ body {
width: 50%; width: 50%;
} }
.message { .message {
min-width: 80%; grid-area: message;
width: calc(100% - 22px);
height: auto; height: auto;
margin: 5px auto; margin: 5px auto;
padding: 5px; padding: 5px 10px 5px 10px;
font-size: small; font-size: small;
color: white; color: white;
&.info { &.info {
@ -42,6 +50,12 @@ body {
background: rgba(0, 255, 0, 0.5); background: rgba(0, 255, 0, 0.5);
} }
} }
div.left {
grid-area: left;
}
div.right {
grid-area: right;
}
img.skin { img.skin {
width: 60%; width: 60%;
padding: 0 1em 1em 1em; padding: 0 1em 1em 1em;

View File

@ -1 +1 @@
{"theme":"light","user":"arne.v.iterson@hotmail.nl","password":""} {"theme":"dark","user":"arne.v.iterson@hotmail.nl","password":"","skinDefault":"http://assets.mojang.com/SkinTemplates/steve.png"}

View File

@ -1,11 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
@ -14,20 +16,26 @@
<div class="content"> <div class="content">
<p class="message"></p> <p class="message"></p>
<form action="#"> <div class="left">
<label for="user">Username or E-mail</label><br> <p class="message info">
<input type="text" id="user" placeholder="Username or E-mail" required><br> Your password will stored in plaintext because the Mojang API requires it, do not use this option unless
you are on a private computer.
</p>
</div>
<div class="right">
<form action="#">
<label for="user">Username or E-mail</label><br>
<input type="text" id="user" placeholder="Username or E-mail" required><br>
<label for="password">Password:</label><br> <label for="password">Password:</label><br>
<input type="password" id="password" placeholder="Password" required><br> <input type="password" id="password" placeholder="Password" required><br>
<label for="save">Save password:</label> <label for="save">Save password:</label>
<input type="checkbox" id="save"> <input type="checkbox" id="save"><br>
<p class="message info">Your password will stored in plaintext because the Mojang API requires it, do not use this option unless you are on a private computer.</p> <button type="submit">Submit</button>
</form>
<button type="submit">Submit</button> </div>
</form>
</div> </div>
<script src="../src/auth.js"></script> <script src="../src/auth.js"></script>
@ -36,4 +44,5 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -1,11 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
@ -14,13 +16,22 @@
<div class="content"> <div class="content">
<p class="message success"></p> <p class="message success"></p>
<button id="current">Current Skin</button><br> <div class="left">
<button id="upload">Upload Skin</button><br> <p class="message info">
<button id="random">Random Skin</button><br> Logging out will delete your password from storage, if you want it to autofill next time you can just
<button id="logout">Logout</button> close this window when you are done.
<p class="message info"> </p>
Logging out will delete your password from storage, if you want it to autofill next time you can just close this window when you are done. <p class="message warning">
</p> Hecc inc. is not responsible for loss of data or explicit content (using random skin selection) seen
when using this program.
</p>
</div>
<div class="right">
<button id="current">Current Skin</button><br>
<button id="upload">Upload Skin</button><br>
<button id="random">Random Skin</button><br>
<button id="logout">Logout</button>
</div>
</div> </div>
<script src="../src/main.js"></script> <script src="../src/main.js"></script>
@ -29,4 +40,5 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -1,11 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
@ -15,12 +17,16 @@
<div class="content"> <div class="content">
<p class="message"></p> <p class="message"></p>
<img src="" class="skin" id="flat" alt="Current Skin" style="display: none;"> <div class="left">
<div id="mesh" style="display: inline;"></div> <img src="" class="skin" id="flat" alt="Current Skin" style="display: none;">
<div id="mesh" style="display: inline;"></div>
<button id="switch" style="display: none;">Switch to 2D</button>
</div>
<button id="switch">Switch to 2D</button> <div class="right">
<button id="download">Download</button> <button id="download">Download</button>
<button id="main">Back</button> <button id="main">Back</button>
</div>
</div> </div>
<script src="../src/skin.js"></script> <script src="../src/skin.js"></script>
@ -29,4 +35,5 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -1,19 +1,34 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
<h3>Random Skin</h3> <h3>Random Skin</h3>
</header> </header>
<div class="content" id="current"> <div class="content" id="random">
<p class="message"></p>
<div class="left">
<img src="" class="skin" id="flat" alt="Current Skin" style="display: none;">
<div id="mesh" style="display: inline;"></div>
<button id="switch" style="display: none;">Switch to 2D</button>
</div>
<div class="right">
<button id="random">Random</button>
<button id="set">Use this skin</button>
<button id="download">Download</button>
<button id="main">Back</button>
</div>
</div> </div>
<script src="../src/skin.js"></script> <script src="../src/skin.js"></script>
@ -22,4 +37,5 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -1,11 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
@ -13,10 +15,28 @@
</header> </header>
<div class="content" id="current"> <div class="content" id="current">
<form action="#"> <p class="message"></p>
<input type="file" id="skin">
<button type="submit">Submit</button> <div class="left">
</form> <img src="" class="skin" id="flat" alt="Current Skin" style="display: none;">
<div id="mesh" style="display: inline;"></div>
<button id="switch" style="display: none;">Switch to 2D</button>
</div>
<div class="right">
<button id="remote">Fetch from URL</button>
<button id="local">Upload file</button>
<form action="#" id="remote" style="display: none;">
<input type="text" id="url" placeholder="URL">
<button type="submit">Submit</button>
</form>
<form action="#" id="local" style="display: none;">
<input type="file" id="skin">
<button type="submit">Submit</button>
</form>
<button id="main">Back</button>
</div>
</div> </div>
<script src="../src/skin.js"></script> <script src="../src/skin.js"></script>
@ -25,4 +45,5 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -12,7 +12,7 @@ if (process.env.NODE_ENV === "dev") {
function createWindow () { function createWindow () {
// Create the browser window. // Create the browser window.
const win = new BrowserWindow({ const win = new BrowserWindow({
width: 320, width: 640,
height: 520, height: 520,
backgroundColor: "#ffffff", backgroundColor: "#ffffff",
resizable: false, resizable: false,

View File

@ -54,7 +54,7 @@ async function authenticate(user, password) {
} }
// Get access token from Mojang Authserver // Get access token from Mojang Authserver
const form = document.querySelectorAll("div.content > form")[0]; const form = document.querySelectorAll("div.content > div.right > form")[0];
form.querySelectorAll("input#user")[0].value = authData.user; form.querySelectorAll("input#user")[0].value = authData.user;
form.querySelectorAll("input#password")[0].value = authData.password; form.querySelectorAll("input#password")[0].value = authData.password;

View File

@ -15,22 +15,22 @@ const msg = document.querySelectorAll("div.content > p.message")[0];
msg.classList.add("success"); msg.classList.add("success");
msg.innerHTML = `Logged in as ${session.selectedProfile.name}`; msg.innerHTML = `Logged in as ${session.selectedProfile.name}`;
document.querySelectorAll("div.content > button#current")[0].addEventListener("click", (e) => { document.querySelectorAll("div.content > div.right > button#current")[0].addEventListener("click", (e) => {
console.log("Clicked current button"); console.log("Clicked current button");
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_current.hbs`)); remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_current.hbs`));
}); });
document.querySelectorAll("div.content > button#upload")[0].addEventListener("click", (e) => { document.querySelectorAll("div.content > div.right > button#upload")[0].addEventListener("click", (e) => {
console.log("Clicked upload button"); console.log("Clicked upload button");
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_upload.hbs`)); remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_upload.hbs`));
}); });
document.querySelectorAll("div.content > button#random")[0].addEventListener("click", (e) => { document.querySelectorAll("div.content > div.right > button#random")[0].addEventListener("click", (e) => {
console.log("Clicked random button"); console.log("Clicked random button");
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_random.hbs`)); remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_random.hbs`));
}); });
document.querySelectorAll("div.content > button#logout")[0].addEventListener("click", (e) => { document.querySelectorAll("div.content > div.right > button#logout")[0].addEventListener("click", (e) => {
console.log("Clicked logout button"); console.log("Clicked logout button");
if (ipcRenderer.sendSync("setSession", {})) { if (ipcRenderer.sendSync("setSession", {})) {
var authData = ipcRenderer.sendSync("getAuth"); var authData = ipcRenderer.sendSync("getAuth");

View File

@ -1,5 +1,9 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
const { BrowserWindow, ipcRenderer, remote } = require("electron"); const {
BrowserWindow,
ipcRenderer,
remote
} = require("electron");
const axios = require("axios").default; const axios = require("axios").default;
const path = require("path"); const path = require("path");
@ -15,6 +19,36 @@ if (!session.accessToken) {
const regex = /(?!\w*_)\w*(?=\.\w*)/g; const regex = /(?!\w*_)\w*(?=\.\w*)/g;
var action = __filename.match(regex)[0]; var action = __filename.match(regex)[0];
var parser = new DOMParser();
var randomUrls = [];
// Switch button and views
var btn = document.querySelectorAll("div.content > div.left > button#switch")[0];
var view = {
flat: document.querySelectorAll("div.content > div.left > img.skin#flat")[0],
mesh: document.querySelectorAll("div.content > div.left > div#mesh")[0]
};
function setView(url, controls = true) {
btn.style.display = "initial";
view.flat.src = url;
view.mesh.innerHTML = "";
// Set mesh view
let skinViewer = new skinview3d.SkinViewer({
domElement: view.mesh,
width: 300,
height: 250,
skinUrl: url
});
let control = skinview3d.createOrbitControls(skinViewer);
control.enableRotate = controls;
control.enableZoom = false;
control.enablePan = false;
}
switch (action) { switch (action) {
case "current": case "current":
@ -22,72 +56,90 @@ case "current":
method: "GET", method: "GET",
url: "https://sessionserver.mojang.com/session/minecraft/profile/" + session.selectedProfile.id url: "https://sessionserver.mojang.com/session/minecraft/profile/" + session.selectedProfile.id
}).then((data) => { }).then((data) => {
// Switch button and views setView(JSON.parse(atob(data.data.properties[0].value)).textures.SKIN.url);
var btn = document.querySelectorAll("div.content > button#switch")[0];
var view = {
flat: document.querySelectorAll("div.content > img.skin#flat")[0],
mesh: document.querySelectorAll("div.content > div#mesh")[0]
};
// Set flat view
const url = JSON.parse(atob(data.data.properties[0].value)).textures.SKIN.url;
view.flat.src = url;
// Set mesh view
let skinViewer = new skinview3d.SkinViewer({
domElement: view.mesh,
width: 200,
height: 200,
skinUrl: url
});
let control = skinview3d.createOrbitControls(skinViewer);
control.enableRotate = true;
control.enableZoom = false;
control.enablePan = false;
// Switch button action
btn.addEventListener("click", (e) => {
console.log("Switch button clicked");
if (view.flat.style.display == "inline") {
view.flat.style.display = "none";
view.mesh.style.display = "inline";
btn.innerHTML = "Switch to 2D";
} else {
view.flat.style.display = "inline";
view.mesh.style.display = "none";
btn.innerHTML = "Switch to 3D";
}
});
// Download button action
document.querySelectorAll("div.content > button#download")[0].addEventListener("click", (e) => {
ipcRenderer.send("download", {
url: url,
properties: {
saveAs: true
}
});
ipcRenderer.on("downloadResult", (event, arg) => {
var msg = document.querySelectorAll("div.content > p.message")[0];
console.log(msg);
msg.classList.add("success");
msg.innerHTML = "Downloaded successfully";
});
});
}); });
break; break;
case "upload": case "upload":
document.querySelectorAll("div.content > div.right > button").forEach(element => {
element.addEventListener("click", (e) => {
document.querySelectorAll("div.content > div.right > button").forEach(button => {
if (button.id != "main") {
button.style.display = "none";
}
});
document.querySelectorAll(`div.content > div.right > form#${element.id}`)[0].style.display = "block";
});
});
break; break;
case "random": case "random":
axios({
method: "GET",
url: "https://nl.namemc.com/minecraft-skins/random"
}).then((data) => {
var namemc = parser.parseFromString(data.data, "text/html");
namemc.querySelectorAll("a").forEach((e) => {
var href = e.getAttribute("href");
if (href.includes("skin")) {
var id = href.split("/")[2];
if (id && id.length == 16 && !(id.includes("-"))) {
randomUrls.push("https://nl.namemc.com/texture/" + id + ".png");
}
}
});
function random() {
console.log(randomUrls.length);
if (randomUrls.length == 0) {
window.location.reload();
} else {
var id = Math.floor(Math.random() * (randomUrls.length - 0)) + 0;
setView(randomUrls[id]);
randomUrls.splice(id, 1);
}
}
random();
document.querySelectorAll("div.content > div.right > button#random")[0].addEventListener("click", (e) => {
random();
});
});
break; break;
} }
document.querySelectorAll("div.content > button#main")[0].addEventListener("click", (e) => { // Download button action
document.querySelectorAll("div.content > div.right > button#download")[0].addEventListener("click", (e) => {
ipcRenderer.send("download", {
url: view.flat.src,
properties: {
saveAs: true
}
});
ipcRenderer.on("downloadResult", (event, arg) => {
var msg = document.querySelectorAll("div.content > p.message")[0];
console.log(msg);
msg.classList.add("success");
msg.innerHTML = "Downloaded successfully";
});
});
// Switch button action
btn.addEventListener("click", (e) => {
if (view.flat.style.display == "inline") {
view.flat.style.display = "none";
view.mesh.style.display = "inline";
btn.innerHTML = "Switch to 2D";
} else {
view.flat.style.display = "inline";
view.mesh.style.display = "none";
btn.innerHTML = "Switch to 3D";
}
});
// Back button action
document.querySelectorAll("div.content > div.right > button#main")[0].addEventListener("click", (e) => {
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/main.hbs`)); remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/main.hbs`));
}); });