Minor fix to killing the animation when the sim is killed
This commit is contained in:
parent
2157af3e63
commit
ef5fa9ae82
@ -140,6 +140,12 @@ namespace pxsim.visuals {
|
||||
this.board.updateSubscribers.push(() => this.updateState());
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
Runtime.messagePosted = (msg) => {
|
||||
switch (msg.type || "") {
|
||||
case "status": if ((msg as pxsim.SimulatorStateMessage).state == "killed") this.kill(); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getView(): SVGAndSize<SVGSVGElement> {
|
||||
@ -350,6 +356,10 @@ namespace pxsim.visuals {
|
||||
this.screenCanvasTemp.style.display = 'none';
|
||||
}
|
||||
|
||||
private kill() {
|
||||
if (this.lastAnimationId) cancelAnimationFrame(this.lastAnimationId);
|
||||
}
|
||||
|
||||
private lastAnimationId: number;
|
||||
public updateState() {
|
||||
if (this.lastAnimationId) cancelAnimationFrame(this.lastAnimationId);
|
||||
@ -372,7 +382,7 @@ namespace pxsim.visuals {
|
||||
}
|
||||
|
||||
private updateStateStep() {
|
||||
console.log("update state step");
|
||||
const selected = this.layoutView.getSelected();
|
||||
const inputNodes = ev3board().getInputNodes();
|
||||
inputNodes.forEach((node, index) => {
|
||||
if (!node.didChange()) return;
|
||||
@ -398,7 +408,6 @@ namespace pxsim.visuals {
|
||||
}
|
||||
});
|
||||
|
||||
const selected = this.layoutView.getSelected();
|
||||
if (selected && (selected.getId() !== this.selectedNode || selected.getPort() !== this.selectedPort)) {
|
||||
this.selectedNode = selected.getId();
|
||||
this.selectedPort = selected.getPort();
|
||||
@ -409,16 +418,17 @@ namespace pxsim.visuals {
|
||||
this.controlGroup.addView(control);
|
||||
}
|
||||
this.closeIconView.setVisible(true);
|
||||
this.resize();
|
||||
} else if (!selected) {
|
||||
this.controlGroup.clear();
|
||||
this.controlView = undefined;
|
||||
this.selectedNode = undefined;
|
||||
this.selectedPort = undefined;
|
||||
this.closeIconView.setVisible(false);
|
||||
this.resize();
|
||||
}
|
||||
|
||||
this.updateScreenStep();
|
||||
//this.resize();
|
||||
}
|
||||
|
||||
private updateScreenStep() {
|
||||
|
@ -78,7 +78,7 @@ namespace pxsim.visuals {
|
||||
return this.getInnerHeight() * 0.6;
|
||||
}
|
||||
|
||||
onBoardStateChanged() {
|
||||
updateState() {
|
||||
if (!this.isVisible) {
|
||||
return;
|
||||
}
|
||||
@ -91,7 +91,6 @@ namespace pxsim.visuals {
|
||||
onComponentVisible() {
|
||||
super.onComponentVisible();
|
||||
this.isVisible = true;
|
||||
this.onBoardStateChanged();
|
||||
}
|
||||
|
||||
onComponentHidden() {
|
||||
|
@ -60,7 +60,7 @@ namespace pxsim.visuals {
|
||||
return this.getInnerHeight() / 4;
|
||||
}
|
||||
|
||||
onBoardStateChanged() {
|
||||
updateState() {
|
||||
if (!this.isVisible) {
|
||||
return;
|
||||
}
|
||||
@ -74,7 +74,6 @@ namespace pxsim.visuals {
|
||||
onComponentVisible() {
|
||||
super.onComponentVisible();
|
||||
this.isVisible = true;
|
||||
this.onBoardStateChanged();
|
||||
}
|
||||
|
||||
onComponentHidden() {
|
||||
|
@ -35,10 +35,6 @@ namespace pxsim.visuals {
|
||||
return false;
|
||||
}
|
||||
|
||||
public shouldUpdateState() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public updateState() {
|
||||
this.updateLight();
|
||||
}
|
||||
|
@ -61,10 +61,6 @@ namespace pxsim.visuals {
|
||||
}
|
||||
}
|
||||
|
||||
public shouldUpdateState() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public updateState() {
|
||||
}
|
||||
|
||||
@ -179,23 +175,8 @@ namespace pxsim.visuals {
|
||||
public setSelected(selected: boolean) { }
|
||||
|
||||
protected getView() {
|
||||
if (!this.rendered) {
|
||||
this.subscribe();
|
||||
}
|
||||
return super.getView();
|
||||
}
|
||||
|
||||
protected onBoardStateChanged() {
|
||||
// To be implemented by sub class
|
||||
}
|
||||
|
||||
protected subscribe() {
|
||||
board().updateSubscribers.push(() => {
|
||||
if (this.state.didChange()) {
|
||||
this.onBoardStateChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class ViewContainer extends View {
|
||||
|
Loading…
Reference in New Issue
Block a user