Servers are now loaded from file, and you can connect to them

Needs some cleanup
Also did some misc. UX changes and tweaks
This commit is contained in:
CakeLancelot 2020-12-22 04:45:43 -06:00
parent c1d268ed18
commit b318c9597e
7 changed files with 156 additions and 74 deletions

View File

@ -5,13 +5,13 @@
"description": "OpenFusion Public Server - Original",
"ip": "144.202.52.9:23000",
"version": "beta-20100104",
"endpoint": "https://dexlabs.systems/api/"
"endpoint": "https://api.dexlabs.systems/"
},
{
"uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9",
"description": "OpenFusion Public Server - Academy",
"ip": "144.202.52.9:24000",
"version": "beta-20111003"
"version": "beta-20111013"
}
],
"favorites": []

View File

@ -106,11 +106,11 @@ button > i {
pointer-events: none;
}
#server-listing-placeholder {
visibility: visible;
}
#of-logo {
opacity: 0.9;
}
#server-table .server-listing-entry {
cursor: pointer;
}

View File

@ -3,78 +3,78 @@ var gameRunning = false;
// Unity invoked methods begin //
// allows us to skip the login screen
/*function authDoCallback(param) {
var unity = document.getElementById('Unity_embed');
unity.SendMessage("GlobalManager", "SetTEGid", "player");
unity.SendMessage("GlobalManager", "SetAuthid", "0");
unity.SendMessage("GlobalManager", "DoAuth", 0);
}*/
// Uncomment and enter credentials to skip login screen
function authDoCallback(param) {
/*var unity = document.getElementById('Unity_embed');
unity.SendMessage("GlobalManager", "SetTEGid", "player");
unity.SendMessage("GlobalManager", "SetAuthid", "0");
unity.SendMessage("GlobalManager", "DoAuth", 0);*/
}
function MarkProgress(param) {}
function redirect(html) {
ipc.send("exit", 0);
ipc.send("exit", 0);
}
function HomePage(param) {
ipc.send("exit", 0);
ipc.send("exit", 0);
}
function PageOut(param) {
ipc.send("exit", 0);
ipc.send("exit", 0);
}
function updateSocialOptions(param) {
ipc.send("exit", 0);
ipc.send("exit", 0);
}
function PayPage(param) {
ipc.send("exit", 0);
ipc.send("exit", 0);
}
// Unity invoked methods end //
function onResize() {
if (gameRunning == true) {
var unity = document.getElementById('Unity_embed');
unity.style.width = window.innerWidth + 'px';
unity.style.height = window.innerHeight + 'px';
}
if (gameRunning == true) {
var unity = document.getElementById('Unity_embed');
unity.style.width = window.innerWidth + 'px';
unity.style.height = window.innerHeight + 'px';
}
}
function launchGame() {
gameRunning = true
gameRunning = true
var sel = document.getElementById("of-serverselector");
sel.remove()
document.body.style.overflow = "hidden";
var sel = document.getElementById("of-serverselector");
sel.remove()
document.body.style.overflow = "hidden";
var object = document.createElement('object');
object.setAttribute('classid', "clsid:444785F1-DE89-4295-863A-D46C3A781394");
object.setAttribute('codebase', "undefined/UnityWebPlayer.cab#version=2,0,0,0");
object.setAttribute('id', "Unity_object");
object.setAttribute('width', "1264");
object.setAttribute('height', "661");
var object = document.createElement('object');
object.setAttribute('classid', "clsid:444785F1-DE89-4295-863A-D46C3A781394");
object.setAttribute('codebase', "undefined/UnityWebPlayer.cab#version=2,0,0,0");
object.setAttribute('id', "Unity_object");
object.setAttribute('width', "1264");
object.setAttribute('height', "661");
var embed = document.createElement('embed');
embed.setAttribute('type', "application/vnd.unity");
embed.setAttribute('pluginspage', "http://www.unity3d.com/unity-web-player-2.x");
embed.setAttribute('id', "Unity_embed");
embed.setAttribute('width', "1280");
embed.setAttribute('height', "680");
embed.setAttribute('src', "http://ht.cdn.turner.com/ff/big/beta-20100104/main.unity3d");
embed.setAttribute('disablecontdparaextmenu', "true");
embed.setAttribute('bordercolor', "000000");
embed.setAttribute('backgroundcolor', "000000");
embed.setAttribute('disableContextMenu', true);
embed.setAttribute('textcolor', "ccffff");
embed.setAttribute('logoimage', "assets/img/unity_dexlabs.png");
embed.setAttribute('progressbarimage', "assets/img/unity_loadingbar.png");
embed.setAttribute('progressframeimage', "assets/img/unity_loadingframe.png");
embed.setAttribute('autoupdateurlsignature', "42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033");
embed.setAttribute('autoupdateurl', "http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta");
var embed = document.createElement('embed');
embed.setAttribute('type', "application/vnd.unity");
embed.setAttribute('pluginspage', "http://www.unity3d.com/unity-web-player-2.x");
embed.setAttribute('id', "Unity_embed");
embed.setAttribute('width', "1280");
embed.setAttribute('height', "680");
embed.setAttribute('src', window.asseturl+"main.unity3d");
embed.setAttribute('disablecontdparaextmenu', "true");
embed.setAttribute('bordercolor', "000000");
embed.setAttribute('backgroundcolor', "000000");
embed.setAttribute('disableContextMenu', true);
embed.setAttribute('textcolor', "ccffff");
embed.setAttribute('logoimage', "assets/img/unity_dexlabs.png");
embed.setAttribute('progressbarimage', "assets/img/unity_loadingbar.png");
embed.setAttribute('progressframeimage', "assets/img/unity_loadingframe.png");
embed.setAttribute('autoupdateurlsignature', "42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033");
embed.setAttribute('autoupdateurl', "http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta");
var div = document.getElementById('client');
object.appendChild(embed);
div.appendChild(object);
document.title = "OpenFusion"
OnResize();
var div = document.getElementById('client');
object.appendChild(embed);
div.appendChild(object);
document.title = "OpenFusion"
onResize();
}

