configure prettier for a prettier project

This commit is contained in:
Hichem Fantar 2022-07-18 19:19:22 +01:00
parent 0060f37e6c
commit 9a083d7a04
12 changed files with 9155 additions and 8698 deletions

33
.prettierignore Normal file
View File

@ -0,0 +1,33 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
locales/
*.pak
*.bin
*.php
rankurl.txt
icudtl.dat
version
resources/app/files/rankurl.txt
node_modules/
dist/
assets/
UnityBugReporter.exe

11
.prettierrc Normal file
View File

@ -0,0 +1,11 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": true,
"singleQuote": false,
"semi": true,
"bracketSameLine": false,
"bracketSpacing": true,
"jsxSingleQuote": false,
"quoteProps": "as-needed"
}

9
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": ["esbenp.prettier-vscode"],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}

View File

@ -1,2 +1,3 @@
# OpenFusionClient # OpenFusionClient
Electron app for joining OpenFusion servers Electron app for joining OpenFusion servers

View File

@ -1,27 +1,54 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no"> <meta
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/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="assets/fonts/fontawesome-all.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/openfusion.css" />
<link rel="stylesheet" href="assets/css/styles.css"> <link rel="stylesheet" href="assets/css/styles.css" />
</head> </head>
<body style="background: rgb(0,0,0);width: 100%;height: 100%;margin: 0;padding: 0;clear:both;" onresize="onResize()"> <body
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">
<div class="col"><img class="img-fluid" id="of-logo" src="assets/img/of-3.png" width="256"> <div class="col">
<p id="of-intro-text">Welcome to OpenFusion.<br>Select a server from the list below to get started.</p> <img
class="img-fluid"
id="of-logo"
src="assets/img/of-3.png"
width="256"
/>
<p id="of-intro-text">
Welcome to OpenFusion.<br />Select a server from the list below to
get started.
</p>
</div> </div>
</div> </div>
<div class="row d-sm-flex d-xl-flex justify-content-center justify-content-sm-center justify-content-xl-center" id="of-serverlist"> <div
class="row d-sm-flex d-xl-flex justify-content-center justify-content-sm-center justify-content-xl-center"
id="of-serverlist"
>
<div class="col-8 mb-2"> <div class="col-8 mb-2">
<div class="table-responsive text-center border rounded border-primary" id="server-table"> <div
class="table-responsive text-center border rounded border-primary"
id="server-table"
>
<table class="table table-striped table-hover mb-0"> <table class="table table-striped table-hover mb-0">
<thead> <thead>
<tr> <tr>
@ -31,21 +58,71 @@
</thead> </thead>
<tbody id="server-tablebody"> <tbody id="server-tablebody">
<tr id="server-listing-placeholder"> <tr id="server-listing-placeholder">
<td colspan="2">No servers added yet... perhaps you should find one?</td> <td colspan="2">
No servers added yet... perhaps you should find one?
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
<div class="row row-cols-2 d-xl-flex justify-content-center justify-content-xl-center" id="of-serverbuttons" style="padding-bottom: 16px;"> <div
class="row row-cols-2 d-xl-flex justify-content-center justify-content-xl-center"
id="of-serverbuttons"
style="padding-bottom: 16px"
>
<div class="col-4 text-left d-inline-flex justify-content-xl-start"> <div class="col-4 text-left d-inline-flex justify-content-xl-start">
<button class="btn btn-success mr-1" data-toggle="modal" data-bs-tooltip="" data-placement="bottom" id="of-addserver-button" type="button" title="Add Server" data-target="#of-addservermodal" onclick="deselectServer()"><i class="fas fa-plus"></i></button> <button
<button class="btn btn-primary mr-1 disabled" data-toggle="modal" data-bs-tooltip="" data-placement="bottom" id="of-editserver-button" type="button" title="Edit Server" data-target="#of-editservermodal" disabled=""><i class="fas fa-edit"></i></button> class="btn btn-success mr-1"
<button class="btn btn-danger mr-1 disabled" data-toggle="modal" data-bs-tooltip="" data-placement="bottom" id="of-deleteserver-button" type="button" title="Delete Server" data-target="#of-deleteservermodal" disabled=""><i class="fas fa-trash-alt"></i></button> data-toggle="modal"
data-bs-tooltip=""
data-placement="bottom"
id="of-addserver-button"
type="button"
title="Add Server"
data-target="#of-addservermodal"
onclick="deselectServer()"
>
<i class="fas fa-plus"></i>
</button>
<button
class="btn btn-primary mr-1 disabled"
data-toggle="modal"
data-bs-tooltip=""
data-placement="bottom"
id="of-editserver-button"
type="button"
title="Edit Server"
data-target="#of-editservermodal"
disabled=""
>
<i class="fas fa-edit"></i>
</button>
<button
class="btn btn-danger mr-1 disabled"
data-toggle="modal"
data-bs-tooltip=""
data-placement="bottom"
id="of-deleteserver-button"
type="button"
title="Delete Server"
data-target="#of-deleteservermodal"
disabled=""
>
<i class="fas fa-trash-alt"></i>
</button>
</div> </div>
<div class="col-4 d-inline-flex justify-content-end"> <div class="col-4 d-inline-flex justify-content-end">
<button class="btn btn-primary disabled" id="of-connect-button" type="button" onclick="connectToServer()" disabled="">Connect&nbsp;<i class="fas fa-angle-double-right"></i></button> <button
class="btn btn-primary disabled"
id="of-connect-button"
type="button"
onclick="connectToServer()"
disabled=""
>
Connect&nbsp;<i class="fas fa-angle-double-right"></i>
</button>
</div> </div>
</div> </div>
</div> </div>
@ -53,80 +130,331 @@
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">About OpenFusionClient</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">About OpenFusionClient</h4>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p class="text-monospace">Version 1.4</p> <p class="text-monospace">Version 1.4</p>
<p>©2020-2022 OpenFusion Contributors<br>OpenFusion is licensed under MIT.<br></p> <p>
<a href="#of-restoreserversmodal" onclick="$('#of-aboutmodal').modal('toggle')" data-toggle="modal" data-target="#of-restoreserversmodal">Reset to Default Servers</a> ©2020-2022 OpenFusion Contributors<br />OpenFusion is licensed
under MIT.<br />
</p>
<a
href="#of-restoreserversmodal"
onclick="$('#of-aboutmodal').modal('toggle')"
data-toggle="modal"
data-target="#of-restoreserversmodal"
>Reset to Default Servers</a
>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="row flex-fill"> <div class="row flex-fill">
<div class="col"><button class="btn btn-primary border rounded border-primary pb-1 pt-1 mr-2 pl-2 pr-2" data-toggle="tooltip" data-bs-tooltip="" type="button" title="Github Page" onclick="window.open(&#39;https://github.com/OpenFusionProject/OpenFusion&#39;,&#39;_blank&#39;);"><i class="fab fa-github" style="font-size: 24px;"></i></button><button class="btn btn-primary border rounded border-primary pb-1 pt-1 pl-2 pr-2" data-toggle="tooltip" data-bs-tooltip="" type="button" title="Discord Chat" onclick="window.open(&#39;https://discord.gg/DYavckB&#39;,&#39;_blank&#39;);"><i class="fab fa-discord" style="font-size: 24px; position:relative; top: 1px;"></i></button></div> <div class="col">
<div class="col text-right"><button class="btn btn-primary border rounded border-primary" type="button" data-dismiss="modal">Close</button></div> <button
class="btn btn-primary border rounded border-primary pb-1 pt-1 mr-2 pl-2 pr-2"
data-toggle="tooltip"
data-bs-tooltip=""
type="button"
title="Github Page"
onclick="window.open(&#39;https://github.com/OpenFusionProject/OpenFusion&#39;,&#39;_blank&#39;);"
>
<i
class="fab fa-github"
style="font-size: 24px"
></i></button
><button
class="btn btn-primary border rounded border-primary pb-1 pt-1 pl-2 pr-2"
data-toggle="tooltip"
data-bs-tooltip=""
type="button"
title="Discord Chat"
onclick="window.open(&#39;https://discord.gg/DYavckB&#39;,&#39;_blank&#39;);"
>
<i
class="fab fa-discord"
style="font-size: 24px; position: relative; top: 1px"
></i>
</button>
</div>
<div class="col text-right">
<button
class="btn btn-primary border rounded border-primary"
type="button"
data-dismiss="modal"
>
Close
</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-addservermodal"> </div>
<div
class="modal fade"
role="dialog"
tabindex="-1"
id="of-addservermodal"
>
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">Add Server</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">Add Server</h4>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form id="addserver-form" class="needs-validation"><label for="addserver-descinput">Server Description</label><input class="form-control form-row w-75" type="text" id="addserver-descinput" placeholder="My OpenFusion Server" required="" minlength="1" maxlength="70"><label for="addserver-ipinput">Server IP</label><input class="form-control form-row w-75" type="text" id="addserver-ipinput" placeholder="127.0.0.1:23000" required="" pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9]+$"><label for="addserver-versionselect">Game Version:&nbsp;</label><select class="form-control w-50" id="addserver-versionselect" required="" style="margin-left: -5px;"></select></form> <form id="addserver-form" class="needs-validation">
<label for="addserver-descinput">Server Description</label
><input
class="form-control form-row w-75"
type="text"
id="addserver-descinput"
placeholder="My OpenFusion Server"
required=""
minlength="1"
maxlength="70"
/><label for="addserver-ipinput">Server IP</label
><input
class="form-control form-row w-75"
type="text"
id="addserver-ipinput"
placeholder="127.0.0.1:23000"
required=""
pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9]+$"
/><label for="addserver-versionselect"
>Game Version:&nbsp;</label
><select
class="form-control w-50"
id="addserver-versionselect"
required=""
style="margin-left: -5px"
></select>
</form>
</div> </div>
<div class="modal-footer"><button class="btn btn-primary border rounded border-primary btn-danger border-danger" id="addserver-cancel" type="button" data-dismiss="modal">Cancel</button><button class="btn btn-primary border rounded border-primary btn-success border-success" id="addserver-savebutton" type="submit" data-dismiss="modal" form="addserver-form" onclick="addServer();">Save</button></div> <div class="modal-footer">
<button
class="btn btn-primary border rounded border-primary btn-danger border-danger"
id="addserver-cancel"
type="button"
data-dismiss="modal"
>
Cancel</button
><button
class="btn btn-primary border rounded border-primary btn-success border-success"
id="addserver-savebutton"
type="submit"
data-dismiss="modal"
form="addserver-form"
onclick="addServer();"
>
Save
</button>
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-editservermodal"> </div>
<div
class="modal fade"
role="dialog"
tabindex="-1"
id="of-editservermodal"
>
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">Edit Server</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">Edit Server</h4>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form id="editserver-form" class="needs-validation"><label for="editserver-descinput">Server Description</label><input class="form-control form-row w-75" type="text" id="editserver-descinput" placeholder="My OpenFusion Server" required="" minlength="1" maxlength="70"><label for="addserver-ipinput">Server IP</label><input class="form-control form-row w-75" type="text" id="editserver-ipinput" placeholder="127.0.0.1:23000" required="" pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9]+$"><label for="editserver-versionselect">Game Version:&nbsp;</label><select class="form-control w-50" id="editserver-versionselect" required="" style="margin-left: -5px;"></select></form> <form id="editserver-form" class="needs-validation">
<label for="editserver-descinput">Server Description</label
><input
class="form-control form-row w-75"
type="text"
id="editserver-descinput"
placeholder="My OpenFusion Server"
required=""
minlength="1"
maxlength="70"
/><label for="addserver-ipinput">Server IP</label
><input
class="form-control form-row w-75"
type="text"
id="editserver-ipinput"
placeholder="127.0.0.1:23000"
required=""
pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9]+$"
/><label for="editserver-versionselect"
>Game Version:&nbsp;</label
><select
class="form-control w-50"
id="editserver-versionselect"
required=""
style="margin-left: -5px"
></select>
</form>
</div> </div>
<div class="modal-footer"><button class="btn btn-primary border rounded border-primary btn-danger border-danger" id="editserver-cancel" type="button" data-dismiss="modal">Cancel</button><button class="btn btn-primary border rounded border-primary btn-success border-success" id="addserver-savebutton" type="submit" data-dismiss="modal" form="editserver-form" onclick="editServer();">Save</button></div> <div class="modal-footer">
<button
class="btn btn-primary border rounded border-primary btn-danger border-danger"
id="editserver-cancel"
type="button"
data-dismiss="modal"
>
Cancel</button
><button
class="btn btn-primary border rounded border-primary btn-success border-success"
id="addserver-savebutton"
type="submit"
data-dismiss="modal"
form="editserver-form"
onclick="editServer();"
>
Save
</button>
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-deleteservermodal"> </div>
<div
class="modal fade"
role="dialog"
tabindex="-1"
id="of-deleteservermodal"
>
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">Are you sure?</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">Are you sure?</h4>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p class="lead">Do you really want to delete<br>"<a id="deleteserver-servername">SERVER_NAME</a>"?<br><br>You could always re-add it later.</p> <p class="lead">
Do you really want to delete<br />"<a
id="deleteserver-servername"
>SERVER_NAME</a
>"?<br /><br />You could always re-add it later.
</p>
</div> </div>
<div class="modal-footer"><button class="btn btn-primary border rounded border-primary" type="button" data-dismiss="modal">Cancel</button><button class="btn btn-primary border rounded border-primary btn-danger border-danger" id="deleteserver-button" type="button" data-dismiss="modal" onclick="deleteServer();">Yes, Delete</button></div> <div class="modal-footer">
<button
class="btn btn-primary border rounded border-primary"
type="button"
data-dismiss="modal"
>
Cancel</button
><button
class="btn btn-primary border rounded border-primary btn-danger border-danger"
id="deleteserver-button"
type="button"
data-dismiss="modal"
onclick="deleteServer();"
>
Yes, Delete
</button>
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-restoreserversmodal"> </div>
<div
class="modal fade"
role="dialog"
tabindex="-1"
id="of-restoreserversmodal"
>
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">Are you sure?</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">Are you sure?</h4>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p class="lead">Do you really want to restore the default servers?</p> <p class="lead">
Do you really want to restore the default servers?
</p>
</div> </div>
<div class="modal-footer"><button class="btn btn-primary border rounded border-primary" type="button" data-dismiss="modal">Cancel</button><button class="btn btn-primary border rounded border-primary btn-danger border-danger" id="deleteserver-button" type="button" data-dismiss="modal" onclick="restoreDefaultServers();">Yes, Restore</button></div> <div class="modal-footer">
<button
class="btn btn-primary border rounded border-primary"
type="button"
data-dismiss="modal"
>
Cancel</button
><button
class="btn btn-primary border rounded border-primary btn-danger border-danger"
id="deleteserver-button"
type="button"
data-dismiss="modal"
onclick="restoreDefaultServers();"
>
Yes, Restore
</button>
</div> </div>
</div> </div>
</div> </div>
<div id="of-versionnumber"><a class="text-monospace text-secondary" href="#of-aboutmodal" data-toggle="modal" data-target="#of-aboutmodal">v1.4</a></div> </div>
<div id="of-versionnumber">
<a
class="text-monospace text-secondary"
href="#of-aboutmodal"
data-toggle="modal"
data-target="#of-aboutmodal"
>v1.4</a
>
</div>
</section> </section>
<section> <section>
<div id="client" style="width: 100%;height: 100%;margin: 0;padding: 0;background: #000;clear:both;"></div> <div
id="client"
style="
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #000;
clear: both;
"
></div>
</section> </section>
<script src="assets/js/jquery.min.js" onload="window.$ = window.jQuery = module.exports;"></script> <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/bootstrap/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>
@ -135,5 +463,4 @@
<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/eastereggs.js"></script>
</body> </body>
</html> </html>

