mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-14 02:30:05 +00:00
Use fs-extra for copying files synchronously
Also, sorry about the diff. Turns out some of the files in the repo were CRLF.
This commit is contained in:
parent
6f42297102
commit
bfac6e9250
@ -1,80 +1,80 @@
|
|||||||
var ipc = require("ipc");
|
var ipc = require("ipc");
|
||||||
var gameRunning = false;
|
var gameRunning = false;
|
||||||
|
|
||||||
// Unity invoked methods begin //
|
// Unity invoked methods begin //
|
||||||
|
|
||||||
// Uncomment and enter credentials to skip login screen
|
// Uncomment and enter credentials to skip login screen
|
||||||
function authDoCallback(param) {
|
function authDoCallback(param) {
|
||||||
/*var unity = document.getElementById('Unity_embed');
|
/*var unity = document.getElementById('Unity_embed');
|
||||||
unity.SendMessage("GlobalManager", "SetTEGid", "player");
|
unity.SendMessage("GlobalManager", "SetTEGid", "player");
|
||||||
unity.SendMessage("GlobalManager", "SetAuthid", "0");
|
unity.SendMessage("GlobalManager", "SetAuthid", "0");
|
||||||
unity.SendMessage("GlobalManager", "DoAuth", 0);*/
|
unity.SendMessage("GlobalManager", "DoAuth", 0);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function MarkProgress(param) {}
|
function MarkProgress(param) {}
|
||||||
|
|
||||||
function redirect(html) {
|
function redirect(html) {
|
||||||
ipc.send("exit", 0);
|
ipc.send("exit", 0);
|
||||||
}
|
}
|
||||||
function HomePage(param) {
|
function HomePage(param) {
|
||||||
ipc.send("exit", 0);
|
ipc.send("exit", 0);
|
||||||
}
|
}
|
||||||
function PageOut(param) {
|
function PageOut(param) {
|
||||||
ipc.send("exit", 0);
|
ipc.send("exit", 0);
|
||||||
}
|
}
|
||||||
function updateSocialOptions(param) {
|
function updateSocialOptions(param) {
|
||||||
ipc.send("exit", 0);
|
ipc.send("exit", 0);
|
||||||
}
|
}
|
||||||
function PayPage(param) {
|
function PayPage(param) {
|
||||||
ipc.send("exit", 0);
|
ipc.send("exit", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unity invoked methods end //
|
// Unity invoked methods end //
|
||||||
|
|
||||||
function onResize() {
|
function onResize() {
|
||||||
if (gameRunning == true) {
|
if (gameRunning == true) {
|
||||||
var unity = document.getElementById('Unity_embed');
|
var unity = document.getElementById('Unity_embed');
|
||||||
unity.style.width = window.innerWidth + 'px';
|
unity.style.width = window.innerWidth + 'px';
|
||||||
unity.style.height = window.innerHeight + 'px';
|
unity.style.height = window.innerHeight + 'px';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function launchGame() {
|
function launchGame() {
|
||||||
gameRunning = true
|
gameRunning = true
|
||||||
|
|
||||||
var sel = document.getElementById("of-serverselector");
|
var sel = document.getElementById("of-serverselector");
|
||||||
sel.remove()
|
sel.remove()
|
||||||
|
|
||||||
document.body.style.overflow = "hidden";
|
document.body.style.overflow = "hidden";
|
||||||
|
|
||||||
var object = document.createElement('object');
|
var object = document.createElement('object');
|
||||||
object.setAttribute('classid', "clsid:444785F1-DE89-4295-863A-D46C3A781394");
|
object.setAttribute('classid', "clsid:444785F1-DE89-4295-863A-D46C3A781394");
|
||||||
object.setAttribute('codebase', "undefined/UnityWebPlayer.cab#version=2,0,0,0");
|
object.setAttribute('codebase', "undefined/UnityWebPlayer.cab#version=2,0,0,0");
|
||||||
object.setAttribute('id', "Unity_object");
|
object.setAttribute('id', "Unity_object");
|
||||||
object.setAttribute('width', "1264");
|
object.setAttribute('width', "1264");
|
||||||
object.setAttribute('height', "661");
|
object.setAttribute('height', "661");
|
||||||
|
|
||||||
var embed = document.createElement('embed');
|
var embed = document.createElement('embed');
|
||||||
embed.setAttribute('type', "application/vnd.unity");
|
embed.setAttribute('type', "application/vnd.unity");
|
||||||
embed.setAttribute('pluginspage', "http://www.unity3d.com/unity-web-player-2.x");
|
embed.setAttribute('pluginspage', "http://www.unity3d.com/unity-web-player-2.x");
|
||||||
embed.setAttribute('id', "Unity_embed");
|
embed.setAttribute('id', "Unity_embed");
|
||||||
embed.setAttribute('width', "1280");
|
embed.setAttribute('width', "1280");
|
||||||
embed.setAttribute('height', "680");
|
embed.setAttribute('height', "680");
|
||||||
embed.setAttribute('src', window.asseturl+"main.unity3d");
|
embed.setAttribute('src', window.asseturl+"main.unity3d");
|
||||||
embed.setAttribute('disablecontdparaextmenu', "true");
|
embed.setAttribute('disablecontdparaextmenu', "true");
|
||||||
embed.setAttribute('bordercolor', "000000");
|
embed.setAttribute('bordercolor', "000000");
|
||||||
embed.setAttribute('backgroundcolor', "000000");
|
embed.setAttribute('backgroundcolor', "000000");
|
||||||
embed.setAttribute('disableContextMenu', true);
|
embed.setAttribute('disableContextMenu', true);
|
||||||
embed.setAttribute('textcolor', "ccffff");
|
embed.setAttribute('textcolor', "ccffff");
|
||||||
embed.setAttribute('logoimage', "assets/img/unity_dexlabs.png");
|
embed.setAttribute('logoimage', "assets/img/unity_dexlabs.png");
|
||||||
embed.setAttribute('progressbarimage', "assets/img/unity_loadingbar.png");
|
embed.setAttribute('progressbarimage', "assets/img/unity_loadingbar.png");
|
||||||
embed.setAttribute('progressframeimage', "assets/img/unity_loadingframe.png");
|
embed.setAttribute('progressframeimage', "assets/img/unity_loadingframe.png");
|
||||||
embed.setAttribute('autoupdateurlsignature', "42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033");
|
embed.setAttribute('autoupdateurlsignature', "42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033");
|
||||||
embed.setAttribute('autoupdateurl', "http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta");
|
embed.setAttribute('autoupdateurl', "http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta");
|
||||||
|
|
||||||
var div = document.getElementById('client');
|
var div = document.getElementById('client');
|
||||||
object.appendChild(embed);
|
object.appendChild(embed);
|
||||||
div.appendChild(object);
|
div.appendChild(object);
|
||||||
document.title = "OpenFusion"
|
document.title = "OpenFusion"
|
||||||
onResize();
|
onResize();
|
||||||
}
|
}
|
@ -1,155 +1,155 @@
|
|||||||
var remote = require("remote");
|
var remote = require("remote");
|
||||||
var remotefs = remote.require('fs');
|
var remotefs = remote.require('fs-extra');
|
||||||
|
|
||||||
var userdir = remote.require('app').getPath('userData');
|
var userdir = remote.require('app').getPath('userData');
|
||||||
var versionarray
|
var versionarray
|
||||||
var serverarray
|
var serverarray
|
||||||
|
|
||||||
function enableServerListButtons() {
|
function enableServerListButtons() {
|
||||||
$('#of-connect-button').removeClass('disabled');
|
$('#of-connect-button').removeClass('disabled');
|
||||||
$('#of-connect-button').prop('disabled', false);
|
$('#of-connect-button').prop('disabled', false);
|
||||||
$('#of-deleteserver-button').removeClass('disabled');
|
$('#of-deleteserver-button').removeClass('disabled');
|
||||||
$('#of-deleteserver-button').prop('disabled', false);
|
$('#of-deleteserver-button').prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function disableServerListButtons() {
|
function disableServerListButtons() {
|
||||||
$('#of-connect-button').addClass('disabled');
|
$('#of-connect-button').addClass('disabled');
|
||||||
$('#of-connect-button').prop('disabled', true);
|
$('#of-connect-button').prop('disabled', true);
|
||||||
$('#of-deleteserver-button').addClass('disabled');
|
$('#of-deleteserver-button').addClass('disabled');
|
||||||
$('#of-deleteserver-button').prop('disabled', true);
|
$('#of-deleteserver-button').prop('disabled', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addServer() {
|
function addServer() {
|
||||||
var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
||||||
|
|
||||||
var server = {};
|
var server = {};
|
||||||
server['uuid'] = uuidv4();
|
server['uuid'] = uuidv4();
|
||||||
server['description'] = $("#addserver-descinput").val().length == 0 ? "My OpenFusion Server" : $("#addserver-descinput").val();
|
server['description'] = $("#addserver-descinput").val().length == 0 ? "My OpenFusion Server" : $("#addserver-descinput").val();
|
||||||
server['ip'] = $("#addserver-ipinput").val().length == 0 ? "127.0.0.1:23000" : $("#addserver-ipinput").val();
|
server['ip'] = $("#addserver-ipinput").val().length == 0 ? "127.0.0.1:23000" : $("#addserver-ipinput").val();
|
||||||
server['version'] = $("#addserver-versionselect option:selected").text();
|
server['version'] = $("#addserver-versionselect option:selected").text();
|
||||||
//server['endpoint'] =
|
//server['endpoint'] =
|
||||||
|
|
||||||
jsontomodify['servers'].push(server)
|
jsontomodify['servers'].push(server)
|
||||||
|
|
||||||
remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4));
|
remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4));
|
||||||
loadServerList();
|
loadServerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteServer() {
|
function deleteServer() {
|
||||||
var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
||||||
var result = jsontomodify['servers'].filter(function(obj) {return (obj.uuid === getSelectedServer())})[0];
|
var result = jsontomodify['servers'].filter(function(obj) {return (obj.uuid === getSelectedServer())})[0];
|
||||||
|
|
||||||
var resultindex = jsontomodify['servers'].indexOf(result);
|
var resultindex = jsontomodify['servers'].indexOf(result);
|
||||||
|
|
||||||
jsontomodify['servers'].splice(resultindex, 1);
|
jsontomodify['servers'].splice(resultindex, 1);
|
||||||
|
|
||||||
remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4));
|
remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4));
|
||||||
loadServerList();
|
loadServerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadGameVersions() {
|
function loadGameVersions() {
|
||||||
var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json"));
|
var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json"));
|
||||||
versionarray = versionjson['versions'];
|
versionarray = versionjson['versions'];
|
||||||
$.each(versionarray, function( key, value ) {
|
$.each(versionarray, function( key, value ) {
|
||||||
$(new Option(value.name, 'val')).appendTo('#addserver-versionselect');
|
$(new Option(value.name, 'val')).appendTo('#addserver-versionselect');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadConfig() {
|
function loadConfig() {
|
||||||
// TODO: actually use these values
|
// TODO: actually use these values
|
||||||
var configjson = JSON.parse(remotefs.readFileSync(userdir+"\\config.json"));
|
var configjson = JSON.parse(remotefs.readFileSync(userdir+"\\config.json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadServerList() {
|
function loadServerList() {
|
||||||
var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
||||||
serverarray = serverjson['servers'];
|
serverarray = serverjson['servers'];
|
||||||
|
|
||||||
$(".server-listing-entry").remove(); // Clear out old stuff, if any
|
$(".server-listing-entry").remove(); // Clear out old stuff, if any
|
||||||
disableServerListButtons(); // Disable buttons until another server is selected
|
disableServerListButtons(); // Disable buttons until another server is selected
|
||||||
|
|
||||||
if (serverarray.length > 0) {
|
if (serverarray.length > 0) {
|
||||||
// Servers were found in the JSON
|
// Servers were found in the JSON
|
||||||
$("#server-listing-placeholder").attr("hidden",true);
|
$("#server-listing-placeholder").attr("hidden",true);
|
||||||
$.each(serverarray, function( key, value ) {
|
$.each(serverarray, function( key, value ) {
|
||||||
// Create the row, and populate the cells
|
// Create the row, and populate the cells
|
||||||
var row = document.createElement('tr');
|
var row = document.createElement('tr');
|
||||||
row.className = 'server-listing-entry'
|
row.className = 'server-listing-entry'
|
||||||
row.setAttribute('id', value.uuid);
|
row.setAttribute('id', value.uuid);
|
||||||
var cellName = document.createElement('td');
|
var cellName = document.createElement('td');
|
||||||
cellName.textContent = value.description
|
cellName.textContent = value.description
|
||||||
var cellVersion = document.createElement('td');
|
var cellVersion = document.createElement('td');
|
||||||
cellVersion.textContent = value.version
|
cellVersion.textContent = value.version
|
||||||
cellVersion.className = 'text-monospace'
|
cellVersion.className = 'text-monospace'
|
||||||
|
|
||||||
row.appendChild(cellName);
|
row.appendChild(cellName);
|
||||||
row.appendChild(cellVersion);
|
row.appendChild(cellVersion);
|
||||||
$("#server-tablebody").append(row);
|
$("#server-tablebody").append(row);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// No servers are added, make sure placeholder is visible
|
// No servers are added, make sure placeholder is visible
|
||||||
$("#server-listing-placeholder").attr("hidden",false);
|
$("#server-listing-placeholder").attr("hidden",false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For writing loginInfo.php, assetInfo.php, etc.
|
// For writing loginInfo.php, assetInfo.php, etc.
|
||||||
function setGameInfo(serverUUID) {
|
function setGameInfo(serverUUID) {
|
||||||
var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0];
|
var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0];
|
||||||
var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0];
|
var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0];
|
||||||
window.asseturl = gameversion.url // gameclient.js needs to access this
|
window.asseturl = gameversion.url // gameclient.js needs to access this
|
||||||
|
|
||||||
remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl);
|
remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl);
|
||||||
remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip);
|
remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip);
|
||||||
|
|
||||||
if (result.hasOwnProperty('endpoint')) {
|
if (result.hasOwnProperty('endpoint')) {
|
||||||
var httpendpoint = result.endpoint.replace("https://", "http://")
|
var httpendpoint = result.endpoint.replace("https://", "http://")
|
||||||
remotefs.writeFileSync(__dirname+"\\rankurl.txt", httpendpoint+"getranks");
|
remotefs.writeFileSync(__dirname+"\\rankurl.txt", httpendpoint+"getranks");
|
||||||
// Write these out too
|
// Write these out too
|
||||||
remotefs.writeFileSync(__dirname+"\\sponsor.php", httpendpoint+"upsell/sponsor.png");
|
remotefs.writeFileSync(__dirname+"\\sponsor.php", httpendpoint+"upsell/sponsor.png");
|
||||||
remotefs.writeFileSync(__dirname+"\\images.php", httpendpoint+"upsell/");
|
remotefs.writeFileSync(__dirname+"\\images.php", httpendpoint+"upsell/");
|
||||||
} else {
|
} else {
|
||||||
// Remove/default the endpoint related stuff, this server won't be using it
|
// Remove/default the endpoint related stuff, this server won't be using it
|
||||||
if (remotefs.existsSync(__dirname+"\\rankurl.txt")) {
|
if (remotefs.existsSync(__dirname+"\\rankurl.txt")) {
|
||||||
remotefs.unlinkSync(__dirname+"\\rankurl.txt");
|
remotefs.unlinkSync(__dirname+"\\rankurl.txt");
|
||||||
remotefs.writeFileSync(__dirname+"\\sponsor.php", "assets/img/welcome.png");
|
remotefs.writeFileSync(__dirname+"\\sponsor.php", "assets/img/welcome.png");
|
||||||
remotefs.writeFileSync(__dirname+"\\images.php", "assets/img/");
|
remotefs.writeFileSync(__dirname+"\\images.php", "assets/img/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the UUID of the server with the selected background color.
|
// 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.
|
// Yes, there are probably better ways to go about this, but it works well enough.
|
||||||
function getSelectedServer() {
|
function getSelectedServer() {
|
||||||
return $("#server-tablebody > tr.bg-primary").prop("id");
|
return $("#server-tablebody > tr.bg-primary").prop("id");
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectToServer() {
|
function connectToServer() {
|
||||||
// Get ID of the selected server, which corresponds to its UUID in the json
|
// Get ID of the selected server, which corresponds to its UUID in the json
|
||||||
console.log("Connecting to server with UUID of " + getSelectedServer());
|
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');
|
$('body,html').css('pointer-events','none');
|
||||||
stopEasterEggs();
|
stopEasterEggs();
|
||||||
$('#of-serverselector').fadeOut('slow', function() {
|
$('#of-serverselector').fadeOut('slow', function() {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('body,html').css('pointer-events','');
|
$('body,html').css('pointer-events','');
|
||||||
setGameInfo(getSelectedServer());
|
setGameInfo(getSelectedServer());
|
||||||
launchGame();
|
launchGame();
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#server-table').on('click', '.server-listing-entry', function(event) {
|
$('#server-table').on('click', '.server-listing-entry', function(event) {
|
||||||
enableServerListButtons();
|
enableServerListButtons();
|
||||||
$(this).addClass('bg-primary').siblings().removeClass('bg-primary');
|
$(this).addClass('bg-primary').siblings().removeClass('bg-primary');
|
||||||
});
|
});
|
||||||
|
|
||||||
// QoL feature: if you double click on a server it will connect
|
// QoL feature: if you double click on a server it will connect
|
||||||
$('#server-table').on('dblclick', '.server-listing-entry', function(event) {
|
$('#server-table').on('dblclick', '.server-listing-entry', function(event) {
|
||||||
$(this).addClass('bg-primary').siblings().removeClass('bg-primary');
|
$(this).addClass('bg-primary').siblings().removeClass('bg-primary');
|
||||||
connectToServer();
|
connectToServer();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#of-deleteservermodal').on('show.bs.modal', function (e) {
|
$('#of-deleteservermodal').on('show.bs.modal', function (e) {
|
||||||
var result = serverarray.filter(function(obj) {return (obj.uuid === getSelectedServer());})[0];
|
var result = serverarray.filter(function(obj) {return (obj.uuid === getSelectedServer());})[0];
|
||||||
$("#deleteserver-servername").html(result.description);
|
$("#deleteserver-servername").html(result.description);
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"autoupdate-check": true,
|
"autoupdate-check": true,
|
||||||
"cache-swapping": false,
|
"cache-swapping": false,
|
||||||
"initial-setup-completed": true
|
"initial-setup-completed": true
|
||||||
}
|
}
|
@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
"uuid": "d9773558-6ddf-4d00-8803-d830a22a842b",
|
"uuid": "d9773558-6ddf-4d00-8803-d830a22a842b",
|
||||||
"description": "OpenFusion Public Server - Original",
|
"description": "OpenFusion Public Server - Original",
|
||||||
"ip": "144.202.52.9:23000",
|
"ip": "144.202.52.9:23000",
|
||||||
"version": "beta-20100104",
|
"version": "beta-20100104",
|
||||||
"endpoint": "https://api.dexlabs.systems/"
|
"endpoint": "https://api.dexlabs.systems/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9",
|
"uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9",
|
||||||
"description": "OpenFusion Public Server - Academy",
|
"description": "OpenFusion Public Server - Academy",
|
||||||
"ip": "144.202.52.9:24000",
|
"ip": "144.202.52.9:24000",
|
||||||
"version": "beta-20111013",
|
"version": "beta-20111013",
|
||||||
"endpoint": "https://api.dexlabs.systems/academy/"
|
"endpoint": "https://api.dexlabs.systems/academy/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"favorites": []
|
"favorites": []
|
||||||
}
|
}
|
@ -1,108 +1,108 @@
|
|||||||
{
|
{
|
||||||
"versions": [
|
"versions": [
|
||||||
{
|
{
|
||||||
"name": "beta-20100104",
|
"name": "beta-20100104",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100104/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100104/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100119",
|
"name": "beta-20100119",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100119/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100119/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100207",
|
"name": "beta-20100207",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100207/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100207/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100307",
|
"name": "beta-20100307",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100307/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100307/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100322",
|
"name": "beta-20100322",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100322/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100322/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100413",
|
"name": "beta-20100413",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100413/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100413/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100502",
|
"name": "beta-20100502",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100502/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100502/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100524",
|
"name": "beta-20100524",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100524/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100524/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100604",
|
"name": "beta-20100604",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100604/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100604/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100616",
|
"name": "beta-20100616",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100616/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100616/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100711",
|
"name": "beta-20100711",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100711/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100711/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100728",
|
"name": "beta-20100728",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100728/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100728/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20100909",
|
"name": "beta-20100909",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100909/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20100909/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20101003",
|
"name": "beta-20101003",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101003/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20101003/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20101011",
|
"name": "beta-20101011",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101011/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20101011/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20101028",
|
"name": "beta-20101028",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101028/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20101028/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20101123",
|
"name": "beta-20101123",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101123/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20101123/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20110213",
|
"name": "beta-20110213",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110213/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20110213/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20110314",
|
"name": "beta-20110314",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110314/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20110314/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20110330",
|
"name": "beta-20110330",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110330/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20110330/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20110424",
|
"name": "beta-20110424",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110424/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20110424/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20110523",
|
"name": "beta-20110523",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110523/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20110523/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20110725",
|
"name": "beta-20110725",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110725/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20110725/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20110818",
|
"name": "beta-20110818",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110818/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20110818/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20110912",
|
"name": "beta-20110912",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110912/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20110912/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beta-20111013",
|
"name": "beta-20111013",
|
||||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20111013/"
|
"url": "http://ht.cdn.turner.com/ff/big/beta-20111013/"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
295
index.js
295
index.js
@ -1,178 +1,117 @@
|
|||||||
var app = require('app'); // Module to control application life.
|
var app = require('app'); // Module to control application life.
|
||||||
var ipc = require('ipc');
|
var ipc = require('ipc');
|
||||||
var fs = require('fs');
|
var fs = require('fs-extra');
|
||||||
var os = require('os');
|
var os = require('os');
|
||||||
var dialog = require('dialog');
|
var dialog = require('dialog');
|
||||||
var BrowserWindow = require('browser-window');
|
var BrowserWindow = require('browser-window');
|
||||||
|
|
||||||
var mainWindow = null;
|
var mainWindow = null;
|
||||||
|
|
||||||
app.commandLine.appendSwitch('--enable-npapi');
|
app.commandLine.appendSwitch('--enable-npapi');
|
||||||
|
|
||||||
// this should be placed at top of main.js to handle setup events quickly
|
function initialSetup() {
|
||||||
if (handleSquirrelEvent()) {
|
// Display a small window to inform the user that the app is working
|
||||||
// squirrel event handled and app will exit in 1000ms, so don't do anything else
|
setupWindow = new BrowserWindow({width: 275, height: 450, resizable: false, center:true, frame:false});
|
||||||
return;
|
setupWindow.loadUrl('file://' + __dirname + '/initialsetup.html');
|
||||||
}
|
// Exec installUnity.bat and wait for it to finish.
|
||||||
|
var child = require('child_process').spawn('cmd.exe', ['/c', 'utils\\installUnity.bat']);
|
||||||
function handleSquirrelEvent() {
|
child.on('exit', function() {
|
||||||
"use strict"
|
console.log("Unity installed.");
|
||||||
|
// Copy over files with default values
|
||||||
if (process.argv.length === 1) {
|
copySync(__dirname+"\\defaults\\config.json", app.getPath('userData')+"\\config.json");
|
||||||
return false;
|
copySync(__dirname+"\\defaults\\servers.json", app.getPath('userData')+"\\servers.json");
|
||||||
}
|
copySync(__dirname+"\\defaults\\versions.json", app.getPath('userData')+"\\versions.json");
|
||||||
|
console.log("JSON files copied.");
|
||||||
const ChildProcess = require('child_process');
|
setupWindow.destroy();
|
||||||
const path = require('path');
|
showMainWindow();
|
||||||
|
})
|
||||||
const appFolder = path.resolve(process.execPath, '..');
|
}
|
||||||
const rootAtomFolder = path.resolve(appFolder, '..');
|
|
||||||
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
|
ipc.on("exit", function(id) {
|
||||||
const exeName = path.basename(process.execPath);
|
mainWindow.destroy();
|
||||||
|
});
|
||||||
const spawn = function(command, args) {
|
|
||||||
let spawnedProcess, error;
|
// Quit when all windows are closed.
|
||||||
|
app.on('window-all-closed', function() {
|
||||||
try {
|
if (process.platform != 'darwin')
|
||||||
spawnedProcess = ChildProcess.spawn(command, args, {detached: true});
|
app.quit();
|
||||||
} catch (error) {}
|
});
|
||||||
|
|
||||||
return spawnedProcess;
|
app.on('ready', function() {
|
||||||
};
|
|
||||||
|
// Check just in case the user forgot to extract the zip.
|
||||||
const spawnUpdate = function(args) {
|
zip_check = app.getPath('exe').includes(os.tmpdir());
|
||||||
return spawn(updateDotExe, args);
|
if (zip_check) {
|
||||||
};
|
errormsg =
|
||||||
|
( "It has been detected that OpenFusionClient is running from the TEMP folder.\n\n"+
|
||||||
const squirrelEvent = process.argv[1];
|
"Please extract the entire Client folder to a location of your choice before starting OpenFusionClient.");
|
||||||
switch (squirrelEvent) {
|
dialog.showErrorBox("Error!", errormsg);
|
||||||
case '--squirrel-install':
|
return;
|
||||||
case '--squirrel-updated':
|
}
|
||||||
// Optionally do things such as:
|
|
||||||
// - Add your .exe to the PATH
|
// Create the browser window.
|
||||||
// - Write to the registry for things like file associations and
|
mainWindow = new BrowserWindow({width: 1280, height: 720, show: false, "web-preferences": {"plugins": true}});
|
||||||
// explorer context menus
|
mainWindow.setMinimumSize(640, 480);
|
||||||
|
|
||||||
// Install desktop and start menu shortcuts
|
// Check for first run
|
||||||
spawnUpdate(['--createShortcut', exeName]);
|
try {
|
||||||
|
if (!fs.existsSync(app.getPath('userData')+"\\config.json")) {
|
||||||
setTimeout(app.quit, 1000);
|
console.log("Config file not found. Running initial setup.");
|
||||||
return true;
|
initialSetup();
|
||||||
|
} else {
|
||||||
case '--squirrel-uninstall':
|
showMainWindow();
|
||||||
// Undo anything you did in the --squirrel-install and
|
}
|
||||||
// --squirrel-updated handlers
|
} catch(e) {
|
||||||
|
console.log("An error occurred while checking for the config.");
|
||||||
// Remove desktop and start menu shortcuts
|
}
|
||||||
spawnUpdate(['--removeShortcut', exeName]);
|
|
||||||
|
// Makes it so external links are opened in the system browser, not Electron
|
||||||
setTimeout(app.quit, 1000);
|
mainWindow.webContents.on('new-window', function(e, url) {
|
||||||
return true;
|
e.preventDefault();
|
||||||
|
require('shell').openExternal(url);
|
||||||
case '--squirrel-obsolete':
|
});
|
||||||
// This is called on the outgoing version of your app before
|
|
||||||
// we update to the new version - it's the opposite of
|
mainWindow.on('closed', function() {
|
||||||
// --squirrel-updated
|
mainWindow = null;
|
||||||
|
});
|
||||||
app.quit();
|
});
|
||||||
return true;
|
|
||||||
}
|
function showMainWindow() {
|
||||||
};
|
// Load the index.html of the app.
|
||||||
|
mainWindow.loadUrl('file://' + __dirname + '/index.html');
|
||||||
// Node version is too old to have a built-in function
|
|
||||||
function copyFile(src, dst) {
|
// Reduces white flash when opening the program
|
||||||
fs.createReadStream(src).pipe(fs.createWriteStream(dst));
|
mainWindow.webContents.on('did-finish-load', function() {
|
||||||
}
|
mainWindow.show();
|
||||||
|
// everything's loaded, tell the renderer process to do its thing
|
||||||
function initialSetup() {
|
mainWindow.webContents.executeJavaScript("loadConfig();");
|
||||||
// Display a small window to inform the user that the app is working
|
mainWindow.webContents.executeJavaScript("loadGameVersions();");
|
||||||
setupWindow = new BrowserWindow({width: 275, height: 450, resizable: false, center:true, frame:false});
|
mainWindow.webContents.executeJavaScript("loadServerList();");
|
||||||
setupWindow.loadUrl('file://' + __dirname + '/initialsetup.html');
|
});
|
||||||
// Exec installUnity.bat and wait for it to finish.
|
|
||||||
var child = require('child_process').spawn('cmd.exe', ['/c', 'utils\\installUnity.bat']);
|
mainWindow.webContents.on('plugin-crashed', function() {
|
||||||
child.on('exit', function() {
|
console.log("Unity Web Player crashed.");
|
||||||
console.log("Unity installed.");
|
});
|
||||||
// Copy over files with default values
|
|
||||||
copyFile(__dirname+"\\defaults\\config.json", app.getPath('userData')+"\\config.json");
|
mainWindow.webContents.on('will-navigate', function(evt, url) {
|
||||||
copyFile(__dirname+"\\default\\servers.json", app.getPath('userData')+"\\servers.json");
|
evt.preventDefault();
|
||||||
copyFile(__dirname+"\\default\\versions.json", app.getPath('userData')+"\\versions.json");
|
// TODO: showMessageBox rather than showErrorBox?
|
||||||
console.log("JSON files copied.");
|
switch (url) {
|
||||||
setupWindow.destroy();
|
case "https://audience.fusionfall.com/ff/regWizard.do?_flowId=fusionfall-registration-flow":
|
||||||
showMainWindow();
|
errormsg =
|
||||||
})
|
( "The register page is currently unimplemented.\n\n"+
|
||||||
}
|
"You can still create an account: type your desired username and password into the provided boxes and click \"Log In\". "+
|
||||||
|
"Your account will then be automatically created on the server. \nBe sure to remember these details!");
|
||||||
ipc.on("exit", function(id) {
|
dialog.showErrorBox("Sorry!", errormsg);
|
||||||
mainWindow.destroy();
|
break;
|
||||||
});
|
case "https://audience.fusionfall.com/ff/login.do":
|
||||||
|
dialog.showErrorBox("Sorry!", "Account management is not available.");
|
||||||
// Quit when all windows are closed.
|
break;
|
||||||
app.on('window-all-closed', function() {
|
case "http://forums.fusionfall.com/":
|
||||||
if (process.platform != 'darwin')
|
require('shell').openExternal("https://discord.gg/DYavckB");
|
||||||
app.quit();
|
break;
|
||||||
});
|
default:
|
||||||
|
mainWindow.webContents.loadURL(url);
|
||||||
app.on('ready', function() {
|
}
|
||||||
|
});
|
||||||
// Check just in case the user forgot to extract the zip.
|
}
|
||||||
zip_check = app.getPath('exe').includes(os.tmpdir());
|
|
||||||
if (zip_check) {
|
|
||||||
errormsg =
|
|
||||||
("It has been detected that OpenFusionClient is running from the TEMP folder.\n\n"+
|
|
||||||
"Please extract the entire Client folder to a location of your choice before starting OpenFusionClient.");
|
|
||||||
dialog.showErrorBox("Error!", errormsg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the browser window.
|
|
||||||
mainWindow = new BrowserWindow({width: 1280, height: 720, show: false, "web-preferences": {"plugins": true}});
|
|
||||||
mainWindow.setMinimumSize(640, 480);
|
|
||||||
|
|
||||||
// Check for first run
|
|
||||||
try {
|
|
||||||
if (!fs.existsSync(app.getPath('userData')+"\\config.json")) {
|
|
||||||
console.log("Config file not found. Running initial setup.");
|
|
||||||
initialSetup();
|
|
||||||
} else {
|
|
||||||
showMainWindow();
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
console.log("An error occurred while checking for the config.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Makes it so external links are opened in the system browser, not Electron
|
|
||||||
mainWindow.webContents.on('new-window', function(e, url) {
|
|
||||||
e.preventDefault();
|
|
||||||
require('shell').openExternal(url);
|
|
||||||
});
|
|
||||||
|
|
||||||
mainWindow.on('closed', function() {
|
|
||||||
mainWindow = null;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function showMainWindow() {
|
|
||||||
// and load the index.html of the app.
|
|
||||||
mainWindow.loadUrl('file://' + __dirname + '/index.html');
|
|
||||||
|
|
||||||
// Reduces white flash when opening the program
|
|
||||||
// Eliminating it entirely requires a newer Electron ver :(
|
|
||||||
mainWindow.webContents.on('did-finish-load', function() {
|
|
||||||
mainWindow.show();
|
|
||||||
mainWindow.webContents.executeJavaScript("loadConfig();");
|
|
||||||
mainWindow.webContents.executeJavaScript("loadGameVersions();");
|
|
||||||
mainWindow.webContents.executeJavaScript("loadServerList();");
|
|
||||||
});
|
|
||||||
|
|
||||||
mainWindow.webContents.on('plugin-crashed', function() {
|
|
||||||
console.log("Unity Web Player crashed.");
|
|
||||||
});
|
|
||||||
|
|
||||||
mainWindow.webContents.on('will-navigate', function(evt, url) {
|
|
||||||
evt.preventDefault();
|
|
||||||
console.log(url);
|
|
||||||
});
|
|
||||||
|
|
||||||
//mainWindow.webContents.openDevTools()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -41,5 +41,8 @@
|
|||||||
"to": "utils"
|
"to": "utils"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"fs-extra": "^0.30.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user