format assets but ignore minified files

This commit is contained in:
Hichem Fantar 2022-07-26 15:48:33 +01:00
parent fd92f2de5e
commit f9c041edc9
6 changed files with 329 additions and 252 deletions

View File

@ -29,5 +29,5 @@ version
resources/app/files/rankurl.txt resources/app/files/rankurl.txt
node_modules/ node_modules/
dist/ dist/
assets/
UnityBugReporter.exe UnityBugReporter.exe
*.min.*

View File

@ -49,9 +49,9 @@ img {
body { body {
user-select: none; user-select: none;
background-color: #000; background-color: #000;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
} }
#of-versionnumber { #of-versionnumber {
@ -61,17 +61,17 @@ body {
} }
.btn-primary { .btn-primary {
background-image: url('../../assets/img/btn-primary-bg.png'); background-image: url("../../assets/img/btn-primary-bg.png");
background-repeat: repeat; background-repeat: repeat;
} }
.btn-success { .btn-success {
background-image: url('../../assets/img/btn-success-bg.png'); background-image: url("../../assets/img/btn-success-bg.png");
background-repeat: repeat; background-repeat: repeat;
} }
.btn-danger { .btn-danger {
background-image: url('../../assets/img/btn-danger-bg.png'); background-image: url("../../assets/img/btn-danger-bg.png");
background-repeat: repeat; background-repeat: repeat;
} }

View File

@ -1,3 +1,3 @@
$(document).ready(function () { $(document).ready(function () {
$('[data-bs-tooltip]').tooltip(); $("[data-bs-tooltip]").tooltip();
}); });

View File

@ -7,7 +7,7 @@ var christmasBegin = new Date(today.getFullYear(), 11, 23);
var christmasEnd = new Date(today.getFullYear(), 12, 8); var christmasEnd = new Date(today.getFullYear(), 12, 8);
var sf; var sf;
if((today >= christmasBegin && today <= christmasEnd)) { if (today >= christmasBegin && today <= christmasEnd) {
console.log("Christmas Activated."); console.log("Christmas Activated.");
sf = new Snowflakes({ zIndex: -100 }); sf = new Snowflakes({ zIndex: -100 });
} }

View File

@ -33,9 +33,9 @@ function PayPage(param) {
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";
} }
} }
@ -47,32 +47,50 @@ function launchGame() {
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(
object.setAttribute('codebase', "undefined/UnityWebPlayer.cab#version=2,0,0,0"); "classid",
object.setAttribute('id', "Unity_object"); "clsid:444785F1-DE89-4295-863A-D46C3A781394"
object.setAttribute('width', "1264"); );
object.setAttribute('height', "661"); 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'); 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(
embed.setAttribute('id', "Unity_embed"); "pluginspage",
embed.setAttribute('width', "1280"); "http://www.unity3d.com/unity-web-player-2.x"
embed.setAttribute('height', "680"); );
embed.setAttribute('src', window.asseturl+"main.unity3d"); embed.setAttribute("id", "Unity_embed");
embed.setAttribute('disablecontdparaextmenu', "true"); embed.setAttribute("width", "1280");
embed.setAttribute('bordercolor', "000000"); embed.setAttribute("height", "680");
embed.setAttribute('backgroundcolor', "000000"); embed.setAttribute("src", window.asseturl + "main.unity3d");
embed.setAttribute('disableContextMenu', true); embed.setAttribute("disablecontdparaextmenu", "true");
embed.setAttribute('textcolor', "ccffff"); embed.setAttribute("bordercolor", "000000");
embed.setAttribute('logoimage', "assets/img/unity_dexlabs.png"); embed.setAttribute("backgroundcolor", "000000");
embed.setAttribute('progressbarimage', "assets/img/unity_loadingbar.png"); embed.setAttribute("disableContextMenu", true);
embed.setAttribute('progressframeimage', "assets/img/unity_loadingframe.png"); embed.setAttribute("textcolor", "ccffff");
embed.setAttribute('autoupdateurlsignature', "42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033"); embed.setAttribute("logoimage", "assets/img/unity_dexlabs.png");
embed.setAttribute('autoupdateurl', "http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta"); 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'); var div = document.getElementById("client");
object.appendChild(embed); object.appendChild(embed);
div.appendChild(object); div.appendChild(object);
document.title = "OpenFusion"; document.title = "OpenFusion";

