File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ export default function ({ scaffolding }) {
3636
3737 // Immediately emit project stop
3838 // Scratch will do this automatically, but there may be a slight delay.
39- vm . runtime . emit ( "PROJECT_RUN_STOP" ) ;
39+ vm . runtime . emit ( 'PROJECT_RUN_STOP' ) ;
40+ vm . runtime . emit ( 'RUNTIME_PAUSED' ) ;
4041 } else {
4142 audioContextStateChange = audioContextStateChange . then ( ( ) => {
4243 return vm . runtime . audioEngine . audioContext . resume ( ) ;
@@ -61,9 +62,9 @@ export default function ({ scaffolding }) {
6162 }
6263 }
6364 pausedThreadState = new WeakMap ( ) ;
64- }
6565
66- vm . emit ( 'P4_PAUSE' , paused ) ;
66+ vm . runtime . emit ( 'RUNTIME_UNPAUSED' ) ;
67+ }
6768 } ;
6869
6970 const ensurePausedThreadIsStillPaused = ( thread ) => {
Original file line number Diff line number Diff line change @@ -1501,15 +1501,21 @@ cd "$(dirname "$0")"
15011501 pauseButton.addEventListener('click', () => {
15021502 vm.setPaused(!isPaused);
15031503 });
1504- const updatePause = (_isPaused) => {
1505- isPaused = _isPaused;
1504+ const updatePause = () => {
15061505 if (isPaused) {
15071506 pauseButton.src = 'data:image/svg+xml,' + encodeURIComponent('<svg width="16" height="16" viewBox="0 0 4.2333332 4.2333335" xmlns="http://www.w3.org/2000/svg"><path d="m3.95163484 2.02835365-1.66643921.9621191-1.66643913.96211911V.10411543l1.66643922.9621191z" fill="#ffae00"/></svg>');
15081507 } else {
15091508 pauseButton.src = 'data:image/svg+xml,' + encodeURIComponent('<svg width="16" height="16" viewBox="0 0 4.2333332 4.2333335" xmlns="http://www.w3.org/2000/svg"><g fill="#ffae00"><path d="M.389.19239126h1.2631972v3.8485508H.389zM2.5810001.19239126h1.2631972v3.8485508H2.5810001z"/></g></svg>');
15101509 }
1511- }
1512- vm.on('P4_PAUSE', updatePause);
1510+ };
1511+ vm.runtime.on('RUNTIME_PAUSED', () => {
1512+ isPaused = true;
1513+ updatePause();
1514+ });
1515+ vm.runtime.on('RUNTIME_UNPAUSED', () => {
1516+ isPaused = false;
1517+ updatePause();
1518+ });
15131519 updatePause();
15141520 scaffolding.addControlButton({
15151521 element: pauseButton,
You can’t perform that action at this time.
0 commit comments