Skip to content

Commit

Permalink
Added ability to unpause with Esc
Browse files Browse the repository at this point in the history
  • Loading branch information
adamthedog committed Feb 1, 2024
1 parent b2e0179 commit fcf1116
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/components/Puzzle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ export const Puzzle = ({
// Pause when page goes out of focus
function prodPause() {
if (process.env.NODE_ENV !== 'development' && !props.prefs?.dontPauseOnLostFocus) {

window.parent.postMessage(
{
type: 'pause',
Expand Down Expand Up @@ -683,9 +682,9 @@ export const Puzzle = ({

const physicalKeyboardHandler = useCallback(
(e: KeyboardEvent) => {
// Disable keyboard when paused / loading play
// Disable keyboard when loading play
if (!(state.success && state.dismissedSuccess)) {
if (loadingPlayState || !state.currentTimeWindowStart) {
if (loadingPlayState) {
return;
}
}
Expand Down
13 changes: 13 additions & 0 deletions app/reducers/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,19 @@ export function gridInterfaceReducer<T extends GridInterfaceState>(
}
if (isKeypressAction(action)) {
const key = action.key;
// Resume on Esc, but only during midgame pause
if (isPuzzleState(state) && !state.currentTimeWindowStart) {
if (state.bankedSeconds === 0) {
return state;
}
if (key.k === KeyK.Escape) {
return {
...state,
currentTimeWindowStart: new Date().getTime()
}
}
return state;
}
if (key.k === KeyK.NumLayout || key.k === KeyK.AbcLayout) {
return { ...state, showExtraKeyLayout: !state.showExtraKeyLayout };
}
Expand Down

0 comments on commit fcf1116

Please sign in to comment.