more glow / stop sound on player stop

This commit is contained in:
Peli de Halleux 2016-06-01 15:45:40 -07:00
parent c5571c20c7
commit 7b74428275
2 changed files with 16 additions and 11 deletions

View File

@ -446,7 +446,7 @@ svg.sim.grayscale {
} }
@keyframes sim-theme-glow-animation { @keyframes sim-theme-glow-animation {
from { opacity: 1; } from { opacity: 1; }
to { opacity: 0.8; } to { opacity: 0.75; }
} }
.sim-flash { .sim-flash {

View File

@ -42,14 +42,14 @@ namespace pxsim {
constructor(private runtime: Runtime) { } constructor(private runtime: Runtime) { }
listen(id: number, evid: number, handler: RefAction) { listen(id: number, evid: number, handler: RefAction) {
let k = id + ':' + evid; let k = id + ":" + evid;
let queue = this.queues[k]; let queue = this.queues[k];
if (!queue) queue = this.queues[k] = new EventQueue<number>(this.runtime); if (!queue) queue = this.queues[k] = new EventQueue<number>(this.runtime);
queue.handler = handler; queue.handler = handler;
} }
queue(id: number, evid: number, value: number = 0) { queue(id: number, evid: number, value: number = 0) {
let k = id + ':' + evid; let k = id + ":" + evid;
let queue = this.queues[k]; let queue = this.queues[k];
if (queue) queue.push(value); if (queue) queue.push(value);
} }
@ -122,7 +122,7 @@ namespace pxsim {
broadcast(msg: number) { broadcast(msg: number) {
Runtime.postMessage(<SimulatorEventBusMessage>{ Runtime.postMessage(<SimulatorEventBusMessage>{
type: 'eventbus', type: "eventbus",
id: DAL.MES_BROADCAST_GENERAL_ID, id: DAL.MES_BROADCAST_GENERAL_ID,
eventid: msg, eventid: msg,
power: this.power, power: this.power,
@ -551,12 +551,12 @@ namespace pxsim {
default: theme = pxsim.micro_bit.randomTheme(); default: theme = pxsim.micro_bit.randomTheme();
} }
console.log('setting up microbit simulator') console.log("setting up microbit simulator")
let view = new pxsim.micro_bit.MicrobitBoardSvg({ let view = new pxsim.micro_bit.MicrobitBoardSvg({
theme: theme, theme: theme,
runtime: runtime runtime: runtime
}) })
document.body.innerHTML = ''; // clear children document.body.innerHTML = ""; // clear children
document.body.appendChild(view.element); document.body.appendChild(view.element);
return Promise.resolve(); return Promise.resolve();
@ -581,22 +581,27 @@ namespace pxsim {
} }
readSerial() { readSerial() {
let v = this.serialIn.shift() || ''; let v = this.serialIn.shift() || "";
return v; return v;
} }
serialOutBuffer: string = ''; kill() {
super.kill();
AudioContextManager.stop();
}
serialOutBuffer: string = "";
writeSerial(s: string) { writeSerial(s: string) {
for (let i = 0; i < s.length; ++i) { for (let i = 0; i < s.length; ++i) {
let c = s[i]; let c = s[i];
this.serialOutBuffer += c; this.serialOutBuffer += c;
if (c == '\n') { if (c == "\n") {
Runtime.postMessage(<SimulatorSerialMessage>{ Runtime.postMessage(<SimulatorSerialMessage>{
type: 'serial', type: "serial",
data: this.serialOutBuffer, data: this.serialOutBuffer,
id: runtime.id id: runtime.id
}) })
this.serialOutBuffer = '' this.serialOutBuffer = ""
break; break;
} }
} }