Compare commits
4 Commits
0.0.1-alph
...
0.0.1-alph
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a31e419cc | |||
| bf9406f924 | |||
| 4f01013d42 | |||
| 9a6e4ab0d1 |
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.
@@ -92,7 +92,7 @@ img.logo {
|
||||
img.mascot {
|
||||
width: 50%;
|
||||
float: right;
|
||||
margin-top: calc(300px - (50% + 12px));
|
||||
margin-top: calc(300px - (50% + 32px));
|
||||
}
|
||||
|
||||
fieldset {
|
||||
@@ -372,7 +372,25 @@ div.checkboxes > input[type="checkbox"] {
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
button.load {
|
||||
content: "";
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
|
||||
[hidden] {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
@keyframes backgroundAnimation {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
function startAudio() {
|
||||
audio.src = "./assets/audio/Golden Hill (Radio Edit).mp3"
|
||||
audio.src = "./assets/audio/main_menu.mp3"
|
||||
audio.loop = true
|
||||
audio.play()
|
||||
audio.onended = () => {
|
||||
@@ -76,7 +76,7 @@ function updateVolume(value) {
|
||||
}
|
||||
|
||||
function logout() {
|
||||
localStorage.removeItem("user")
|
||||
system.call("auth::reset")
|
||||
document.location.href = './login.html'
|
||||
}
|
||||
|
||||
@@ -84,18 +84,20 @@ system.result("server::ping", pong => {
|
||||
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) {
|
||||
system.call("game::optionSet", { key, value })
|
||||
const span = document.querySelector(`span#${key}`)
|
||||
if (span) {
|
||||
span.innerText = Math.floor(value)
|
||||
}
|
||||
}
|
||||
|
||||
function handleSettingsChanges(key, value) {
|
||||
system.call("settings::set", { key, value })
|
||||
const span = document.querySelector(`span#${key == "ram" ? "currentRam" : key}`)
|
||||
if (span) {
|
||||
span.innerText = key == "ram" ? Math.floor(value.max / 1024) + " G" : value
|
||||
}
|
||||
}
|
||||
|
||||
system.result("game::parseOptions", options => {
|
||||
@@ -123,11 +125,20 @@ system.result("game::launch", info => {
|
||||
}
|
||||
})
|
||||
|
||||
system.result("player::profile", playerProfile => {
|
||||
console.log(playerProfile)
|
||||
})
|
||||
|
||||
system.result("oculus::getdefaultshaderset", boolean => {
|
||||
sildurs_shader.checked = boolean
|
||||
})
|
||||
|
||||
window.onload = () => {
|
||||
system.call("hardware::ramInformation")
|
||||
system.call("game::parseOptions")
|
||||
system.call("server::ping")
|
||||
system.call("player::profile")
|
||||
system.call("settings::read")
|
||||
system.call("oculus::getdefaultshaderset")
|
||||
startAudio()
|
||||
}
|
||||
@@ -19,12 +19,3 @@ system.result("auth::microsoft", () => {
|
||||
system.result("auth::refresh", () => {
|
||||
selectLoginType("select")
|
||||
})
|
||||
|
||||
window.onload = () => {
|
||||
if (localStorage.getItem("user")) {
|
||||
system.call("auth::refresh", {
|
||||
user: JSON.parse(localStorage.getItem("user"))
|
||||
})
|
||||
selectLoginType("token")
|
||||
}
|
||||
}
|
||||
@@ -46,10 +46,10 @@
|
||||
Ram alloué
|
||||
</label>
|
||||
<div class="ranges">
|
||||
<span>
|
||||
<span id="currentRam">
|
||||
0.5GB
|
||||
</span>
|
||||
<input type="range" name="ram" min="0" max="2048" id="ram" onchange="handleSettingsChanges(this.name, this.value)">
|
||||
<input type="range" name="ram" min="0" max="2048" id="ram" onchange="handleSettingsChanges('ram', { max: this.value })">
|
||||
<span id="maxRam">
|
||||
MAX
|
||||
</span>
|
||||
@@ -59,7 +59,7 @@
|
||||
Distance de rendu
|
||||
</label>
|
||||
<div class="ranges">
|
||||
<span>
|
||||
<span id="renderDistance">
|
||||
4
|
||||
</span>
|
||||
<input type="range" name="renderDistance" min="4" max="32" id="renderDistance" onchange="handleOptionsChanges(this.name, this.value)">
|
||||
@@ -72,7 +72,7 @@
|
||||
Taille de l'interface
|
||||
</label>
|
||||
<div class="ranges">
|
||||
<span>
|
||||
<span id="guiScale">
|
||||
1
|
||||
</span>
|
||||
<input type="range" name="guiScale" min="1" max="4" id="guiScale" onchange="handleOptionsChanges(this.name, this.value)">
|
||||
@@ -100,12 +100,12 @@
|
||||
Luminsoité max
|
||||
</label>
|
||||
</div>
|
||||
<!-- <div>
|
||||
<input type="checkbox" name="sildurs_shader" id="sildurs_shader">
|
||||
<div>
|
||||
<input type="checkbox" name="sildurs_shader" id="sildurs_shader" onclick="system.call('oculus::defaultshaderset', { boolean: this.checked })">
|
||||
<label for="sildurs_shader">
|
||||
Sildur's Shader
|
||||
</label>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</details>
|
||||
@@ -205,12 +205,12 @@
|
||||
<section class="center">
|
||||
<img class="logo" src="./assets/img/logo.png" alt="">
|
||||
<br>
|
||||
<button class="play" name="play" onclick="system.call('game::launch')">
|
||||
<button class="play load" name="play" onclick="system.call('game::launch')">
|
||||
Jouer
|
||||
</button>
|
||||
</section>
|
||||
<section class="right">
|
||||
<img class="mascot" src="./assets/img/alcaz_mascote.png" alt="">
|
||||
<img class="mascot" src="./assets/img/sulli.png" alt="">
|
||||
</section>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
2
build.js
2
build.js
@@ -43,7 +43,7 @@ async function buildApp() {
|
||||
"!dist",
|
||||
"!.env"
|
||||
],
|
||||
buildNumber: 1,
|
||||
buildNumber: 2,
|
||||
buildVersion: `${package.version}`,
|
||||
releaseInfo: {
|
||||
releaseDate: getFormattedProductionDate(),
|
||||
|
||||
90
main.js
90
main.js
@@ -1,4 +1,5 @@
|
||||
const { BrowserWindow, app, net, dialog, ipcMain, nativeImage, session, shell } = require("electron")
|
||||
const properties = require("js-java-properties")
|
||||
const msmc = require("msmc")
|
||||
const os = require("node:os")
|
||||
const fs = require("node:fs")
|
||||
@@ -13,6 +14,7 @@ const fileManager = require("./modules/fileManager")
|
||||
const launcher = new Client()
|
||||
const { io } = require("socket.io-client")
|
||||
const download = require("download")
|
||||
const rpc = require("./modules/rpc")
|
||||
const socket = io({
|
||||
host: config.api.websockets.base.host,
|
||||
port: config.api.websockets.base.port
|
||||
@@ -20,6 +22,8 @@ const socket = io({
|
||||
|
||||
let launcherWindow, auth, gamePlayable = false, launchProcess
|
||||
|
||||
rpc.startRichPresence()
|
||||
|
||||
async function createLauncherWindow() {
|
||||
gameOptions.initOptions(path.join(app.getPath("appData"), ".catboat", "options.txt"))
|
||||
launcherSettings.initSettings(path.join(app.getPath("appData"), ".catboat"))
|
||||
@@ -181,6 +185,7 @@ ipcMain.on("call", async (event, data) => {
|
||||
case "auth::mojang":
|
||||
if (data.args.trim() != "") {
|
||||
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 launcherWindow.loadFile(path.join(__dirname, "app", "logged.html"))
|
||||
} else {
|
||||
@@ -190,11 +195,13 @@ ipcMain.on("call", async (event, data) => {
|
||||
case "auth::microsoft":
|
||||
const authManager = new msmc.Auth("select_account")
|
||||
try {
|
||||
const xboxManager = await authManager.launch("raw")
|
||||
const xboxManager = await authManager.launch("electron")
|
||||
const token = await xboxManager.getMinecraft()
|
||||
auth = token.mclc()
|
||||
await fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${auth.uuid}`)
|
||||
await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html"))
|
||||
console.log(auth.meta)
|
||||
launcherSettings.set("auth", { token: auth.meta, type: "msa", clientToken: auth.client_token })
|
||||
launcherWindow.loadFile(path.join(__dirname, "app", "logged.html"))
|
||||
fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${auth.uuid}`)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
if (error == "error.gui.closed") {
|
||||
@@ -202,32 +209,11 @@ ipcMain.on("call", async (event, data) => {
|
||||
}
|
||||
}
|
||||
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"))
|
||||
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>")
|
||||
}
|
||||
}
|
||||
case "auth::reset":
|
||||
launcherSettings.set("auth", { token: "", type: "msa", clientToken: "" })
|
||||
break
|
||||
case "settings::set":
|
||||
launcherSettings.set(data.args.key, data.args.value)
|
||||
break
|
||||
case "shell::openExternal":
|
||||
shell.openExternal(data.args.url)
|
||||
@@ -274,6 +260,19 @@ ipcMain.on("call", async (event, data) => {
|
||||
case "app::devtools":
|
||||
launcherWindow.webContents.openDevTools()
|
||||
break
|
||||
case "oculus::defaultshaderset":
|
||||
const oculusProperties = properties.parse(fs.readFileSync(path.join(app.getPath("appData"), ".catboat", "config", "oculus.properties")).toString())
|
||||
if (data.args.boolean) {
|
||||
properties.setProperty(oculusProperties, "shaderPack", "Sildur%27s+Vibrant+Shaders+v1.50+Medium.zip")
|
||||
} else {
|
||||
properties.setProperty(oculusProperties, "shaderPack", "")
|
||||
}
|
||||
fs.writeFileSync(path.join(app.getPath("appData"), ".catboat", "config", "oculus.properties"), properties.stringify(oculusProperties))
|
||||
break
|
||||
case "oculus::getdefaultshaderset":
|
||||
const $oculusProperties = properties.parse(fs.readFileSync(path.join(app.getPath("appData"), ".catboat", "config", "oculus.properties")).toString())
|
||||
launcherWindow.webContents.send("Response<oculus::getdefaultshaderset>", properties.getProperty($oculusProperties, "shaderPack") == "Sildur%27s+Vibrant+Shaders+v1.50+Medium.zip" ? true : false)
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
@@ -282,9 +281,9 @@ async function launchGame(restartGame) {
|
||||
const downloadQueue = []
|
||||
const remoteFiles = await fileManager.getRemoteFiles()
|
||||
const localFiles = fs.readdirSync(path.join(app.getPath("appData"), ".catboat"), { recursive: true })
|
||||
launcherWindow.setProgressBar(10, {
|
||||
mode: "indeterminate"
|
||||
})
|
||||
if (launcherWindow instanceof BrowserWindow) {
|
||||
launcherWindow.webContents.send("Response<progress::update>", { type: "landing" })
|
||||
}
|
||||
for (const remoteFile of remoteFiles) {
|
||||
try {
|
||||
const localFile = localFiles.find(file => file === remoteFile)
|
||||
@@ -313,27 +312,20 @@ async function launchGame(restartGame) {
|
||||
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"
|
||||
})
|
||||
if (launcherWindow instanceof BrowserWindow) {
|
||||
launcherWindow.webContents.send("Response<progress::update>", { type: "landing" })
|
||||
}
|
||||
} catch (error) {
|
||||
launcherWindow.setProgressBar(((downloadQueue.indexOf(item) + 1) / downloadQueue.length) * 100, {
|
||||
mode: "error"
|
||||
})
|
||||
if (launcherWindow instanceof BrowserWindow) {
|
||||
launcherWindow.webContents.send("Response<progress::error>", { type: "landing" })
|
||||
}
|
||||
dialog.showErrorBox("Erreur lors du téléchargement des fichiers", error.toString())
|
||||
continue
|
||||
}
|
||||
}
|
||||
launcherWindow.setProgressBar(0, {
|
||||
mode: "none"
|
||||
})
|
||||
dialog.showMessageBox(launcherWindow, {
|
||||
title: "Téléchargement des fichiers",
|
||||
message: "Téléchargement fini."
|
||||
})
|
||||
gamePlayable = true
|
||||
launcher.on("close", () => {
|
||||
launcherSettings.webContents.send("Response<game::launch>", { disablePlayButton: true })
|
||||
launcherWindow.webContents.send("Response<game::launch>", { disablePlayButton: true })
|
||||
gamePlayable = true
|
||||
})
|
||||
launcher.on("debug", (log) => {
|
||||
@@ -342,6 +334,9 @@ async function launchGame(restartGame) {
|
||||
launcher.on("data", (log) => {
|
||||
console.log(log)
|
||||
})
|
||||
launcher.on("data", (log) => {
|
||||
console.log(log)
|
||||
})
|
||||
if (gamePlayable || restartGame) {
|
||||
const $launchProcess = await launcher.launch({
|
||||
root: path.join(app.getPath("appData"), ".catboat"),
|
||||
@@ -351,6 +346,7 @@ async function launchGame(restartGame) {
|
||||
type: "release"
|
||||
},
|
||||
forge: path.join(app.getPath("appData"), ".catboat", "forge-1.16.5.jar"),
|
||||
javaPath: "C:\\Program Files\\Java\\jdk-17\\bin\\java.exe",
|
||||
memory: {
|
||||
min: 512,
|
||||
max: launcherSettings.get("ram").max
|
||||
@@ -368,5 +364,7 @@ socket.on("force-game-update", async () => {
|
||||
})
|
||||
launchProcess.kill()
|
||||
await launchGame(true)
|
||||
} else {
|
||||
await launchGame(false)
|
||||
}
|
||||
})
|
||||
182
modules/java.js
Normal file
182
modules/java.js
Normal file
@@ -0,0 +1,182 @@
|
||||
const os = require("os")
|
||||
const path = require("path")
|
||||
const osmeta = require("./osmeta")
|
||||
const { exec } = require("child_process")
|
||||
const files = require("./files")
|
||||
const config = require("../config.json")
|
||||
const settings = require("./settings")
|
||||
const { dialog, BrowserWindow, shell } = require("electron")
|
||||
const AdmZip = require("adm-zip")
|
||||
|
||||
function isJavaInstalled() {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
exec(`"${settings.get("javaPath") == "" ? "java" : settings.get("javaPath")}" -version`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject({
|
||||
java: false
|
||||
})
|
||||
}
|
||||
const output = `${stdout}\n${stderr}`
|
||||
const lines = output.split("\n")
|
||||
const version = lines.filter(line => line.includes("version \""))[0]
|
||||
try {
|
||||
let matchRegEx
|
||||
if (version.includes("_")) {
|
||||
matchRegEx = /(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)\_(?<update>\d+)/
|
||||
} else {
|
||||
matchRegEx = /(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/
|
||||
}
|
||||
const versionMatch = version.match(matchRegEx)
|
||||
const { major, minor, patch, update } = versionMatch.groups
|
||||
resolve({
|
||||
java: true,
|
||||
version: {
|
||||
major: parseInt(major),
|
||||
minor: parseInt(minor),
|
||||
patch: parseInt(patch),
|
||||
update: update ? parseInt(update) : null
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
reject({
|
||||
java: false,
|
||||
error
|
||||
})
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
reject({
|
||||
java: false,
|
||||
error
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function showJavaErrorBox() {
|
||||
const javaErrorBox = await dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
|
||||
title: "Mauvaise version de Java",
|
||||
message: "Mauvaise version de Java",
|
||||
detail: "La version de java installé sur votre ordinateur n'est pas compatible avec la version de minecraft utilisé",
|
||||
icon: path.join(__dirname, "code/app/assets/img/java.png"),
|
||||
buttons: [
|
||||
"Fermer",
|
||||
"Installer automatiquement java",
|
||||
"Installer manuellement java",
|
||||
"Utilise un chemin d'accès personnalié",
|
||||
],
|
||||
cancelId: 0,
|
||||
defaultId: 1
|
||||
})
|
||||
return javaErrorBox
|
||||
}
|
||||
function installJava(dest) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const response = await fetch(`${config.apiServicesURL}/api/java`)
|
||||
const java = await response.json()
|
||||
const arch = osmeta.arch() == "unknow" ? "x64" : osmeta.arch()
|
||||
if (java.downloads[os.platform()]) {
|
||||
if (java.downloads[os.platform()][arch]) {
|
||||
files.downloadFile(config.apiServicesURL + java.downloads[os.platform()][arch].url, path.join(dest, "java.zip"), (error, file) => {
|
||||
if (error) throw error
|
||||
try {
|
||||
const zip = new AdmZip(path.join(dest, "java.zip"))
|
||||
zip.extractAllTo(path.join(dest, "java"), true)
|
||||
files.removeFile(path.join(dest, "java.zip"))
|
||||
if (os.platform() == "darwin") {
|
||||
exec(`chmod +x "${path.join(dest, "java", "jre-1.8.0_411.jre", "Contents", "Home", "bin", "java")}"`, (error) => {
|
||||
if (error) reject(error)
|
||||
resolve(path.join(dest, "java", "jre-1.8.0_411.jre", "Contents", "Home", "bin", "java"))
|
||||
})
|
||||
} else {
|
||||
exec(`chmod +x "${path.join(dest, "java", "bin", "java")}"`, (error) => {
|
||||
if (error) reject(error)
|
||||
resolve(path.join(dest, "java", "bin", "java"))
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
reject(new Error("Java are not supported for your OS arch"))
|
||||
}
|
||||
} else {
|
||||
reject(new Error("Java are not supported for your OS"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function main(requiredJavaVersionMinor, dest) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const java = await isJavaInstalled()
|
||||
if (java.version.minor < parseInt(requiredJavaVersionMinor)) {
|
||||
const javaErrorBox = await showJavaErrorBox()
|
||||
switch (javaErrorBox.response) {
|
||||
case 0:
|
||||
resolve()
|
||||
break
|
||||
case 1:
|
||||
installJava(dest).then(javaPath => {
|
||||
resolve(javaPath)
|
||||
})
|
||||
break
|
||||
case 2:
|
||||
shell.openExternal(`https://www.java.com/fr/download/manual.jsp`)
|
||||
resolve()
|
||||
break
|
||||
case 3:
|
||||
const javaBinPathSelect = await dialog.showOpenDialog(BrowserWindow.getFocusedWindow(), {
|
||||
filters: [
|
||||
{
|
||||
name: "java",
|
||||
}
|
||||
]
|
||||
})
|
||||
if (javaBinPathSelect.canceled) {
|
||||
showJavaErrorBox()
|
||||
} else {
|
||||
resolve(javaBinPathSelect.filePaths[0])
|
||||
}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
} catch (error) {
|
||||
const javaErrorBox = await showJavaErrorBox()
|
||||
switch (javaErrorBox.response) {
|
||||
case 0:
|
||||
resolve()
|
||||
break
|
||||
case 1:
|
||||
installJava(dest).then(javaPath => {
|
||||
resolve(javaPath)
|
||||
})
|
||||
break
|
||||
case 2:
|
||||
shell.openExternal(`https://www.java.com/fr/download/manual.jsp`)
|
||||
resolve()
|
||||
break
|
||||
case 3:
|
||||
const javaBinPathSelect = await dialog.showOpenDialog(BrowserWindow.getFocusedWindow(), {
|
||||
filters: [
|
||||
{
|
||||
name: "java",
|
||||
}
|
||||
]
|
||||
})
|
||||
if (javaBinPathSelect.canceled) {
|
||||
showJavaErrorBox()
|
||||
} else {
|
||||
resolve(javaBinPathSelect.filePaths[0])
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.java = main
|
||||
@@ -5,23 +5,27 @@ let launcherDataPath = path.join(__dirname, ".catboat")
|
||||
|
||||
const baseSettings = {
|
||||
ram: {
|
||||
max: 1024
|
||||
max: 2048
|
||||
},
|
||||
auth: {
|
||||
token: "",
|
||||
type: "msa",
|
||||
clientToken: ""
|
||||
}
|
||||
}
|
||||
|
||||
function initSettings($launcherDataPath) {
|
||||
launcherDataPath = $launcherDataPath
|
||||
const gameDir = path.parse($launcherDataPath).dir
|
||||
if (!fs.existsSync(gameDir)) {
|
||||
if (!fs.existsSync(launcherDataPath)) {
|
||||
try {
|
||||
fs.mkdirSync(gameDir)
|
||||
fs.mkdirSync(launcherDataPath)
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync($launcherDataPath)) {
|
||||
if (!fs.existsSync(path.join(launcherDataPath, "launcher_settings.json"))) {
|
||||
try {
|
||||
fs.writeFileSync($launcherDataPath, JSON.stringify(baseSettings, null, 4))
|
||||
fs.writeFileSync(path.join(launcherDataPath, "launcher_settings.json"), JSON.stringify(baseSettings, null, 4))
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
@@ -37,7 +41,8 @@ function writeSettings(settings) {
|
||||
fs.writeFileSync(path.join(launcherDataPath, "launcher_settings.json"), JSON.stringify(settings, null, 4))
|
||||
return
|
||||
} catch (error) {
|
||||
throw error
|
||||
clean()
|
||||
return writeSettings(settings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +63,8 @@ function get(key) {
|
||||
|
||||
return value
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de l'accès aux paramètres :", error.message)
|
||||
throw error
|
||||
clean()
|
||||
return get(key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +86,10 @@ function set(key, 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) {
|
||||
console.error("Erreur lors de la mise à jour des paramètres :", error.message)
|
||||
throw error
|
||||
clean()
|
||||
return set(ke, value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +106,8 @@ function readSettings() {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(path.join(launcherDataPath, "launcher_settings.json")))
|
||||
} catch (error) {
|
||||
throw error
|
||||
clean()
|
||||
return readSettings()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
27
modules/osmeta.js
Normal file
27
modules/osmeta.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const os = require("os")
|
||||
|
||||
function arch() {
|
||||
switch (os.arch()) {
|
||||
case "x32":
|
||||
case "ia32":
|
||||
case "x86":
|
||||
case "mips":
|
||||
case "ppc":
|
||||
case "s390":
|
||||
return "x86"
|
||||
case "x64":
|
||||
case "arm64":
|
||||
return "arm64"
|
||||
case "mipsel":
|
||||
case "ppc64":
|
||||
case "riscv64":
|
||||
case "s390x":
|
||||
case "loong64":
|
||||
return "x64"
|
||||
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.arch = arch
|
||||
10
package-lock.json
generated
10
package-lock.json
generated
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"discord-rpc": "^4.0.1",
|
||||
"download": "^8.0.0",
|
||||
"js-java-properties": "^1.0.3",
|
||||
"minecraft-launcher-core": "^3.18.2",
|
||||
"msmc": "^5.0.5",
|
||||
"socket.io-client": "^4.8.1"
|
||||
@@ -4218,6 +4219,15 @@
|
||||
"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": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"dependencies": {
|
||||
"discord-rpc": "^4.0.1",
|
||||
"download": "^8.0.0",
|
||||
"js-java-properties": "^1.0.3",
|
||||
"minecraft-launcher-core": "^3.18.2",
|
||||
"msmc": "^5.0.5",
|
||||
"socket.io-client": "^4.8.1"
|
||||
|
||||
Reference in New Issue
Block a user