Skip to content

Commit

Permalink
centralize in simdriver
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll committed Aug 28, 2023
1 parent f3ef1ce commit 00b73d9
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion multiplayer/src/services/simHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ export async function simulateAsync(
driver.options.onSimulatorCommand = msg => {
if (msg.command === "restart") {
runOptions.storedState = getStoredState(runOpts);
driver.stopSound();
driver.run(js, runOptions);
}
if (msg.command == "setstate") {
Expand Down
1 change: 0 additions & 1 deletion pxtrunner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ namespace pxt.runner {
simDriver.options.onSimulatorCommand = msg => {
if (msg.command === "restart") {
runOptions.storedState = getStoredState(simOptions.id)
simDriver.stopSound();
simDriver.run(js, runOptions);
}
if (msg.command == "setstate") {
Expand Down
3 changes: 3 additions & 0 deletions pxtsim/simdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,15 @@ namespace pxsim {

public stop(unload = false, starting = false) {
this.clearDebugger();
this.stopSound();
this.postMessage({ type: 'stop', source: MESSAGE_SOURCE });
this.setState(starting ? SimulatorState.Starting : SimulatorState.Stopped);
if (unload)
this.unload();
}

public suspend() {
this.stopSound();
this.postMessage({ type: 'stop', source: MESSAGE_SOURCE });
this.setState(SimulatorState.Suspended);
}
Expand Down Expand Up @@ -695,6 +697,7 @@ namespace pxsim {
activePlayer: opts.activePlayer,
theme: opts.theme,
}
this.stopSound();
this.start();
}

Expand Down
1 change: 0 additions & 1 deletion webapp/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3645,7 +3645,6 @@ export class ProjectView
|| this.debugOptionsChanged()) {
this.startSimulator();
} else {
simulator.driver.stopSound();
simulator.driver.restart(); // fast restart
}
simulator.driver.focus()
Expand Down
1 change: 0 additions & 1 deletion webapp/src/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ export function mute(mute: boolean) {

export function stop(unload?: boolean, starting?: boolean) {
if (!driver) return;
driver.stopSound();
driver.stop(unload, starting);
}

Expand Down

0 comments on commit 00b73d9

Please sign in to comment.