View File

@ -1,83 +1,119 @@
var remote = require("remote"); var remote = require("remote");
var remotefs = remote.require('fs-extra'); var remotefs = remote.require("fs-extra");
var dns = remote.require('dns'); var dns = remote.require("dns");
var userdir = remote.require('app').getPath('userData'); var userdir = remote.require("app").getPath("userData");
var versionarray; var versionarray;
var serverarray; var serverarray;
var config; var config;
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-editserver-button').removeClass('disabled'); $("#of-editserver-button").removeClass("disabled");
$('#of-editserver-button').prop('disabled', false); $("#of-editserver-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-editserver-button').addClass('disabled'); $("#of-editserver-button").addClass("disabled");
$('#of-editserver-button').prop('disabled', true); $("#of-editserver-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"] =
server['ip'] = $("#addserver-ipinput").val().length == 0 ? "127.0.0.1:23000" : $("#addserver-ipinput").val(); $("#addserver-descinput").val().length == 0
server['version'] = $("#addserver-versionselect option:selected").text(); ? "My OpenFusion Server"
: $("#addserver-descinput").val();
server["ip"] =
$("#addserver-ipinput").val().length == 0
? "127.0.0.1:23000"
: $("#addserver-ipinput").val();
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 editServer() { function editServer() {
var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); var jsontomodify = JSON.parse(
remotefs.readFileSync(userdir + "\\servers.json")
);
$.each(jsontomodify["servers"], function (key, value) { $.each(jsontomodify["servers"], function (key, value) {
if (value["uuid"] == getSelectedServer()) { if (value["uuid"] == getSelectedServer()) {
value['description'] = $("#editserver-descinput").val().length == 0 ? value['description'] : $("#editserver-descinput").val(); value["description"] =
value['ip'] = $("#editserver-ipinput").val().length == 0 ? value['ip'] : $("#editserver-ipinput").val(); $("#editserver-descinput").val().length == 0
value['version'] = $("#editserver-versionselect option:selected").text(); ? value["description"]
: $("#editserver-descinput").val();
value["ip"] =
$("#editserver-ipinput").val().length == 0
? value["ip"]
: $("#editserver-ipinput").val();
value["version"] = $(
"#editserver-versionselect option:selected"
).text();
} }
}); });
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(
var result = jsontomodify['servers'].filter(function(obj) {return (obj.uuid === getSelectedServer())})[0]; remotefs.readFileSync(userdir + "\\servers.json")
);
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 restoreDefaultServers() { function restoreDefaultServers() {
remotefs.copySync(__dirname+"\\defaults\\servers.json", userdir+"\\servers.json"); remotefs.copySync(
__dirname + "\\defaults\\servers.json",
userdir + "\\servers.json"
);
loadServerList(); loadServerList();
} }
function loadGameVersions() { function loadGameVersions() {
var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json")); var versionjson = JSON.parse(
versionarray = versionjson['versions']; remotefs.readFileSync(userdir + "\\versions.json")
);
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");
$(new Option(value.name, 'val')).appendTo('#editserver-versionselect'); $(new Option(value.name, "val")).appendTo("#editserver-versionselect");
}); });
} }
@ -87,8 +123,10 @@ function loadConfig() {
} }
function loadServerList() { function loadServerList() {
var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); var serverjson = JSON.parse(
serverarray = serverjson['servers']; remotefs.readFileSync(userdir + "\\servers.json")
);
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
@ -98,14 +136,14 @@ function loadServerList() {
$("#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);
@ -119,23 +157,28 @@ function loadServerList() {
// 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) {
var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0]; return obj.uuid === serverUUID;
})[0];
var gameversion = versionarray.filter(function (obj) {
return obj.name === result.version;
})[0];
if(config['cache-swapping']) { // if cache swapping property exists AND is `true`, run cache swapping logic if (config["cache-swapping"]) {
// if cache swapping property exists AND is `true`, run cache swapping logic
// Cache folder renaming // Cache folder renaming
var cachedir = userdir + '\\..\\..\\LocalLow\\Unity\\Web Player\\Cache'; var cachedir = userdir + "\\..\\..\\LocalLow\\Unity\\Web Player\\Cache";
var curversion = cachedir + '\\Fusionfall'; var curversion = cachedir + "\\Fusionfall";
var newversion = cachedir + '\\' + gameversion.name; var newversion = cachedir + "\\" + gameversion.name;
var record = userdir + '\\.lastver'; var record = userdir + "\\.lastver";
if (remotefs.existsSync(curversion)) { if (remotefs.existsSync(curversion)) {
// cache already exists // cache already exists
// find out what version it belongs to // find out what version it belongs to
if (remotefs.existsSync(record)) { if (remotefs.existsSync(record)) {
var lastversion = remotefs.readFileSync(record); var lastversion = remotefs.readFileSync(record);
remotefs.renameSync(curversion, cachedir + '\\' + lastversion); remotefs.renameSync(curversion, cachedir + "\\" + lastversion);
console.log('Cached version ' + lastversion); console.log("Cached version " + lastversion);
} else { } else {
console.log( console.log(
"Couldn't find last version record; cache may get overwritten" "Couldn't find last version record; cache may get overwritten"
@ -146,7 +189,7 @@ function setGameInfo(serverUUID) {
if (remotefs.existsSync(newversion)) { if (remotefs.existsSync(newversion)) {
// rename saved cache to FusionFall // rename saved cache to FusionFall
remotefs.renameSync(newversion, curversion); remotefs.renameSync(newversion, curversion);
console.log('Loaded cached ' + gameversion.name); console.log("Loaded cached " + gameversion.name);
} }
// make note of what version we are launching for next launch // make note of what version we are launching for next launch
@ -156,17 +199,29 @@ function setGameInfo(serverUUID) {
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);
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(
remotefs.writeFileSync(__dirname+"\\images.php", httpendpoint+"upsell/"); __dirname + "\\sponsor.php",
httpendpoint + "upsell/sponsor.png"
);
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/");
} }
} }
@ -180,11 +235,12 @@ function setGameInfo(serverUUID) {
port = result.ip.substr(sepPos + 1); port = result.ip.substr(sepPos + 1);
} else { } else {
address = result.ip; address = result.ip;
port = 23000 // default port = 23000; // default
} }
// DNS resolution. there is no synchronous version for some stupid reason // DNS resolution. there is no synchronous version for some stupid reason
if(!address.match(/^[0-9.]+$/)) dns.resolve4(address, function(err, res) { if (!address.match(/^[0-9.]+$/))
dns.resolve4(address, function (err, res) {
if (!err) { if (!err) {
console.log("Resolved " + address + " to " + res[0]); console.log("Resolved " + address + " to " + res[0]);
address = res[0]; address = res[0];
@ -217,11 +273,11 @@ function connectToServer() {
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());
}, 200); }, 200);
}); });
@ -230,31 +286,32 @@ function connectToServer() {
// If applicable, deselect currently selected server. // If applicable, deselect currently selected server.
function deselectServer() { function deselectServer() {
disableServerListButtons(); disableServerListButtons();
$(".server-listing-entry").removeClass('bg-primary'); $(".server-listing-entry").removeClass("bg-primary");
} }
$('#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-editservermodal').on('show.bs.modal', function (e) { $("#of-editservermodal").on("show.bs.modal", function (e) {
var jsontomodify = JSON.parse(
var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); remotefs.readFileSync(userdir + "\\servers.json")
);
$.each(jsontomodify["servers"], function (key, value) { $.each(jsontomodify["servers"], function (key, value) {
if (value["uuid"] == getSelectedServer()) { if (value["uuid"] == getSelectedServer()) {
$("#editserver-descinput")[0].value = value['description']; $("#editserver-descinput")[0].value = value["description"];
$("#editserver-ipinput")[0].value = value['ip']; $("#editserver-ipinput")[0].value = value["ip"];
var versionIndex = -1; var versionIndex = -1;
$.each($("#editserver-versionselect")[0], function (key, val) { $.each($("#editserver-versionselect")[0], function (key, val) {
if(val.text === value['version']) { if (val.text === value["version"]) {
versionIndex = key; versionIndex = key;
} }
}); });
@ -263,7 +320,9 @@ $('#of-editservermodal').on('show.bs.modal', function (e) {
}); });
}); });
$('#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);
}); });