new commit

This commit is contained in:
2025-05-09 00:00:55 +02:00
parent 4f01013d42
commit bf9406f924
11 changed files with 46 additions and 96 deletions

View File

@@ -6,22 +6,26 @@ let launcherDataPath = path.join(__dirname, ".catboat")
const baseSettings = {
ram: {
max: 1024
},
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()
}
}