View File

@ -1,13 +1,95 @@
// Write loginInfo.php, assetInfo.php, etc.
function setGameInfo(uuid) {
var remote = require("remote");
var remotefs = remote.require('fs');
var userdir = remote.require('app').getPath('userData');
var versionarray
var serverarray
function enableServerListButtons() {
$('#of-connect-button').removeClass('disabled');
$('#of-deleteserver-button').removeClass('disabled');
}
function disableServerListButtons() {
$('#of-connect-button').addClass('disabled');
$('#of-deleteserver-button').addClass('disabled');
}
function loadGameVersions() {
var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json"));
versionarray = versionjson['versions'];
$.each(versionarray, function( key, value ) {
$(new Option(value.name, 'val')).appendTo('#addserver-versionselect');
});
}
function loadConfig() {
// TODO: actually use these values
var configjson = JSON.parse(remotefs.readFileSync(userdir+"\\config.json"));
}
function loadServerList() {
var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
serverarray = serverjson['servers'];
if (serverarray.length > 0) {
$("#server-listing-placeholder").attr("hidden",true);
$.each(serverarray, function( key, value ) {
var row = document.createElement('tr');
row.className = 'server-listing-entry'
row.setAttribute('id', value.uuid)
var cellName = document.createElement('td');
cellName.textContent = value.description
var cellVersion = document.createElement('td');
cellVersion.textContent = value.version
cellVersion.className = 'text-monospace'
row.appendChild(cellName);
row.appendChild(cellVersion);
document.getElementById('server-tablebody').appendChild(row);
});
} else {
// no servers added, make sure placeholder is visible
$("#server-listing-placeholder").attr("hidden",false);
}
}
// For writing loginInfo.php, assetInfo.php, etc.
function setGameInfo(serverUUID) {
var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0];
var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0];
window.asseturl = gameversion.url
remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl);
remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip);
// TODO: write rank endpoint
remotefs.writeFileSync(__dirname+"\\rankurl.txt", "http://api.dexlabs.systems/getranks");
}
function connectToServer() {
stopEasterEggs();
$('#of-serverselector').fadeOut('slow', function() {
setTimeout(function(){
launchGame();
}, 200);
});
// Get ID of the selected server, which corresponds to its UUID in the json
var uuid = $("tr.bg-primary").prop("id");
console.log("Connecting to server with UUID of " + uuid);
// prevent the user from clicking anywhere else during the transition
$('body,html').css('pointer-events','none');
stopEasterEggs();
$('#of-serverselector').fadeOut('slow', function() {
setTimeout(function(){
$('body,html').css('pointer-events','');
setGameInfo(uuid);
launchGame();
}, 200);
});
}
$('#server-table').on('click', '.server-listing-entry', function(event) {
enableServerListButtons();
$(this).addClass('bg-primary').siblings().removeClass('bg-primary');
});
$('#server-table').on('dblclick', '.server-listing-entry', function(event) {
$(this).addClass('bg-primary').siblings().removeClass('bg-primary');
connectToServer();
});

View File

@ -29,7 +29,7 @@
<th>Game Version</th>
</tr>
</thead>
<tbody>
<tbody id="server-tablebody">
<tr id="server-listing-placeholder">
<td colspan="2">No servers added yet... perhaps you should find one?</td>
</tr>
@ -39,8 +39,8 @@
</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="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" onclick="connectToServer()" disabled="">Connect&nbsp;<i class="fas fa-angle-double-right"></i></button></div>
<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"><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" onclick="connectToServer()">Connect&nbsp;<i class="fas fa-angle-double-right"></i></button></div>
</div>
</div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-aboutmodal">

View File

@ -1 +1 @@
144.202.52.9:23000
144.202.52.9:23000

View File

@ -27,7 +27,7 @@ function initialSetup() {
}
ipc.on("exit", function(id) {
mainWindow.destroy()
mainWindow.destroy()
});
// Quit when all windows are closed.
@ -62,7 +62,6 @@ app.on('ready', function() {
mainWindow = new BrowserWindow({width: 1280, height: 720, show: false, "web-preferences": {"plugins": true}});
mainWindow.setMinimumSize(640, 480);
// Makes it so external links are opened in the system browser, not Electron
mainWindow.webContents.on('new-window', function(e, url) {
e.preventDefault();
@ -75,12 +74,13 @@ app.on('ready', function() {
// Reduces white flash when opening the program
// Eliminating it entirely requires a newer Electron ver :(
mainWindow.webContents.on('did-finish-load', function() {
setTimeout(function(){
mainWindow.show();
}, 40);
mainWindow.show();
mainWindow.webContents.executeJavaScript("loadConfig();");
mainWindow.webContents.executeJavaScript("loadGameVersions();");
mainWindow.webContents.executeJavaScript("loadServerList();");
});
//mainWindow.webContents.openDevTools()
mainWindow.webContents.openDevTools()
mainWindow.on('closed', function() {
mainWindow = null;