From b318c9597eff8c41834f8052afd4c57358b8a480 Mon Sep 17 00:00:00 2001 From: CakeLancelot Date: Tue, 22 Dec 2020 04:45:43 -0600 Subject: [PATCH] Servers are now loaded from file, and you can connect to them Needs some cleanup Also did some misc. UX changes and tweaks --- resources/app/default_servers.json | 4 +- resources/app/files/assets/css/openfusion.css | 8 +- resources/app/files/assets/js/gameclient.js | 100 +++++++++--------- .../app/files/assets/js/serverselector.js | 98 +++++++++++++++-- resources/app/files/index.html | 6 +- resources/app/files/loginInfo.php | 2 +- resources/app/index.js | 12 +-- 7 files changed, 156 insertions(+), 74 deletions(-) diff --git a/resources/app/default_servers.json b/resources/app/default_servers.json index f6f894d..c1468b3 100644 --- a/resources/app/default_servers.json +++ b/resources/app/default_servers.json @@ -5,13 +5,13 @@ "description": "OpenFusion Public Server - Original", "ip": "144.202.52.9:23000", "version": "beta-20100104", - "endpoint": "https://dexlabs.systems/api/" + "endpoint": "https://api.dexlabs.systems/" }, { "uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9", "description": "OpenFusion Public Server - Academy", "ip": "144.202.52.9:24000", - "version": "beta-20111003" + "version": "beta-20111013" } ], "favorites": [] diff --git a/resources/app/files/assets/css/openfusion.css b/resources/app/files/assets/css/openfusion.css index a28b048..f810cf2 100644 --- a/resources/app/files/assets/css/openfusion.css +++ b/resources/app/files/assets/css/openfusion.css @@ -106,11 +106,11 @@ button > i { pointer-events: none; } -#server-listing-placeholder { - visibility: visible; -} - #of-logo { opacity: 0.9; } +#server-table .server-listing-entry { + cursor: pointer; +} + diff --git a/resources/app/files/assets/js/gameclient.js b/resources/app/files/assets/js/gameclient.js index 5c810b6..253d4be 100644 --- a/resources/app/files/assets/js/gameclient.js +++ b/resources/app/files/assets/js/gameclient.js @@ -3,78 +3,78 @@ var gameRunning = false; // Unity invoked methods begin // -// allows us to skip the login screen -/*function authDoCallback(param) { - var unity = document.getElementById('Unity_embed'); - unity.SendMessage("GlobalManager", "SetTEGid", "player"); - unity.SendMessage("GlobalManager", "SetAuthid", "0"); - unity.SendMessage("GlobalManager", "DoAuth", 0); -}*/ +// Uncomment and enter credentials to skip login screen +function authDoCallback(param) { + /*var unity = document.getElementById('Unity_embed'); + unity.SendMessage("GlobalManager", "SetTEGid", "player"); + unity.SendMessage("GlobalManager", "SetAuthid", "0"); + unity.SendMessage("GlobalManager", "DoAuth", 0);*/ +} function MarkProgress(param) {} function redirect(html) { - ipc.send("exit", 0); + ipc.send("exit", 0); } function HomePage(param) { - ipc.send("exit", 0); + ipc.send("exit", 0); } function PageOut(param) { - ipc.send("exit", 0); + ipc.send("exit", 0); } function updateSocialOptions(param) { - ipc.send("exit", 0); + ipc.send("exit", 0); } function PayPage(param) { - ipc.send("exit", 0); + ipc.send("exit", 0); } // Unity invoked methods end // function onResize() { - if (gameRunning == true) { - var unity = document.getElementById('Unity_embed'); - unity.style.width = window.innerWidth + 'px'; - unity.style.height = window.innerHeight + 'px'; - } + if (gameRunning == true) { + var unity = document.getElementById('Unity_embed'); + unity.style.width = window.innerWidth + 'px'; + unity.style.height = window.innerHeight + 'px'; + } } function launchGame() { - gameRunning = true + gameRunning = true - var sel = document.getElementById("of-serverselector"); - sel.remove() - - document.body.style.overflow = "hidden"; + var sel = document.getElementById("of-serverselector"); + sel.remove() + + document.body.style.overflow = "hidden"; - var object = document.createElement('object'); - object.setAttribute('classid', "clsid:444785F1-DE89-4295-863A-D46C3A781394"); - object.setAttribute('codebase', "undefined/UnityWebPlayer.cab#version=2,0,0,0"); - object.setAttribute('id', "Unity_object"); - object.setAttribute('width', "1264"); - object.setAttribute('height', "661"); + var object = document.createElement('object'); + object.setAttribute('classid', "clsid:444785F1-DE89-4295-863A-D46C3A781394"); + object.setAttribute('codebase', "undefined/UnityWebPlayer.cab#version=2,0,0,0"); + object.setAttribute('id', "Unity_object"); + object.setAttribute('width', "1264"); + object.setAttribute('height', "661"); - var embed = document.createElement('embed'); - embed.setAttribute('type', "application/vnd.unity"); - embed.setAttribute('pluginspage', "http://www.unity3d.com/unity-web-player-2.x"); - embed.setAttribute('id', "Unity_embed"); - embed.setAttribute('width', "1280"); - embed.setAttribute('height', "680"); - embed.setAttribute('src', "http://ht.cdn.turner.com/ff/big/beta-20100104/main.unity3d"); - embed.setAttribute('disablecontdparaextmenu', "true"); - embed.setAttribute('bordercolor', "000000"); - embed.setAttribute('backgroundcolor', "000000"); - embed.setAttribute('disableContextMenu', true); - embed.setAttribute('textcolor', "ccffff"); - embed.setAttribute('logoimage', "assets/img/unity_dexlabs.png"); - embed.setAttribute('progressbarimage', "assets/img/unity_loadingbar.png"); - embed.setAttribute('progressframeimage', "assets/img/unity_loadingframe.png"); - embed.setAttribute('autoupdateurlsignature', "42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033"); - embed.setAttribute('autoupdateurl', "http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta"); + var embed = document.createElement('embed'); + embed.setAttribute('type', "application/vnd.unity"); + embed.setAttribute('pluginspage', "http://www.unity3d.com/unity-web-player-2.x"); + embed.setAttribute('id', "Unity_embed"); + embed.setAttribute('width', "1280"); + embed.setAttribute('height', "680"); + embed.setAttribute('src', window.asseturl+"main.unity3d"); + embed.setAttribute('disablecontdparaextmenu', "true"); + embed.setAttribute('bordercolor', "000000"); + embed.setAttribute('backgroundcolor', "000000"); + embed.setAttribute('disableContextMenu', true); + embed.setAttribute('textcolor', "ccffff"); + embed.setAttribute('logoimage', "assets/img/unity_dexlabs.png"); + embed.setAttribute('progressbarimage', "assets/img/unity_loadingbar.png"); + embed.setAttribute('progressframeimage', "assets/img/unity_loadingframe.png"); + embed.setAttribute('autoupdateurlsignature', "42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033"); + embed.setAttribute('autoupdateurl', "http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta"); - var div = document.getElementById('client'); - object.appendChild(embed); - div.appendChild(object); - document.title = "OpenFusion" - OnResize(); + var div = document.getElementById('client'); + object.appendChild(embed); + div.appendChild(object); + document.title = "OpenFusion" + onResize(); } \ No newline at end of file diff --git a/resources/app/files/assets/js/serverselector.js b/resources/app/files/assets/js/serverselector.js index 73f7a44..81471fe 100644 --- a/resources/app/files/assets/js/serverselector.js +++ b/resources/app/files/assets/js/serverselector.js @@ -1,13 +1,95 @@ -// Write loginInfo.php, assetInfo.php, etc. -function setGameInfo(uuid) { +var remote = require("remote"); +var remotefs = remote.require('fs'); +var userdir = remote.require('app').getPath('userData'); +var versionarray +var serverarray + +function enableServerListButtons() { + $('#of-connect-button').removeClass('disabled'); + $('#of-deleteserver-button').removeClass('disabled'); +} + +function disableServerListButtons() { + $('#of-connect-button').addClass('disabled'); + $('#of-deleteserver-button').addClass('disabled'); +} + +function loadGameVersions() { + var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json")); + versionarray = versionjson['versions']; + $.each(versionarray, function( key, value ) { + $(new Option(value.name, 'val')).appendTo('#addserver-versionselect'); + }); +} + +function loadConfig() { + // TODO: actually use these values + var configjson = JSON.parse(remotefs.readFileSync(userdir+"\\config.json")); +} + +function loadServerList() { + var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); + serverarray = serverjson['servers']; + + if (serverarray.length > 0) { + $("#server-listing-placeholder").attr("hidden",true); + $.each(serverarray, function( key, value ) { + var row = document.createElement('tr'); + row.className = 'server-listing-entry' + row.setAttribute('id', value.uuid) + var cellName = document.createElement('td'); + cellName.textContent = value.description + var cellVersion = document.createElement('td'); + cellVersion.textContent = value.version + cellVersion.className = 'text-monospace' + + row.appendChild(cellName); + row.appendChild(cellVersion); + document.getElementById('server-tablebody').appendChild(row); + }); + } else { + // no servers added, make sure placeholder is visible + $("#server-listing-placeholder").attr("hidden",false); + } +} + +// For writing loginInfo.php, assetInfo.php, etc. +function setGameInfo(serverUUID) { + var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0]; + var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0]; + + window.asseturl = gameversion.url + + remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl); + remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip); + // TODO: write rank endpoint + remotefs.writeFileSync(__dirname+"\\rankurl.txt", "http://api.dexlabs.systems/getranks"); } function connectToServer() { - stopEasterEggs(); - $('#of-serverselector').fadeOut('slow', function() { - setTimeout(function(){ - launchGame(); - }, 200); - }); + // Get ID of the selected server, which corresponds to its UUID in the json + var uuid = $("tr.bg-primary").prop("id"); + console.log("Connecting to server with UUID of " + uuid); + + // prevent the user from clicking anywhere else during the transition + $('body,html').css('pointer-events','none'); + stopEasterEggs(); + $('#of-serverselector').fadeOut('slow', function() { + setTimeout(function(){ + $('body,html').css('pointer-events',''); + setGameInfo(uuid); + launchGame(); + }, 200); + }); } + +$('#server-table').on('click', '.server-listing-entry', function(event) { + enableServerListButtons(); + $(this).addClass('bg-primary').siblings().removeClass('bg-primary'); +}); + +$('#server-table').on('dblclick', '.server-listing-entry', function(event) { + $(this).addClass('bg-primary').siblings().removeClass('bg-primary'); + connectToServer(); +}); \ No newline at end of file diff --git a/resources/app/files/index.html b/resources/app/files/index.html index c039162..7e795ae 100644 --- a/resources/app/files/index.html +++ b/resources/app/files/index.html @@ -29,7 +29,7 @@ Game Version - + No servers added yet... perhaps you should find one? @@ -39,8 +39,8 @@
-
-
+
+