summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLawnCable <lawncable.tmw2@simonlaux.de>2018-05-22 18:22:02 -0400
committerLawnCable <lawncable.tmw2@simonlaux.de>2018-05-22 18:22:02 -0400
commit2e97e2f4265ab946be252c1a1090b168d114db7f (patch)
tree22a91bff8c250d16d45d6a64abddc6d2df07271c
parent6537f4538509f190a39c7188684ca454209dd710 (diff)
downloadelectron-2e97e2f4265ab946be252c1a1090b168d114db7f.tar.gz
electron-2e97e2f4265ab946be252c1a1090b168d114db7f.tar.bz2
electron-2e97e2f4265ab946be252c1a1090b168d114db7f.tar.xz
electron-2e97e2f4265ab946be252c1a1090b168d114db7f.zip
Test Download and running is working now for windows - but it is not done yet
-rw-r--r--Readme.md3
-rw-r--r--package-lock.json100
-rw-r--r--package.json4
-rw-r--r--src/main.ts6
-rw-r--r--src/main/manaplus/manaApp/windows.ts79
-rw-r--r--src/main/manaplus/manaplus.ts57
-rw-r--r--src/main/status.ts2
7 files changed, 182 insertions, 69 deletions
diff --git a/Readme.md b/Readme.md
index e0c0ace..103ed40 100644
--- a/Readme.md
+++ b/Readme.md
@@ -18,6 +18,7 @@ npm start
- Optional -> server data update on the launcher to enable the option for adding and chaining texture packs
+- adding custom gameservers
## Idea-State:
- Keyboard shortcut to show a game helper windows that can show different information and maybe even do stuff InGame (like a join event button that teleports you to the event)
@@ -28,3 +29,5 @@ npm start
- joining a Event with teleporting there (if logged in into the launcher)
- Show on which server the player plays
- Show in which world the Player is (if logged in into the launcher) {works that the launcher connects to the gameserver and asks him where the player is}
+
+- Display every screenshot for each server in the launcher and enable drag them out of there in other directories
diff --git a/package-lock.json b/package-lock.json
index 9ec8365..057bd9e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4,11 +4,23 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+ "@types/extract-zip": {
+ "version": "1.6.2",
+ "resolved": "https://registry.npmjs.org/@types/extract-zip/-/extract-zip-1.6.2.tgz",
+ "integrity": "sha1-XH60QcQRNhZ6QriLZAUeYmDCnoY="
+ },
+ "@types/fs-extra": {
+ "version": "5.0.2",
+ "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.2.tgz",
+ "integrity": "sha512-Q3FWsbdmkQd1ib11A4XNWQvRD//5KpPoGawA8aB2DR7pWKoW9XQv3+dGxD/Z1eVFze23Okdo27ZQytVFlweKvQ==",
+ "requires": {
+ "@types/node": "8.10.17"
+ }
+ },
"@types/node": {
"version": "8.10.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.17.tgz",
- "integrity": "sha512-3N3FRd/rA1v5glXjb90YdYUa+sOB7WrkU2rAhKZnF4TKD86Cym9swtulGuH0p9nxo7fP5woRNa8b0oFTpCO1bg==",
- "dev": true
+ "integrity": "sha512-3N3FRd/rA1v5glXjb90YdYUa+sOB7WrkU2rAhKZnF4TKD86Cym9swtulGuH0p9nxo7fP5woRNa8b0oFTpCO1bg=="
},
"ajv": {
"version": "5.5.2",
@@ -144,7 +156,6 @@
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz",
"integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=",
- "dev": true,
"requires": {
"inherits": "2.0.3",
"readable-stream": "2.3.6",
@@ -154,14 +165,12 @@
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
- "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
- "dev": true
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
- "dev": true,
"requires": {
"core-util-is": "1.0.2",
"inherits": "2.0.3",
@@ -176,7 +185,6 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
- "dev": true,
"requires": {
"safe-buffer": "5.1.2"
}
@@ -209,7 +217,6 @@
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
- "dev": true,
"requires": {
"ms": "2.0.0"
}
@@ -292,6 +299,30 @@
"rc": "1.2.7",
"semver": "5.5.0",
"sumchecker": "1.3.1"
+ },
+ "dependencies": {
+ "fs-extra": {
+ "version": "0.30.0",
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
+ "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
+ "dev": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "jsonfile": "2.4.0",
+ "klaw": "1.3.1",
+ "path-is-absolute": "1.0.1",
+ "rimraf": "2.6.2"
+ }
+ },
+ "jsonfile": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
+ "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
+ "dev": true,
+ "requires": {
+ "graceful-fs": "4.1.11"
+ }
+ }
}
},
"error-ex": {
@@ -318,7 +349,6 @@
"version": "1.6.6",
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.6.tgz",
"integrity": "sha1-EpDt6NINCHK0Kf0/NRyhKOxe+Fw=",
- "dev": true,
"requires": {
"concat-stream": "1.6.0",
"debug": "2.6.9",
@@ -345,7 +375,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz",
"integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=",
- "dev": true,
"requires": {
"pend": "1.2.0"
}
@@ -376,16 +405,13 @@
}
},
"fs-extra": {
- "version": "0.30.0",
- "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
- "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
- "dev": true,
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz",
+ "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==",
"requires": {
"graceful-fs": "4.1.11",
- "jsonfile": "2.4.0",
- "klaw": "1.3.1",
- "path-is-absolute": "1.0.1",
- "rimraf": "2.6.2"
+ "jsonfile": "4.0.0",
+ "universalify": "0.1.1"
}
},
"fs.realpath": {
@@ -425,8 +451,7 @@
"graceful-fs": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
- "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
- "dev": true
+ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
},
"har-schema": {
"version": "2.0.0",
@@ -486,8 +511,7 @@
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
- "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
- "dev": true
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"ini": {
"version": "1.3.5",
@@ -572,10 +596,9 @@
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
},
"jsonfile": {
- "version": "2.4.0",
- "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
- "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
- "dev": true,
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
+ "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"requires": {
"graceful-fs": "4.1.11"
}
@@ -679,7 +702,6 @@
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz",
"integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=",
- "dev": true,
"requires": {
"minimist": "0.0.8"
},
@@ -687,16 +709,14 @@
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
- "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
- "dev": true
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
- "dev": true
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"normalize-package-data": {
"version": "2.4.0",
@@ -800,8 +820,7 @@
"pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
- "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=",
- "dev": true
+ "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
},
"performance-now": {
"version": "2.1.0",
@@ -847,8 +866,7 @@
"process-nextick-args": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
- "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
- "dev": true
+ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
},
"progress-stream": {
"version": "1.2.0",
@@ -1176,8 +1194,7 @@
"typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
- "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
- "dev": true
+ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"typescript": {
"version": "2.8.3",
@@ -1185,11 +1202,15 @@
"integrity": "sha512-K7g15Bb6Ra4lKf7Iq2l/I5/En+hLIHmxWZGq3D4DIRNFxMNV6j2SHSvDOqs2tGd4UvD/fJvrwopzQXjLrT7Itw==",
"dev": true
},
+ "universalify": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz",
+ "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc="
+ },
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
- "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
- "dev": true
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"uuid": {
"version": "3.2.1",
@@ -1244,7 +1265,6 @@
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz",
"integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=",
- "dev": true,
"requires": {
"fd-slicer": "1.0.1"
}
diff --git a/package.json b/package.json
index 81c507a..de36d18 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,11 @@
"LICENSE"
],
"dependencies": {
+ "@types/extract-zip": "^1.6.2",
+ "@types/fs-extra": "^5.0.2",
"discord-rpc": "^3.0.0-beta.10",
+ "extract-zip": "^1.6.6",
+ "fs-extra": "^6.0.1",
"request": "^2.87.0",
"request-progress": "^3.0.0"
}
diff --git a/src/main.ts b/src/main.ts
index b9662dc..cf5ff4b 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -27,9 +27,6 @@ const createWindow = () => {
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/../assets/index.html`);
- // Open the DevTools.
- mainWindow.webContents.openDevTools();
-
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
@@ -94,9 +91,10 @@ import { ManaPlus } from './main/manaplus/manaplus';
ManaPlus.init();
ipcMain.on('play', async (event:any, arg:any) => {
+ if(Status.getStatus().playing)return;
console.log("play", arg);
Status.setPlaying(true);
- await ManaPlus.start(arg.server,arg.port,arg.engine,arg.username,arg.password);
+ await ManaPlus.start(arg.address,arg.port,arg.engine,arg.username,arg.password);
//Status.showError("Failed To Launch Mana Plus","Not implemented yet!","Launch Manaplus faild: Not Implemented");
return false;
});
diff --git a/src/main/manaplus/manaApp/windows.ts b/src/main/manaplus/manaApp/windows.ts
index 0728e32..a5f5b02 100644
--- a/src/main/manaplus/manaApp/windows.ts
+++ b/src/main/manaplus/manaApp/windows.ts
@@ -1,9 +1,10 @@
import { ManaPlusApp } from './manaApp.interface';
import { app } from 'electron';
-//import * as path from 'path';
-import * as fs from 'fs';
+import * as fs from 'fs-extra';
import { Status } from '../../status';
import {download, Progress as ProgressType} from '../../util/downloader';
+import * as extract from 'extract-zip';
+
export class ManaPlusAppWindows implements ManaPlusApp {
private path:string;
@@ -15,41 +16,99 @@ export class ManaPlusAppWindows implements ManaPlusApp {
this.path = ManaPath;
}
run(parameters: string[]): void {
+ Status.setActivity(`Starting ManaPlus`);
+ const gameExe = this.path+"\\Mana\\manaplus.exe";
+ console.log(gameExe, parameters);
+ const child = require('child_process').execFile(gameExe, parameters, function(err:Error, data:any) {
+ console.log(err);
+ console.log(data.toString());
+ });
+ child.on('close', ()=>{
+ Status.setPlaying(false);
+ Status.removeActivity();
+ });
+ child.on('error', ()=>{
+ Status.setPlaying(false);
+ //// TODO: Handle Error
+ });
}
getGameDir(): string {
- return this.path;
+ return this.path+"\\Mana\\";
}
getVersion(): Promise<string> {
- throw new Error("Not Installed.");
+ throw new Error("Not Implemented yet");
}
isInstalled(): boolean {
return fs.existsSync(this.path+"\\Mana\\manaplus.exe");
}
async update() {
+ fs.existsSync(app.getPath('userData')+"\\temp") || fs.mkdirSync(app.getPath('userData')+"\\temp");
// Get Update URL
Status.setProgress(500);
Status.setActivity("Fetching Download URL");
//// TODO: Fetch update url
Status.setProgress(-1);
const downloadURL = 'https://[URL]/Mana.zip';
+
+ const updateDestination:string = `${app.getPath('userData')}\\temp\\update.zip`;
try {
- await download(downloadURL, `${app.getPath('userData')}\\temp\\update.zip`, (state:ProgressType) => {
+ await download(downloadURL, updateDestination, (state:ProgressType) => {
Status.setProgress(Math.floor(state.percent*100));
Status.setActivity(`Downloading ManaPlus... ${state.speed}`);
console.log(state);
});
} catch (e){
console.log(e);
- Status.showError("ManaPlus download failed", e.message, `DL Failed: ${e.message}`);
- throw new Error("Download Error");
+
}
- Status.setProgress(100);
- Status.setActivity(`ManaPlus download completed`);
- Status.showError("Unziping isn't implemented yet", "WIP", "not further implemented")
+ Status.setProgress(500);
+ // Backup old files
+ Status.setActivity(`Backup Old version`);
+ try {
+ await fs.remove(this.path+'\\Mana2')
+ if(fs.existsSync(this.path+'\\Mana'))
+ await fs.move(this.path+'\\Mana', this.path+'\\Mana2');
+ console.log("Backup old version done.");
+ } catch (err) {
+ Status.showError("Backup old version Failed", err.message, `Backup old version Failed: ${err.message}`);
+ throw new Error("Backup error");
+ }
+
+ Status.setProgress(500);
+ Status.setActivity(`ManaPlus download completed. Unziping..`);
+ const extraction = new Promise((resolve, reject)=>{
+ extract(updateDestination, {dir: this.path }, function (err) {
+ if(err){
+ console.log(err);
+ Status.showError("ManaPlus unziping failed", err.message, `Unzip Failed: ${err.message}`);
+ reject(new Error("Extraction Error"));
+ }
+ resolve();
+ });
+ });
+ await extraction;
+
+ Status.setActivity('Unziping completed');
+
+ //IDEA: Check Integrity of gamefiles
+ // DELETE Old File and remove update file
+ Status.setActivity('Cleaning up (Deleting update files)');
+ try {
+ await fs.remove(this.path+'\\Mana2')
+ await fs.remove(updateDestination)
+ console.log('Cleanup done');
+ } catch (err) {
+ console.error(err);
+ Status.showError("Clean up Failed", "Please remove '"+updateDestination+"' and '"+'this.path'+'\\Mana2'+"' manualy", `Unzip Failed: ${err.message}`);
+ }
+ Status.setProgress(-1);
+ //Status.showError("Unziping isn't implemented yet", "WIP", "not further implemented")
+ Status.setActivity('Update successfull');
+
return 0;
}
updateAvailible(): Promise<{ isNewVersion: boolean; newestVersion: string; }> {
diff --git a/src/main/manaplus/manaplus.ts b/src/main/manaplus/manaplus.ts
index dfa86a7..22e4ffd 100644
--- a/src/main/manaplus/manaplus.ts
+++ b/src/main/manaplus/manaplus.ts
@@ -1,6 +1,10 @@
import { ManaPlusApp } from './ManaApp/manaApp.interface';
import { ManaPlusAppWindows } from './ManaApp/windows';
import * as os from 'os';
+import * as path from 'path';
+import * as fs from 'fs-extra';
+import { app } from 'electron';
+import { Status } from '../status';
let ManaPlusInstance:ManaPlusApp;
@@ -23,9 +27,15 @@ export namespace ManaPlus{
return await ManaPlusInstance.update();
}
- export async function start(server: any,engine: any,port: any,username: any,password: any){
-
- const params = makeParams(server,engine,port,username,password);
+ export async function start(server: any,port: any,engine: any,username: any,password: any){
+ let params:string[];
+ try {
+ params = await makeParams(server,port,engine,username,password);
+ } catch (e){
+ console.log(e);
+ Status.showError("Launch Preperation Failed", e.message, "Launch preparation failed")
+ return;
+ }
let willUpdate:boolean=false;
// check if it is installed
willUpdate = !ManaPlusInstance.isInstalled();
@@ -47,15 +57,34 @@ function wasInitilized(){
return typeof(ManaPlusInstance) !== "undefined" && typeof(ManaPlusInstance) !== "undefined";
}
-function makeParams(server: any,engine: any,port: any,username: any,password: any):string[]{
- // TODO check if everything is there
- var parameters = [
- "-s"+server,
- "-y"+engine,
- "-p"+port,
- "-U"+username,
- "-P"+password,
- ];
- // TODO make this function real
- return [];
+async function makeParams(server: any,port: any,engine: any,username?: any,password?: any):Promise<string[]>{
+ let parameters:string[] = [];
+ if(server && engine && port){
+ parameters.push(...[
+ "-s", server,
+ "-y", engine,
+ "-p", port
+ ]);
+ if(username && password){
+ parameters.push(...[
+ "-U", username,
+ "-P", password
+ ]);
+ }
+ }
+ // Setup Paths and stuff
+ const configDir = path.normalize(app.getPath('userData')+"/mana_config");
+ const localDataDir = path.normalize(app.getPath('userData')+"/mana_local_data");
+ const screenshotsDir = path.normalize(app.getPath('userData')+`/screenshots/${server}`);
+ await fs.ensureDir(configDir);
+ await fs.ensureDir(localDataDir);
+ await fs.ensureDir(screenshotsDir);
+ parameters.push(...[
+ "-C", configDir,
+ "-L", localDataDir,
+ "--screenshot-dir", screenshotsDir
+ ]);
+ console.log(parameters);
+
+ return parameters;
}
diff --git a/src/main/status.ts b/src/main/status.ts
index 537e31b..18fccd1 100644
--- a/src/main/status.ts
+++ b/src/main/status.ts
@@ -29,7 +29,7 @@ export namespace Status {
status.ActivityIsError=false;
updateStatus();
}
- export function removeActivity(value: string){
+ export function removeActivity(){
status.activity=null;
status.ActivityIsError=false;
updateStatus();