v0.0.1-alpha.9 - Added option to enable/disable prereleases.

Added option to enable/disable prerelease updates.
Implemented launcher tab on the settings UI, as this is the only current value.
Added semver dependency.
This commit is contained in:
Daniel Scalzi 2018-06-04 19:34:47 -04:00
parent 790a3e0e8b
commit 50d85d30cc
No known key found for this signature in database
GPG Key ID: 5CA2F145B63535F9
8 changed files with 88 additions and 17 deletions

View File

@ -1017,6 +1017,7 @@ body, button {
.settingsTabHeader { .settingsTabHeader {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-bottom: 20px;
} }
.settingsTabHeaderText { .settingsTabHeaderText {
font-size: 20px; font-size: 20px;
@ -1126,9 +1127,6 @@ input:checked + .toggleSwitchSlider:before {
* * */ * * */
/* Add account button styles. */ /* Add account button styles. */
#settingsAddAccountContainer {
margin-top: 20px;
}
#settingsAddAccount { #settingsAddAccount {
background: rgba(0, 0, 0, 0.25); background: rgba(0, 0, 0, 0.25);
border: 1px solid rgba(126, 126, 126, 0.57); border: 1px solid rgba(126, 126, 126, 0.57);
@ -1283,7 +1281,7 @@ input:checked + .toggleSwitchSlider:before {
#settingsGameResolutionContainer { #settingsGameResolutionContainer {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin: 20px 0px; margin-bottom: 20px;
} }
#settingsGameResolutionContent { #settingsGameResolutionContent {
display: flex; display: flex;

View File

@ -40,7 +40,9 @@ const DEFAULT_CONFIG = {
autoConnect: true, autoConnect: true,
launchDetached: true launchDetached: true
}, },
launcher: {} launcher: {
allowPrerelease: false
}
}, },
commonDirectory: path.join(dataPath, 'common'), commonDirectory: path.join(dataPath, 'common'),
instanceDirectory: path.join(dataPath, 'instances'), instanceDirectory: path.join(dataPath, 'instances'),
@ -507,4 +509,25 @@ exports.getLaunchDetached = function(def = false){
*/ */
exports.setLaunchDetached = function(launchDetached){ exports.setLaunchDetached = function(launchDetached){
config.settings.game.launchDetached = launchDetached config.settings.game.launchDetached = launchDetached
}
// Launcher Settings
/**
* Check if the launcher should download prerelease versions.
*
* @param {boolean} def Optional. If true, the default value will be returned.
* @returns {boolean} Whether or not the launcher should download prerelease versions.
*/
exports.getAllowPrerelease = function(def = false){
return !def ? config.settings.launcher.allowPrerelease : DEFAULT_CONFIG.settings.launcher.allowPrerelease
}
/**
* Change the status of Whether or not the launcher should download prerelease versions.
*
* @param {boolean} launchDetached Whether or not the launcher should download prerelease versions.
*/
exports.setAllowPrerelease = function(allowPrerelease){
config.settings.launcher.allowPrerelease = allowPrerelease
} }

View File

@ -86,6 +86,11 @@ function saveSettingsValues(){
sFn(v.value) sFn(v.value)
} else if(v.type === 'checkbox'){ } else if(v.type === 'checkbox'){
sFn(v.checked) sFn(v.checked)
// Special Conditions
const cVal = v.getAttribute('cValue')
if(cVal === 'AllowPrerelease'){
changeAllowPrerelease(v.checked)
}
} }
} }
} }

View File

