windows95/src/preload.js

43 lines
1 KiB
JavaScript
Raw Normal View History

2018-08-25 08:01:33 +02:00
const { remote, shell, ipcRenderer } = require('electron')
2018-08-25 05:55:18 +02:00
const path = require('path')
2019-02-03 22:49:09 +01:00
const EventEmitter = require('events')
2018-08-23 07:03:28 +02:00
2019-02-03 22:49:09 +01:00
const { resetState, restoreState, saveState } = require('./state')
const { getDiskImageSize } = require('./utils/disk-image-size')
const { IPC_COMMANDS, CONSTANTS } = require('./constants')
2018-08-23 07:03:28 +02:00
2019-02-03 22:49:09 +01:00
class Windows95 extends EventEmitter {
constructor () {
super()
// Constants
this.CONSTANTS = CONSTANTS
2019-02-03 23:02:30 +01:00
this.IPC_COMMANDS = IPC_COMMANDS
2019-02-03 22:49:09 +01:00
// Methods
this.getDiskImageSize = getDiskImageSize
this.restoreState = restoreState
this.resetState = resetState
this.saveState = saveState
Object.keys(IPC_COMMANDS).forEach((command) => {
ipcRenderer.on(command, (...args) => {
this.emit(command, args)
})
})
}
2018-08-23 07:32:07 +02:00
2018-08-25 08:01:33 +02:00
showDiskImage () {
2018-08-25 05:55:18 +02:00
const imagePath = path.join(__dirname, 'images/windows95.img')
.replace('app.asar', 'app.asar.unpacked')
2018-08-25 05:55:18 +02:00
shell.showItemInFolder(imagePath)
2019-02-03 22:49:09 +01:00
}
2018-08-25 05:55:18 +02:00
2019-02-03 22:49:09 +01:00
quit () {
remote.app.quit()
}
2018-08-23 07:03:28 +02:00
}
2018-08-25 08:01:33 +02:00
2019-02-03 22:49:09 +01:00
window.windows95 = new Windows95()