Getting ready to add logic

* Empty out placeholders in fields
* Slight tweaks to page itself
* Bootstrap updated to 4.5.3
* Include uuid package
* Separate some logic in index.js to new functions
* Add default jsons, as well as code to copy it over on first launch
This commit is contained in:
CakeLancelot 2020-12-17 22:13:54 -06:00
parent 217391b95e
commit 7009328f35
12 changed files with 219 additions and 49 deletions

View File

@ -0,0 +1,5 @@
{
"autoupdate-check": true,
"cache-swapping": false,
"initial-setup-completed": true
}

View File

@ -0,0 +1,18 @@
{
"servers": [
{
"uuid": "d9773558-6ddf-4d00-8803-d830a22a842b",
"description": "OpenFusion Public Server - Original",
"ip": "144.202.52.9:23000",
"version": "beta-20100104",
"endpoint": "https://dexlabs.systems/api/"
},
{
"uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9",
"description": "OpenFusion Public Server - Academy",
"ip": "144.202.52.9:24000",
"version": "beta-20111003"
}
],
"favorites": []
}

View File

@ -0,0 +1,108 @@
{
"versions": [
{
"name": "beta-20100104",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100104/"
},
{
"name": "beta-20100119",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100119/"
},
{
"name": "beta-20100207",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100207/"
},
{
"name": "beta-20100307",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100307/"
},
{
"name": "beta-20100322",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100322/"
},
{
"name": "beta-20100413",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100413/"
},
{
"name": "beta-20100502",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100502/"
},
{
"name": "beta-20100524",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100524/"
},
{
"name": "beta-20100604",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100604/"
},
{
"name": "beta-20100616",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100616/"
},
{
"name": "beta-20100711",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100711/"
},
{
"name": "beta-20100728",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100728/"
},
{
"name": "beta-20100909",
"url": "http://ht.cdn.turner.com/ff/big/beta-20100909/"
},
{
"name": "beta-20101003",
"url": "http://ht.cdn.turner.com/ff/big/beta-20101003/"
},
{
"name": "beta-20101011",
"url": "http://ht.cdn.turner.com/ff/big/beta-20101011/"
},
{
"name": "beta-20101028",
"url": "http://ht.cdn.turner.com/ff/big/beta-20101028/"
},
{
"name": "beta-20101123",
"url": "http://ht.cdn.turner.com/ff/big/beta-20101123/"
},
{
"name": "beta-20110213",
"url": "http://ht.cdn.turner.com/ff/big/beta-20110213/"
},
{
"name": "beta-20110314",
"url": "http://ht.cdn.turner.com/ff/big/beta-20110314/"
},
{
"name": "beta-20110330",
"url": "http://ht.cdn.turner.com/ff/big/beta-20110330/"
},
{
"name": "beta-20110424",
"url": "http://ht.cdn.turner.com/ff/big/beta-20110424/"
},
{
"name": "beta-20110523",
"url": "http://ht.cdn.turner.com/ff/big/beta-20110523/"
},
{
"name": "beta-20110725",
"url": "http://ht.cdn.turner.com/ff/big/beta-20110725/"
},
{
"name": "beta-20110818",
"url": "http://ht.cdn.turner.com/ff/big/beta-20110818/"
},
{
"name": "beta-20110912",
"url": "http://ht.cdn.turner.com/ff/big/beta-20110912/"
},
{
"name": "beta-20111013",
"url": "http://ht.cdn.turner.com/ff/big/beta-20111013/"
}
]
}

View File

