Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: re-branding of the launcher #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/assets/css/launcher.css
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,13 @@ body, button {
border-radius: 50px;
border: 1px solid rgba(126, 126, 126, 0.57);
}

input:disabled + .toggleSwitchSlider {
background-color: rgb(77, 77, 77);
/* box-shadow: inset 2px 1px 20px black; */
border: 1px solid rgb(30, 31, 30)
}

.toggleSwitchSlider:before {
position: absolute;
content: "";
Expand All @@ -1372,6 +1379,13 @@ body, button {
border-radius: 50px;
transition: .4s;
}

input:checked:disabled + .toggleSwitchSlider {
background-color: rgb(74, 95, 71);
/* box-shadow: inset 2px 1px 20px black; */
border: 1px solid rgb(74, 83, 72)
}w

input:checked + .toggleSwitchSlider {
background-color: rgb(31, 140, 11);
/* box-shadow: inset 2px 1px 20px black; */
Expand Down
20 changes: 20 additions & 0 deletions app/assets/js/configmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const DEFAULT_CONFIG = {
resHeight: 720,
fullscreen: false,
autoConnect: true,
CloseOnLaunch: false,
launchDetached: true
},
launcher: {
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
15 changes: 15 additions & 0 deletions app/assets/js/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ bindFileSelectors()
* will be disabled until the value is corrected. This is an automated
* process. More complex UI may need to be bound separately.
*/

closeOnLaunchCheckbox = document.querySelector('input[cValue="CloseOnLaunch"]')
launchDetachedCheckbox = document.querySelector('input[cValue="LaunchDetached"]')

closeOnLaunchCheckbox.addEventListener('change', function() {
if (this.checked) {
launchDetachedCheckbox.disabled = true
launchDetachedCheckbox.checked = true
} else {
launchDetachedCheckbox.disabled = false
}
})



function initSettingsValidators(){
const sEls = document.getElementById('settingsContainer').querySelectorAll('[cValue]')
Array.from(sEls).map((v, index, arr) => {
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
13 changes: 12 additions & 1 deletion 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 Expand Up @@ -145,7 +156,7 @@

</div>
</div>
<div id="settingsDropinModsContainer">
<div id="settingsDropinModsContainer" style="display: none;">
<div class="settingsModsHeader"><%- lang('settings.dropinMods') %></div>
<button id="settingsDropinFileSystemButton"><%- lang('settings.addMods') %> <span id="settingsDropinRefreshNote"><%- lang('settings.dropinRefreshNote') %></span></button>
<div id="settingsDropinModsContent">
Expand Down
Loading