@ -28,7 +28,6 @@ webFrame.setVisualZoomLevelLimits(1, 1)
webFrame.setLayoutZoomLevelLimits(0, 0) webFrame.setLayoutZoomLevelLimits(0, 0)
// Initialize auto updates in production environments. // Initialize auto updates in production environments.
// TODO Make this the case after implementation is done.
let updateCheckListener let updateCheckListener
if(!isDev){ if(!isDev){
ipcRenderer.on('autoUpdateNotification', (event, arg, info) => { ipcRenderer.on('autoUpdateNotification', (event, arg, info) => {
@ -71,6 +70,18 @@ if(!isDev){
ipcRenderer.send('autoUpdateAction', 'initAutoUpdater') ipcRenderer.send('autoUpdateAction', 'initAutoUpdater')
} }
/**
* Send a notification to the main process changing the value of
* allowPrerelease. If we are running a prerelease version, then
* this will always be set to true, regardless of the current value
* of val.
*
* @param {boolean} val The new allow prerelease value.
*/
function changeAllowPrerelease(val){
ipcRenderer.send('autoUpdateAction', 'allowPrereleaseChange', val)
}
function showUpdateUI(info){ function showUpdateUI(info){
//TODO Make this message a bit more informative `${info.version}` //TODO Make this message a bit more informative `${info.version}`
document.getElementById('image_seal_container').setAttribute('update', true) document.getElementById('image_seal_container').setAttribute('update', true)

View File

@ -98,6 +98,18 @@
<span class="settingsTabHeaderText">Launcher Settings</span> <span class="settingsTabHeaderText">Launcher Settings</span>
<span class="settingsTabHeaderDesc">Options related to the launcher itself.</span> <span class="settingsTabHeaderDesc">Options related to the launcher itself.</span>
</div> </div>
<div class="settingsFieldContainer">
<div class="settingsFieldLeft">
<span class="settingsFieldTitle">Allow prerelease updates.</span>
<span class="settingsFieldDesc">Prereleases contain the latest features and updates, however they may be buggy.<br>This will always be true if you are using a prerelease version.</span>
</div>
<div class="settingsFieldRight">
<label class="toggleSwitch">
<input type="checkbox" cValue="AllowPrerelease">
<span class="toggleSwitchSlider"></span>
</label>
</div>
</div>
</div> </div>
</div> </div>
<script src="./assets/js/scripts/settings.js"></script> <script src="./assets/js/scripts/settings.js"></script>

View File

@ -1,15 +1,24 @@
// Requirements
const {app, BrowserWindow, ipcMain} = require('electron') const {app, BrowserWindow, ipcMain} = require('electron')
const autoUpdater = require('electron-updater').autoUpdater const autoUpdater = require('electron-updater').autoUpdater
const isDev = require('electron-is-dev') const ConfigManager = require('./app/assets/js/configmanager.js')
const path = require('path') const ejse = require('ejs-electron')
const url = require('url') const fs = require('fs')
const fs = require('fs') const isDev = require('electron-is-dev')
const ejse = require('ejs-electron') const path = require('path')
const semver = require('semver')
const url = require('url')
// Setup auto updater. // Setup auto updater.
function initAutoUpdater(event) { function initAutoUpdater(event) {
// Defaults to true if application version contains prerelease components (e.g. 0.12.1-alpha.1)
// autoUpdater.allowPrerelease = true if(ConfigManager.getAllowPrerelease()){
autoUpdater.allowPrerelease = true
} else {
// Defaults to true if application version contains prerelease components (e.g. 0.12.1-alpha.1)
// autoUpdater.allowPrerelease = true
}
if(isDev){ if(isDev){
autoUpdater.autoInstallOnAppQuit = false autoUpdater.autoInstallOnAppQuit = false
autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml') autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml')
@ -29,7 +38,7 @@ function initAutoUpdater(event) {
} }
// Open channel to listen for update actions. // Open channel to listen for update actions.
ipcMain.on('autoUpdateAction', (event, arg) => { ipcMain.on('autoUpdateAction', (event, arg, data) => {
switch(arg){ switch(arg){
case 'initAutoUpdater': case 'initAutoUpdater':
console.log('Initializing auto updater.') console.log('Initializing auto updater.')
@ -42,6 +51,18 @@ ipcMain.on('autoUpdateAction', (event, arg) => {
event.sender.send('autoUpdateNotification', 'realerror', err) event.sender.send('autoUpdateNotification', 'realerror', err)
}) })
break break
case 'allowPrereleaseChange':
if(!data){
const preRelComp = semver.prerelease(app.getVersion())
if(preRelComp != null && preRelComp.length > 0){
autoUpdater.allowPrerelease = true
} else {
autoUpdater.allowPrerelease = data
}
} else {
autoUpdater.allowPrerelease = data
}
break
case 'installUpdateNow': case 'installUpdateNow':
autoUpdater.quitAndInstall() autoUpdater.quitAndInstall()
break break

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "westeroscraftlauncher", "name": "westeroscraftlauncher",
"version": "0.0.1-alpha.8", "version": "0.0.1-alpha.9",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "westeroscraftlauncher", "name": "westeroscraftlauncher",
"version": "0.0.1-alpha.8", "version": "0.0.1-alpha.9",
"description": "Custom modded launcher for Westeroscraft", "description": "Custom modded launcher for Westeroscraft",
"productName": "WesterosCraft Launcher", "productName": "WesterosCraft Launcher",
"main": "index.js", "main": "index.js",
@ -39,6 +39,7 @@
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"request": "^2.87.0", "request": "^2.87.0",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"semver": "^5.5.0",
"tar-fs": "^1.16.2", "tar-fs": "^1.16.2",
"uuid": "^3.2.1", "uuid": "^3.2.1",
"winreg": "^1.2.4" "winreg": "^1.2.4"