diff --git a/resources/app/default_servers.json b/resources/app/default_servers.json index c1468b3..2b75de4 100644 --- a/resources/app/default_servers.json +++ b/resources/app/default_servers.json @@ -11,7 +11,8 @@ "uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9", "description": "OpenFusion Public Server - Academy", "ip": "144.202.52.9:24000", - "version": "beta-20111013" + "version": "beta-20111013", + "endpoint": "https://api.dexlabs.systems/academy/" } ], "favorites": [] diff --git a/resources/app/files/assets/img/spinner.gif b/resources/app/files/assets/img/spinner.gif new file mode 100644 index 0000000..8ff6006 Binary files /dev/null and b/resources/app/files/assets/img/spinner.gif differ diff --git a/resources/app/files/assets/js/serverselector.js b/resources/app/files/assets/js/serverselector.js index 81471fe..16be006 100644 --- a/resources/app/files/assets/js/serverselector.js +++ b/resources/app/files/assets/js/serverselector.js @@ -7,12 +7,16 @@ var serverarray function enableServerListButtons() { $('#of-connect-button').removeClass('disabled'); + $('#of-connect-button').prop('disabled', false); $('#of-deleteserver-button').removeClass('disabled'); + $('#of-deleteserver-button').prop('disabled', false); } function disableServerListButtons() { $('#of-connect-button').addClass('disabled'); + $('#of-connect-button').prop('disabled', true); $('#of-deleteserver-button').addClass('disabled'); + $('#of-deleteserver-button').prop('disabled', true); } function loadGameVersions() { @@ -26,29 +30,32 @@ function loadGameVersions() { 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']; + 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' + $(".server-listing-entry").remove(); // clear out old stuff, if any + disableServerListButtons(); - row.appendChild(cellName); - row.appendChild(cellVersion); - document.getElementById('server-tablebody').appendChild(row); - }); - } else { + 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); } @@ -58,18 +65,28 @@ function loadServerList() { 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"); + + 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() { // 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); // prevent the user from clicking anywhere else during the transition diff --git a/resources/app/files/index.html b/resources/app/files/index.html index 7e795ae..4be623b 100644 --- a/resources/app/files/index.html +++ b/resources/app/files/index.html @@ -39,8 +39,8 @@
-
-
+
+
- + @@ -86,7 +86,7 @@ - + diff --git a/resources/app/files/initialsetup.html b/resources/app/files/initialsetup.html new file mode 100644 index 0000000..53f4cb1 --- /dev/null +++ b/resources/app/files/initialsetup.html @@ -0,0 +1,18 @@ + + + + OpenFusion: Initial Setup + + +
+
+
+ +
+
+

OpenFusion is setting up...
Please wait - this should take
less than a minute.

+
+
+
+ + \ No newline at end of file diff --git a/resources/app/index.js b/resources/app/index.js index fe41107..eb8500a 100644 --- a/resources/app/index.js +++ b/resources/app/index.js @@ -15,19 +15,25 @@ function copyFile(src, dst) { } 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. - require('child_process').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.") + var child = require('child_process').spawn('cmd.exe', ['/c', 'utils\\installUnity.bat']); + child.on('exit', function() { + 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."); + setupWindow.destroy(); + showMainWindow(); + }) } ipc.on("exit", function(id) { - mainWindow.destroy() + mainWindow.destroy(); }); // Quit when all windows are closed. @@ -43,31 +49,39 @@ app.on('ready', function() { if (zip_check) { errormsg = ("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); return; } - // Check for first run - try { - 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 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); + // Check for first run + try { + if (!fs.existsSync(app.getPath('userData')+"\\config.json")) { + console.log("Config file not found. Running initial setup."); + initialSetup(); + } else { + showMainWindow(); + } + } catch(e) { + console.log("An error occurred while checking for the config."); + } + // Makes it so external links are opened in the system browser, not Electron mainWindow.webContents.on('new-window', function(e, url) { e.preventDefault(); require('shell').openExternal(url); }); + mainWindow.on('closed', function() { + mainWindow = null; + }); +}); + +function showMainWindow() { // and load the index.html of the app. mainWindow.loadUrl('file://' + __dirname + '/files/index.html'); @@ -81,9 +95,7 @@ app.on('ready', function() { }); mainWindow.webContents.openDevTools() +} + - mainWindow.on('closed', function() { - mainWindow = null; - }); - -}); \ No newline at end of file + \ No newline at end of file diff --git a/utils/WebPlayer/UnityBugReporter.exe b/utils/WebPlayer/UnityBugReporter.exe deleted file mode 100644 index 05adf3f..0000000 Binary files a/utils/WebPlayer/UnityBugReporter.exe and /dev/null differ