mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-22 13:40:06 +00:00
Add initial setup splash window
as well as other additions and tweaks
This commit is contained in:
parent
b318c9597e
commit
a73b3a4b3f
@ -11,7 +11,8 @@
|
|||||||
"uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9",
|
"uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9",
|
||||||
"description": "OpenFusion Public Server - Academy",
|
"description": "OpenFusion Public Server - Academy",
|
||||||
"ip": "144.202.52.9:24000",
|
"ip": "144.202.52.9:24000",
|
||||||
"version": "beta-20111013"
|
"version": "beta-20111013",
|
||||||
|
"endpoint": "https://api.dexlabs.systems/academy/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"favorites": []
|
"favorites": []
|
||||||
|
BIN
resources/app/files/assets/img/spinner.gif
Normal file
BIN
resources/app/files/assets/img/spinner.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
@ -7,12 +7,16 @@ var serverarray
|
|||||||
|
|
||||||
function enableServerListButtons() {
|
function enableServerListButtons() {
|
||||||
$('#of-connect-button').removeClass('disabled');
|
$('#of-connect-button').removeClass('disabled');
|
||||||
|
$('#of-connect-button').prop('disabled', false);
|
||||||
$('#of-deleteserver-button').removeClass('disabled');
|
$('#of-deleteserver-button').removeClass('disabled');
|
||||||
|
$('#of-deleteserver-button').prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function disableServerListButtons() {
|
function disableServerListButtons() {
|
||||||
$('#of-connect-button').addClass('disabled');
|
$('#of-connect-button').addClass('disabled');
|
||||||
|
$('#of-connect-button').prop('disabled', true);
|
||||||
$('#of-deleteserver-button').addClass('disabled');
|
$('#of-deleteserver-button').addClass('disabled');
|
||||||
|
$('#of-deleteserver-button').prop('disabled', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadGameVersions() {
|
function loadGameVersions() {
|
||||||
@ -26,12 +30,15 @@ function loadGameVersions() {
|
|||||||
function loadConfig() {
|
function loadConfig() {
|
||||||
// TODO: actually use these values
|
// TODO: actually use these values
|
||||||
var configjson = JSON.parse(remotefs.readFileSync(userdir+"\\config.json"));
|
var configjson = JSON.parse(remotefs.readFileSync(userdir+"\\config.json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadServerList() {
|
function loadServerList() {
|
||||||
var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
||||||
serverarray = serverjson['servers'];
|
serverarray = serverjson['servers'];
|
||||||
|
|
||||||
|
$(".server-listing-entry").remove(); // clear out old stuff, if any
|
||||||
|
disableServerListButtons();
|
||||||
|
|
||||||
if (serverarray.length > 0) {
|
if (serverarray.length > 0) {
|
||||||
$("#server-listing-placeholder").attr("hidden",true);
|
$("#server-listing-placeholder").attr("hidden",true);
|
||||||
$.each(serverarray, function( key, value ) {
|
$.each(serverarray, function( key, value ) {
|
||||||
@ -58,18 +65,28 @@ function loadServerList() {
|
|||||||
function setGameInfo(serverUUID) {
|
function setGameInfo(serverUUID) {
|
||||||
var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0];
|
var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0];
|
||||||
var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0];
|
var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0];
|
||||||
|
|
||||||
window.asseturl = gameversion.url
|
window.asseturl = gameversion.url
|
||||||
|
|
||||||
remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl);
|
remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl);
|
||||||
remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip);
|
remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip);
|
||||||
// TODO: write rank endpoint
|
|
||||||
remotefs.writeFileSync(__dirname+"\\rankurl.txt", "http://api.dexlabs.systems/getranks");
|
if (result.hasOwnProperty('endpoint')) {
|
||||||
|
var rankurl = result.endpoint.replace("https://", "http://") + "getranks"
|
||||||
|
console.log("Using rank endpoint " + rankurl)
|
||||||
|
remotefs.writeFileSync(__dirname+"\\rankurl.txt", rankurl);
|
||||||
|
} else {
|
||||||
|
// delete the file, this server won't be using it
|
||||||
|
remotefs.unlinkSync(__dirname+"\\rankurl.txt")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSelectedServer() {
|
||||||
|
return $("tr.bg-primary").prop("id");
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectToServer() {
|
function connectToServer() {
|
||||||
// Get ID of the selected server, which corresponds to its UUID in the json
|
// Get ID of the selected server, which corresponds to its UUID in the json
|
||||||
var uuid = $("tr.bg-primary").prop("id");
|
var uuid = getSelectedServer();
|
||||||
console.log("Connecting to server with UUID of " + uuid);
|
console.log("Connecting to server with UUID of " + uuid);
|
||||||
|
|
||||||
// prevent the user from clicking anywhere else during the transition
|
// prevent the user from clicking anywhere else during the transition
|
||||||
|
@ -39,8 +39,8 @@
|
|||||||
</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"><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 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()">Connect <i class="fas fa-angle-double-right"></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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal fade" role="dialog" tabindex="-1" id="of-aboutmodal">
|
<div class="modal fade" role="dialog" tabindex="-1" id="of-aboutmodal">
|
||||||
@ -73,7 +73,7 @@
|
|||||||
<option value="" selected="" id="addserver-versionlist-placeholder" disabled="">Please select a verison...</option>
|
<option value="" selected="" id="addserver-versionlist-placeholder" disabled="">Please select a verison...</option>
|
||||||
</select></form>
|
</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 disabled border rounded border-primary btn-success border-success" id="addserver-savebutton" type="submit" data-dismiss="modal" disabled="" form="addserver-form">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 disabled border rounded border-primary btn-success border-success" id="addserver-savebutton" type="submit" data-dismiss="modal" disabled="" form="addserver-form" onclick="addServer();">Save</button></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -86,7 +86,7 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p class="lead">Do you really want to delete <a id="deleteserver-servername">SERVER_NAME</a>?<br>You could always re-add it later.</p>
|
<p class="lead">Do you really want to delete <a id="deleteserver-servername">SERVER_NAME</a>?<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">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>
|
||||||
|
18
resources/app/files/initialsetup.html
Normal file
18
resources/app/files/initialsetup.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OpenFusion: Initial Setup</title>
|
||||||
|
</head>
|
||||||
|
<body style="overflow:hidden;background-color:#000;user-select:none;-webkit-user-select:none;">
|
||||||
|
<center>
|
||||||
|
<div><img src="assets/img/of-3.png" width="256">
|
||||||
|
<div>
|
||||||
|
<img src="assets/img/spinner.gif" width=50px/>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</center>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -15,19 +15,25 @@ function copyFile(src, dst) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initialSetup() {
|
function initialSetup() {
|
||||||
|
// 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.loadUrl('file://' + __dirname + '/files/initialsetup.html');
|
||||||
// Exec installUnity.bat and wait for it to finish.
|
// Exec installUnity.bat and wait for it to finish.
|
||||||
require('child_process').execFileSync('cmd.exe', ['/c', 'utils\\installUnity.bat']);
|
var child = require('child_process').spawn('cmd.exe', ['/c', 'utils\\installUnity.bat']);
|
||||||
|
child.on('exit', function() {
|
||||||
console.log("Unity installed.");
|
console.log("Unity installed.");
|
||||||
|
|
||||||
// Copy over files with default values
|
// Copy over files with default values
|
||||||
copyFile(__dirname+"\\default_config.json", app.getPath('userData')+"\\config.json");
|
copyFile(__dirname+"\\default_config.json", app.getPath('userData')+"\\config.json");
|
||||||
copyFile(__dirname+"\\default_servers.json", app.getPath('userData')+"\\servers.json");
|
copyFile(__dirname+"\\default_servers.json", app.getPath('userData')+"\\servers.json");
|
||||||
copyFile(__dirname+"\\default_versions.json", app.getPath('userData')+"\\versions.json");
|
copyFile(__dirname+"\\default_versions.json", app.getPath('userData')+"\\versions.json");
|
||||||
console.log("JSON files copied.")
|
console.log("JSON files copied.");
|
||||||
|
setupWindow.destroy();
|
||||||
|
showMainWindow();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.on("exit", function(id) {
|
ipc.on("exit", function(id) {
|
||||||
mainWindow.destroy()
|
mainWindow.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
@ -48,26 +54,34 @@ app.on('ready', function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the browser window.
|
||||||
|
mainWindow = new BrowserWindow({width: 1280, height: 720, show: false, "web-preferences": {"plugins": true}});
|
||||||
|
mainWindow.setMinimumSize(640, 480);
|
||||||
|
|
||||||
// Check for first run
|
// Check for first run
|
||||||
try {
|
try {
|
||||||
if (!fs.existsSync(app.getPath('userData')+"\\config.json")) {
|
if (!fs.existsSync(app.getPath('userData')+"\\config.json")) {
|
||||||
console.log("Config file not found. Running initial setup.");
|
console.log("Config file not found. Running initial setup.");
|
||||||
initialSetup();
|
initialSetup();
|
||||||
|
} else {
|
||||||
|
showMainWindow();
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("An error occurred while checking for the config.");
|
console.log("An error occurred while checking for the config.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the browser window.
|
|
||||||
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
|
// 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 = null;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function showMainWindow() {
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadUrl('file://' + __dirname + '/files/index.html');
|
mainWindow.loadUrl('file://' + __dirname + '/files/index.html');
|
||||||
|
|
||||||
@ -81,9 +95,7 @@ app.on('ready', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.webContents.openDevTools()
|
mainWindow.webContents.openDevTools()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mainWindow.on('closed', function() {
|
|
||||||
mainWindow = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user