mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-14 02:30:05 +00:00
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:
parent
c1d268ed18
commit
b318c9597e
@ -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": []
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,13 @@ var gameRunning = false;
|
||||
|
||||
// Unity invoked methods begin //
|
||||
|
||||
// allows us to skip the login screen
|
||||
/*function authDoCallback(param) {
|
||||
var unity = document.getElementById('Unity_embed');
|
||||
// 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);
|
||||
}*/
|
||||
unity.SendMessage("GlobalManager", "DoAuth", 0);*/
|
||||
}
|
||||
|
||||
function MarkProgress(param) {}
|
||||
|
||||
@ -60,7 +60,7 @@ function launchGame() {
|
||||
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('src', window.asseturl+"main.unity3d");
|
||||
embed.setAttribute('disablecontdparaextmenu', "true");
|
||||
embed.setAttribute('bordercolor', "000000");
|
||||
embed.setAttribute('backgroundcolor', "000000");
|
||||
@ -76,5 +76,5 @@ function launchGame() {
|
||||
object.appendChild(embed);
|
||||
div.appendChild(object);
|
||||
document.title = "OpenFusion"
|
||||
OnResize();
|
||||
onResize();
|
||||
}
|
@ -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() {
|
||||
// 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();
|
||||
});
|
@ -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 <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 <i class="fas fa-angle-double-right"></i></button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" role="dialog" tabindex="-1" id="of-aboutmodal">
|
||||
|
@ -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.webContents.executeJavaScript("loadConfig();");
|
||||
mainWindow.webContents.executeJavaScript("loadGameVersions();");
|
||||
mainWindow.webContents.executeJavaScript("loadServerList();");
|
||||
});
|
||||
|
||||
//mainWindow.webContents.openDevTools()
|
||||
mainWindow.webContents.openDevTools()
|
||||
|
||||
mainWindow.on('closed', function() {
|
||||
mainWindow = null;
|
||||
|
Loading…
Reference in New Issue
Block a user