mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-22 05:30:05 +00:00
Compare commits
8 Commits
7bc438d76a
...
d554b6b968
Author | SHA1 | Date | |
---|---|---|---|
|
d554b6b968 | ||
|
5da0da1981 | ||
|
101de9d68b | ||
|
d0f947c4a5 | ||
|
4726a50be7 | ||
|
3d9107a7f1 | ||
|
c1db7bc047 | ||
|
51f7eaf33d |
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020-2022 OpenFusion Contributors
|
Copyright (c) 2020-2023 OpenFusion Contributors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -54,7 +54,7 @@ body {
|
|||||||
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||||
}
|
}
|
||||||
|
|
||||||
#of-versionnumber {
|
#of-versionnumberdiv {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 4px;
|
bottom: 4px;
|
||||||
right: 8px;
|
right: 8px;
|
||||||
|
@ -25,6 +25,23 @@ function disableServerListButtons() {
|
|||||||
$("#of-deleteserver-button").prop("disabled", true);
|
$("#of-deleteserver-button").prop("disabled", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAppVersion() {
|
||||||
|
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)
|
||||||
|
} else {
|
||||||
|
return appversion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setAppVersionText() {
|
||||||
|
$("#of-aboutversionnumber").text("Version " + getAppVersion());
|
||||||
|
$("#of-versionnumber").text("v" + getAppVersion());
|
||||||
|
}
|
||||||
|
|
||||||
function addServer() {
|
function addServer() {
|
||||||
var jsontomodify = JSON.parse(
|
var jsontomodify = JSON.parse(
|
||||||
remotefs.readFileSync(userdir + "\\servers.json")
|
remotefs.readFileSync(userdir + "\\servers.json")
|
||||||
@ -155,6 +172,50 @@ 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";
|
||||||
|
|
||||||
|
// 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)) {
|
||||||
|
// cache already exists, find out what version it belongs to
|
||||||
|
if (remotefs.existsSync(record)) {
|
||||||
|
lastversion = remotefs.readFileSync(record);
|
||||||
|
if (lastversion != newversion) {
|
||||||
|
remotefs.renameSync(
|
||||||
|
currentcache,
|
||||||
|
cacheroot + "\\" + lastversion
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
"Cached version unchanged, renaming will be skipped"
|
||||||
|
);
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
console.log("Current cache is " + lastversion);
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
"Couldn't find last version record; cache may get overwritten"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remotefs.existsSync(newcache) || !skip) {
|
||||||
|
// rename saved cache to FusionFall
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
// 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) {
|
||||||
@ -164,36 +225,15 @@ function setGameInfo(serverUUID) {
|
|||||||
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 (config["cache-swapping"]) {
|
if (config["cache-swapping"]) {
|
||||||
// if cache swapping property exists AND is `true`, run cache swapping logic
|
try {
|
||||||
// Cache folder renaming
|
performCacheSwap(gameversion.name);
|
||||||
var cachedir = userdir + "\\..\\..\\LocalLow\\Unity\\Web Player\\Cache";
|
} catch (ex) {
|
||||||
var curversion = cachedir + "\\Fusionfall";
|
console.log(
|
||||||
var newversion = cachedir + "\\" + gameversion.name;
|
"Error when swapping cache, it may get overwritten:\n" + ex
|
||||||
var record = userdir + "\\.lastver";
|
);
|
||||||
|
|
||||||
if (remotefs.existsSync(curversion)) {
|
|
||||||
// cache already exists
|
|
||||||
// find out what version it belongs to
|
|
||||||
if (remotefs.existsSync(record)) {
|
|
||||||
var lastversion = remotefs.readFileSync(record);
|
|
||||||
remotefs.renameSync(curversion, cachedir + "\\" + lastversion);
|
|
||||||
console.log("Cached version " + lastversion);
|
|
||||||
} else {
|
|
||||||
console.log(
|
|
||||||
"Couldn't find last version record; cache may get overwritten"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remotefs.existsSync(newversion)) {
|
|
||||||
// rename saved cache to FusionFall
|
|
||||||
remotefs.renameSync(newversion, curversion);
|
|
||||||
console.log("Loaded cached " + gameversion.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// make note of what version we are launching for next launch
|
|
||||||
remotefs.writeFileSync(record, gameversion.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.asseturl = gameversion.url; // gameclient.js needs to access this
|
window.asseturl = gameversion.url; // gameclient.js needs to access this
|
||||||
|
28
build/afterpack.js
Normal file
28
build/afterpack.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
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(dir, { recursive: true }, (err) => {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// patch executable for large address awareness
|
||||||
|
fs.open(exefile, "r+", (err, fd) => {
|
||||||
|
if(!err) {
|
||||||
|
fs.write(
|
||||||
|
fd, new Uint8Array([0x22]), 0, 1, 0x166,
|
||||||
|
(err) => {
|
||||||
|
if(err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
fs.closeSync(fd);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const dir = './dist/win-ia32-unpacked/resources/default_app'
|
|
||||||
|
|
||||||
exports.default = async function(context) {
|
|
||||||
fs.rmdir(dir, { recursive: true }, (err) => {
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
PUSHD %~dp0
|
|
||||||
.\UnityWebPlayer.exe /quiet /S
|
|
||||||
robocopy WebPlayer "%USERPROFILE%\AppData\LocalLow\Unity\WebPlayer" /s /e
|
|
||||||
del "%USERPROFILE%\AppData\LocalLow\Unity\WebPlayer\UnityBugReporter.exe"
|
|
||||||
POPD
|
|
@ -151,9 +151,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p class="text-monospace">Version 1.4</p>
|
<p id="of-aboutversionnumber" class="text-monospace">APP_VERSION_NUMBER</p>
|
||||||
<p>
|
<p>
|
||||||
©2020-2022 OpenFusion Contributors<br />OpenFusion
|
©2020-2023 OpenFusion Contributors<br />OpenFusion
|
||||||
is licensed under MIT.<br />
|
is licensed under MIT.<br />
|
||||||
</p>
|
</p>
|
||||||
<a
|
<a
|
||||||
@ -447,13 +447,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="of-versionnumber">
|
<div id="of-versionnumberdiv">
|
||||||
<a
|
<a
|
||||||
|
id="of-versionnumber"
|
||||||
class="text-monospace text-secondary"
|
class="text-monospace text-secondary"
|
||||||
href="#of-aboutmodal"
|
href="#of-aboutmodal"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
data-target="#of-aboutmodal"
|
data-target="#of-aboutmodal"
|
||||||
>v1.4</a
|
>v0</a
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
64
index.js
64
index.js
@ -9,6 +9,51 @@ var mainWindow = null;
|
|||||||
|
|
||||||
app.commandLine.appendSwitch("--enable-npapi");
|
app.commandLine.appendSwitch("--enable-npapi");
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
function installUnity(callback) {
|
||||||
|
var utilsdir = __dirname + "\\..\\..\\utils";
|
||||||
|
|
||||||
|
// if running in non-packaged / development mode, this dir will be slightly different
|
||||||
|
if (process.env.npm_node_execpath) {
|
||||||
|
utilsdir = app.getAppPath() + "\\build\\utils";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function initialSetup(firstTime) {
|
function initialSetup(firstTime) {
|
||||||
// Display a small window to inform the user that the app is working
|
// Display a small window to inform the user that the app is working
|
||||||
setupWindow = new BrowserWindow({
|
setupWindow = new BrowserWindow({
|
||||||
@ -19,13 +64,7 @@ function initialSetup(firstTime) {
|
|||||||
frame: false,
|
frame: false,
|
||||||
});
|
});
|
||||||
setupWindow.loadUrl("file://" + __dirname + "/initialsetup.html");
|
setupWindow.loadUrl("file://" + __dirname + "/initialsetup.html");
|
||||||
// Exec installUnity.bat and wait for it to finish.
|
installUnity(function () {
|
||||||
var child = require("child_process").spawn("cmd.exe", [
|
|
||||||
"/c",
|
|
||||||
"utils\\installUnity.bat",
|
|
||||||
]);
|
|
||||||
child.on("exit", function () {
|
|
||||||
console.log("Unity installed.");
|
|
||||||
if (!firstTime) {
|
if (!firstTime) {
|
||||||
// migration from pre-1.4
|
// migration from pre-1.4
|
||||||
// Back everything up, just in case
|
// Back everything up, just in case
|
||||||
@ -107,11 +146,15 @@ app.on("ready", function () {
|
|||||||
console.log("Pre-1.4 config detected. Running migration.");
|
console.log("Pre-1.4 config detected. Running migration.");
|
||||||
initialSetup(false);
|
initialSetup(false);
|
||||||
} else {
|
} else {
|
||||||
showMainWindow();
|
if (verifyUnity()) {
|
||||||
|
showMainWindow();
|
||||||
|
} else {
|
||||||
|
installUnity(showMainWindow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (ex) {
|
||||||
console.log("An error occurred while checking for the config.");
|
console.log("An error occurred while checking for the config");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@ -131,6 +174,7 @@ function showMainWindow() {
|
|||||||
|
|
||||||
// Reduces white flash when opening the program
|
// Reduces white flash when opening the program
|
||||||
mainWindow.webContents.on("did-finish-load", function () {
|
mainWindow.webContents.on("did-finish-load", function () {
|
||||||
|
mainWindow.webContents.executeJavaScript("setAppVersionText();");
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
// everything's loaded, tell the renderer process to do its thing
|
// everything's loaded, tell the renderer process to do its thing
|
||||||
mainWindow.webContents.executeJavaScript("loadConfig();");
|
mainWindow.webContents.executeJavaScript("loadConfig();");
|
||||||
|
3443
package-lock.json
generated
3443
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "openfusionclient",
|
"name": "OpenFusionClient",
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"description": "OpenFusionClient",
|
"description": "OpenFusionClient",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "npx patch-package && npm explore electron-prebuilt -- npm run postinstall",
|
"postinstall": "npx patch-package && npm explore electron-prebuilt -- npm run postinstall",
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"build": "node build.js",
|
|
||||||
"pack": "electron-builder --win --ia32 --dir",
|
"pack": "electron-builder --win --ia32 --dir",
|
||||||
"dist": "electron-builder --win --ia32",
|
"dist": "electron-builder --win --ia32",
|
||||||
"prettier": "npx prettier --write ."
|
"prettier": "npx prettier --write ."
|
||||||
@ -14,9 +13,9 @@
|
|||||||
"author": "OpenFusion Contributors",
|
"author": "OpenFusion Contributors",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron-builder": "^22.10.5",
|
"electron-builder": "^22.14.13",
|
||||||
"electron-prebuilt": "^0.31.2",
|
"electron-prebuilt": "^0.31.2",
|
||||||
"patch-package": "^6.4.7",
|
"patch-package": "^6.5.1",
|
||||||
"prettier": "^2.7.1"
|
"prettier": "^2.7.1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -26,7 +25,7 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"appId": "xyz.openfusion.client",
|
"appId": "xyz.openfusion.client",
|
||||||
"productName": "OpenFusionClient",
|
"productName": "OpenFusionClient",
|
||||||
"copyright": "© 2020-2022 OpenFusion Contributors",
|
"copyright": "© 2020-2023 OpenFusion Contributors",
|
||||||
"electronDownload": {
|
"electronDownload": {
|
||||||
"version": "0.31.2",
|
"version": "0.31.2",
|
||||||
"platform": "win32",
|
"platform": "win32",
|
||||||
@ -52,18 +51,23 @@
|
|||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"!patches${/*}",
|
"!patches${/*}",
|
||||||
|
"!.vscode${/*}",
|
||||||
"!*.php",
|
"!*.php",
|
||||||
"!rankurl.txt",
|
"!rankurl.txt",
|
||||||
"!README.md",
|
"!README.md",
|
||||||
"!.npmrc"
|
"!LICENSE.md",
|
||||||
|
"!.npmrc",
|
||||||
|
"!.prettierrc",
|
||||||
|
"!.prettierignore"
|
||||||
],
|
],
|
||||||
"extraFiles": [
|
"extraFiles": [
|
||||||
|
"LICENSE.md",
|
||||||
{
|
{
|
||||||
"from": "build/utils",
|
"from": "build/utils",
|
||||||
"to": "utils"
|
"to": "utils"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"afterPack": "./build/delete-default-app.js"
|
"afterPack": "./build/afterpack.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs-extra": "^0.30.0"
|
"fs-extra": "^0.30.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user