Skip to content

Commit 0b28256

Browse files
committed
added the possibility to close the launcher when starting the game
1 parent c1c4dd8 commit 0b28256

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed

Diff for: app/assets/css/launcher.css

+14
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,13 @@ body, button {
13601360
border-radius: 50px;
13611361
border: 1px solid rgba(126, 126, 126, 0.57);
13621362
}
1363+
1364+
input:disabled + .toggleSwitchSlider {
1365+
background-color: rgb(77, 77, 77);
1366+
/* box-shadow: inset 2px 1px 20px black; */
1367+
border: 1px solid rgb(30, 31, 30)
1368+
}
1369+
13631370
.toggleSwitchSlider:before {
13641371
position: absolute;
13651372
content: "";
@@ -1372,6 +1379,13 @@ body, button {
13721379
border-radius: 50px;
13731380
transition: .4s;
13741381
}
1382+
1383+
input:checked:disabled + .toggleSwitchSlider {
1384+
background-color: rgb(74, 95, 71);
1385+
/* box-shadow: inset 2px 1px 20px black; */
1386+
border: 1px solid rgb(74, 83, 72)
1387+
}w
1388+
13751389
input:checked + .toggleSwitchSlider {
13761390
background-color: rgb(31, 140, 11);
13771391
/* box-shadow: inset 2px 1px 20px black; */

Diff for: app/assets/js/configmanager.js

+20
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const DEFAULT_CONFIG = {
8282
resHeight: 720,
8383
fullscreen: false,
8484
autoConnect: true,
85+
CloseOnLaunch: false,
8586
launchDetached: true
8687
},
8788
launcher: {
@@ -733,6 +734,25 @@ exports.setFullscreen = function(fullscreen){
733734
config.settings.game.fullscreen = fullscreen
734735
}
735736

737+
/**
738+
* Check if the launcher should be closed when the game launch.
739+
*
740+
* @param {boolean} def Optional. If true, the default value will be returned.
741+
* @returns {boolean} Whether or not the launcher should be closed when the game launched.
742+
*/
743+
exports.getCloseOnLaunch = function(def = false){
744+
return !def ? config.settings.game.CloseOnLaunch : DEFAULT_CONFIG.settings.game.CloseOnLaunch
745+
}
746+
747+
/**
748+
* Change the status if the launcher should be closed when the game launch.
749+
*
750+
* @param {boolean} CloseOnLaunch Whether or not the launcher should be closed when the game launched.
751+
*/
752+
exports.setCloseOnLaunch = function(CloseOnLaunch){
753+
config.settings.game.CloseOnLaunch = CloseOnLaunch
754+
}
755+
736756
/**
737757
* Check if the game should auto connect to servers.
738758
*

Diff for: app/assets/js/processbuilder.js

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const { getMojangOS, isLibraryCompatible, mcVersionAtLeast } = require('helios-
77
const { Type } = require('helios-distribution-types')
88
const os = require('os')
99
const path = require('path')
10+
const remote = require('@electron/remote')
11+
const win = remote.getCurrentWindow()
1012

1113
const ConfigManager = require('./configmanager')
1214

@@ -82,6 +84,10 @@ class ProcessBuilder {
8284
child.unref()
8385
}
8486

87+
if(ConfigManager.getCloseOnLaunch()){
88+
win.close()
89+
}
90+
8591
child.stdout.setEncoding('utf8')
8692
child.stderr.setEncoding('utf8')
8793

Diff for: app/assets/js/scripts/settings.js

+15
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ bindFileSelectors()
8989
* will be disabled until the value is corrected. This is an automated
9090
* process. More complex UI may need to be bound separately.
9191
*/
92+
93+
closeOnLaunchCheckbox = document.querySelector('input[cValue="CloseOnLaunch"]')
94+
launchDetachedCheckbox = document.querySelector('input[cValue="LaunchDetached"]')
95+
96+
closeOnLaunchCheckbox.addEventListener('change', function() {
97+
if (this.checked) {
98+
launchDetachedCheckbox.disabled = true
99+
launchDetachedCheckbox.checked = true
100+
} else {
101+
launchDetachedCheckbox.disabled = false
102+
}
103+
})
104+
105+
106+
92107
function initSettingsValidators(){
93108
const sEls = document.getElementById('settingsContainer').querySelectorAll('[cValue]')
94109
Array.from(sEls).map((v, index, arr) => {

Diff for: app/assets/lang/en_US.toml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ accountSelectConfirm = "Select"
4949
accountSelectCancel = "Cancel"
5050

5151
[ejs.settings]
52+
closeLauncherOnLaunch = "Close the launcher when the game is launched."
5253
navHeaderText = "Settings"
5354
navAccount = "Account"
5455
navMinecraft = "Minecraft"

Diff for: app/settings.ejs

+11
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@
9393
</label>
9494
</div>
9595
</div>
96+
<div class="settingsFieldContainer">
97+
<div class="settingsFieldLeft">
98+
<span class="settingsFieldTitle"><%- lang('settings.closeLauncherOnLaunch') %></span>
99+
</div>
100+
<div class="settingsFieldRight">
101+
<label class="toggleSwitch">
102+
<input type="checkbox" cValue="CloseOnLaunch">
103+
<span class="toggleSwitchSlider"></span>
104+
</label>
105+
</div>
106+
</div>
96107
<div class="settingsFieldContainer">
97108
<div class="settingsFieldLeft">
98109
<span class="settingsFieldTitle"><%- lang('settings.autoConnectTitle') %></span>

0 commit comments

Comments
 (0)