Commit 8d68125 1 parent 3a4c029 commit 8d68125 Copy full SHA for 8d68125
File tree 3 files changed +27
-20
lines changed
3 files changed +27
-20
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ export async function init(): Promise<void> {
80
80
if ( toRun ) {
81
81
goToGame ( toRun ) ;
82
82
} else {
83
- await processLocationChange ( window . location . search , { paused : false } ) ;
83
+ await processLocationChange ( window . location . search ) ;
84
84
}
85
85
baseInit$ . set ( true ) ;
86
86
}
Original file line number Diff line number Diff line change @@ -71,24 +71,27 @@ export const gameSourceMap$ = atom((get) => {
71
71
} ) ;
72
72
73
73
history . listen ( ( { location } ) => {
74
- processLocationChange ( location . search , location . state as Record < string , unknown > | null ) ;
74
+ processLocationChange ( location . search ) ;
75
75
} ) ;
76
76
77
- export async function processLocationChange ( location : string , state : Record < string , unknown > | null ) : Promise < void > {
78
- if ( state ) {
79
- if ( state . paused ) {
80
- onOpenPauseScreen ( ) ;
81
- } else {
82
- onClosePauseScreen ( ) ;
83
- }
84
- }
77
+ export async function processLocationChange ( location : string ) : Promise < void > {
85
78
const search = new URLSearchParams ( location ) ;
86
79
const game_id = search . get ( 'run' ) ;
87
80
if ( game_id ) {
88
- if ( currentGame$ . value ?. id === game_id ) return ;
81
+ if ( currentGame$ . value ?. id === game_id ) {
82
+ if ( search . has ( 'pause' ) ) {
83
+ onOpenPauseScreen ( ) ;
84
+ } else {
85
+ onClosePauseScreen ( ) ;
86
+ }
87
+ return ;
88
+ }
89
89
await initDeferred$ . value . promise ;
90
90
const descriptor = games$ . value [ game_id ] ;
91
91
await runGame ( descriptor ) ;
92
+ if ( search . has ( 'pause' ) ) {
93
+ onOpenPauseScreen ( ) ;
94
+ }
92
95
currentMode$ . set ( 'game' ) ;
93
96
} else if ( search . has ( 'catalog' ) ) {
94
97
if ( currentGameEntry$ . value ) stopCurrentGame ( ) ;
Original file line number Diff line number Diff line change @@ -7,22 +7,26 @@ export const isPauseScreenVisible$ = atom(false);
7
7
export const pauseScreenCurrentPanel$ = atom ( 'credits' ) ;
8
8
9
9
export function openPauseScreen ( ) : void {
10
- history . push (
11
- {
12
- search : history . location . search ,
13
- } ,
14
- {
15
- paused : true ,
16
- } ,
17
- ) ;
10
+ const search = new URLSearchParams ( history . location . search ) ;
11
+ search . set ( 'pause' , 'true' ) ;
12
+ history . push ( {
13
+ search : search . toString ( ) ,
14
+ } ) ;
18
15
}
19
16
20
17
export function onOpenPauseScreen ( ) : void {
21
18
isPauseScreenVisible$ . set ( true ) ;
22
19
}
23
20
24
21
export function closePauseScreen ( ) : void {
25
- history . back ( ) ;
22
+ if ( window . history . length > 1 ) {
23
+ return history . back ( ) ;
24
+ }
25
+ const search = new URLSearchParams ( history . location . search ) ;
26
+ search . delete ( 'pause' ) ;
27
+ history . push ( {
28
+ search : search . toString ( ) ,
29
+ } ) ;
26
30
}
27
31
28
32
export function onClosePauseScreen ( ) : void {
You can’t perform that action at this time.
0 commit comments