mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-22 13:40:06 +00:00
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
This commit is contained in:
parent
043bf219e7
commit
dabb8bf484
@ -61,7 +61,7 @@ function launchGame() {
|
|||||||
object.setAttribute("height", "661");
|
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.ffuwp");
|
||||||
embed.setAttribute(
|
embed.setAttribute(
|
||||||
"pluginspage",
|
"pluginspage",
|
||||||
"http://www.unity3d.com/unity-web-player-2.x"
|
"http://www.unity3d.com/unity-web-player-2.x"
|
||||||
|
8
build/OpenFusionClient.exe.manifest
Normal file
8
build/OpenFusionClient.exe.manifest
Normal 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>
|
Binary file not shown.
@ -2,8 +2,8 @@
|
|||||||
<plist>
|
<plist>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>3.5.2f2</string>
|
<string>2.5.5b4</string>
|
||||||
<key>UnityBuildNumber</key>
|
<key>UnityBuildNumber</key>
|
||||||
<string>4c6ee796dacc</string>
|
<string>50</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,6 +2,10 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
<meta
|
||||||
|
http-equiv="Content-Type"
|
||||||
|
contentType="text/html; charset=UTF-8"
|
||||||
|
/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<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" />
|
||||||
|
137
index.js
137
index.js
@ -6,60 +6,18 @@ var dialog = require("dialog");
|
|||||||
var BrowserWindow = require("browser-window");
|
var BrowserWindow = require("browser-window");
|
||||||
|
|
||||||
var mainWindow = null;
|
var mainWindow = null;
|
||||||
|
|
||||||
app.commandLine.appendSwitch("enable-npapi");
|
app.commandLine.appendSwitch("enable-npapi");
|
||||||
|
app.commandLine.appendSwitch("no-proxy-server");
|
||||||
|
|
||||||
function verifyMD5Hash(file, hash) {
|
var userData = app.getPath("userData");
|
||||||
if (fs.existsSync(file)) {
|
var unityHomeDir = __dirname + "\\..\\..\\WebPlayer";
|
||||||
var buffer = fs.readFileSync(file);
|
// if running in non-packaged / development mode, this dir will be slightly different
|
||||||
var computedHash = require("crypto")
|
if (process.env.npm_node_execpath) {
|
||||||
.createHash("md5")
|
unityHomeDir = app.getAppPath() + "\\build\\WebPlayer";
|
||||||
.update(buffer)
|
|
||||||
.digest("hex");
|
|
||||||
if (hash == computedHash) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyUnity() {
|
process.env["UNITY_HOME_DIR"] = unityHomeDir;
|
||||||
var loaderPath =
|
process.env["UNITY_DISABLE_PLUGIN_UPDATES"] = "yes";
|
||||||
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) {
|
|
||||||
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 dest = app.getPath("appData") + "\\..\\LocalLow\\Unity\\WebPlayer";
|
|
||||||
fs.copySync(utilsDir + "\\WebPlayer", dest, { clobber: true });
|
|
||||||
// avoids error reporter popping up when closing Electron
|
|
||||||
fs.removeSync(dest + "\\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
|
||||||
@ -70,46 +28,41 @@ function initialSetup(firstTime) {
|
|||||||
center: true,
|
center: true,
|
||||||
frame: false,
|
frame: false,
|
||||||
});
|
});
|
||||||
setupWindow.loadUrl("file://" + __dirname + "/initial-setup.html");
|
if (!firstTime) {
|
||||||
installUnity(function () {
|
// migration from pre-1.4
|
||||||
if (!firstTime) {
|
// Back everything up, just in case
|
||||||
// migration from pre-1.4
|
setupWindow.loadUrl("file://" + __dirname + "/initial-setup.html");
|
||||||
// Back everything up, just in case
|
fs.copySync(userData + "\\config.json", userData + "\\config.json.bak");
|
||||||
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
|
|
||||||
fs.copySync(
|
fs.copySync(
|
||||||
__dirname + "\\defaults\\versions.json",
|
userData + "\\servers.json",
|
||||||
app.getPath("userData") + "\\versions.json"
|
userData + "\\servers.json.bak"
|
||||||
);
|
);
|
||||||
fs.copySync(
|
fs.copySync(
|
||||||
__dirname + "\\defaults\\config.json",
|
userData + "\\versions.json",
|
||||||
app.getPath("userData") + "\\config.json"
|
userData + "\\versions.json.bak"
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
// first-time setup
|
||||||
|
// Copy default servers
|
||||||
|
fs.copySync(
|
||||||
|
__dirname + "\\defaults\\servers.json",
|
||||||
|
userData + "\\servers.json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
console.log("JSON files copied.");
|
// Copy default versions and config
|
||||||
setupWindow.destroy();
|
fs.copySync(
|
||||||
showMainWindow();
|
__dirname + "\\defaults\\versions.json",
|
||||||
});
|
userData + "\\versions.json"
|
||||||
|
);
|
||||||
|
fs.copySync(
|
||||||
|
__dirname + "\\defaults\\config.json",
|
||||||
|
userData + "\\config.json"
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log("JSON files copied.");
|
||||||
|
setupWindow.destroy();
|
||||||
|
showMainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.on("exit", function (id) {
|
ipc.on("exit", function (id) {
|
||||||
@ -131,18 +84,20 @@ app.on("ready", function () {
|
|||||||
dialog.showErrorBox("Error!", errorMessage);
|
dialog.showErrorBox("Error!", errorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 1280,
|
width: 1280,
|
||||||
height: 720,
|
height: 720,
|
||||||
show: false,
|
show: false,
|
||||||
"web-preferences": { plugins: true },
|
"web-preferences": {
|
||||||
|
plugins: true,
|
||||||
|
"extra-plugin-dirs": [unityHomeDir + "\\loader"],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
mainWindow.setMinimumSize(640, 480);
|
mainWindow.setMinimumSize(640, 480);
|
||||||
|
|
||||||
// Check for first run
|
// Check for first run
|
||||||
var configPath = app.getPath("userData") + "\\config.json";
|
var configPath = userData + "\\config.json";
|
||||||
try {
|
try {
|
||||||
if (!fs.existsSync(configPath)) {
|
if (!fs.existsSync(configPath)) {
|
||||||
console.log("Config file not found. Running initial setup.");
|
console.log("Config file not found. Running initial setup.");
|
||||||
@ -153,11 +108,7 @@ 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 {
|
||||||
if (verifyUnity()) {
|
showMainWindow();
|
||||||
showMainWindow();
|
|
||||||
} else {
|
|
||||||
installUnity(showMainWindow);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "OpenFusionClient",
|
"name": "OpenFusionClient",
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"description": "OpenFusionClient",
|
"description": "OpenFusionClient",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -63,8 +63,12 @@
|
|||||||
"extraFiles": [
|
"extraFiles": [
|
||||||
"LICENSE.md",
|
"LICENSE.md",
|
||||||
{
|
{
|
||||||
"from": "build/utils",
|
"from": "build/OpenFusionClient.exe.manifest",
|
||||||
"to": "utils"
|
"to": "OpenFusionClient.exe.manifest"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "build/WebPlayer",
|
||||||
|
"to": "WebPlayer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"afterPack": "./build/after-pack.js"
|
"afterPack": "./build/after-pack.js"
|
||||||
|
Loading…
Reference in New Issue
Block a user