mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-23 04:02:14 -08:00
3cdad516c9
Introduced an option to activate debug mode in Athena's Shield. Updated relevant JavaScript files and configuration to handle the debug mode setting. Added a new method for retrieving the debug status within the parserAthShield.js class.
85 lines
2.9 KiB
JavaScript
85 lines
2.9 KiB
JavaScript
const fs = require('fs')
|
|
const readline = require('readline')
|
|
const path = require('path')
|
|
|
|
// Path to the configuration file
|
|
const configPath = path.join(__dirname, 'variables.athshield')
|
|
|
|
// Load the variables from the file
|
|
function loadConfig() {
|
|
const rawData = fs.readFileSync(configPath)
|
|
return JSON.parse(rawData.toString()) // Convert Buffer to string
|
|
}
|
|
|
|
// Save the variables to the file
|
|
function saveConfig(config) {
|
|
const data = JSON.stringify(config, null, 2)
|
|
fs.writeFileSync(configPath, data)
|
|
}
|
|
|
|
// Create the readline interface
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout
|
|
})
|
|
|
|
// Function to ask questions to the user
|
|
function startCLI() {
|
|
const config = loadConfig()
|
|
|
|
rl.question('Would you like to activate Athena\'s Shield? (yes/no): ', (answer) => {
|
|
if (answer.trim().startsWith('//')) {
|
|
console.log('This is a comment; the line is ignored.')
|
|
rl.close()
|
|
return
|
|
}
|
|
|
|
if (answer.toLowerCase() === 'yes') {
|
|
config.athenaShieldActivated = true
|
|
|
|
rl.question('Would you like to activate debug mode? (yes/no): ', (debugAnswer) => {
|
|
config.debug = debugAnswer.toLowerCase() === 'yes' // Set debug to true or false
|
|
|
|
rl.question('Would you like to hide or block the menu? (hide/block): ', (menuAnswer) => {
|
|
if (menuAnswer.trim().startsWith('//')) {
|
|
console.log('This is a comment; the line is ignored.')
|
|
rl.close()
|
|
return
|
|
}
|
|
|
|
if (menuAnswer.toLowerCase() === 'hide') {
|
|
config.menuVisibility = 'hidden' // Set to 'hidden'
|
|
console.log('Athena\'s Shield activated. Menu hidden.')
|
|
} else if (menuAnswer.toLowerCase() === 'block') {
|
|
config.menuVisibility = 'blocked' // Set to 'blocked'
|
|
console.log('Athena\'s Shield activated. Menu blocked.')
|
|
} else {
|
|
console.log('Invalid option for the menu.')
|
|
rl.close()
|
|
return
|
|
}
|
|
|
|
// Save the modified configuration
|
|
saveConfig(config)
|
|
rl.close()
|
|
})
|
|
})
|
|
} else if (answer.toLowerCase() === 'no') {
|
|
console.log('Athena\'s Shield not activated. Closing the CLI.')
|
|
config.athenaShieldActivated = false
|
|
config.menuVisibility = 'visible' // Reset to default
|
|
config.debug = 'false'
|
|
|
|
// Save the modified configuration
|
|
saveConfig(config)
|
|
rl.close()
|
|
} else {
|
|
console.log('Invalid response.')
|
|
rl.close()
|
|
}
|
|
})
|
|
}
|
|
|
|
// Launch the CLI
|
|
startCLI()
|