@ -10,6 +10,23 @@ var mainWindow = null;
app.commandLine.appendSwitch('--enable-npapi');
// Node version is too old to have a built-in function
function copyFile(src, dst) {
fs.createReadStream(src).pipe(fs.createWriteStream(dst));
}
function initialSetup() {
// Exec installUnity.bat and wait for it to finish.
child.execFileSync('cmd.exe', ['/c', 'utils\\installUnity.bat']);
console.log("Unity installed.");
// Copy over files with default values
copyFile(__dirname+"\\default_config.json", app.getPath('userData')+"\\config.json");
copyFile(__dirname+"\\default_servers.json", app.getPath('userData')+"\\servers.json");
copyFile(__dirname+"\\default_versions.json", app.getPath('userData')+"\\versions.json");
console.log("JSON files copied.")
}
ipc.on("exit", function(id) {
mainWindow.destroy()
});
@ -32,18 +49,14 @@ app.on('ready', function() {
return;
}
// Check for first run
try {
if (fs.existsSync(app.getPath('userData')+"\\unityinstalled")) {
console.log("File exists. Skipping Unity Install.");
} else {
console.log("File does not exist. Installing Unity.");
// Exec installUnity.bat and wait for it to finish.
child.execFileSync('cmd.exe', ['/c', 'utils\\installUnity.bat']);
fs.openSync(app.getPath('userData')+"\\unityinstalled", 'a');
console.log("Unity installed.");
if (!fs.existsSync(app.getPath('userData')+"\\config.json")) {
console.log("Config file not found. Running initial setup.");
initialSetup();
}
} catch(e) {
console.log("An error occurred.");
console.log("An error occurred while checking for the config.");
}
// Create the browser window.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,12 +3,22 @@
user-select: none;
}
#server-table > .table-striped thead th {
background-color: #34476E;
}
#server-table > .table-striped tbody tr:nth-of-type(odd) {
background-color: #34476E;
}
#server-listing-placeholder > td {
background-color: #24314D;
user-select: none;
-webkit-user-select: none;
}
#server-table > .table-striped tbody tr:nth-of-type(even), th {
background-color: #34476E;
background-color: #24314D;
}
#server-table {
@ -30,11 +40,6 @@ img {
--gray-dark: #343a40;
--primary: #6699FF;
--secondary: #384E7A;
--success: #28a745;
--info: #17a2b8;
--warning: #ffc107;
--danger: #dc3545;
--light: #f8f9fa;
--dark: #384E7A;
}
@ -101,3 +106,11 @@ button > i {
pointer-events: none;
}
#server-listing-placeholder {
visibility: visible;
}
#of-logo {
opacity: 0.9;
}

View File

@ -0,0 +1,13 @@
// You're kind of ruining the surprise by reading this, but whatever
var today = new Date();
// Check Christmas season: Date constructor in Javascript uses an index
// so 11 is Dec. of this year, and 12 is Jan. of the next
var christmasBegin = new Date(today.getFullYear(), 11, 10);
var christmasEnd = new Date(today.getFullYear(), 12, 8);
if((today >= christmasBegin && today <= christmasEnd)) {
console.log("Christmas Activated.");
var sf = new Snowflakes({zIndex: -100});
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).uuidv4=e()}(this,(function(){"use strict";var t,e=new Uint8Array(16);function o(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(e)}var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function r(t){return"string"==typeof t&&n.test(t)}for(var i=[],u=0;u<256;++u)i.push((u+256).toString(16).substr(1));return function(t,e,n){var u=(t=t||{}).random||(t.rng||o)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,e){n=n||0;for(var f=0;f<16;++f)e[n+f]=u[f];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=(i[t[e+0]]+i[t[e+1]]+i[t[e+2]]+i[t[e+3]]+"-"+i[t[e+4]]+i[t[e+5]]+"-"+i[t[e+6]]+i[t[e+7]]+"-"+i[t[e+8]]+i[t[e+9]]+"-"+i[t[e+10]]+i[t[e+11]]+i[t[e+12]]+i[t[e+13]]+i[t[e+14]]+i[t[e+15]]).toLowerCase();if(!r(o))throw TypeError("Stringified UUID is invalid");return o}(u)}}));

View File

