1
0
mirror of https://github.com/dscalzi/HeliosLauncher.git synced 2025-01-06 11:02:12 -08:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Ulysse Gressé-Lugué
3346712a9a
Merge a314e51b1f into 6aaeeff9a4 2024-11-21 14:48:45 +01:00
Daniel Scalzi
6aaeeff9a4
Update comment. 2024-11-12 15:14:59 -05:00
Daniel Scalzi
9cca37ca8a
Fix issue with submodule library overrides. () 2024-11-12 14:48:55 -05:00
Ulysse Gressé-Lugué
a314e51b1f
Update processbuilder.js 2024-05-23 13:22:16 +02:00
Ulysse Gressé-Lugué
f08bbcc3e0
Update processbuilder.js 2024-05-06 13:58:18 +02:00

View File

@ -416,7 +416,7 @@ class ProcessBuilder {
}
//args.push('-Dlog4j.configurationFile=D:\\WesterosCraft\\game\\common\\assets\\log_configs\\client-1.12.xml')
// Java Arguments
if(process.platform === 'darwin'){
args.push('-Xdock:name=HeliosLauncher')
@ -432,6 +432,26 @@ class ProcessBuilder {
// Vanilla Arguments
args = args.concat(this.vanillaManifest.arguments.game)
async function WriteFullscreenToOptions(filePath, lineToReplace, newLine) {
try {
const exists = await fs.pathExists(filePath);
if (exists) {
let fileContent = await fs.readFile(filePath, 'utf8');
if (fileContent.includes(lineToReplace)) {
fileContent = fileContent.replace(lineToReplace, newLine);
await fs.outputFile(filePath, fileContent);
} else {
await fs.outputFile(filePath, newLine);
}
} else {
await fs.outputFile(filePath, newLine);
}
} catch (err) {
logger.info('Error while writing fullscreen to options.txt:', err);
}
}
for(let i=0; i<args.length; i++){
if(typeof args[i] === 'object' && args[i].rules != null){
@ -453,11 +473,16 @@ class ProcessBuilder {
// This should be fine for a while.
if(rule.features.has_custom_resolution != null && rule.features.has_custom_resolution === true){
if(ConfigManager.getFullscreen()){
logger.info("gamedir: ", this.gameDir)
WriteFullscreenToOptions(path.join(this.gameDir, "options.txt"), 'fullscreen:false', 'fullscreen:true')
args[i].value = [
'--fullscreen',
'true'
]
} else {
WriteFullscreenToOptions(path.join(this.gameDir, "options.txt"), 'fullscreen:true', 'fullscreen:false');
}
checksum++
}
}
@ -839,9 +864,7 @@ class ProcessBuilder {
libs[mdl.getVersionlessMavenIdentifier()] = mdl.getPath()
if(mdl.subModules.length > 0){
const res = this._resolveModuleLibraries(mdl)
if(res.length > 0){
libs = {...libs, ...res}
}
libs = {...libs, ...res}
}
}
}
@ -850,9 +873,7 @@ class ProcessBuilder {
for(let i=0; i<mods.length; i++){
if(mods.sub_modules != null){
const res = this._resolveModuleLibraries(mods[i])
if(res.length > 0){
libs = {...libs, ...res}
}
libs = {...libs, ...res}
}
}
@ -863,27 +884,25 @@ class ProcessBuilder {
* Recursively resolve the path of each library required by this module.
*
* @param {Object} mdl A module object from the server distro index.
* @returns {Array.<string>} An array containing the paths of each library this module requires.
* @returns {{[id: string]: string}} An object containing the paths of each library this module requires.
*/
_resolveModuleLibraries(mdl){
if(!mdl.subModules.length > 0){
return []
return {}
}
let libs = []
let libs = {}
for(let sm of mdl.subModules){
if(sm.rawModule.type === Type.Library){
if(sm.rawModule.classpath ?? true) {
libs.push(sm.getPath())
libs[sm.getVersionlessMavenIdentifier()] = sm.getPath()
}
}
// If this module has submodules, we need to resolve the libraries for those.
// To avoid unnecessary recursive calls, base case is checked here.
if(mdl.subModules.length > 0){
const res = this._resolveModuleLibraries(sm)
if(res.length > 0){
libs = libs.concat(res)
}
libs = {...libs, ...res}
}
}
return libs
@ -891,4 +910,4 @@ class ProcessBuilder {
}
module.exports = ProcessBuilder
module.exports = ProcessBuilder