diff --git a/.gitignore b/.gitignore index b1c5543..9f3e3c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,9 @@ - locales/ - *.dll - *.pak - -OpenFusionClient.exe - *.bin - +*.php +OpenFusionClient.exe icudtl.dat - version - -resources/app/files/assetInfo.php - -resources/app/files/loginInfo.php - resources/app/files/rankurl.txt diff --git a/resources/app/default_config.json b/resources/app/default_config.json index e4e7c75..4ea5fba 100644 --- a/resources/app/default_config.json +++ b/resources/app/default_config.json @@ -1,5 +1,5 @@ { - "autoupdate-check": true, - "cache-swapping": false, - "initial-setup-completed": true + "autoupdate-check": true, + "cache-swapping": false, + "initial-setup-completed": true } \ No newline at end of file diff --git a/resources/app/default_servers.json b/resources/app/default_servers.json index 2b75de4..239b072 100644 --- a/resources/app/default_servers.json +++ b/resources/app/default_servers.json @@ -1,19 +1,19 @@ { - "servers": [ - { - "uuid": "d9773558-6ddf-4d00-8803-d830a22a842b", - "description": "OpenFusion Public Server - Original", - "ip": "144.202.52.9:23000", - "version": "beta-20100104", - "endpoint": "https://api.dexlabs.systems/" - }, - { - "uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9", - "description": "OpenFusion Public Server - Academy", - "ip": "144.202.52.9:24000", - "version": "beta-20111013", - "endpoint": "https://api.dexlabs.systems/academy/" - } - ], - "favorites": [] + "servers": [ + { + "uuid": "d9773558-6ddf-4d00-8803-d830a22a842b", + "description": "OpenFusion Public Server - Original", + "ip": "144.202.52.9:23000", + "version": "beta-20100104", + "endpoint": "https://api.dexlabs.systems/" + }, + { + "uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9", + "description": "OpenFusion Public Server - Academy", + "ip": "144.202.52.9:24000", + "version": "beta-20111013", + "endpoint": "https://api.dexlabs.systems/academy/" + } + ], + "favorites": [] } \ No newline at end of file diff --git a/resources/app/default_versions.json b/resources/app/default_versions.json index 3d3d1ab..6c019b1 100644 --- a/resources/app/default_versions.json +++ b/resources/app/default_versions.json @@ -1,108 +1,108 @@ { - "versions": [ - { - "name": "beta-20100104", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100104/" - }, - { - "name": "beta-20100119", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100119/" - }, - { - "name": "beta-20100207", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100207/" - }, - { - "name": "beta-20100307", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100307/" - }, - { - "name": "beta-20100322", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100322/" - }, - { - "name": "beta-20100413", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100413/" - }, - { - "name": "beta-20100502", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100502/" - }, - { - "name": "beta-20100524", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100524/" - }, - { - "name": "beta-20100604", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100604/" - }, - { - "name": "beta-20100616", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100616/" - }, - { - "name": "beta-20100711", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100711/" - }, - { - "name": "beta-20100728", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100728/" - }, - { - "name": "beta-20100909", - "url": "http://ht.cdn.turner.com/ff/big/beta-20100909/" - }, - { - "name": "beta-20101003", - "url": "http://ht.cdn.turner.com/ff/big/beta-20101003/" - }, - { - "name": "beta-20101011", - "url": "http://ht.cdn.turner.com/ff/big/beta-20101011/" - }, - { - "name": "beta-20101028", - "url": "http://ht.cdn.turner.com/ff/big/beta-20101028/" - }, - { - "name": "beta-20101123", - "url": "http://ht.cdn.turner.com/ff/big/beta-20101123/" - }, - { - "name": "beta-20110213", - "url": "http://ht.cdn.turner.com/ff/big/beta-20110213/" - }, - { - "name": "beta-20110314", - "url": "http://ht.cdn.turner.com/ff/big/beta-20110314/" - }, - { - "name": "beta-20110330", - "url": "http://ht.cdn.turner.com/ff/big/beta-20110330/" - }, - { - "name": "beta-20110424", - "url": "http://ht.cdn.turner.com/ff/big/beta-20110424/" - }, - { - "name": "beta-20110523", - "url": "http://ht.cdn.turner.com/ff/big/beta-20110523/" - }, - { - "name": "beta-20110725", - "url": "http://ht.cdn.turner.com/ff/big/beta-20110725/" - }, - { - "name": "beta-20110818", - "url": "http://ht.cdn.turner.com/ff/big/beta-20110818/" - }, - { - "name": "beta-20110912", - "url": "http://ht.cdn.turner.com/ff/big/beta-20110912/" - }, - { - "name": "beta-20111013", - "url": "http://ht.cdn.turner.com/ff/big/beta-20111013/" - } - ] + "versions": [ + { + "name": "beta-20100104", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100104/" + }, + { + "name": "beta-20100119", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100119/" + }, + { + "name": "beta-20100207", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100207/" + }, + { + "name": "beta-20100307", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100307/" + }, + { + "name": "beta-20100322", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100322/" + }, + { + "name": "beta-20100413", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100413/" + }, + { + "name": "beta-20100502", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100502/" + }, + { + "name": "beta-20100524", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100524/" + }, + { + "name": "beta-20100604", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100604/" + }, + { + "name": "beta-20100616", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100616/" + }, + { + "name": "beta-20100711", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100711/" + }, + { + "name": "beta-20100728", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100728/" + }, + { + "name": "beta-20100909", + "url": "http://ht.cdn.turner.com/ff/big/beta-20100909/" + }, + { + "name": "beta-20101003", + "url": "http://ht.cdn.turner.com/ff/big/beta-20101003/" + }, + { + "name": "beta-20101011", + "url": "http://ht.cdn.turner.com/ff/big/beta-20101011/" + }, + { + "name": "beta-20101028", + "url": "http://ht.cdn.turner.com/ff/big/beta-20101028/" + }, + { + "name": "beta-20101123", + "url": "http://ht.cdn.turner.com/ff/big/beta-20101123/" + }, + { + "name": "beta-20110213", + "url": "http://ht.cdn.turner.com/ff/big/beta-20110213/" + }, + { + "name": "beta-20110314", + "url": "http://ht.cdn.turner.com/ff/big/beta-20110314/" + }, + { + "name": "beta-20110330", + "url": "http://ht.cdn.turner.com/ff/big/beta-20110330/" + }, + { + "name": "beta-20110424", + "url": "http://ht.cdn.turner.com/ff/big/beta-20110424/" + }, + { + "name": "beta-20110523", + "url": "http://ht.cdn.turner.com/ff/big/beta-20110523/" + }, + { + "name": "beta-20110725", + "url": "http://ht.cdn.turner.com/ff/big/beta-20110725/" + }, + { + "name": "beta-20110818", + "url": "http://ht.cdn.turner.com/ff/big/beta-20110818/" + }, + { + "name": "beta-20110912", + "url": "http://ht.cdn.turner.com/ff/big/beta-20110912/" + }, + { + "name": "beta-20111013", + "url": "http://ht.cdn.turner.com/ff/big/beta-20111013/" + } + ] } diff --git a/resources/app/files/assets/js/serverselector.js b/resources/app/files/assets/js/serverselector.js index 0bc1b16..fe149fc 100644 --- a/resources/app/files/assets/js/serverselector.js +++ b/resources/app/files/assets/js/serverselector.js @@ -19,6 +19,34 @@ function disableServerListButtons() { $('#of-deleteserver-button').prop('disabled', true); } +function addServer() { + var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); + + var server = {}; + server['uuid'] = uuidv4(); + server['description'] = $("#addserver-descinput").val(); + server['ip'] = $("#addserver-ipinput").val(); + server['version'] = $("#addserver-versionselect option:selected").text(); + //server['endpoint'] = + + jsontomodify['servers'].push(server) + + remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4)); + loadServerList(); +} + +function deleteServer() { + var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); + var result = jsontomodify['servers'].filter(function(obj) {return (obj.uuid === getSelectedServer())})[0]; + + var resultindex = jsontomodify['servers'].indexOf(result); + + jsontomodify['servers'].splice(resultindex, 1); + + remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4)); + loadServerList(); +} + function loadGameVersions() { var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json")); versionarray = versionjson['versions']; @@ -33,30 +61,32 @@ function loadConfig() { } function loadServerList() { - var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); - serverarray = serverjson['servers']; + var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); + serverarray = serverjson['servers']; - $(".server-listing-entry").remove(); // clear out old stuff, if any - disableServerListButtons(); + $(".server-listing-entry").remove(); // Clear out old stuff, if any + disableServerListButtons(); // Disable buttons until another is selected - 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' + if (serverarray.length > 0) { + // Servers were found in the JSON + $("#server-listing-placeholder").attr("hidden",true); + $.each(serverarray, function( key, value ) { + // Create the row, and populate the cells + 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 + row.appendChild(cellName); + row.appendChild(cellVersion); + $("#server-tablebody").append(row); + }); + } else { + // No servers are added, make sure placeholder is visible $("#server-listing-placeholder").attr("hidden",false); } } @@ -71,33 +101,38 @@ function setGameInfo(serverUUID) { remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip); if (result.hasOwnProperty('endpoint')) { - var rankurl = result.endpoint.replace("https://", "http://") + "getranks" - console.log("Using rank endpoint " + rankurl) - remotefs.writeFileSync(__dirname+"\\rankurl.txt", rankurl); + var httpendpoint = result.endpoint.replace("https://", "http://") + remotefs.writeFileSync(__dirname+"\\rankurl.txt", httpendpoint+"getranks"); + // Write these out too + remotefs.writeFileSync(__dirname+"\\sponsor.php", httpendpoint+"upsell/sponsor.png"); + remotefs.writeFileSync(__dirname+"\\images.php", httpendpoint+"upsell/"); } else { if (remotefs.existsSync(__dirname+"\\rankurl.txt")) { // delete the file, this server won't be using it remotefs.unlinkSync(__dirname+"\\rankurl.txt"); + remotefs.writeFileSync(__dirname+"\\sponsor.php", "assets/img/welcome.png"); + remotefs.writeFileSync(__dirname+"\\images.php", "assets/img/"); } } } +// Returns the UUID of the server with the selected background color. +// Yes, there are probably better ways to go about this, but it works well enough. function getSelectedServer() { - return $("tr.bg-primary").prop("id"); + return $("#server-tablebody > tr.bg-primary").prop("id"); } function connectToServer() { // Get ID of the selected server, which corresponds to its UUID in the json - var uuid = getSelectedServer(); - console.log("Connecting to server with UUID of " + uuid); + console.log("Connecting to server with UUID of " + getSelectedServer()); - // prevent the user from clicking anywhere else during the transition + // 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); + setGameInfo(getSelectedServer()); launchGame(); }, 200); }); @@ -111,4 +146,9 @@ $('#server-table').on('click', '.server-listing-entry', function(event) { $('#server-table').on('dblclick', '.server-listing-entry', function(event) { $(this).addClass('bg-primary').siblings().removeClass('bg-primary'); connectToServer(); -}); \ No newline at end of file +}); + +$('#of-deleteservermodal').on('show.bs.modal', function (e) { + var result = serverarray.filter(function(obj) {return (obj.uuid === getSelectedServer());})[0]; + $("#deleteserver-servername").html(result.description); +}); diff --git a/resources/app/files/index.html b/resources/app/files/index.html index 4be623b..c76efb8 100644 --- a/resources/app/files/index.html +++ b/resources/app/files/index.html @@ -69,11 +69,11 @@
Do you really want to delete SERVER_NAME?
You could always re-add it later.
Do you really want to delete
"SERVER_NAME"?
You could always re-add it later.