@ -6,14 +6,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>OpenFusion: Server Selector</title>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&amp;display=swap">
<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);">
<div class="container animated fadeIn delay-1s" id="of-server-picker">
<div class="container" id="of-server-picker">
<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">
<p id="of-intro-text">Welcome to OpenFusion.<br>Select a server from the list below to get started.</p>
@ -30,41 +29,32 @@
</tr>
</thead>
<tbody>
<tr>
<td>OpenFusion Public Server - Original</td>
<td class="text-monospace">beta-20100104</td>
</tr>
<tr>
<td>OpenFusion Public Server - Academy</td>
<td class="text-monospace">beta-20111013</td>
<tr id="server-listing-placeholder">
<td colspan="2">No servers added yet... perhaps you should find one?</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row row-cols-2 d-xl-flex justify-content-center justify-content-xl-center" id="of-serverbuttons">
<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"><i class="fas fa-plus"></i></button><button class="btn btn-danger 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 class="col-4 d-inline-flex justify-content-end"><button class="btn btn-primary disabled" id="of-connect-button" type="button" disabled="">Connect&nbsp;<i class="fas fa-angle-double-right"></i></button></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="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"><i class="fas fa-plus"></i></button><button class="btn btn-danger 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 class="col-4 d-inline-flex justify-content-end"><button class="btn btn-primary" id="of-connect-button" type="button" onclick="$(&quot;div&quot;).fadeOut()">Connect&nbsp;<i class="fas fa-angle-double-right"></i></button></div>
</div>
</div>
<div id="of-versionnumber"><a class="text-monospace text-secondary" href="#of-aboutmodal" data-toggle="modal" data-target="#of-aboutmodal">v1.3</a></div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-aboutmodal">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<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></div>
<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 class="modal-body">
<p class="text-monospace">Version 1.3-GIT_HASH</p>
<p>©2020 OpenFusion Contributors<br>OpenFusion is licensed under MIT.<br></p>
</div>
<div class="modal-footer">
<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="openGithubPage();"><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="openDiscordPage();"><i class="fab fa-discord" style="font-size: 24px; position:relative; top: 1px;"></i></button>
</div>
<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="openGithubPage();"><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="openDiscordPage();"><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>
@ -75,30 +65,37 @@
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<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></div>
<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 class="modal-body">
<fieldset class="text-left" name="of-addserver-fields"><label>Server Description<input type="text" class="form-row" name="of-serverdesc-field" placeholder="My OpenFusion Server" pattern=".*/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+):([0-9]+)" required="" size="50"></label><label>Server IP<input type="text" class="form-row" name="of-serverip-field" placeholder="127.0.0.1:23000" size="50"></label></fieldset><label>Game Version:&nbsp;<select><option value="12" selected="">beta-20100104</option><option value="13">beta-20100728</option><option value="14">beta-20111013</option></select></label></div>
<div
class="modal-footer"><button class="btn btn-primary border rounded border-primary btn-danger border-danger" type="button" data-dismiss="modal">Cancel</button><button class="btn btn-primary disabled border rounded border-primary btn-success border-success"
type="button" data-dismiss="modal" disabled="">Save</button></div>
<fieldset class="text-left" name="of-addserver-fields"><label>Server Description<input type="text" id="addserver-descinput" class="form-row" name="of-serverdesc-field" placeholder="My OpenFusion Server" required="" size="50" minlength="1" maxlength="70"></label><label>Server IP<input type="text" id="addserver-ipinput" class="form-row" name="of-serverip-field" placeholder="127.0.0.1:23000" size="50" 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></fieldset><label>Game Version:&nbsp;<select id="addserver-versionselect" required="">
<option value="" selected="" id="addserver-versionlist-placeholder" disabled="">Please select a verison...</option>
</select></label>
</div>
<div class="modal-footer"><button class="btn btn-primary border rounded border-primary btn-danger border-danger" type="button" data-dismiss="modal">Cancel</button><button class="btn btn-primary disabled border rounded border-primary btn-success border-success" id="addserver-savebutton" type="button" data-dismiss="modal" disabled="">Save</button></div>
</div>
</div>
</div>
</div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-deleteservermodal">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<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></div>
<div class="modal-body">
<p class="lead">Do you really want to delete SERVER_NAME?<br>You could always re-add it later.</p>
<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 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" type="button" data-dismiss="modal">Yes, Delete</button></div>
<div class="modal-body">
<p class="lead">Do you really want to delete&nbsp;<a id="deleteserver-servername">SERVER_NAME</a>?<br>You could always re-add it later.</p>
</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">Yes, Delete</button></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.3</a></div>
<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/bs-init.js"></script>
<script src="assets/js/snowflakes.min.js"></script>
<script src="assets/js/eastereggs.js"></script>
<script src="assets/js/uuidv4.min.js"></script>
</body>
</html>