diff options
author | LawnCable <lawncable.tmw2@simonlaux.de> | 2018-05-22 01:32:10 -0400 |
---|---|---|
committer | LawnCable <lawncable.tmw2@simonlaux.de> | 2018-05-22 01:32:10 -0400 |
commit | 4fdd86da90dd811378b153de31da542f9fabb355 (patch) | |
tree | 59f78e5cdf361b9f513c6f3dd5f23639841b5d7e /src/main/manaplus/manaplus.ts | |
parent | d6ff248cee446218392567296cfcd2fb8723b066 (diff) | |
download | electron-4fdd86da90dd811378b153de31da542f9fabb355.tar.gz electron-4fdd86da90dd811378b153de31da542f9fabb355.tar.bz2 electron-4fdd86da90dd811378b153de31da542f9fabb355.tar.xz electron-4fdd86da90dd811378b153de31da542f9fabb355.zip |
started update logic for windows - only downloads the zip for now
Diffstat (limited to 'src/main/manaplus/manaplus.ts')
-rw-r--r-- | src/main/manaplus/manaplus.ts | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/manaplus/manaplus.ts b/src/main/manaplus/manaplus.ts new file mode 100644 index 0000000..dfa86a7 --- /dev/null +++ b/src/main/manaplus/manaplus.ts @@ -0,0 +1,61 @@ +import { ManaPlusApp } from './ManaApp/manaApp.interface'; +import { ManaPlusAppWindows } from './ManaApp/windows'; +import * as os from 'os'; + +let ManaPlusInstance:ManaPlusApp; + +export namespace ManaPlus{ + + export const ERRORS = { + NOT_INITILIZED_YET_ERROR:new Error("The ManaPlus updater wasn't initilized") + } + + export function init(){ + if(os.platform() == "win32"){ + ManaPlusInstance = new ManaPlusAppWindows(); + console.log("GameDir:"+ManaPlusInstance.getGameDir()); + } + } + + export async function update(){ + if(!wasInitilized())throw ERRORS.NOT_INITILIZED_YET_ERROR; + + 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); + let willUpdate:boolean=false; + // check if it is installed + willUpdate = !ManaPlusInstance.isInstalled(); + //Check if update is availible and ask if the user wants to update + //TODO + + // Install/Update the gameclient if needed + if(willUpdate){ + await update(); + } + + //IDEA have client data updated here to, if needed + ManaPlusInstance.run(params); + + } +} + +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 []; +} |