7 Commits

Author SHA1 Message Date
CakeLancelot
43f0c8c684 Revise loader DLL to work under Wine, loading screen beta text, cleanup 2023-09-16 20:57:13 -05:00
CakeLancelot
d4dc403e90 Remove now unnecessary attributes from game-client.js 2023-09-14 15:13:23 -05:00
CakeLancelot
ab5de9488d Fix DNS resolution
not sure why this works but resolve4 doesn't
2023-09-14 06:44:11 -05:00
CakeLancelot
dabb8bf484 Use extra-plugin-dirs in Electron to load plugin, add fusion manifest.
This has the advantage of being self contained (doesn't conflict with Unity 3.x - 5.x loader, so we can use the original one) and **disabling auto updates actually works**.

We can also eliminate any code used to install and verify unity, since it's all self contained.

Also added fusion manifest file to set process as DPI aware, and set ACP to UTF-8 on Windows 10 1903 and above.

Bumped version to 1.4.2
2023-09-14 05:29:34 -05:00
CakeLancelot
043bf219e7 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
2023-09-03 05:12:30 -05:00
CakeLancelot
7131026b2f Misc tweaks
loadURL() -> loadUrl() in index.js
Move Bootstrap files
2023-09-02 23:03:00 -05:00
7dd018e336 Use local fonts for Bootstrap
bootstrap.min.css was fetching a css snippet for the Roboto font
remotely. Inlined the snippet and modified it to load the font files
locally.
2023-09-03 01:44:09 +02:00
50 changed files with 254 additions and 267 deletions

View File

@@ -1,45 +1,52 @@
# OpenFusionClient
[![Current Release](https://img.shields.io/github/v/release/OpenFusionProject/OpenFusionClient)](https://github.com/OpenFusionProject/OpenFusionClient/releases/latest) [![Discord](https://img.shields.io/badge/chat-on%20discord-7289da.svg?logo=discord)](https://discord.gg/DYavckB)[![License](https://img.shields.io/github/license/OpenFusionProject/OpenFusionClient)](https://github.com/OpenFusionProject/OpenFusionClient/blob/master/LICENSE.md)
An Electron app that allows you to easily join FusionFall servers.
An Electron app that allows you to easily join FusionFall servers.
It automatically installs FF's custom build of Unity Web Player, manages text files such as `assetInfo.php`/`loginInfo.php`, and embeds the game, all in a few clicks!
It automatically installs FF's custom build of Unity Web Player, manages text files such as `assetInfo.php`/`loginInfo.php`, and embeds the game, all in a few clicks!
For an overview of how the game client worked originally, please see [this section in the OpenFusion README](https://github.com/OpenFusionProject/OpenFusion#architecture ).
For an overview of how the game client worked originally, please see [this section in the OpenFusion README](https://github.com/OpenFusionProject/OpenFusion#architecture).
## Disclaimer
This repository does not contain any code from the actual FusionFall game client. **Think of it more as a launcher:** it abstracts away having to use a NPAPI plugin capable web browser, along with having to host a HTTP server for it to connect to.
This repository does not contain any code from the actual FusionFall game client. **Think of it more as a launcher:** it abstracts away having to use a NPAPI plugin capable web browser, along with having to host a HTTP server for it to connect to.
In addition, if you are interested in contributing: do note that **this project likely cannot utilize more modern Javascript techniques**. In order to use NPAPI plugins, a very old version of Electron was needed (0.31.0). This limits the project to only a portion of ES5 in non-strict mode, and a reduced subset of Node/Electron APIs.
In addition, if you are interested in contributing: do note that **this project likely cannot utilize more modern Javascript techniques**. In order to use NPAPI plugins, a very old version of Electron was needed (0.31.0). This limits the project to only a portion of ES5 in non-strict mode, and a reduced subset of Node/Electron APIs.
## Usage
Provided that you have npm installed, clone the repository, then run install like so:
```
git clone https://github.com/OpenFusionProject/OpenFusionClient.git
npm install
```
After that has completed you can then test OpenFusionClient:
```
npm run start
```
If you would like to package it as a standalone win32 application:
```
npm run pack
```
You can then compress the application directory into a zip file and installer for distribution:
```
npm run dist
```
Before opening a PR or running pack/dist, please do a code formatting pass:
```
npm run prettier
```
## License
MIT unless specified otherwise

File diff suppressed because one or more lines are too long

30
assets/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -47,6 +47,11 @@ img {
}
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
clear: both;
user-select: none;
background-color: #000;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
@@ -129,3 +134,12 @@ button > i {
#server-table .server-listing-entry {
cursor: pointer;
}
#client {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #000;
clear: both;
}

Binary file not shown.

Binary file not shown.

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
function authDoCallback(param) {
/*var unity = document.getElementById('Unity_embed');
/*var unity = document.getElementById('unityEmbed');
unity.SendMessage("GlobalManager", "SetTEGid", "player");
unity.SendMessage("GlobalManager", "SetAuthid", "0");
unity.SendMessage("GlobalManager", "DoAuth", 0);*/
@@ -33,7 +33,7 @@ function PayPage(param) {
function onResize() {
if (gameRunning == true) {
var unity = document.getElementById("Unity_embed");
var unity = document.getElementById("unityEmbed");
unity.style.width = window.innerWidth + "px";
unity.style.height = window.innerHeight + "px";
}
@@ -56,38 +56,29 @@ function launchGame() {
"codebase",
"undefined/UnityWebPlayer.cab#version=2,0,0,0"
);
object.setAttribute("id", "Unity_object");
object.setAttribute("id", "unityObject");
object.setAttribute("width", "1264");
object.setAttribute("height", "661");
var embed = document.createElement("embed");
embed.setAttribute("type", "application/vnd.unity");
embed.setAttribute("type", "application/vnd.ffuwp");
embed.setAttribute(
"pluginspage",
"http://www.unity3d.com/unity-web-player-2.x"
);
embed.setAttribute("id", "Unity_embed");
embed.setAttribute("id", "unityEmbed");
embed.setAttribute("width", "1280");
embed.setAttribute("height", "680");
embed.setAttribute("src", window.asseturl + "main.unity3d");
embed.setAttribute("disablecontdparaextmenu", "true");
embed.setAttribute("src", window.assetUrl + "main.unity3d");
embed.setAttribute("bordercolor", "000000");
embed.setAttribute("backgroundcolor", "000000");
embed.setAttribute("disableContextMenu", true);
embed.setAttribute("textcolor", "ccffff");
embed.setAttribute("logoimage", "assets/img/unity_dexlabs.png");
embed.setAttribute("progressbarimage", "assets/img/unity_loadingbar.png");
embed.setAttribute("logoimage", "assets/img/unity-dexlabs.png");
embed.setAttribute("progressbarimage", "assets/img/unity-loadingbar.png");
embed.setAttribute(
"progressframeimage",
"assets/img/unity_loadingframe.png"
);
embed.setAttribute(
"autoupdateurlsignature",
"42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033"
);
embed.setAttribute(
"autoupdateurl",
"http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta"
"assets/img/unity-loadingframe.png"
);
var div = document.getElementById("client");

View File

@@ -1,10 +1,11 @@
// TODO: path.join in this file, pass in json paths from index.js
var remote = require("remote");
var remotefs = remote.require("fs-extra");
var dns = remote.require("dns");
var userdir = remote.require("app").getPath("userData");
var versionarray;
var serverarray;
var userDir = remote.require("app").getPath("userData");
var versionArray;
var serverArray;
var config;
function enableServerListButtons() {
@@ -26,14 +27,14 @@ function disableServerListButtons() {
}
function getAppVersion() {
appversion = remote.require("app").getVersion();
appVersion = remote.require("app").getVersion();
// simplify version, ex. 1.4.0 -> 1.4,
// but only if a revision number isn't present
if (appversion.endsWith(".0")) {
return appversion.substr(0, appversion.length - 2);
if (appVersion.endsWith(".0")) {
return appVersion.substr(0, appVersion.length - 2);
} else {
return appversion;
return appVersion;
}
}
@@ -43,8 +44,8 @@ function setAppVersionText() {
}
function addServer() {
var jsontomodify = JSON.parse(
remotefs.readFileSync(userdir + "\\servers.json")
var jsonToModify = JSON.parse(
remotefs.readFileSync(userDir + "\\servers.json")
);
var server = {};
@@ -60,20 +61,20 @@ function addServer() {
server["version"] = $("#addserver-versionselect option:selected").text();
//server['endpoint'] =
jsontomodify["servers"].push(server);
jsonToModify["servers"].push(server);
remotefs.writeFileSync(
userdir + "\\servers.json",
JSON.stringify(jsontomodify, null, 4)
userDir + "\\servers.json",
JSON.stringify(jsonToModify, null, 4)
);
loadServerList();
}
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()) {
value["description"] =
$("#editserver-descinput").val().length == 0
@@ -90,27 +91,27 @@ function editServer() {
});
remotefs.writeFileSync(
userdir + "\\servers.json",
JSON.stringify(jsontomodify, null, 4)
userDir + "\\servers.json",
JSON.stringify(jsonToModify, null, 4)
);
loadServerList();
}
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) {
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)
userDir + "\\servers.json",
JSON.stringify(jsonToModify, null, 4)
);
loadServerList();
}
@@ -118,17 +119,17 @@ function deleteServer() {
function restoreDefaultServers() {
remotefs.copySync(
__dirname + "\\defaults\\servers.json",
userdir + "\\servers.json"
userDir + "\\servers.json"
);
loadServerList();
}
function loadGameVersions() {
var versionjson = JSON.parse(
remotefs.readFileSync(userdir + "\\versions.json")
var versionJson = JSON.parse(
remotefs.readFileSync(userDir + "\\versions.json")
);
versionarray = versionjson["versions"];
$.each(versionarray, function (key, value) {
versionArray = versionJson["versions"];
$.each(versionArray, function (key, value) {
$(new Option(value.name, "val")).appendTo("#addserver-versionselect");
$(new Option(value.name, "val")).appendTo("#editserver-versionselect");
});
@@ -136,22 +137,22 @@ function loadGameVersions() {
function loadConfig() {
// load config object globally
config = JSON.parse(remotefs.readFileSync(userdir + "\\config.json"));
config = JSON.parse(remotefs.readFileSync(userDir + "\\config.json"));
}
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
disableServerListButtons(); // Disable buttons until another server is selected
if (serverarray.length > 0) {
if (serverArray.length > 0) {
// Servers were found in the JSON
$("#server-listing-placeholder").attr("hidden", true);
$.each(serverarray, function (key, value) {
$.each(serverArray, function (key, value) {
// Create the row, and populate the cells
var row = document.createElement("tr");
row.className = "server-listing-entry";
@@ -172,25 +173,25 @@ function loadServerList() {
}
}
function performCacheSwap(newversion) {
var cacheroot = userdir + "\\..\\..\\LocalLow\\Unity\\Web Player\\Cache";
var currentcache = cacheroot + "\\Fusionfall";
var newcache = cacheroot + "\\" + newversion;
var record = userdir + "\\.lastver";
function performCacheSwap(newVersion) {
var cacheRoot = userDir + "\\..\\..\\LocalLow\\Unity\\Web Player\\Cache";
var currentCache = cacheRoot + "\\Fusionfall";
var newCache = cacheRoot + "\\" + newVersion;
var record = userDir + "\\.lastver";
// 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
// (file/folder is already open in another process)
var skip = false;
if (remotefs.existsSync(currentcache)) {
if (remotefs.existsSync(currentCache)) {
// cache already exists, find out what version it belongs to
if (remotefs.existsSync(record)) {
lastversion = remotefs.readFileSync(record);
if (lastversion != newversion) {
lastVersion = remotefs.readFileSync(record);
if (lastVersion != newVersion) {
remotefs.renameSync(
currentcache,
cacheroot + "\\" + lastversion
currentCache,
cacheRoot + "\\" + lastVersion
);
} else {
console.log(
@@ -198,7 +199,7 @@ function performCacheSwap(newversion) {
);
skip = true;
}
console.log("Current cache is " + lastversion);
console.log("Current cache is " + lastVersion);
} else {
console.log(
"Couldn't find last version record; cache may get overwritten"
@@ -206,29 +207,29 @@ function performCacheSwap(newversion) {
}
}
if (remotefs.existsSync(newcache) || !skip) {
if (remotefs.existsSync(newCache) || !skip) {
// rename saved cache to FusionFall
remotefs.renameSync(newcache, currentcache);
console.log("Current cache swapped to " + newversion);
remotefs.renameSync(newCache, currentCache);
console.log("Current cache swapped to " + newVersion);
}
// 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.
function setGameInfo(serverUUID) {
var result = serverarray.filter(function (obj) {
var result = serverArray.filter(function (obj) {
return obj.uuid === serverUUID;
})[0];
var gameversion = versionarray.filter(function (obj) {
var gameVersion = versionArray.filter(function (obj) {
return obj.name === result.version;
})[0];
// if cache swapping property exists AND is `true`, run cache swapping logic
if (config["cache-swapping"]) {
try {
performCacheSwap(gameversion.name);
performCacheSwap(gameVersion.name);
} catch (ex) {
console.log(
"Error when swapping cache, it may get overwritten:\n" + ex
@@ -236,23 +237,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")) {
var httpendpoint = result.endpoint.replace("https://", "http://");
var httpEndpoint = result.endpoint.replace("https://", "http://");
remotefs.writeFileSync(
__dirname + "\\rankurl.txt",
httpendpoint + "getranks"
httpEndpoint + "getranks"
);
// Write these out too
remotefs.writeFileSync(
__dirname + "\\sponsor.php",
httpendpoint + "upsell/sponsor.png"
httpEndpoint + "upsell/sponsor.png"
);
remotefs.writeFileSync(
__dirname + "\\images.php",
httpendpoint + "upsell/"
httpEndpoint + "upsell/"
);
} else {
// Remove/default the endpoint related stuff, this server won't be using it
@@ -280,10 +281,10 @@ function setGameInfo(serverUUID) {
// DNS resolution. there is no synchronous version for some stupid reason
if (!address.match(/^[0-9.]+$/))
dns.resolve4(address, function (err, res) {
dns.lookup(address, family=4, function (err, resolvedAddress) {
if (!err) {
console.log("Resolved " + address + " to " + res[0]);
address = res[0];
console.log("Resolved " + address + " to " + resolvedAddress);
address = resolvedAddress;
} else {
console.log("Err: " + err.code);
}
@@ -341,10 +342,10 @@ $("#server-table").on("dblclick", ".server-listing-entry", function (event) {
});
$("#of-editservermodal").on("show.bs.modal", function (e) {
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()) {
$("#editserver-descinput")[0].value = value["description"];
$("#editserver-ipinput")[0].value = value["ip"];
@@ -361,7 +362,7 @@ $("#of-editservermodal").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();
})[0];
$("#deleteserver-servername").html(result.description);

View File

@@ -0,0 +1,8 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">
<activeCodePage>UTF-8</activeCodePage>
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist>
<dict>
<key>CFBundleVersion</key>
<string>2.5.5b4</string>
<key>UnityBuildNumber</key>
<string>50</string>
</dict>
<?xml version="1.0" encoding="UTF-8"?>
<plist>
<dict>
<key>CFBundleVersion</key>
<string>2.5.5b4</string>
<key>UnityBuildNumber</key>
<string>50</string>
</dict>
</plist>

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist>
<dict>
<key>CFBundleVersion</key>
<string>3.5.2f2</string>
<key>UnityBuildNumber</key>
<string>4c6ee796dacc</string>
</dict>
<?xml version="1.0" encoding="UTF-8"?>
<plist>
<dict>
<key>CFBundleVersion</key>
<string>2.5.5b4</string>
<key>UnityBuildNumber</key>
<string>50</string>
</dict>
</plist>

View File

@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist>
<dict>
<key>CFBundleVersion</key>
<string>2.5.5b4</string>
<key>UnityBuildNumber</key>
<string>50</string>
<key>monoVersion</key>
<string>fusion-2.x.x</string>
<key>monoMinimumRevision</key>
<string>2.0.0f6</string>
</dict>
<?xml version="1.0" encoding="UTF-8"?>
<plist>
<dict>
<key>CFBundleVersion</key>
<string>2.5.5b4</string>
<key>UnityBuildNumber</key>
<string>50</string>
<key>monoVersion</key>
<string>fusion-2.x.x</string>
<key>monoMinimumRevision</key>
<string>2.0.0f6</string>
</dict>
</plist>

View File

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

Binary file not shown.

View File

@@ -3,27 +3,18 @@
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, shrink-to-fit=no"
http-equiv="Content-Type"
contentType="text/html; charset=UTF-8"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenFusion: Server Selector</title>
<link rel="stylesheet" href="assets/bootstrap/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/css/openfusion.css" />
<link rel="stylesheet" href="assets/css/styles.css" />
</head>
<body
style="
background: rgb(0, 0, 0);
width: 100%;
height: 100%;
margin: 0;
padding: 0;
clear: both;
"
onresize="onResize()"
>
<body onresize="onResize()">
<section id="of-serverselector">
<div class="container" id="serverselector-container">
<div class="row text-center mt-3" id="of-logoheader">
@@ -464,28 +455,18 @@
</div>
</section>
<section>
<div
id="client"
style="
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #000;
clear: both;
"
></div>
<div id="client"></div>
</section>
<script
src="assets/js/jquery.min.js"
onload="window.$ = window.jQuery = module.exports;"
></script>
<script src="assets/bootstrap/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/uuidv4.min.js"></script>
<script src="assets/js/serverselector.js"></script>
<script src="assets/js/gameclient.js"></script>
<script src="assets/js/server-selector.js"></script>
<script src="assets/js/game-client.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>
</html>

165
index.js
View File

@@ -1,56 +1,31 @@
var app = require("app"); // Module to control application life.
var ipc = require("ipc");
var fs = require("fs-extra");
var os = require("os");
var dialog = require("dialog");
var BrowserWindow = require("browser-window");
var fs = require("fs-extra");
var ipc = require("ipc");
var os = require("os");
var path = require("path");
var BrowserWindow = require("browser-window");
var mainWindow = null;
app.commandLine.appendSwitch("--enable-npapi");
var userData = app.getPath("userData");
var unityHomeDir = path.join(__dirname, "../../WebPlayer");
function verifyUnity() {
var dllpath =
app.getPath("appData") +
"\\..\\LocalLow\\Unity\\WebPlayer\\player\\fusion-2.x.x\\webplayer_win.dll";
if (fs.existsSync(dllpath)) {
var buff = fs.readFileSync(dllpath);
var hash = require("crypto")
.createHash("md5")
.update(buff)
.digest("hex");
if (hash == "e5028405b4483de9e5e5fe9cd5f1e98f") {
return true;
}
}
return false;
// if running in non-packaged / development mode, this dir will be slightly different
if (process.env.npm_node_execpath) {
unityHomeDir = path.join(app.getAppPath(), "/build/WebPlayer");
}
function installUnity(callback) {
var utilsdir = __dirname + "\\..\\..\\utils";
process.env["UNITY_HOME_DIR"] = unityHomeDir;
process.env["UNITY_DISABLE_PLUGIN_UPDATES"] = "yes";
// if running in non-packaged / development mode, this dir will be slightly different
if (process.env.npm_node_execpath) {
utilsdir = app.getAppPath() + "\\build\\utils";
}
app.commandLine.appendSwitch("enable-npapi");
app.commandLine.appendSwitch("load-plugin", path.join(unityHomeDir, "/loader/npUnity3D32.dll"));
app.commandLine.appendSwitch("no-proxy-server");
// run the installer silently
var child = require("child_process").spawn(
utilsdir + "\\UnityWebPlayer.exe",
["/quiet", "/S"]
);
child.on("exit", function () {
// overwrite 3.5.2 loader/player with FF's custom version
var dstfolder =
app.getPath("appData") + "\\..\\LocalLow\\Unity\\WebPlayer";
fs.copySync(utilsdir + "\\WebPlayer", dstfolder, { clobber: true });
// avoids error reporter popping up when closing Electron
fs.removeSync(dstfolder + "\\UnityBugReporter.exe");
console.log("Unity Web Player installed successfully.");
callback();
});
}
var configPath = path.join(userData, "/config.json");
var serversPath = path.join(userData, "/servers.json");
var versionsPath = path.join(userData, "/versions.json");
function initialSetup(firstTime) {
// Display a small window to inform the user that the app is working
@@ -61,46 +36,29 @@ function initialSetup(firstTime) {
center: true,
frame: false,
});
setupWindow.loadUrl("file://" + __dirname + "/initialsetup.html");
installUnity(function () {
if (!firstTime) {
// migration from pre-1.4
// Back everything up, just in case
fs.copySync(
app.getPath("userData") + "\\config.json",
app.getPath("userData") + "\\config.json.bak"
);
fs.copySync(
app.getPath("userData") + "\\servers.json",
app.getPath("userData") + "\\servers.json.bak"
);
fs.copySync(
app.getPath("userData") + "\\versions.json",
app.getPath("userData") + "\\versions.json.bak"
);
} else {
// first-time setup
// Copy default servers
fs.copySync(
__dirname + "\\defaults\\servers.json",
app.getPath("userData") + "\\servers.json"
);
}
// Copy default versions and config
if (!firstTime) {
// migration from pre-1.4
// Back everything up, just in case
setupWindow.loadUrl("file://" + __dirname + "/initial-setup.html");
fs.copySync(configPath, configPath + ".bak");
fs.copySync(serversPath, serversPath + ".bak");
fs.copySync(versionsPath, versionsPath + ".bak");
} else {
// first-time setup
// Copy default servers
fs.copySync(
__dirname + "\\defaults\\versions.json",
app.getPath("userData") + "\\versions.json"
);
fs.copySync(
__dirname + "\\defaults\\config.json",
app.getPath("userData") + "\\config.json"
path.join(__dirname, "/defaults/servers.json"),
serversPath
);
}
console.log("JSON files copied.");
setupWindow.destroy();
showMainWindow();
});
// Copy default versions and config
fs.copySync(path.join(__dirname, "/defaults/versions.json"), versionsPath);
fs.copySync(path.join(__dirname, "/defaults/config.json"), configPath);
console.log("JSON files copied.");
setupWindow.destroy();
showMainWindow();
}
ipc.on("exit", function (id) {
@@ -114,26 +72,26 @@ app.on("window-all-closed", function () {
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 =
zipCheck = app.getPath("exe").includes(os.tmpdir());
if (zipCheck) {
var errorMessage =
"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);
dialog.showErrorBox("Error!", errorMessage);
return;
}
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1280,
height: 720,
show: false,
"web-preferences": { plugins: true },
"web-preferences": {
plugins: true
},
});
mainWindow.setMinimumSize(640, 480);
// Check for first run
var configPath = app.getPath("userData") + "\\config.json";
try {
if (!fs.existsSync(configPath)) {
console.log("Config file not found. Running initial setup.");
@@ -144,20 +102,20 @@ app.on("ready", function () {
console.log("Pre-1.4 config detected. Running migration.");
initialSetup(false);
} else {
if (verifyUnity()) {
showMainWindow();
} else {
installUnity(showMainWindow);
}
showMainWindow();
}
}
} 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
mainWindow.webContents.on("new-window", function (e, url) {
e.preventDefault();
mainWindow.webContents.on("new-window", function (event, url) {
event.preventDefault();
require("shell").openExternal(url);
});
@@ -181,19 +139,24 @@ function showMainWindow() {
});
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) {
evt.preventDefault();
mainWindow.webContents.on("will-navigate", function (event, url) {
event.preventDefault();
// TODO: showMessageBox rather than showErrorBox?
switch (url) {
case "https://audience.fusionfall.com/ff/regWizard.do?_flowId=fusionfall-registration-flow":
errormsg =
var errorMessage =
"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!";
dialog.showErrorBox("Sorry!", errormsg);
dialog.showErrorBox("Sorry!", errorMessage);
break;
case "https://audience.fusionfall.com/ff/login.do":
dialog.showErrorBox(
@@ -205,7 +168,7 @@ function showMainWindow() {
require("shell").openExternal("https://discord.gg/DYavckB");
break;
default:
mainWindow.loadURL(url);
mainWindow.loadUrl(url);
}
});
}

View File

@@ -1,6 +1,6 @@
{
"name": "OpenFusionClient",
"version": "1.4.1",
"version": "1.4.3",
"description": "OpenFusionClient",
"main": "index.js",
"scripts": {
@@ -63,11 +63,15 @@
"extraFiles": [
"LICENSE.md",
{
"from": "build/utils",
"to": "utils"
"from": "build/OpenFusionClient.exe.manifest",
"to": "OpenFusionClient.exe.manifest"
},
{
"from": "build/WebPlayer",
"to": "WebPlayer"
}
],
"afterPack": "./build/afterpack.js"
"afterPack": "./build/after-pack.js"
},
"dependencies": {
"fs-extra": "2.0.0"