116
index.js
View File

@ -1,40 +1,69 @@
var app = require('app'); // Module to control application life. var app = require("app"); // Module to control application life.
var ipc = require('ipc'); var ipc = require("ipc");
var fs = require('fs-extra'); var fs = require("fs-extra");
var os = require('os'); var os = require("os");
var dialog = require('dialog'); 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");
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({width: 275, height: 450, resizable: false, center:true, frame:false}); setupWindow = new BrowserWindow({
setupWindow.loadUrl('file://' + __dirname + '/initialsetup.html'); width: 275,
height: 450,
resizable: false,
center: true,
frame: false,
});
setupWindow.loadUrl("file://" + __dirname + "/initialsetup.html");
// Exec installUnity.bat and wait for it to finish. // Exec installUnity.bat and wait for it to finish.
var child = require('child_process').spawn('cmd.exe', ['/c', 'utils\\installUnity.bat']); var child = require("child_process").spawn("cmd.exe", [
child.on('exit', function() { "/c",
"utils\\installUnity.bat",
]);
child.on("exit", function () {
console.log("Unity installed."); console.log("Unity installed.");
if(!firstTime) { // migration from pre-1.4 if (!firstTime) {
// migration from pre-1.4
// Back everything up, just in case // Back everything up, just in case
fs.copySync(app.getPath('userData')+"\\config.json", app.getPath('userData')+"\\config.json.bak"); fs.copySync(
fs.copySync(app.getPath('userData')+"\\servers.json", app.getPath('userData')+"\\servers.json.bak"); app.getPath("userData") + "\\config.json",
fs.copySync(app.getPath('userData')+"\\versions.json", app.getPath('userData')+"\\versions.json.bak"); app.getPath("userData") + "\\config.json.bak"
} else { // first-time setup );
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 // Copy default servers
fs.copySync(__dirname+"\\defaults\\servers.json", app.getPath('userData')+"\\servers.json"); fs.copySync(
__dirname + "\\defaults\\servers.json",
app.getPath("userData") + "\\servers.json"
);
} }
// Copy default versions and config // Copy default versions and config
fs.copySync(__dirname+"\\defaults\\versions.json", app.getPath('userData')+"\\versions.json"); fs.copySync(
fs.copySync(__dirname+"\\defaults\\config.json", app.getPath('userData')+"\\config.json"); __dirname + "\\defaults\\versions.json",
app.getPath("userData") + "\\versions.json"
);
fs.copySync(
__dirname + "\\defaults\\config.json",
app.getPath("userData") + "\\config.json"
);
console.log("JSON files copied."); console.log("JSON files copied.");
setupWindow.destroy(); setupWindow.destroy();
showMainWindow(); showMainWindow();
}) });
} }
ipc.on("exit", function (id) { ipc.on("exit", function (id) {
@ -42,36 +71,39 @@ ipc.on("exit", function(id) {
}); });
// Quit when all windows are closed. // Quit when all windows are closed.
app.on('window-all-closed', function() { app.on("window-all-closed", function () {
if (process.platform != 'darwin') if (process.platform != "darwin") app.quit();
app.quit();
}); });
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()); zip_check = app.getPath("exe").includes(os.tmpdir());
if (zip_check) { if (zip_check) {
errormsg = errormsg =
( "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!", errormsg);
return; return;
} }
// Create the browser window. // Create the browser window.
mainWindow = new BrowserWindow({width: 1280, height: 720, show: false, "web-preferences": {"plugins": true}}); mainWindow = new BrowserWindow({
width: 1280,
height: 720,
show: false,
"web-preferences": { plugins: true },
});
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 = app.getPath("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.");
initialSetup(true); initialSetup(true);
} else { } else {
var config = fs.readJsonSync(configPath); var config = fs.readJsonSync(configPath);
if(!config['last-version-initialized']) { if (!config["last-version-initialized"]) {
console.log("Pre-1.4 config detected. Running migration."); console.log("Pre-1.4 config detected. Running migration.");
initialSetup(false); initialSetup(false);
} else { } else {
@ -83,22 +115,22 @@ app.on('ready', function() {
} }
// 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 (e, url) {
e.preventDefault(); e.preventDefault();
require('shell').openExternal(url); require("shell").openExternal(url);
}); });
mainWindow.on('closed', function() { mainWindow.on("closed", function () {
mainWindow = null; mainWindow = null;
}); });
}); });
function showMainWindow() { function showMainWindow() {
// Load the index.html of the app. // Load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/index.html'); mainWindow.loadUrl("file://" + __dirname + "/index.html");
// 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.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();");
@ -106,26 +138,26 @@ function showMainWindow() {
mainWindow.webContents.executeJavaScript("loadServerList();"); mainWindow.webContents.executeJavaScript("loadServerList();");
}); });
mainWindow.webContents.on('plugin-crashed', function() { mainWindow.webContents.on("plugin-crashed", function () {
console.log("Unity Web Player crashed."); console.log("Unity Web Player crashed.");
}); });
mainWindow.webContents.on('will-navigate', function(evt, url) { mainWindow.webContents.on("will-navigate", function (evt, url) {
evt.preventDefault(); evt.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 = errormsg =
( "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!", errormsg);
break; break;
case "https://audience.fusionfall.com/ff/login.do": case "https://audience.fusionfall.com/ff/login.do":
dialog.showErrorBox("Sorry!", "Account management is not available."); dialog.showErrorBox("Sorry!", "Account management is not available.");
break; break;
case "http://forums.fusionfall.com/": case "http://forums.fusionfall.com/":
require('shell').openExternal("https://discord.gg/DYavckB"); require("shell").openExternal("https://discord.gg/DYavckB");
break; break;
default: default:
mainWindow.webContents.loadURL(url); mainWindow.webContents.loadURL(url);

View File

@ -3,14 +3,35 @@
<head> <head>
<title>OpenFusion: Initial Setup</title> <title>OpenFusion: Initial Setup</title>
</head> </head>
<body style="overflow:hidden;background-color:#000;user-select:none;-webkit-user-select:none;"> <body
style="
overflow: hidden;
background-color: #000;
user-select: none;
-webkit-user-select: none;
"
>
<center> <center>
<div><img src="assets/img/of-3.png" width="256">
<div> <div>
<img src="assets/img/spinner.gif" width=50px/> <img src="assets/img/of-3.png" width="256" />
<div>
<img src="assets/img/spinner.gif" width="50px" />
</div> </div>
<div style="margin-top: 15px;"> <div style="margin-top: 15px">
<p style='text-shadow:1px 1px 8px #4349C4;color:#4A76B7;font-size:18px;font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";'>OpenFusion is setting up...<br>Please wait - this should take <br>less than a minute.</p> <p
style="
text-shadow: 1px 1px 8px #4349c4;
color: #4a76b7;
font-size: 18px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji';
"
>
OpenFusion is setting up...<br />Please wait - this should take
<br />less than a minute.
</p>
</div> </div>
</div> </div>
</center> </center>

24
package-lock.json generated
View File

@ -15,7 +15,8 @@
"devDependencies": { "devDependencies": {
"electron-builder": "^22.10.5", "electron-builder": "^22.10.5",
"electron-prebuilt": "^0.31.2", "electron-prebuilt": "^0.31.2",
"patch-package": "^6.4.7" "patch-package": "^6.4.7",
"prettier": "^2.7.1"
} }
}, },
"node_modules/@develar/schema-utils": { "node_modules/@develar/schema-utils": {
@ -3403,6 +3404,21 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/pretty-bytes": { "node_modules/pretty-bytes": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz",
@ -7272,6 +7288,12 @@
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=",
"dev": true "dev": true
}, },
"prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true
},
"pretty-bytes": { "pretty-bytes": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz",

View File

@ -13,9 +13,10 @@
"author": "OpenFusion Contributors", "author": "OpenFusion Contributors",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"electron-builder": "^22.10.5",
"electron-prebuilt": "^0.31.2", "electron-prebuilt": "^0.31.2",
"patch-package": "^6.4.7", "patch-package": "^6.4.7",
"electron-builder": "^22.10.5" "prettier": "^2.7.1"
}, },
"repository": { "repository": {
"type": "git", "type": "git",