Consistency pass and small tweaks

**Formatting going forward**
Variables: camelCase (capitalization of two letter abbreviations is OK, e.g. playerID)
Classes: PascalCase
CSS: kebab-case
Files: kebab-case

**Other miscellaneous changes**
* The WebPlayer crashing as well as failing to load the config file are now fatal  errors and will quit the app
* Moved some style attributes from index.html into openfusion.css
This commit is contained in:
CakeLancelot 2023-09-03 04:56:24 -05:00
parent 7131026b2f
commit 043bf219e7
12 changed files with 145 additions and 137 deletions

View File

@ -47,6 +47,11 @@ img {
} }
body { body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
clear: both;
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,
@ -129,3 +134,12 @@ button > i {
#server-table .server-listing-entry { #server-table .server-listing-entry {
cursor: pointer; cursor: pointer;
} }
#client {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #000;
clear: both;
}

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -5,7 +5,7 @@ var gameRunning = false;
// 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('unityEmbed');
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);*/
@ -33,7 +33,7 @@ function PayPage(param) {
function onResize() { function onResize() {
if (gameRunning == true) { if (gameRunning == true) {
var unity = document.getElementById("Unity_embed"); var unity = document.getElementById("unityEmbed");
unity.style.width = window.innerWidth + "px"; unity.style.width = window.innerWidth + "px";
unity.style.height = window.innerHeight + "px"; unity.style.height = window.innerHeight + "px";
} }
@ -56,7 +56,7 @@ function launchGame() {
"codebase", "codebase",
"undefined/UnityWebPlayer.cab#version=2,0,0,0" "undefined/UnityWebPlayer.cab#version=2,0,0,0"
); );
object.setAttribute("id", "Unity_object"); object.setAttribute("id", "unityObject");
object.setAttribute("width", "1264"); object.setAttribute("width", "1264");
object.setAttribute("height", "661"); object.setAttribute("height", "661");
@ -66,20 +66,19 @@ function launchGame() {
"pluginspage", "pluginspage",
"http://www.unity3d.com/unity-web-player-2.x" "http://www.unity3d.com/unity-web-player-2.x"
); );
embed.setAttribute("id", "Unity_embed"); embed.setAttribute("id", "unityEmbed");
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("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( embed.setAttribute(
"progressframeimage", "progressframeimage",
"assets/img/unity_loadingframe.png" "assets/img/unity-loadingframe.png"
); );
embed.setAttribute( embed.setAttribute(
"autoupdateurlsignature", "autoupdateurlsignature",

View File

@ -2,9 +2,9 @@ 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() {
@ -26,14 +26,14 @@ function disableServerListButtons() {
} }
function getAppVersion() { function getAppVersion() {
appversion = remote.require("app").getVersion(); appVersion = remote.require("app").getVersion();
// simplify version, ex. 1.4.0 -> 1.4, // simplify version, ex. 1.4.0 -> 1.4,
// but only if a revision number isn't present // but only if a revision number isn't present
if (appversion.endsWith(".0")) { if (appVersion.endsWith(".0")) {
return appversion.substr(0, appversion.length - 2); return appVersion.substr(0, appVersion.length - 2);
} else { } else {
return appversion; return appVersion;
} }
} }
@ -43,8 +43,8 @@ function setAppVersionText() {
} }
function addServer() { function addServer() {
var jsontomodify = JSON.parse( var jsonToModify = JSON.parse(
remotefs.readFileSync(userdir + "\\servers.json") remotefs.readFileSync(userDir + "\\servers.json")
); );
var server = {}; var server = {};
@ -60,20 +60,20 @@ function addServer() {
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( remotefs.writeFileSync(
userdir + "\\servers.json", userDir + "\\servers.json",
JSON.stringify(jsontomodify, null, 4) JSON.stringify(jsonToModify, null, 4)
); );
loadServerList(); loadServerList();
} }
function editServer() { function editServer() {
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()) {
value["description"] = value["description"] =
$("#editserver-descinput").val().length == 0 $("#editserver-descinput").val().length == 0
@ -90,27 +90,27 @@ function editServer() {
}); });
remotefs.writeFileSync( remotefs.writeFileSync(
userdir + "\\servers.json", userDir + "\\servers.json",
JSON.stringify(jsontomodify, null, 4) JSON.stringify(jsonToModify, null, 4)
); );
loadServerList(); loadServerList();
} }
function deleteServer() { function deleteServer() {
var jsontomodify = JSON.parse( var jsonToModify = JSON.parse(
remotefs.readFileSync(userdir + "\\servers.json") remotefs.readFileSync(userDir + "\\servers.json")
); );
var result = jsontomodify["servers"].filter(function (obj) { var result = jsonToModify["servers"].filter(function (obj) {
return obj.uuid === getSelectedServer(); return obj.uuid === getSelectedServer();
})[0]; })[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( remotefs.writeFileSync(
userdir + "\\servers.json", userDir + "\\servers.json",
JSON.stringify(jsontomodify, null, 4) JSON.stringify(jsonToModify, null, 4)
); );
loadServerList(); loadServerList();
} }
@ -118,17 +118,17 @@ function deleteServer() {
function restoreDefaultServers() { function restoreDefaultServers() {
remotefs.copySync( remotefs.copySync(
__dirname + "\\defaults\\servers.json", __dirname + "\\defaults\\servers.json",
userdir + "\\servers.json" userDir + "\\servers.json"
); );
loadServerList(); loadServerList();
} }
function loadGameVersions() { function loadGameVersions() {
var versionjson = JSON.parse( var versionJson = JSON.parse(
remotefs.readFileSync(userdir + "\\versions.json") 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");
$(new Option(value.name, "val")).appendTo("#editserver-versionselect"); $(new Option(value.name, "val")).appendTo("#editserver-versionselect");
}); });
@ -136,22 +136,22 @@ function loadGameVersions() {
function loadConfig() { function loadConfig() {
// load config object globally // load config object globally
config = JSON.parse(remotefs.readFileSync(userdir + "\\config.json")); config = JSON.parse(remotefs.readFileSync(userDir + "\\config.json"));
} }
function loadServerList() { function loadServerList() {
var serverjson = JSON.parse( var serverJson = JSON.parse(
remotefs.readFileSync(userdir + "\\servers.json") 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";
@ -172,25 +172,25 @@ function loadServerList() {
} }
} }
function performCacheSwap(newversion) { function performCacheSwap(newVersion) {
var cacheroot = userdir + "\\..\\..\\LocalLow\\Unity\\Web Player\\Cache"; var cacheRoot = userDir + "\\..\\..\\LocalLow\\Unity\\Web Player\\Cache";
var currentcache = cacheroot + "\\Fusionfall"; var currentCache = cacheRoot + "\\Fusionfall";
var newcache = cacheroot + "\\" + newversion; var newCache = cacheRoot + "\\" + newVersion;
var record = userdir + "\\.lastver"; var record = userDir + "\\.lastver";
// if cache renaming would result in a no-op (ex. launching the same version // if cache renaming would result in a no-op (ex. launching the same version
// two times), then skip it. this avoids permissions errors with multiple clients // two times), then skip it. this avoids permissions errors with multiple clients
// (file/folder is already open in another process) // (file/folder is already open in another process)
var skip = false; var skip = false;
if (remotefs.existsSync(currentcache)) { if (remotefs.existsSync(currentCache)) {
// cache already exists, find out what version it belongs to // cache already exists, find out what version it belongs to
if (remotefs.existsSync(record)) { if (remotefs.existsSync(record)) {
lastversion = remotefs.readFileSync(record); lastVersion = remotefs.readFileSync(record);
if (lastversion != newversion) { if (lastVersion != newVersion) {
remotefs.renameSync( remotefs.renameSync(
currentcache, currentCache,
cacheroot + "\\" + lastversion cacheRoot + "\\" + lastVersion
); );
} else { } else {
console.log( console.log(
@ -198,7 +198,7 @@ function performCacheSwap(newversion) {
); );
skip = true; skip = true;
} }
console.log("Current cache is " + lastversion); console.log("Current cache is " + 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"
@ -206,29 +206,29 @@ function performCacheSwap(newversion) {
} }
} }
if (remotefs.existsSync(newcache) || !skip) { if (remotefs.existsSync(newCache) || !skip) {
// rename saved cache to FusionFall // rename saved cache to FusionFall
remotefs.renameSync(newcache, currentcache); remotefs.renameSync(newCache, currentCache);
console.log("Current cache swapped to " + newversion); console.log("Current cache swapped to " + newVersion);
} }
// make note of what version we are launching for next launch // make note of what version we are launching for next launch
remotefs.writeFileSync(record, newversion); remotefs.writeFileSync(record, newVersion);
} }
// 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) { var result = serverArray.filter(function (obj) {
return obj.uuid === serverUUID; return obj.uuid === serverUUID;
})[0]; })[0];
var gameversion = versionarray.filter(function (obj) { var gameVersion = versionArray.filter(function (obj) {
return obj.name === result.version; return obj.name === result.version;
})[0]; })[0];
// if cache swapping property exists AND is `true`, run cache swapping logic // if cache swapping property exists AND is `true`, run cache swapping logic
if (config["cache-swapping"]) { if (config["cache-swapping"]) {
try { try {
performCacheSwap(gameversion.name); performCacheSwap(gameVersion.name);
} catch (ex) { } catch (ex) {
console.log( console.log(
"Error when swapping cache, it may get overwritten:\n" + ex "Error when swapping cache, it may get overwritten:\n" + ex
@ -236,23 +236,23 @@ function setGameInfo(serverUUID) {
} }
} }
window.asseturl = gameversion.url; // gameclient.js needs to access this window.assetUrl = gameVersion.url; // game-client.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( remotefs.writeFileSync(
__dirname + "\\rankurl.txt", __dirname + "\\rankurl.txt",
httpendpoint + "getranks" httpEndpoint + "getranks"
); );
// Write these out too // Write these out too
remotefs.writeFileSync( remotefs.writeFileSync(
__dirname + "\\sponsor.php", __dirname + "\\sponsor.php",
httpendpoint + "upsell/sponsor.png" httpEndpoint + "upsell/sponsor.png"
); );
remotefs.writeFileSync( remotefs.writeFileSync(
__dirname + "\\images.php", __dirname + "\\images.php",
httpendpoint + "upsell/" 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
@ -341,10 +341,10 @@ $("#server-table").on("dblclick", ".server-listing-entry", function (event) {
}); });
$("#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"];
@ -361,7 +361,7 @@ $("#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) { var result = serverArray.filter(function (obj) {
return obj.uuid === getSelectedServer(); return obj.uuid === getSelectedServer();
})[0]; })[0];
$("#deleteserver-servername").html(result.description); $("#deleteserver-servername").html(result.description);

View File

@ -1,16 +1,16 @@
const fs = require('fs'); const fs = require('fs');
const defaultdir = './dist/win-ia32-unpacked/resources/default_app' const defaultDir = './dist/win-ia32-unpacked/resources/default_app'
const exefile = './dist/win-ia32-unpacked/OpenFusionClient.exe' const exeFile = './dist/win-ia32-unpacked/OpenFusionClient.exe'
exports.default = function() { exports.default = function() {
// remove leftover files from default electron app // remove leftover files from default electron app
fs.rm(defaultdir, { recursive: true }, (err) => { fs.rm(defaultDir, { recursive: true }, (err) => {
if (err) { if (err) {
throw err; throw err;
} }
}); });
// patch executable for large address awareness // patch executable for large address awareness
fs.open(exefile, "r+", (err, fd) => { fs.open(exeFile, "r+", (err, fd) => {
if(!err) { if(!err) {
fs.write( fs.write(
fd, new Uint8Array([0x22]), 0, 1, 0x166, fd, new Uint8Array([0x22]), 0, 1, 0x166,

View File

@ -2,10 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta <meta name="viewport" content="width=device-width, initial-scale=1.0" />
name="viewport"
content="width=device-width, initial-scale=1.0, shrink-to-fit=no"
/>
<title>OpenFusion: Server Selector</title> <title>OpenFusion: Server Selector</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css" /> <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
<link rel="stylesheet" href="assets/fonts/fontawesome-all.min.css" /> <link rel="stylesheet" href="assets/fonts/fontawesome-all.min.css" />
@ -13,17 +10,7 @@
<link rel="stylesheet" href="assets/css/styles.css" /> <link rel="stylesheet" href="assets/css/styles.css" />
</head> </head>
<body <body onresize="onResize()">
style="
background: rgb(0, 0, 0);
width: 100%;
height: 100%;
margin: 0;
padding: 0;
clear: both;
"
onresize="onResize()"
>
<section id="of-serverselector"> <section id="of-serverselector">
<div class="container" id="serverselector-container"> <div class="container" id="serverselector-container">
<div class="row text-center mt-3" id="of-logoheader"> <div class="row text-center mt-3" id="of-logoheader">
@ -464,17 +451,7 @@
</div> </div>
</section> </section>
<section> <section>
<div <div id="client"></div>
id="client"
style="
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #000;
clear: both;
"
></div>
</section> </section>
<script <script
src="assets/js/jquery.min.js" src="assets/js/jquery.min.js"
@ -483,9 +460,9 @@
<script src="assets/js/bootstrap.min.js"></script> <script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/bs-init.js"></script> <script src="assets/js/bs-init.js"></script>
<script src="assets/js/uuidv4.min.js"></script> <script src="assets/js/uuidv4.min.js"></script>
<script src="assets/js/serverselector.js"></script> <script src="assets/js/server-selector.js"></script>
<script src="assets/js/gameclient.js"></script> <script src="assets/js/game-client.js"></script>
<script src="assets/js/snowflakes.min.js"></script> <script src="assets/js/snowflakes.min.js"></script>
<script src="assets/js/eastereggs.js"></script> <script src="assets/js/easter-eggs.js"></script>
</body> </body>
</html> </html>

View File

@ -7,46 +7,55 @@ var BrowserWindow = require("browser-window");
var mainWindow = null; var mainWindow = null;
app.commandLine.appendSwitch("--enable-npapi"); app.commandLine.appendSwitch("enable-npapi");
function verifyUnity() { function verifyMD5Hash(file, hash) {
var dllpath = if (fs.existsSync(file)) {
app.getPath("appData") + var buffer = fs.readFileSync(file);
"\\..\\LocalLow\\Unity\\WebPlayer\\player\\fusion-2.x.x\\webplayer_win.dll"; var computedHash = require("crypto")
if (fs.existsSync(dllpath)) {
var buff = fs.readFileSync(dllpath);
var hash = require("crypto")
.createHash("md5") .createHash("md5")
.update(buff) .update(buffer)
.digest("hex"); .digest("hex");
if (hash == "e5028405b4483de9e5e5fe9cd5f1e98f") { if (hash == computedHash) {
return true; return true;
} }
} }
return false; return false;
} }
function verifyUnity() {
var loaderPath =
app.getPath("appData") +
"\\..\\LocalLow\\Unity\\WebPlayer\\loader\\npUnity3D32.dll";
var playerPath =
app.getPath("appData") +
"\\..\\LocalLow\\Unity\\WebPlayer\\player\\fusion-2.x.x\\webplayer_win.dll";
return (
verifyMD5Hash(loaderPath, "dbbac62d8379d2d870479b04b8157b99") &&
verifyMD5Hash(playerPath, "e5028405b4483de9e5e5fe9cd5f1e98f")
);
}
function installUnity(callback) { function installUnity(callback) {
var utilsdir = __dirname + "\\..\\..\\utils"; var utilsDir = __dirname + "\\..\\..\\utils";
// if running in non-packaged / development mode, this dir will be slightly different // if running in non-packaged / development mode, this dir will be slightly different
if (process.env.npm_node_execpath) { if (process.env.npm_node_execpath) {
utilsdir = app.getAppPath() + "\\build\\utils"; utilsDir = app.getAppPath() + "\\build\\utils";
} }
// run the installer silently // run the installer silently
var child = require("child_process").spawn( var child = require("child_process").spawn(
utilsdir + "\\UnityWebPlayer.exe", utilsDir + "\\UnityWebPlayer.exe",
["/quiet", "/S"] ["/quiet", "/S"]
); );
child.on("exit", function () { child.on("exit", function () {
// overwrite 3.5.2 loader/player with FF's custom version // overwrite 3.5.2 loader/player with FF's custom version
var dstfolder = var dest = app.getPath("appData") + "\\..\\LocalLow\\Unity\\WebPlayer";
app.getPath("appData") + "\\..\\LocalLow\\Unity\\WebPlayer"; fs.copySync(utilsDir + "\\WebPlayer", dest, { clobber: true });
fs.copySync(utilsdir + "\\WebPlayer", dstfolder, { clobber: true });
// avoids error reporter popping up when closing Electron // avoids error reporter popping up when closing Electron
fs.removeSync(dstfolder + "\\UnityBugReporter.exe"); fs.removeSync(dest + "\\UnityBugReporter.exe");
console.log("Unity Web Player installed successfully."); console.log("Unity Web Player installed successfully.");
callback(); callback();
}); });
@ -61,7 +70,7 @@ function initialSetup(firstTime) {
center: true, center: true,
frame: false, frame: false,
}); });
setupWindow.loadUrl("file://" + __dirname + "/initialsetup.html"); setupWindow.loadUrl("file://" + __dirname + "/initial-setup.html");
installUnity(function () { installUnity(function () {
if (!firstTime) { if (!firstTime) {
// migration from pre-1.4 // migration from pre-1.4
@ -114,12 +123,12 @@ app.on("window-all-closed", function () {
app.on("ready", function () { app.on("ready", function () {
// Check just in case the user forgot to extract the zip. // Check just in case the user forgot to extract the zip.
zip_check = app.getPath("exe").includes(os.tmpdir()); zipCheck = app.getPath("exe").includes(os.tmpdir());
if (zip_check) { if (zipCheck) {
errormsg = var errorMessage =
"It has been detected that OpenFusionClient is running from the TEMP folder.\n\n" + "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."; "Please extract the entire Client folder to a location of your choice before starting OpenFusionClient.";
dialog.showErrorBox("Error!", errormsg); dialog.showErrorBox("Error!", errorMessage);
return; return;
} }
@ -152,12 +161,16 @@ app.on("ready", function () {
} }
} }
} catch (ex) { } catch (ex) {
console.log("An error occurred while checking for the config"); dialog.showErrorBox(
"Error!",
"An error occurred while checking for the config. Make sure you have sufficent permissions."
);
app.quit();
} }
// Makes it so external links are opened in the system browser, not Electron // Makes it so external links are opened in the system browser, not Electron
mainWindow.webContents.on("new-window", function (e, url) { mainWindow.webContents.on("new-window", function (event, url) {
e.preventDefault(); event.preventDefault();
require("shell").openExternal(url); require("shell").openExternal(url);
}); });
@ -181,19 +194,24 @@ function showMainWindow() {
}); });
mainWindow.webContents.on("plugin-crashed", function () { mainWindow.webContents.on("plugin-crashed", function () {
console.log("Unity Web Player crashed."); var errorMessage =
"Unity Web Player has crashed - please re-open the application.\n" +
"If this error persists, please read the FAQ or ask for support in our Discord server.";
dialog.showErrorBox("Error!", errorMessage);
mainWindow.destroy();
app.quit();
}); });
mainWindow.webContents.on("will-navigate", function (evt, url) { mainWindow.webContents.on("will-navigate", function (event, url) {
evt.preventDefault(); event.preventDefault();
// TODO: showMessageBox rather than showErrorBox? // TODO: showMessageBox rather than showErrorBox?
switch (url) { switch (url) {
case "https://audience.fusionfall.com/ff/regWizard.do?_flowId=fusionfall-registration-flow": case "https://audience.fusionfall.com/ff/regWizard.do?_flowId=fusionfall-registration-flow":
errormsg = var errorMessage =
"The register page is currently unimplemented.\n\n" + "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". ' + '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!"; "Your account will then be automatically created on the server. \nBe sure to remember these details!";
dialog.showErrorBox("Sorry!", errormsg); dialog.showErrorBox("Sorry!", errorMessage);
break; break;
case "https://audience.fusionfall.com/ff/login.do": case "https://audience.fusionfall.com/ff/login.do":
dialog.showErrorBox( dialog.showErrorBox(

View File

@ -67,7 +67,7 @@
"to": "utils" "to": "utils"
} }
], ],
"afterPack": "./build/afterpack.js" "afterPack": "./build/after-pack.js"
}, },
"dependencies": { "dependencies": {
"fs-extra": "2.0.0" "fs-extra": "2.0.0"