storm button hotkeys
parent
e17ad7c8ff
commit
cc91171bca
|
@ -41,12 +41,14 @@ export default class StormCtrl {
|
||||||
};
|
};
|
||||||
this.promotion = makePromotion(this.withGround, this.makeCgOpts, redraw);
|
this.promotion = makePromotion(this.withGround, this.makeCgOpts, redraw);
|
||||||
this.checkDupTab();
|
this.checkDupTab();
|
||||||
|
setTimeout(this.hotkeys, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
clockMillis = (): number | undefined =>
|
clockMillis = (): number | undefined =>
|
||||||
this.vm.run.startAt && Math.max(0, this.vm.run.startAt + this.vm.clock - getNow());
|
this.vm.run.startAt && Math.max(0, this.vm.run.startAt + this.vm.clock - getNow());
|
||||||
|
|
||||||
end = (): void => {
|
end = (): void => {
|
||||||
|
if (!this.vm.puzzleStartAt) return;
|
||||||
this.vm.history.reverse();
|
this.vm.history.reverse();
|
||||||
this.vm.run.endAt = getNow();
|
this.vm.run.endAt = getNow();
|
||||||
this.ground(false);
|
this.ground(false);
|
||||||
|
@ -244,4 +246,11 @@ export default class StormCtrl {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private hotkeys = () => {
|
||||||
|
window.Mousetrap
|
||||||
|
.bind('space', () => location.reload())
|
||||||
|
.bind('return', this.end);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,17 +49,15 @@ const renderControls = (ctrl: StormCtrl): VNode =>
|
||||||
attrs: {
|
attrs: {
|
||||||
href: '/storm',
|
href: '/storm',
|
||||||
'data-icon': 'B',
|
'data-icon': 'B',
|
||||||
title: 'New run'
|
title: 'New run (hotkey: Space)'
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
h('a.storm__control__end.button.button-empty', {
|
h('a.storm__control__end.button.button-empty', {
|
||||||
attrs: {
|
attrs: {
|
||||||
'data-icon': 'b',
|
'data-icon': 'b',
|
||||||
title: 'End run',
|
title: 'End run (hotkey: Enter)',
|
||||||
},
|
},
|
||||||
hook: onInsert(el => el.addEventListener('click', () => {
|
hook: onInsert(el => el.addEventListener('click', ctrl.end))
|
||||||
if (ctrl.vm.puzzleStartAt) ctrl.end()
|
|
||||||
}))
|
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue