chore: Improve build

This commit is contained in:
Felix Rieseberg 2019-08-24 16:58:21 +02:00
parent 7653d7294c
commit 186a2a8ba9
10 changed files with 77 additions and 57 deletions

View file

@ -17,6 +17,18 @@ module.exports = {
osxSign: { osxSign: {
identity: 'Developer ID Application: Felix Rieseberg (LT94ZKYDCJ)' identity: 'Developer ID Application: Felix Rieseberg (LT94ZKYDCJ)'
}, },
ignore: [
/\/assets(\/?)/,
/\/docs(\/?)/,
/\/tools(\/?)/,
/\/src\/.*\.ts/,
/package-lock\.json/,
/README\.md/,
/tsconfig\.json/,
/Dockerfile/,
/issue_template\.md/,
/HELP\.md/,
]
}, },
makers: [ makers: [
{ {

View file

@ -22,6 +22,7 @@ export const IPC_COMMANDS = {
MACHINE_STOP: 'MACHINE_STOP', MACHINE_STOP: 'MACHINE_STOP',
MACHINE_RESET: 'MACHINE_RESET', MACHINE_RESET: 'MACHINE_RESET',
MACHINE_ALT_F4: 'MACHINE_ALT_F4', MACHINE_ALT_F4: 'MACHINE_ALT_F4',
MACHINE_ESC: 'MACHINE_ESC',
MACHINE_ALT_ENTER: 'MACHINE_ALT_ENTER', MACHINE_ALT_ENTER: 'MACHINE_ALT_ENTER',
MACHINE_CTRL_ALT_DEL: 'MACHINE_CTRL_ALT_DEL', MACHINE_CTRL_ALT_DEL: 'MACHINE_CTRL_ALT_DEL',
// Machine events // Machine events

View file

@ -2,6 +2,7 @@
@import "./emulator.less"; @import "./emulator.less";
@import "./info.less"; @import "./info.less";
@import "./settings.less"; @import "./settings.less";
@import "./start.less";
/* GENERAL RESETS */ /* GENERAL RESETS */
@ -51,7 +52,6 @@ section {
.nav-link > img, .nav-link > img,
.btn > img { .btn > img {
height: 24px; height: 24px;
margin-top: -3px;
margin-right: 4px; margin-right: 4px;
} }
@ -66,8 +66,7 @@ section {
nav .nav-link, nav .nav-link,
nav .nav-logo { nav .nav-logo {
height: 33px; height: 37px;
line-height: 1.5;
display: flex; display: flex;
} }
@ -85,7 +84,7 @@ section {
.btn { .btn {
height: 40px; height: 40px;
padding-top: 6px; padding-top: 3px;
} }
.btn:focus { .btn:focus {

9
src/less/start.less Normal file
View file

@ -0,0 +1,9 @@
#section-start {
display: flex;
flex-direction: column;
> small {
margin-top: 25px;
font-size: .8rem;
}
}

View file

@ -140,6 +140,11 @@ async function createMenu({ isRunning } = { isRunning: false }) {
click: () => send(IPC_COMMANDS.MACHINE_ALT_ENTER), click: () => send(IPC_COMMANDS.MACHINE_ALT_ENTER),
enabled: isRunning enabled: isRunning
}, },
{
label: "Send Esc",
click: () => send(IPC_COMMANDS.MACHINE_ESC),
enabled: isRunning
},
{ {
type: "separator" type: "separator"
}, },

View file

@ -11,7 +11,9 @@ export function getOrCreateWindow(): BrowserWindow {
height: 768, height: 768,
useContentSize: true, useContentSize: true,
webPreferences: { webPreferences: {
nodeIntegration: true nodeIntegration: true,
sandbox: false,
webviewTag: false
} }
}); });

View file

@ -7,18 +7,12 @@ export interface CardStartProps {
export class CardStart extends React.Component<CardStartProps, {}> { export class CardStart extends React.Component<CardStartProps, {}> {
public render() { public render() {
return ( return (
<section id="section-start" className="visible"> <section id="section-start">
<div <button className="btn" id="win95" onClick={this.props.startEmulator}>
className="btn btn-start"
id="win95"
onClick={this.props.startEmulator}
>
<img src="../../static/run.png" /> <img src="../../static/run.png" />
<span>Start Windows 95</span> <span>Start Windows 95</span>
<br /> </button>
<br /> <small>Hit ESC to lock or unlock your mouse</small>
<small>Hit ESC to lock or unlock your mouse</small>
</div>
</section> </section>
); );
} }

View file

@ -69,6 +69,8 @@ export class Emulator extends React.Component<{}, EmulatorState> {
} else { } else {
this.lockMouse(); this.lockMouse();
} }
evt.stopPropagation();
} }
}; };
@ -117,44 +119,31 @@ export class Emulator extends React.Component<{}, EmulatorState> {
*/ */
public setupIpcListeners() { public setupIpcListeners() {
ipcRenderer.on(IPC_COMMANDS.MACHINE_CTRL_ALT_DEL, () => { ipcRenderer.on(IPC_COMMANDS.MACHINE_CTRL_ALT_DEL, () => {
if (this.state.emulator && this.state.isRunning) { this.sendKeys([
this.state.emulator.keyboard_send_scancodes([ 0x1d, // ctrl
0x1d, // ctrl 0x38, // alt
0x38, // alt 0x53 // delete
0x53, // delete ]);
// break codes
0x1d | 0x80,
0x38 | 0x80,
0x53 | 0x80
]);
}
}); });
ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_F4, () => { ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_F4, () => {
if (this.state.emulator && this.state.isRunning) { this.sendKeys([
this.state.emulator.keyboard_send_scancodes([ 0x38, // alt
0x38, // alt 0x3e // f4
0x3e, // f4 ]);
// break codes
0x38 | 0x80,
0x3e | 0x80
]);
}
}); });
ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_ENTER, () => { ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_ENTER, () => {
if (this.state.emulator && this.state.isRunning) { this.sendKeys([
this.state.emulator.keyboard_send_scancodes([ 0x38, // alt
0x38, // alt 0 // enter
0, // enter ]);
});
// break codes ipcRenderer.on(IPC_COMMANDS.MACHINE_ESC, () => {
0x38 | 0x80, this.sendKeys([
0 | 0x80 0x18 // alt
]); ]);
}
}); });
ipcRenderer.on(IPC_COMMANDS.MACHINE_STOP, this.stopEmulator); ipcRenderer.on(IPC_COMMANDS.MACHINE_STOP, this.stopEmulator);
@ -467,4 +456,23 @@ export class Emulator extends React.Component<{}, EmulatorState> {
this.setState({ scale: target }); this.setState({ scale: target });
} }
} }
/**
* Send keys to the emulator (including the key-up),
* if it's running
*
* @param {Array<number>} codes
*/
private sendKeys(codes: Array<number>) {
if (this.state.emulator && this.state.isRunning) {
const scancodes = codes;
// Push break codes (key-up)
for (const scancode of scancodes) {
scancodes.push(scancode | 0x80);
}
this.state.emulator.keyboard_send_scancodes(scancodes);
}
}
} }

View file

@ -12,15 +12,5 @@
<body class="paused windows95"> <body class="paused windows95">
<div id="app"></div> <div id="app"></div>
<script src="../src/renderer/app.tsx"></script> <script src="../src/renderer/app.tsx"></script>
<link rel="prefetch" href="../static/boot-fresh.png" />
<link rel="prefetch" href="../static/drive.png" />
<link rel="prefetch" href="../static/floppy.png" />
<link rel="prefetch" href="../static/reset-state.png" />
<link rel="prefetch" href="../static/reset.png" />
<link rel="prefetch" href="../static/run.png" />
<link rel="prefetch" href="../static/select-floppy.png" />
<link rel="prefetch" href="../static/settings.png" />
<link rel="prefetch" href="../static/show-disk-image.png" />
<link rel="prefetch" href="../static/start.png" />
</body> </body>
</html> </html>

View file

@ -25,7 +25,7 @@ async function compileParcel (options = {}) {
// key: './ssl/k.key' // path to custom key // key: './ssl/k.key' // path to custom key
// }, // },
logLevel: 3, // 3 = log everything, 2 = log warnings & errors, 1 = log errors logLevel: 3, // 3 = log everything, 2 = log warnings & errors, 1 = log errors
hmr: true, // Enable or disable HMR while watching hmr: false, // Enable or disable HMR while watching
hmrPort: 0, // The port the HMR socket runs on, defaults to a random free port (0 in node.js resolves to a random free port) hmrPort: 0, // The port the HMR socket runs on, defaults to a random free port (0 in node.js resolves to a random free port)
sourceMaps: true, // Enable or disable sourcemaps, defaults to enabled (minified builds currently always create sourcemaps) sourceMaps: true, // Enable or disable sourcemaps, defaults to enabled (minified builds currently always create sourcemaps)
hmrHostname: '', // A hostname for hot module reload, default to '' hmrHostname: '', // A hostname for hot module reload, default to ''