From 009a1b58af1fb82e7689f300db378c5e026b9194 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Fri, 27 Apr 2018 00:04:09 -0400 Subject: [PATCH] Added basic functionality to server selection UI. The server list is now dynamically generated based on the servers listed in the distribution index. Also, moved to event.key for key bindings as event.keyCode is deprecated. --- app/assets/css/launcher.css | 4 +-- app/assets/js/scripts/landing.js | 2 +- app/assets/js/scripts/overlay.js | 57 ++++++++++++++++++++++++++++- app/assets/js/scripts/uicore.js | 2 +- app/assets/westeroscraft.json | 39 +++++++++++++++++++- app/overlay.ejs | 61 +++----------------------------- 6 files changed, 102 insertions(+), 63 deletions(-) diff --git a/app/assets/css/launcher.css b/app/assets/css/launcher.css index b4d36a63..fdc0cc8c 100644 --- a/app/assets/css/launcher.css +++ b/app/assets/css/launcher.css @@ -1562,7 +1562,7 @@ p { margin: 0px 10px 0px 5px; border: 1px solid #fff; height: 50px; - width: auto; + width: 50px; } /* Content container for the server listing's details. */ @@ -1657,7 +1657,7 @@ p { border-style: solid; border-color: transparent rgba(0, 0, 0, 0.40) transparent transparent; } -#serverListingStarWrapper:hover .serverListingStarTooltip { +.serverListingStarWrapper:hover .serverListingStarTooltip { visibility: visible; opacity: 1; transition-delay:0s; diff --git a/app/assets/js/scripts/landing.js b/app/assets/js/scripts/landing.js index a968d427..719e5877 100644 --- a/app/assets/js/scripts/landing.js +++ b/app/assets/js/scripts/landing.js @@ -113,7 +113,7 @@ function updateSelectedServer(serverName){ updateSelectedServer(AssetGuard.getServerById(ConfigManager.getGameDirectory(), ConfigManager.getSelectedServer()).name) server_selection_button.addEventListener('click', (e) => { e.target.blur() - toggleOverlay(true, 'serverSelectContent') + toggleServerSelection(true) }) // Test menu transform. diff --git a/app/assets/js/scripts/overlay.js b/app/assets/js/scripts/overlay.js index 0b3e0cf8..195ab7f2 100644 --- a/app/assets/js/scripts/overlay.js +++ b/app/assets/js/scripts/overlay.js @@ -42,6 +42,11 @@ function toggleOverlay(toggleState, dismissable = false, content = 'overlayConte } } +function toggleServerSelection(toggleState){ + prepareServerSelectionList() + toggleOverlay(toggleState, 'serverSelectContent') +} + /** * Set the content of the overlay. * @@ -91,12 +96,26 @@ function setDismissHandler(handler){ /* Server Select View */ +document.addEventListener('keydown', (e) => { + if(document.getElementById('serverSelectContent').style.display !== 'none'){ + console.debug('ServSelLi Keydown Called:', document.getElementById('serverSelectContent').style.display) + if(e.key === 'Escape'){ + document.getElementById('serverSelectCancel').click() + } else if(e.key === 'Enter'){ + document.getElementById('serverSelectConfirm').click() + } + } +}) + +document.getElementById('serverSelectActions').onsubmit = () => { return false } + document.getElementById('serverSelectConfirm').addEventListener('click', () => { const listings = document.getElementsByClassName('serverListing') for(let i=0; i + +
+ ${servers[i].name} + ${servers[i].description} +
+
${servers[i].mc_version}
+
${servers[i].revision}
+ ${servers[i].default_selected ? `
+ + + + + + + + Main Server +
` : ``} +
+
+ ` + } + document.getElementById('serverSelectListScrollable').innerHTML = htmlString + +} + +function prepareServerSelectionList(){ + populateServerListings() + setServerListingHandlers() +} \ No newline at end of file diff --git a/app/assets/js/scripts/uicore.js b/app/assets/js/scripts/uicore.js index 527dd08b..758f575f 100644 --- a/app/assets/js/scripts/uicore.js +++ b/app/assets/js/scripts/uicore.js @@ -99,7 +99,7 @@ $(document).on('click', 'a[href^="http"]', function(event) { * DevTools, for example the chrome debugger in VS Code. */ document.addEventListener('keydown', function (e) { - if(e.keyCode == 73 && e.ctrlKey && e.shiftKey){ + if(e.key === 'I' && e.ctrlKey && e.shiftKey){ let window = remote.getCurrentWindow() window.toggleDevTools() } diff --git a/app/assets/westeroscraft.json b/app/assets/westeroscraft.json index a9668516..e0c2c01c 100644 --- a/app/assets/westeroscraft.json +++ b/app/assets/westeroscraft.json @@ -12,9 +12,10 @@ { "id": "WesterosCraft-1.11.2", "name": "WesterosCraft Production Server", + "description": "Main WesterosCraft server. Connect to enter the Realm.", "news_feed": "http://www.westeroscraft.com/api/rss.php?preset_id=12700544", "icon_url": "http://mc.westeroscraft.com/WesterosCraftLauncher/files/server-prod.png", - "revision": "0.0.1", + "revision": "3.4.17", "server_ip": "mc.westeroscraft.com", "mc_version": "1.11.2", "discord": { @@ -409,6 +410,42 @@ } } ] + }, + { + "id": "WesterosCraftTest-1.11.2", + "name": "WesterosCraft Test Server", + "description": "Main testing server. Experimental changes are live here.", + "news_feed": "http://www.westeroscraft.com/api/rss.php?preset_id=12700544", + "icon_url": "http://mc.westeroscraft.com/WesterosCraftLauncher/files/server-test.png", + "revision": "3.6.0", + "server_ip": "mc.westeroscraft.com:4444", + "mc_version": "1.11.2", + "discord": { + "shortId": "Test Server", + "largeImageText": "WesterosCraft Test Server", + "largeImageKey": "server-test" + }, + "default_selected": false, + "autoconnect": true, + "modules": [] + }, + { + "id": "WesterosCraftTest-1.12.2", + "name": "WesterosCraft 1.12.2 Test Server", + "description": "Tests for our version change to 1.12.2 are live here.", + "news_feed": "http://www.westeroscraft.com/api/rss.php?preset_id=12700544", + "icon_url": "http://mc.westeroscraft.com/WesterosCraftLauncher/files/server-test.png", + "revision": "4.0.1", + "server_ip": "mc.westeroscraft.com:4445", + "mc_version": "1.12.2", + "discord": { + "shortId": "1.12.2 Test Server", + "largeImageText": "WesterosCraft 1.12.2 Test Server", + "largeImageKey": "server-test" + }, + "default_selected": false, + "autoconnect": true, + "modules": [] } ] } \ No newline at end of file diff --git a/app/overlay.ejs b/app/overlay.ejs index 9f714c0d..0340afdd 100644 --- a/app/overlay.ejs +++ b/app/overlay.ejs @@ -1,72 +1,19 @@