mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
Add start of default content installation
This commit is contained in:
parent
a6dc3f9b41
commit
c1e114c576
4 changed files with 162 additions and 0 deletions
19
console/src/downloader.css
Normal file
19
console/src/downloader.css
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Proxima Nova';
|
||||||
|
src: url('vendor/ProximaNova/ProximaNova-Regular.otf');
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
font-family: "Proxima Nova", "Open Sans", Arial, Helvetica, sans-serif;
|
||||||
|
font-size: 1.022em;
|
||||||
|
line-height: 130%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
progress {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
25
console/src/downloader.html
Normal file
25
console/src/downloader.html
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>High Fidelity</title>
|
||||||
|
<script src="downloader.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="downloader.css"></link>
|
||||||
|
</head>
|
||||||
|
<body onload="ready()">
|
||||||
|
<div id="state-downloading" class="state">
|
||||||
|
<progress max="100" value="80" id="download-progress"></progress>
|
||||||
|
</div>
|
||||||
|
<div id="state-installing" class="state">
|
||||||
|
Installing!
|
||||||
|
</div>
|
||||||
|
<div id="state-error" class="state">
|
||||||
|
Error :(
|
||||||
|
<div id='error-message'></div>
|
||||||
|
<button>OK</button>
|
||||||
|
</div>
|
||||||
|
<div id="state-complete" class="state">
|
||||||
|
Complete
|
||||||
|
<button>OK</button>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
37
console/src/downloader.js
Normal file
37
console/src/downloader.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
function ready() {
|
||||||
|
console.log("Ready");
|
||||||
|
|
||||||
|
const electron = require('electron');
|
||||||
|
window.$ = require('./vendor/jquery/jquery-2.1.4.min.js');
|
||||||
|
|
||||||
|
$(".state").hide();
|
||||||
|
|
||||||
|
var currentState = null;
|
||||||
|
|
||||||
|
function updateState(state, args) {
|
||||||
|
console.log(state, args);
|
||||||
|
|
||||||
|
if (state == 'downloading') {
|
||||||
|
console.log("Updating progress bar");
|
||||||
|
$('#download-progress').attr('value', args.progress * 100);
|
||||||
|
} else if (state == 'installing') {
|
||||||
|
} else if (state == 'complete') {
|
||||||
|
} else if (state == 'error') {
|
||||||
|
$('#error-message').innerHTML = args.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentState != state) {
|
||||||
|
if (currentState) {
|
||||||
|
$('#state-' + currentState).hide();
|
||||||
|
}
|
||||||
|
$('#state-' + state).show();
|
||||||
|
currentState = state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
electron.ipcRenderer.on('update', function(event, message) {
|
||||||
|
updateState(message.state, message.args);
|
||||||
|
});
|
||||||
|
|
||||||
|
updateState('downloading', { progress: 0 });
|
||||||
|
}
|
|
@ -15,6 +15,10 @@ var fs = require('fs');
|
||||||
var Tail = require('always-tail');
|
var Tail = require('always-tail');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var unzip = require('unzip');
|
||||||
|
|
||||||
|
var request = require('request');
|
||||||
|
var progress = require('request-progress');
|
||||||
|
|
||||||
var Config = require('./modules/config').Config;
|
var Config = require('./modules/config').Config;
|
||||||
|
|
||||||
|
@ -289,6 +293,77 @@ function updateTrayMenu(serverState) {
|
||||||
|
|
||||||
const httpStatusPort = 60332;
|
const httpStatusPort = 60332;
|
||||||
|
|
||||||
|
function maybeInstallDefaultContentSet() {
|
||||||
|
var hasRun = userConfig.get('hasRun', false);
|
||||||
|
|
||||||
|
if (false && hasRun) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show popup
|
||||||
|
var window = new BrowserWindow({
|
||||||
|
icon: APP_ICON,
|
||||||
|
width: 400,
|
||||||
|
height: 160,
|
||||||
|
center: true,
|
||||||
|
frame: true,
|
||||||
|
useContentSize: true,
|
||||||
|
resizable: false
|
||||||
|
});
|
||||||
|
window.loadURL('file://' + __dirname + '/downloader.html');
|
||||||
|
// window.setMenu(null);
|
||||||
|
window.show();
|
||||||
|
|
||||||
|
function sendStateUpdate(state, args) {
|
||||||
|
console.log(state, args);
|
||||||
|
window.webContents.send('update', { state: state, args: args });
|
||||||
|
}
|
||||||
|
|
||||||
|
var unzipper = unzip.Extract({ path: 'download2', verbose: true });
|
||||||
|
unzipper.on('close', function() {
|
||||||
|
console.log("Done", arguments);
|
||||||
|
sendStateUpdate('complete');
|
||||||
|
})
|
||||||
|
unzipper.on('error', function (err) {
|
||||||
|
console.log("ERROR");
|
||||||
|
sendStateUpdate('error', {
|
||||||
|
message: "Error installing resources."
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// responseMessage.pipe(unzipper);
|
||||||
|
// responseData.pipe(process.stdout);
|
||||||
|
// console.log("UNZIPPING");
|
||||||
|
|
||||||
|
// Start downloading content set
|
||||||
|
progress(request.get({
|
||||||
|
url: "http://localhost:8000/contentSet.zip",
|
||||||
|
// url: "http://builds.highfidelity.com/interface-win64-3908.xe"
|
||||||
|
}, function(error, responseMessage, responseData) {
|
||||||
|
if (error || responseMessage.statusCode != 200) {
|
||||||
|
var message = '';
|
||||||
|
if (error) {
|
||||||
|
message = "Error contacting resource server.";
|
||||||
|
} else {
|
||||||
|
message = "Error downloading resources from server.";
|
||||||
|
}
|
||||||
|
sendStateUpdate('error', {
|
||||||
|
message: message
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
sendStateUpdate('installing');
|
||||||
|
}
|
||||||
|
}), { throttle: 250 }).on('progress', function(state) {
|
||||||
|
// Update progress popup
|
||||||
|
console.log("progress", state);
|
||||||
|
sendStateUpdate('downloading', { progress: state.percentage });
|
||||||
|
}).pipe(unzipper);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
userConfig.set('hasRun', true);
|
||||||
|
}
|
||||||
|
|
||||||
function maybeShowSplash() {
|
function maybeShowSplash() {
|
||||||
var suppressSplash = userConfig.get('doNotShowSplash', false);
|
var suppressSplash = userConfig.get('doNotShowSplash', false);
|
||||||
|
|
||||||
|
@ -313,6 +388,10 @@ function maybeShowSplash() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function detectExistingStackManagerResources() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
app.on('ready', function() {
|
app.on('ready', function() {
|
||||||
|
@ -327,6 +406,8 @@ app.on('ready', function() {
|
||||||
tray.setToolTip('High Fidelity');
|
tray.setToolTip('High Fidelity');
|
||||||
|
|
||||||
updateTrayMenu(ProcessGroupStates.STOPPED);
|
updateTrayMenu(ProcessGroupStates.STOPPED);
|
||||||
|
|
||||||
|
maybeInstallDefaultContentSet();
|
||||||
maybeShowSplash();
|
maybeShowSplash();
|
||||||
|
|
||||||
if (interfacePath && dsPath && acPath) {
|
if (interfacePath && dsPath && acPath) {
|
||||||
|
|
Loading…
Reference in a new issue