new commit
This commit is contained in:
parent
4f01013d42
commit
bf9406f924
Binary file not shown.
BIN
app/assets/audio/main_menu.mp3
Normal file
BIN
app/assets/audio/main_menu.mp3
Normal file
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 389 KiB |
BIN
app/assets/img/sulli.png
Normal file
BIN
app/assets/img/sulli.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 846 KiB |
@ -7,7 +7,7 @@ const audioPourcentageLabel = document.querySelector("label[for='audioVolume']")
|
|||||||
const audio = new Audio()
|
const audio = new Audio()
|
||||||
|
|
||||||
function startAudio() {
|
function startAudio() {
|
||||||
audio.src = "./assets/audio/Golden Hill (Radio Edit).mp3"
|
audio.src = "./assets/audio/main_menu.mp3"
|
||||||
audio.loop = true
|
audio.loop = true
|
||||||
audio.play()
|
audio.play()
|
||||||
audio.onended = () => {
|
audio.onended = () => {
|
||||||
@ -76,7 +76,7 @@ function updateVolume(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
localStorage.removeItem("user")
|
system.call("auth::reset")
|
||||||
document.location.href = './login.html'
|
document.location.href = './login.html'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,12 +84,6 @@ system.result("server::ping", pong => {
|
|||||||
playersStatus.innerText = `${pong.players.online}/${pong.players.max}`
|
playersStatus.innerText = `${pong.players.online}/${pong.players.max}`
|
||||||
})
|
})
|
||||||
|
|
||||||
system.result("player::profile", playerProfile => {
|
|
||||||
if (!localStorage.getItem("user")) {
|
|
||||||
localStorage.setItem("user", JSON.stringify(playerProfile))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function handleOptionsChanges(key, value) {
|
function handleOptionsChanges(key, value) {
|
||||||
system.call("game::optionSet", { key, value })
|
system.call("game::optionSet", { key, value })
|
||||||
}
|
}
|
||||||
@ -123,6 +117,11 @@ system.result("game::launch", info => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
system.result("player::profile", playerProfile => {
|
||||||
|
console.log(playerProfile)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
system.call("hardware::ramInformation")
|
system.call("hardware::ramInformation")
|
||||||
system.call("game::parseOptions")
|
system.call("game::parseOptions")
|
||||||
|
|||||||
@ -19,12 +19,3 @@ system.result("auth::microsoft", () => {
|
|||||||
system.result("auth::refresh", () => {
|
system.result("auth::refresh", () => {
|
||||||
selectLoginType("select")
|
selectLoginType("select")
|
||||||
})
|
})
|
||||||
|
|
||||||
window.onload = () => {
|
|
||||||
if (localStorage.getItem("user")) {
|
|
||||||
system.call("auth::refresh", {
|
|
||||||
user: JSON.parse(localStorage.getItem("user"))
|
|
||||||
})
|
|
||||||
selectLoginType("token")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -210,7 +210,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</section>
|
</section>
|
||||||
<section class="right">
|
<section class="right">
|
||||||
<img class="mascot" src="./assets/img/alcaz_mascote.png" alt="">
|
<img class="mascot" src="./assets/img/sulli.png" alt="">
|
||||||
</section>
|
</section>
|
||||||
</footer>
|
</footer>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
73
main.js
73
main.js
@ -46,7 +46,7 @@ async function createLauncherWindow() {
|
|||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
preload: path.join(__dirname, "modules", "preload.js"),
|
preload: path.join(__dirname, "modules", "preload.js"),
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
devTools: false
|
devTools: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (os.platform() == "darwin") {
|
if (os.platform() == "darwin") {
|
||||||
@ -184,6 +184,7 @@ ipcMain.on("call", async (event, data) => {
|
|||||||
case "auth::mojang":
|
case "auth::mojang":
|
||||||
if (data.args.trim() != "") {
|
if (data.args.trim() != "") {
|
||||||
auth = Authenticator.getAuth(data.args.username, data.args.password)
|
auth = Authenticator.getAuth(data.args.username, data.args.password)
|
||||||
|
launcherSettings.set("auth", { token: (await auth).access_token, type: "mojang", clientToken: (await auth).client_token })
|
||||||
await fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${(await auth).uuid}`)
|
await fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${(await auth).uuid}`)
|
||||||
await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html"))
|
await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html"))
|
||||||
} else {
|
} else {
|
||||||
@ -196,6 +197,8 @@ ipcMain.on("call", async (event, data) => {
|
|||||||
const xboxManager = await authManager.launch("electron")
|
const xboxManager = await authManager.launch("electron")
|
||||||
const token = await xboxManager.getMinecraft()
|
const token = await xboxManager.getMinecraft()
|
||||||
auth = token.mclc()
|
auth = token.mclc()
|
||||||
|
console.log(auth.meta)
|
||||||
|
launcherSettings.set("auth", { token: auth.meta, type: "msa", clientToken: auth.client_token })
|
||||||
launcherWindow.loadFile(path.join(__dirname, "app", "logged.html"))
|
launcherWindow.loadFile(path.join(__dirname, "app", "logged.html"))
|
||||||
fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${auth.uuid}`)
|
fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${auth.uuid}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -205,32 +208,8 @@ ipcMain.on("call", async (event, data) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "auth::refresh":
|
case "auth::reset":
|
||||||
const user = data.args.user
|
launcherSettings.set("auth", { token: "", type: "msa", clientToken: "" })
|
||||||
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"))
|
|
||||||
await fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${auth.uuid}`)
|
|
||||||
} catch (error) {
|
|
||||||
dialog.showErrorBox("Erreur lors de la connexion via token", error)
|
|
||||||
console.error(error)
|
|
||||||
launcherWindow.webContents.send("Response<auth::refresh>")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
auth = Authenticator.refreshAuth(user.access_token, user.client_token)
|
|
||||||
await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html"))
|
|
||||||
await fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${(await auth).uuid}`)
|
|
||||||
} catch (error) {
|
|
||||||
dialog.showErrorBox("Erreur lors de la connexion via token", error)
|
|
||||||
console.error(error)
|
|
||||||
launcherWindow.webContents.send("Response<auth::refresh>")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
case "shell::openExternal":
|
case "shell::openExternal":
|
||||||
shell.openExternal(data.args.url)
|
shell.openExternal(data.args.url)
|
||||||
@ -288,45 +267,7 @@ async function launchGame(restartGame) {
|
|||||||
launcherWindow.setProgressBar(10, {
|
launcherWindow.setProgressBar(10, {
|
||||||
mode: "indeterminate"
|
mode: "indeterminate"
|
||||||
})
|
})
|
||||||
for (const remoteFile of remoteFiles) {
|
|
||||||
try {
|
|
||||||
const localFile = localFiles.find(file => file === remoteFile)
|
|
||||||
|
|
||||||
if (!localFile) {
|
|
||||||
downloadQueue.push(remoteFile)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const localHash = await fileManager.getFileHash(path.join(app.getPath("appData"), ".catboat", localFile))
|
|
||||||
const remoteHash = await fileManager.getRemoteFileHash(localFile)
|
|
||||||
if (localHash != remoteHash) {
|
|
||||||
downloadQueue.push(localFile)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const localFile of localFiles) {
|
|
||||||
if (!remoteFiles.find(remoteFile => remoteFile.path == localFile) && localFile.startsWith("/mods")) {
|
|
||||||
fs.unlinkSync(path.join(app.getPath("appData"), ".catboat", localFile))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const item of downloadQueue) {
|
|
||||||
const url = `${config.api.base}${config.api.endpoints.downloadFile}/${new String(item).replace(/\\/g, "/")}`
|
|
||||||
try {
|
|
||||||
await download(url, path.join(app.getPath("appData"), ".catboat", path.dirname(item)))
|
|
||||||
launcherWindow.setProgressBar(((downloadQueue.indexOf(item) + 1) / downloadQueue.length) * 100, {
|
|
||||||
mode: "normal"
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
launcherWindow.setProgressBar(((downloadQueue.indexOf(item) + 1) / downloadQueue.length) * 100, {
|
|
||||||
mode: "error"
|
|
||||||
})
|
|
||||||
dialog.showErrorBox("Erreur lors du téléchargement des fichiers", error.toString())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
launcherWindow.setProgressBar(0, {
|
launcherWindow.setProgressBar(0, {
|
||||||
mode: "none"
|
mode: "none"
|
||||||
})
|
})
|
||||||
@ -371,5 +312,7 @@ socket.on("force-game-update", async () => {
|
|||||||
})
|
})
|
||||||
launchProcess.kill()
|
launchProcess.kill()
|
||||||
await launchGame(true)
|
await launchGame(true)
|
||||||
|
} else {
|
||||||
|
await launchGame(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -6,22 +6,26 @@ let launcherDataPath = path.join(__dirname, ".catboat")
|
|||||||
const baseSettings = {
|
const baseSettings = {
|
||||||
ram: {
|
ram: {
|
||||||
max: 1024
|
max: 1024
|
||||||
|
},
|
||||||
|
auth: {
|
||||||
|
token: "",
|
||||||
|
type: "msa",
|
||||||
|
clientToken: ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSettings($launcherDataPath) {
|
function initSettings($launcherDataPath) {
|
||||||
launcherDataPath = $launcherDataPath
|
launcherDataPath = $launcherDataPath
|
||||||
const gameDir = path.parse($launcherDataPath).dir
|
if (!fs.existsSync(launcherDataPath)) {
|
||||||
if (!fs.existsSync(gameDir)) {
|
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(gameDir)
|
fs.mkdirSync(launcherDataPath)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fs.existsSync($launcherDataPath)) {
|
if (!fs.existsSync(path.join(launcherDataPath, "launcher_settings.json"))) {
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync($launcherDataPath, JSON.stringify(baseSettings, null, 4))
|
fs.writeFileSync(path.join(launcherDataPath, "launcher_settings.json"), JSON.stringify(baseSettings, null, 4))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
@ -37,7 +41,8 @@ function writeSettings(settings) {
|
|||||||
fs.writeFileSync(path.join(launcherDataPath, "launcher_settings.json"), JSON.stringify(settings, null, 4))
|
fs.writeFileSync(path.join(launcherDataPath, "launcher_settings.json"), JSON.stringify(settings, null, 4))
|
||||||
return
|
return
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
clean()
|
||||||
|
return writeSettings(settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,8 +63,8 @@ function get(key) {
|
|||||||
|
|
||||||
return value
|
return value
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Erreur lors de l'accès aux paramètres :", error.message)
|
clean()
|
||||||
throw error
|
return get(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,10 +86,10 @@ function set(key, newValue) {
|
|||||||
|
|
||||||
obj[keys[keys.length - 1]] = newValue
|
obj[keys[keys.length - 1]] = newValue
|
||||||
|
|
||||||
fs.writeFileSync(filePath, JSON.stringify(settings, null, 2))
|
fs.writeFileSync(filePath, JSON.stringify(settings, null, 4))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Erreur lors de la mise à jour des paramètres :", error.message)
|
clean()
|
||||||
throw error
|
return set(ke, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +106,8 @@ function readSettings() {
|
|||||||
try {
|
try {
|
||||||
return JSON.parse(fs.readFileSync(path.join(launcherDataPath, "launcher_settings.json")))
|
return JSON.parse(fs.readFileSync(path.join(launcherDataPath, "launcher_settings.json")))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
clean()
|
||||||
|
return readSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
package-lock.json
generated
10
package-lock.json
generated
@ -11,6 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord-rpc": "^4.0.1",
|
"discord-rpc": "^4.0.1",
|
||||||
"download": "^8.0.0",
|
"download": "^8.0.0",
|
||||||
|
"js-java-properties": "^1.0.3",
|
||||||
"minecraft-launcher-core": "^3.18.2",
|
"minecraft-launcher-core": "^3.18.2",
|
||||||
"msmc": "^5.0.5",
|
"msmc": "^5.0.5",
|
||||||
"socket.io-client": "^4.8.1"
|
"socket.io-client": "^4.8.1"
|
||||||
@ -4218,6 +4219,15 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/js-java-properties": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-java-properties/-/js-java-properties-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-KFvPPxguCIv4T/Z45tk+eDkD2UiPglaarN8qyrY3RsJDnhz2LMlHp52WFYRYjub5F4SlMKv2u0Z6F/yR1eZ5Jg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 14"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/js-yaml": {
|
"node_modules/js-yaml": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord-rpc": "^4.0.1",
|
"discord-rpc": "^4.0.1",
|
||||||
"download": "^8.0.0",
|
"download": "^8.0.0",
|
||||||
|
"js-java-properties": "^1.0.3",
|
||||||
"minecraft-launcher-core": "^3.18.2",
|
"minecraft-launcher-core": "^3.18.2",
|
||||||
"msmc": "^5.0.5",
|
"msmc": "^5.0.5",
|
||||||
"socket.io-client": "^4.8.1"
|
"socket.io-client": "^4.8.1"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user