Skip to content

Commit

Permalink
Close the launcher on game launch.
Browse files Browse the repository at this point in the history
Added a requested feature in: dscalzi#246

Default: false
  • Loading branch information
Ulysse2211 committed May 6, 2024
1 parent eb683f8 commit 22102da
Show file tree
Hide file tree
Showing 5 changed files with 4,771 additions and 4,733 deletions.
20 changes: 20 additions & 0 deletions app/assets/js/configmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const DEFAULT_CONFIG = {
resWidth: 1280,
resHeight: 720,
fullscreen: false,
CloseOnLaunch: false,
autoConnect: true,
launchDetached: true
},
Expand Down Expand Up @@ -733,6 +734,25 @@ exports.setFullscreen = function(fullscreen){
config.settings.game.fullscreen = fullscreen
}

/**
* Check if the launcher should be closed when the game launch.
*
* @param {boolean} def Optional. If true, the default value will be returned.
* @returns {boolean} Whether or not the launcher should be closed when the game launched.
*/
exports.getCloseOnLaunch = function(def = false){
return !def ? config.settings.game.CloseOnLaunch : DEFAULT_CONFIG.settings.game.CloseOnLaunch
}

/**
* Change the status if the launcher should be closed when the game launch.
*
* @param {boolean} CloseOnLaunch Whether or not the launcher should be closed when the game launched.
*/
exports.setCloseOnLaunch = function(CloseOnLaunch){
config.settings.game.CloseOnLaunch = CloseOnLaunch
}

/**
* Check if the game should auto connect to servers.
*
Expand Down
6 changes: 6 additions & 0 deletions app/assets/js/processbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const { getMojangOS, isLibraryCompatible, mcVersionAtLeast } = require('helios-
const { Type } = require('helios-distribution-types')
const os = require('os')
const path = require('path')
const remote = require('@electron/remote');
const win = remote.getCurrentWindow();

const ConfigManager = require('./configmanager')

Expand Down Expand Up @@ -82,6 +84,10 @@ class ProcessBuilder {
child.unref()
}

if(ConfigManager.getCloseOnLaunch()){
win.close();
}

child.stdout.setEncoding('utf8')
child.stderr.setEncoding('utf8')

Expand Down
1 change: 1 addition & 0 deletions app/assets/lang/en_US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ accountSelectConfirm = "Select"
accountSelectCancel = "Cancel"

[ejs.settings]
closeLauncherOnLaunch = "Close the launcher when the game is launched."
navHeaderText = "Settings"
navAccount = "Account"
navMinecraft = "Minecraft"
Expand Down
11 changes: 11 additions & 0 deletions app/settings.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@
</label>
</div>
</div>
<div class="settingsFieldContainer">
<div class="settingsFieldLeft">
<span class="settingsFieldTitle"><%- lang('settings.closeLauncherOnLaunch') %></span>
</div>
<div class="settingsFieldRight">
<label class="toggleSwitch">
<input type="checkbox" cValue="CloseOnLaunch">
<span class="toggleSwitchSlider"></span>
</label>
</div>
</div>
<div class="settingsFieldContainer">
<div class="settingsFieldLeft">
<span class="settingsFieldTitle"><%- lang('settings.autoConnectTitle') %></span>
Expand Down
Loading

0 comments on commit 22102da

Please sign in to comment.