mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-25 06:40:15 +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
|
||||
|
||||
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
|
||||
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";
|
||||
}
|
||||
|
||||
#of-versionnumber {
|
||||
#of-versionnumberdiv {
|
||||
position: fixed;
|
||||
bottom: 4px;
|
||||
right: 8px;
|
||||
|
@ -25,6 +25,23 @@ function disableServerListButtons() {
|
||||
$("#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() {
|
||||
var jsontomodify = JSON.parse(
|
||||
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.
|
||||
function setGameInfo(serverUUID) {
|
||||
var result = serverarray.filter(function (obj) {
|
||||
@ -164,38 +225,17 @@ function setGameInfo(serverUUID) {
|
||||
return obj.name === result.version;
|
||||
})[0];
|
||||
|
||||
if (config["cache-swapping"]) {
|
||||
// if cache swapping property exists AND is `true`, run cache swapping logic
|
||||
// Cache folder renaming
|
||||
var cachedir = userdir + "\\..\\..\\LocalLow\\Unity\\Web Player\\Cache";
|
||||
var curversion = cachedir + "\\Fusionfall";
|
||||
var newversion = cachedir + "\\" + gameversion.name;
|
||||
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 {
|
||||
if (config["cache-swapping"]) {
|
||||
try {
|
||||
performCacheSwap(gameversion.name);
|
||||
} catch (ex) {
|
||||
console.log(
|
||||
"Couldn't find last version record; cache may get overwritten"
|
||||
"Error when swapping cache, it may get overwritten:\n" + ex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
remotefs.writeFileSync(__dirname + "\\assetInfo.php", asseturl);
|
||||
|
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>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="text-monospace">Version 1.4</p>
|
||||
<p id="of-aboutversionnumber" class="text-monospace">APP_VERSION_NUMBER</p>
|
||||
<p>
|
||||
©2020-2022 OpenFusion Contributors<br />OpenFusion
|
||||
©2020-2023 OpenFusion Contributors<br />OpenFusion
|
||||
is licensed under MIT.<br />
|
||||
</p>
|
||||
<a
|
||||
@ -447,13 +447,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="of-versionnumber">
|
||||
<div id="of-versionnumberdiv">
|
||||
<a
|
||||
id="of-versionnumber"
|
||||
class="text-monospace text-secondary"
|
||||
href="#of-aboutmodal"
|
||||
data-toggle="modal"
|
||||
data-target="#of-aboutmodal"
|
||||
>v1.4</a
|
||||
>v0</a
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
|
62
index.js
62
index.js
@ -9,6 +9,51 @@ var mainWindow = null;
|
||||
|
||||
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) {
|
||||
// Display a small window to inform the user that the app is working
|
||||
setupWindow = new BrowserWindow({
|
||||
@ -19,13 +64,7 @@ function initialSetup(firstTime) {
|
||||
frame: false,
|
||||
});
|
||||
setupWindow.loadUrl("file://" + __dirname + "/initialsetup.html");
|
||||
// Exec installUnity.bat and wait for it to finish.
|
||||
var child = require("child_process").spawn("cmd.exe", [
|
||||
"/c",
|
||||
"utils\\installUnity.bat",
|
||||
]);
|
||||
child.on("exit", function () {
|
||||
console.log("Unity installed.");
|
||||
installUnity(function () {
|
||||
if (!firstTime) {
|
||||
// migration from pre-1.4
|
||||
// Back everything up, just in case
|
||||
@ -107,11 +146,15 @@ app.on("ready", function () {
|
||||
console.log("Pre-1.4 config detected. Running migration.");
|
||||
initialSetup(false);
|
||||
} else {
|
||||
if (verifyUnity()) {
|
||||
showMainWindow();
|
||||
} else {
|
||||
installUnity(showMainWindow);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("An error occurred while checking for the config.");
|
||||
}
|
||||
} catch (ex) {
|
||||
console.log("An error occurred while checking for the config");
|
||||
}
|
||||
|
||||
// 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
|
||||
mainWindow.webContents.on("did-finish-load", function () {
|
||||
mainWindow.webContents.executeJavaScript("setAppVersionText();");
|
||||
mainWindow.show();
|
||||
// everything's loaded, tell the renderer process to do its thing
|
||||
mainWindow.webContents.executeJavaScript("loadConfig();");
|
||||
|
3451
package-lock.json
generated
3451
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",
|
||||
"version": "1.4.0",
|
||||
"name": "OpenFusionClient",
|
||||
"version": "1.4.1",
|
||||
"description": "OpenFusionClient",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"postinstall": "npx patch-package && npm explore electron-prebuilt -- npm run postinstall",
|
||||
"start": "electron .",
|
||||
"build": "node build.js",
|
||||
"pack": "electron-builder --win --ia32 --dir",
|
||||
"dist": "electron-builder --win --ia32",
|
||||
"prettier": "npx prettier --write ."
|
||||
@ -14,9 +13,9 @@
|
||||
"author": "OpenFusion Contributors",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"electron-builder": "^22.10.5",
|
||||
"electron-builder": "^22.14.13",
|
||||
"electron-prebuilt": "^0.31.2",
|
||||
"patch-package": "^6.4.7",
|
||||
"patch-package": "^6.5.1",
|
||||
"prettier": "^2.7.1"
|
||||
},
|
||||
"repository": {
|
||||
@ -26,7 +25,7 @@
|
||||
"build": {
|
||||
"appId": "xyz.openfusion.client",
|
||||
"productName": "OpenFusionClient",
|
||||
"copyright": "© 2020-2022 OpenFusion Contributors",
|
||||
"copyright": "© 2020-2023 OpenFusion Contributors",
|
||||
"electronDownload": {
|
||||
"version": "0.31.2",
|
||||
"platform": "win32",
|
||||
@ -52,18 +51,23 @@
|
||||
},
|
||||
"files": [
|
||||
"!patches${/*}",
|
||||
"!.vscode${/*}",
|
||||
"!*.php",
|
||||
"!rankurl.txt",
|
||||
"!README.md",
|
||||
"!.npmrc"
|
||||
"!LICENSE.md",
|
||||
"!.npmrc",
|
||||
"!.prettierrc",
|
||||
"!.prettierignore"
|
||||
],
|
||||
"extraFiles": [
|
||||
"LICENSE.md",
|
||||
{
|
||||
"from": "build/utils",
|
||||
"to": "utils"
|
||||
}
|
||||
],
|
||||
"afterPack": "./build/delete-default-app.js"
|
||||
"afterPack": "./build/afterpack.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "^0.30.0"
|
||||
|
Loading…
Reference in New Issue
Block a user