Skip to content

Commit

Permalink
v0.0.1-alpha.8 - Implemented Minecraft Settings Tab.
Browse files Browse the repository at this point in the history
Implemented minecraft settings tab.
Updated distro index documentation to reflext the file system overhaul.
  • Loading branch information
dscalzi committed Jun 4, 2018
1 parent 0cc861f commit 790a3e0
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 46 deletions.
123 changes: 120 additions & 3 deletions app/assets/css/launcher.css
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,101 @@ body, button {
font-size: 12px;
}

/* Remove spin button from number inputs. */
#settingsContainer input[type=number]::-webkit-inner-spin-button {
-webkit-appearance: none;
}

/* Default styles for text/number inputs. */
#settingsContainer input[type=number],
#settingsContainer input[type=text] {
color: white;
background: rgba(0, 0, 0, 0.25);
border-radius: 3px;
border: 1px solid rgba(126, 126, 126, 0.57);
font-family: 'Avenir Book';
transition: 0.25s ease;
}
#settingsContainer input[type=number]:focus,
#settingsContainer input[type=text]:focus {
outline: none;
border-color: rgba(126, 126, 126, 0.87);
}
#settingsContainer input[type=number][error] {
border-color: rgb(255, 27, 12);
background: rgba(236, 0, 0, 0.25);
color: rgb(255, 27, 12);
}

/* Styles for a generic settings entry. */
.settingsFieldContainer {
display: flex;
align-items: center;
justify-content: space-between;
margin: 20px 0px;
width: 75%;
}
.settingsFieldLeft {
display: flex;
flex-direction: column;
}
.settingsFieldTitle {
font-size: 14px;
font-family: 'Avenir Medium';
color: rgba(255, 255, 255, 0.95);
}
.settingsFieldDesc {
font-size: 12px;
color: rgba(255, 255, 255, .95);
}
.settingsDivider {
height: 1px;
width: 75%;
background: rgba(255, 255, 255, 0.25);
}

/* Toggle Switch */
.toggleSwitch {
position: relative;
display: inline-block;
width: 50px;
height: 25px;
border-radius: 3px;
box-sizing: border-box;
}
.toggleSwitch input {
display:none;
}
.toggleSwitchSlider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.25);
transition: .4s;
border-radius: 3px;
border: 1px solid rgba(126, 126, 126, 0.57);
}
.toggleSwitchSlider:before {
position: absolute;
content: "";
height: 17px;
width: 21px;
left: 3px;
bottom: 3px;
background-color: rgb(202, 202, 202);
border-radius: 3px;
transition: .4s;
}
input:checked + .toggleSwitchSlider {
background-color: rgba(36, 255, 0, 0.25);
}
input:checked + .toggleSwitchSlider:before {
transform: translateX(21px);
}

/* * *
* Settings View (Account Tab)
* * */
Expand Down Expand Up @@ -1056,9 +1151,6 @@ body, button {
#settingsCurrentAccountsHeader {
margin: 20px 0px;
}
#settingsCurrentAccountsHeaderText {
font-size: 16px;
}

/* Auth account list container styles. */
#settingsCurrentAccounts {
Expand Down Expand Up @@ -1183,6 +1275,31 @@ body, button {
opacity: 1;
}

/* * *
* Settings View (Minecraft Tab)
* * */

/* Game resolution UI elements. */
#settingsGameResolutionContainer {
display: flex;
flex-direction: column;
margin: 20px 0px;
}
#settingsGameResolutionContent {
display: flex;
align-items: center;
padding-top: 10px;
}
#settingsGameResolutionCross {
color: grey;
padding: 0px 15px;
}
#settingsGameWidth,
#settingsGameHeight {
padding: 7.5px 5px;
width: 75px;
}

/*******************************************************************************
* *
* Landing View (Structural Styles) *
Expand Down
2 changes: 0 additions & 2 deletions app/assets/js/assetguard.js
Original file line number Diff line number Diff line change
Expand Up @@ -1488,11 +1488,9 @@ class AssetGuard extends EventEmitter {
obPath = path.join(this.commonPath, 'libraries', obPath)
break
case 'forgemod':
//obPath = path.join(this.basePath, 'mods', obPath)
obPath = path.join(this.commonPath, 'modstore', obPath)
break
case 'litemod':
//obPath = path.join(this.basePath, 'mods', version, obPath)
obPath = path.join(this.commonPath, 'modstore', obPath)
break
case 'file':
Expand Down
49 changes: 25 additions & 24 deletions app/assets/js/configmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,25 +394,6 @@ exports.setJVMOptions = function(jvmOptions){

// Game Settings

/**
* Retrieve the absolute path of the game directory.
*
* @param {boolean} def Optional. If true, the default value will be returned.
* @returns {string} The absolute path of the game directory.
*/
exports.getGameDirectory = function(def = false){
return !def ? config.settings.game.directory : DEFAULT_CONFIG.settings.game.directory
}

