From 631c3cd6d4dab788f71598ea065093cf6073a41c Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sat, 14 Apr 2018 22:20:59 -0400 Subject: [PATCH] Added option to dismiss Java download prompt. You will be given an option to install Java manually. Selecting this will bring you to a final prompt which gives some useful information about installing Java and where you can find help. You have two options on this prompt. The first is to simply aknowledge it, which will dismiss it. The second is to go back to the first prompt. --- app/assets/css/launcher.css | 20 ++++++++++++ app/assets/js/actionbinder.js | 57 ++++++++++++++++++++++++++++++----- app/overlay.ejs | 5 ++- 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/app/assets/css/launcher.css b/app/assets/css/launcher.css index c6ca994..9f0d7ae 100644 --- a/app/assets/css/launcher.css +++ b/app/assets/css/launcher.css @@ -1417,6 +1417,12 @@ p { font-weight: bold; } +#overlayActionContainer { + display: flex; + flex-direction: column; + justify-content: center; +} + #overlayAcknowledge { background: none; border: 1px solid #ffffff; @@ -1436,4 +1442,18 @@ p { #overlayAcknowledge:active { border-color: rgba(255, 255, 255, 0.75); color: rgba(255, 255, 255, 0.75); +} + +#overlayDismiss { + font-family: 'Avenir Book'; + font-weight: bold; + font-size: 10px; + text-decoration: none; + padding-top: 2.5px; +} +#overlayDismiss:hover { + color: rgba(255, 255, 255, 0.75); +} +#overlayDismiss:active { + color: rgba(165, 165, 165, 0.75); } \ No newline at end of file diff --git a/app/assets/js/actionbinder.js b/app/assets/js/actionbinder.js index 2daa296..32373e0 100644 --- a/app/assets/js/actionbinder.js +++ b/app/assets/js/actionbinder.js @@ -99,17 +99,21 @@ document.addEventListener('readystatechange', function(){ * Toggle the visibility of the overlay. * * @param {boolean} toggleState True to display, false to hide. + * @param {boolean} dismissable Optional. True to show the dismiss option, otherwise false. */ -function toggleOverlay(toggleState){ +function toggleOverlay(toggleState, dismissable = false){ if(toggleState == null){ toggleState = !document.getElementById('main').hasAttribute('overlay') } if(toggleState){ document.getElementById('main').setAttribute('overlay', true) + $('#overlayDismiss').toggle(dismissable) $('#overlayContainer').fadeToggle(250) } else { document.getElementById('main').removeAttribute('overlay') - $('#overlayContainer').fadeToggle(250) + $('#overlayContainer').fadeToggle(250, () => { + $('#overlayDismiss').toggle(dismissable) + }) } } @@ -119,11 +123,13 @@ function toggleOverlay(toggleState){ * @param {string} title Overlay title text. * @param {string} description Overlay description text. * @param {string} acknowledge Acknowledge button text. + * @param {string} dismiss Dismiss button text. */ -function setOverlayContent(title, description, acknowledge){ +function setOverlayContent(title, description, acknowledge, dismiss = 'Dismiss'){ document.getElementById('overlayTitle').innerHTML = title document.getElementById('overlayDesc').innerHTML = description document.getElementById('overlayAcknowledge').innerHTML = acknowledge + document.getElementById('overlayDismiss').innerHTML = dismiss } /** @@ -142,6 +148,22 @@ function setOverlayHandler(handler){ } } +/** + * Set the onclick handler of the overlay dismiss button. + * If the handler is null, a default handler will be added. + * + * @param {function} handler + */ +function setDismissHandler(handler){ + if(handler == null){ + document.getElementById('overlayDismiss').onclick = () => { + toggleOverlay(false) + } + } else { + document.getElementById('overlayDismiss').onclick = handler + } +} + /* Launch Progress Wrapper Functions */ /** @@ -212,21 +234,42 @@ function asyncSystemScan(launchAfter = true){ sysAEx.on('message', (m) => { if(m.content === 'validateJava'){ - + m.result = null if(m.result == null){ // If the result is null, no valid Java installation was found. // Show this information to the user. setOverlayContent( 'No Compatible
Java Installation Found', 'In order to join WesterosCraft, you need a 64-bit installation of Java 8. Would you like us to install a copy? By installing, you accept Oracle\'s license agreement.', - 'Install Java' + 'Install Java', + 'Install Manually' ) setOverlayHandler(() => { setLaunchDetails('Preparing Java Download..') sysAEx.send({task: 0, content: '_enqueueOracleJRE', argsArr: [ConfigManager.getLauncherDirectory()]}) toggleOverlay(false) }) - toggleOverlay(true) + setDismissHandler(() => { + $('#overlayContent').fadeOut(250, () => { + //$('#overlayDismiss').toggle(false) + setOverlayContent( + 'Don\'t Forget!
Java is Required', + 'A valid x64 installation of Java 8 is required to launch. Downloads can be found on Oracle\'s website. Once installed, you will be able to connect to the server.

Please refer to our Troubleshooting Guide if you have any difficulty.', + 'I Understand', + 'Go Back' + ) + setOverlayHandler(() => { + toggleLaunchArea(false) + toggleOverlay(false) + }) + setDismissHandler(() => { + toggleOverlay(false, true) + asyncSystemScan() + }) + $('#overlayContent').fadeIn(250) + }) + }) + toggleOverlay(true, true) // TODO Add option to not install Java x64. @@ -423,7 +466,7 @@ function dlAsync(login = true){ //if(!(await AuthManager.validateSelected())){ // //} - const authUser = ConfigManager.getSelectedAccount(); + const authUser = ConfigManager.getSelectedAccount() console.log('authu', authUser) let pb = new ProcessBuilder(ConfigManager.getGameDirectory(), serv, versionData, forgeData, authUser) setLaunchDetails('Launching game..') diff --git a/app/overlay.ejs b/app/overlay.ejs index 18283bd..f5df5f7 100644 --- a/app/overlay.ejs +++ b/app/overlay.ejs @@ -2,6 +2,9 @@
Lorem Ipsum:
Finis Illud
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.. - +
+ + +
\ No newline at end of file