More Additions

Added Modpack Folder Icon to open root modpack data directory
Added option to toggle Console on Launch
Added a store of the distro hash in MD5
Added Cached Distro notification
Tweaked some of the text for ram warnings/desc
This commit is contained in:
Peter 2021-07-13 00:21:09 +01:00
parent 842f98b81d
commit b3846d86b0
9 changed files with 180 additions and 2 deletions

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 198.084 198.084" style="enable-background:new 0 0 198.084 198.084;" xml:space="preserve">
<path d="M197.951,77.097l-16.024,78.532c-1.222,5.987-6.488,10.288-12.599,10.288H20.196c-8.135,0-14.225-7.459-12.599-15.429
L21.94,80.197c1.29-6.32,6.849-10.859,13.299-10.859h150.14h6.237c3.068,0,5.558,2.11,6.266,4.856
C198.117,75.109,198.155,76.094,197.951,77.097z M12.142,78.198c2.23-10.928,11.943-18.86,23.097-18.86h150.076
c-0.6-5.713-5.444-10.181-11.314-10.181H94.819c-1.605-9.628-9.995-16.989-20.07-16.989H13.35C5.989,32.167,0,38.156,0,45.517
v92.186L12.142,78.198z"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -20,6 +20,24 @@ exports.getLauncherDirectory = function(){
return launcherDir
}
/**
* Retrieve the file hash for the current stored distribution file
*
* @returns {string} The absolute path of the launcher directory.
*/
exports.getDistributionHash = function(){
return config.distributionHash
}
/**
* Stores the current distribution file hash into the configuration
*
* @returns {string} The absolute path of the launcher directory.
*/
exports.setDistributionHash = function(hash){
config.distributionHash = hash
}
/**
* Get the launcher's data directory. This is where all files related
* to game launch are installed (common, instances, java, etc).
@ -105,7 +123,8 @@ const DEFAULT_CONFIG = {
resHeight: 480,
fullscreen: false,
autoConnect: true,
launchDetached: true
launchDetached: true,
consoleOnLaunch: false
},
launcher: {
allowPrerelease: false,
@ -119,6 +138,7 @@ const DEFAULT_CONFIG = {
dismissed: false
},
clientToken: null,
distributionHash: null,
selectedServer: null, // Resolved
selectedAccount: null,
authenticationDatabase: {},
@ -739,6 +759,25 @@ exports.setLaunchDetached = function(launchDetached){
config.settings.game.launchDetached = launchDetached
}
/**
* Check if the game should open the devtools console on launch
*
* @param {boolean} def Optional. If true, the default value will be returned.
* @returns {boolean} Whether or not to open the devtools console on launch
*/
exports.getConsoleOnLaunch = function(def = false){
return !def ? config.settings.game.consoleOnLaunch : DEFAULT_CONFIG.settings.game.consoleOnLaunch
}
/**
* Change the status of whether or not the devtools console should open on launch
*
* @param {boolean} consoleOnLaunch whether or not to open the devtools console on launch
*/
exports.setConsoleOnLaunch = function(consoleOnLaunch){
config.settings.game.consoleOnLaunch = consoleOnLaunch
}
// Launcher Settings
/**

View File

@ -1,5 +1,6 @@
const fs = require('fs')
const path = require('path')
const crypto = require('crypto')
const request = require('request')
const ConfigManager = require('./configmanager')
@ -581,6 +582,8 @@ exports.pullRemote = function(){
fs.writeFile(distroDest, body, 'utf-8', (err) => {
if(!err){
ConfigManager.setDistributionHash(crypto.createHash('md5').update(body).digest('hex'))
ConfigManager.save()
resolve(data)
return
} else {

View File

@ -29,6 +29,13 @@ function onDistroLoad(data){
ipcRenderer.send('distributionIndexDone', data != null)
}
function sendLoadFromCacheNotification(data){
if(data != null){
ipcRenderer.send('cachedDistributionNotification', data != null)
logger.log('Sent a cached distribution notification alert')
}
}
// Ensure Distribution is downloaded and cached.
DistroManager.pullRemote().then((data) => {
logger.log('Loaded distribution index.')
@ -45,6 +52,7 @@ DistroManager.pullRemote().then((data) => {
logger.log('Successfully loaded an older version of the distribution index.')
onDistroLoad(data)
sendLoadFromCacheNotification(data)
}).catch((err) => {

View File

@ -86,6 +86,10 @@ function setLaunchEnabled(val){
// Bind launch button
document.getElementById('launch_button').addEventListener('click', function(e){
if(checkCurrentServer(true)){
if(ConfigManager.getConsoleOnLaunch()){
let window = remote.getCurrentWindow()
window.toggleDevTools()
}
loggerLanding.log('Launching game..')
const mcVersion = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer()).getMinecraftVersion()
const jExe = ConfigManager.getJavaExecutable()
@ -116,6 +120,14 @@ document.getElementById('settingsMediaButton').onclick = (e) => {
switchView(getCurrentView(), VIEWS.settings)
}
document.getElementById('openInstanceMediaButton').onclick = (e) => {
if(ConfigManager.getSelectedServer()){
shell.openPath(path.join(ConfigManager.getDataDirectory(), 'instances', ConfigManager.getSelectedServer()))
} else {
shell.openPath(path.join(ConfigManager.getDataDirectory(), 'instances'))
}
}
// Bind avatar overlay button.
document.getElementById('avatarOverlay').onclick = (e) => {
prepareSettings()
@ -659,6 +671,7 @@ function dlAsync(login = true){
DiscordWrapper.updateDetails('Loading game..')
}
proc.stdout.on('data', gameStateChange)
proc.stdout.on('data', gameCrashReportListener)
proc.stdout.removeListener('data', tempListener)
proc.stderr.removeListener('data', gameErrorListener)
}
@ -689,6 +702,30 @@ function dlAsync(login = true){
}
}
const gameCrashReportListener = function(data){
data = data.trim()
if(data.includes('---- Minecraft Crash Report ----')){
let date = new Date()
let CRASH_REPORT_FOLDER = path.join(ConfigManager.getInstanceDirectory(), serv.getID(), 'crash-reports')
let CRASH_REPORT_NAME = ('crash-' + date.getFullYear() + '-' + (date.getMonth() + 1).toLocaleString(undefined, {minimumIntegerDigits: 2}) + '-' + date.getDate().toLocaleString(undefined, {minimumIntegerDigits: 2}) + '_' + date.getHours().toLocaleString(undefined, {minimumIntegerDigits: 2}) + '.' + date.getMinutes().toLocaleString(undefined, {minimumIntegerDigits: 2}) + '.' + date.getSeconds().toLocaleString(undefined, {minimumIntegerDigits: 2}) + '-client.txt')
let CRASH_REPORT_PATH = path.join(CRASH_REPORT_FOLDER, CRASH_REPORT_NAME)
shell.showItemInFolder(CRASH_REPORT_PATH)
setOverlayContent(
'Game Crashed!',
'Uh oh! It looks like your game has just crashed. We have opened up the crash-reports folder so that you can easily share it with our staff team over on Discord. If you have any repeating crashes, we always recommend that you come and see us!<br><br>For future reference, your crash report file is: <br>' + CRASH_REPORT_NAME,
'Okay, thanks!',
'Open Crash Report'
)
setOverlayHandler(() => {
toggleOverlay(false)
})
setDismissHandler(() => {
shell.openPath(CRASH_REPORT_PATH)
})
toggleOverlay(true, true)
}
}
const gameErrorListener = function(data){
data = data.trim()
if(data.indexOf('Could not find or load main class net.minecraft.launchwrapper.Launch') > -1){

View File

@ -417,3 +417,24 @@ ipcRenderer.on('distributionIndexDone', (event, res) => {
}
}
})
ipcRenderer.on('cachedDistributionNotification', (event, res) => {
if(res) {
setTimeout(() => {
setOverlayContent(
'Warning: Cached Distribution Startup',
'We were unable to grab the latest server information from the internet upon startup, so we have used a previously stored version instead.<br><br>This is not recommended, and you should restart your client to fix this to avoid your modpack files being out of date. If you wish to continue using the launcher, you can try again at any time by pressing the refresh button on the landing screen.<br><br>If this continues to occur, and you are not too sure why, come and see us on Discord!',
'Understood',
'Join our Discord'
)
setOverlayHandler(() => {
toggleOverlay(false)
})
setDismissHandler(() => {
shell.openExternal('https://vcnet.work/discord')
})
toggleOverlay(true, true)
}, 2000)
}
})

View File

@ -25,6 +25,19 @@
</svg>
<div id="settingsTooltip">Settings</div>
</button>
<div class="mediaContainer" id="settingsMediaContainer">
<button class="mediaButton" id="openInstanceMediaButton">
<svg id="openInstanceSVG" class="mediaSVG" viewBox="0 0 198.084 198.084">
<g>
<path d="M197.951,77.097l-16.024,78.532c-1.222,5.987-6.488,10.288-12.599,10.288H20.196c-8.135,0-14.225-7.459-12.599-15.429
L21.94,80.197c1.29-6.32,6.849-10.859,13.299-10.859h150.14h6.237c3.068,0,5.558,2.11,6.266,4.856
C198.117,75.109,198.155,76.094,197.951,77.097z M12.142,78.198c2.23-10.928,11.943-18.86,23.097-18.86h150.076
c-0.6-5.713-5.444-10.181-11.314-10.181H94.819c-1.605-9.628-9.995-16.989-20.07-16.989H13.35C5.989,32.167,0,38.156,0,45.517
v92.186L12.142,78.198z"/>
</g>
</svg>
</button>
</div>
</div>
</div>
<div class="mediaDivider"></div>

View File

@ -87,6 +87,18 @@
</label>
</div>
</div>
<div class="settingsFieldContainer">
<div class="settingsFieldLeft">
<span class="settingsFieldTitle">Open console on launch</span>
<span class="settingsFieldDesc">This opens the DevTool Console on launch allowing you to view the client log in realtime.</span>
</div>
<div class="settingsFieldRight">
<label class="toggleSwitch">
<input type="checkbox" cValue="ConsoleOnLaunch">
<span class="toggleSwitchSlider"></span>
</label>
</div>
</div>
</div>
<div id="settingsTabMods" class="settingsTab" style="display: none;">
<div class="settingsTabHeader">
@ -167,7 +179,7 @@
<span id="settingsMinRAMLabel" class="settingsMemoryLabel">3G</span>
</div>
</div>
<div id="settingsMemoryDesc">The recommended minimum RAM is 3 gigabytes. Setting the minimum and maximum values to the same value may reduce lag.</div>
<div id="settingsMemoryDesc">The recommended minimum RAM is 3 gigabytes. Setting the minimum and maximum values to the same value may reduce lag. In order to use the memory you have allocated, it must be free and available in your system. Allocating all of your total memory is not recommended.</div>
</div>
<div id="settingsMemoryContentRight">
<div id="settingsMemoryStatus">

View File

@ -86,6 +86,10 @@ ipcMain.on('distributionIndexDone', (event, res) => {
event.sender.send('distributionIndexDone', res)
})
ipcMain.on('cachedDistributionNotification', (event, res) => {
event.sender.send('cachedDistributionNotification', res)
})
// Disable hardware acceleration.
// https://electronjs.org/docs/tutorial/offscreen-rendering
app.disableHardwareAcceleration()