diff options
Diffstat (limited to 'src/main/status.ts')
-rw-r--r-- | src/main/status.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main/status.ts b/src/main/status.ts new file mode 100644 index 0000000..ffd6551 --- /dev/null +++ b/src/main/status.ts @@ -0,0 +1,47 @@ +import { mainWindow } from '../main'; + +type STATUS = { + progress:number, + activity:string, + playing:boolean, +} + +const status:STATUS = { + progress:null, + activity:null, + playing:false, //Is manaplus starting or started +} + +export namespace Status { + export function setProgress(value: number){ + status.progress=value; + updateStatus(); + } + export function removeProgress(){ + status.progress=null; + updateStatus(); + } + export function setActivity(value: string){ + status.activity=value; + updateStatus(); + } + export function setPlaying(value: boolean){ + status.playing=value; + updateStatus(); + } + export function getStatus():STATUS{ + return status; + } +} + +function updateStatus(){ + + if(status.progress==null || status.progress<0) + mainWindow.setProgressBar(-1); + else if(status.progress>100) + mainWindow.setProgressBar(2); + else + mainWindow.setProgressBar(status.progress/100); + + mainWindow.webContents.send('status-update', status); +} |