Add generic file sync and improve UI for game launch
Introduced GenericFilesService to fetch and validate required game files before launching. Updated launcher version to beta and added support for AuthlibInjector agent in launch options. Improved avatar rendering and button states in the UI, including pixelated avatar display and disabled state handling for logout during game launch.
This commit is contained in:
@@ -54,6 +54,8 @@ main > aside > nav > button:first-of-type > img {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 5px;
|
||||
image-rendering: pixelated;
|
||||
image-rendering: crisp-edges;
|
||||
}
|
||||
|
||||
main > aside > nav > button:nth-child(2) {
|
||||
@@ -70,7 +72,7 @@ main > aside > nav > button:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
main > aside > nav > button:has(> i.fas.fa-sign-out-alt):hover {
|
||||
main > aside > nav > button:has(> i.fas.fa-sign-out-alt):not(:disabled):hover {
|
||||
color: #ff4747;
|
||||
}
|
||||
|
||||
@@ -124,6 +126,11 @@ button.play:disabled {
|
||||
filter: grayscale(100%);
|
||||
}
|
||||
|
||||
button.logout:disabled {
|
||||
cursor: not-allowed;
|
||||
filter: brightness(0.70);
|
||||
}
|
||||
|
||||
button.play > i {
|
||||
margin-right: 5px;
|
||||
font-size: 14px;
|
||||
|
||||
@@ -3,6 +3,7 @@ const dynmapFrame = document.querySelector("article.frame.dynmap > iframe")
|
||||
const capesSelector = document.querySelector("article.capes > div.capes")
|
||||
const logsContainer = document.querySelector("div.container.logs")
|
||||
const playButton = document.querySelector("button.play")
|
||||
const logoutButton = document.querySelector("button.logout")
|
||||
|
||||
let viewerInstance = new skinview3d.SkinViewer({
|
||||
canvas: document.getElementById("skin"),
|
||||
@@ -43,7 +44,29 @@ window.getPlayer = async function getPlayer() {
|
||||
return result
|
||||
}
|
||||
|
||||
window.displayMinecraftHead = function displayMinecraftHead(skinUrl, targetImg) {
|
||||
const canvas = document.createElement("canvas")
|
||||
const ctx = canvas.getContext("2d")
|
||||
const skinImg = new Image()
|
||||
|
||||
skinImg.crossOrigin = "anonymous"
|
||||
|
||||
skinImg.onload = function() {
|
||||
canvas.width = 8
|
||||
canvas.height = 8
|
||||
|
||||
ctx.imageSmoothingEnabled = false
|
||||
|
||||
ctx.drawImage(skinImg, 8, 8, 8, 8, 0, 0, 8, 8)
|
||||
ctx.drawImage(skinImg, 40, 8, 8, 8, 0, 0, 8, 8)
|
||||
document.querySelector(targetImg).src = canvas.toDataURL()
|
||||
}
|
||||
|
||||
skinImg.src = skinUrl
|
||||
}
|
||||
|
||||
window.profile = await getPlayer()
|
||||
displayMinecraftHead(`https://yggdrasil.azures.fr/textures/${profile.skins.find(skin => skin.state == "ACTIVE").url.replace(/^\//, "")}`, "img.avatar")
|
||||
|
||||
window.refreshProfile = async function refreshProfile() {
|
||||
window.profile = await getPlayer()
|
||||
@@ -97,13 +120,16 @@ window.initSkin = async function initSkin() {
|
||||
return
|
||||
}
|
||||
|
||||
const skinUrl = `https://yggdrasil.azures.fr/textures/${profile.skins.find(skin => skin.state == "ACTIVE").url.replace(/^\//, "")}`
|
||||
viewerInstance = new skinview3d.SkinViewer({
|
||||
canvas: document.getElementById("skin"),
|
||||
width: container.clientWidth,
|
||||
height: container.clientHeight,
|
||||
skin: `https://yggdrasil.azures.fr/textures/${profile.skins.find(skin => skin.state == "ACTIVE").url.replace(/^\//, "")}`
|
||||
skin: skinUrl
|
||||
})
|
||||
|
||||
displayMinecraftHead(skinUrl, "img.avatar")
|
||||
|
||||
const activeCape = window.profile.capes.find(s => s.state === "ACTIVE") || null
|
||||
const capeUrl = activeCape == null ? null : `https://yggdrasil.azures.fr/textures/${activeCape.url.replace(/^\//, "")}?t=${Date.now()}`
|
||||
|
||||
@@ -147,6 +173,7 @@ window.validateSkinSelection = async function validateSkinSelection(localPath) {
|
||||
if (activeSkin) {
|
||||
const skinUrl = `https://yggdrasil.azures.fr/textures/${activeSkin.url.replace(/^\//, "")}?t=${Date.now()}`
|
||||
const capeUrl = activeCape == null ? null : `https://yggdrasil.azures.fr/textures/${activeCape.url.replace(/^\//, "")}?t=${Date.now()}`
|
||||
displayMinecraftHead(skinUrl, "img.avatar")
|
||||
await viewerInstance.loadSkin(skinUrl, {
|
||||
model: variant.toLowerCase() === "slim" ? "slim" : "default"
|
||||
})
|
||||
@@ -246,12 +273,14 @@ window.play = async function play() {
|
||||
gamelog.clear()
|
||||
showLoadingBar()
|
||||
playButton.setAttribute("disabled", "")
|
||||
logoutButton.setAttribute("disabled", "")
|
||||
const gameLaunch = await system.call("launcher::game")
|
||||
if (gameLaunch.success) {
|
||||
hideLoadingBar()
|
||||
} else {
|
||||
hideLoadingBar()
|
||||
playButton.removeAttribute("disabled")
|
||||
logoutButton.removeAttribute("disabled")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user