/**
* Set the absolute path of the game directory.
*
* @param {string} directory The absolute path of the new game directory.
*/
exports.setGameDirectory = function(directory){
config.settings.game.directory = directory
}

/**
* Retrieve the width of the game window.
*
Expand All @@ -429,7 +410,17 @@ exports.getGameWidth = function(def = false){
* @param {number} resWidth The new width of the game window.
*/
exports.setGameWidth = function(resWidth){
config.settings.game.resWidth = resWidth
config.settings.game.resWidth = Number.parseInt(resWidth)
}

/**
* Validate a potential new width value.
*
* @param {*} resWidth The width value to validate.
*/
exports.validateGameWidth = function(resWidth){
const nVal = Number.parseInt(resWidth)
return Number.isInteger(nVal) && nVal >= 0
}

/**
Expand All @@ -448,7 +439,17 @@ exports.getGameHeight = function(def = false){
* @param {number} resHeight The new height of the game window.
*/
exports.setGameHeight = function(resHeight){
config.settings.game.resHeight = resHeight
config.settings.game.resHeight = Number.parseInt(resHeight)
}

/**
* Validate a potential new height value.
*
* @param {*} resHeight The height value to validate.
*/
exports.validateGameHeight = function(resHeight){
const nVal = Number.parseInt(resHeight)
return Number.isInteger(nVal) && nVal >= 0
}

/**
Expand All @@ -457,7 +458,7 @@ exports.setGameHeight = function(resHeight){
* @param {boolean} def Optional. If true, the default value will be returned.
* @returns {boolean} Whether or not the game is set to launch in fullscreen mode.
*/
exports.isFullscreen = function(def = false){
exports.getFullscreen = function(def = false){
return !def ? config.settings.game.fullscreen : DEFAULT_CONFIG.settings.game.fullscreen
}

Expand All @@ -476,7 +477,7 @@ exports.setFullscreen = function(fullscreen){
* @param {boolean} def Optional. If true, the default value will be returned.
* @returns {boolean} Whether or not the game should auto connect to servers.
*/
exports.isAutoConnect = function(def = false){
exports.getAutoConnect = function(def = false){
return !def ? config.settings.game.autoConnect : DEFAULT_CONFIG.settings.game.autoConnect
}

Expand All @@ -495,7 +496,7 @@ exports.setAutoConnect = function(autoConnect){
* @param {boolean} def Optional. If true, the default value will be returned.
* @returns {boolean} Whether or not the game will launch as a detached process.
*/
exports.isLaunchDetached = function(def = false){
exports.getLaunchDetached = function(def = false){
return !def ? config.settings.game.launchDetached : DEFAULT_CONFIG.settings.game.launchDetached
}

Expand Down
8 changes: 4 additions & 4 deletions app/assets/js/processbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class ProcessBuilder {

const child = child_process.spawn(ConfigManager.getJavaExecutable(), args, {
cwd: this.gameDir,
detached: ConfigManager.isLaunchDetached()
detached: ConfigManager.getLaunchDetached()
})

if(ConfigManager.isLaunchDetached()){
if(ConfigManager.getLaunchDetached()){
child.unref()
}

Expand Down Expand Up @@ -188,7 +188,7 @@ class ProcessBuilder {
mcArgs.push('absolute:' + this.fmlDir)

// Prepare game resolution
if(ConfigManager.isFullscreen()){
if(ConfigManager.getFullscreen()){
mcArgs.unshift('--fullscreen')
} else {
mcArgs.unshift(ConfigManager.getGameWidth())
Expand All @@ -198,7 +198,7 @@ class ProcessBuilder {
}

// Prepare autoconnect
if(ConfigManager.isAutoConnect() && this.server.autoconnect){
if(ConfigManager.getAutoConnect() && this.server.autoconnect){
const serverURL = new URL('my://' + this.server.server_ip)
mcArgs.unshift(serverURL.hostname)
mcArgs.unshift('--server')
Expand Down
Loading

0 comments on commit 790a3e0

Please sign in to comment.