Skip to content
Snippets Groups Projects
Commit 43b1ae85 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Call renderer.draw after project loads to show the initial state

parent 9e783d8a
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,12 @@ class Stage extends React.Component {
this.canvas = document.createElement('canvas');
this.renderer = new Renderer(this.canvas);
this.props.vm.attachRenderer(this.renderer);
// Calling draw a single time before any project is loaded just makes
// the canvas white instead of solid black–needed because it is not
// possible to use CSS to style the canvas to have a different
// default color
this.props.vm.renderer.draw();
}
this.props.vm.attachV2SVGAdapter(new V2SVGAdapter());
this.props.vm.attachV2BitmapAdapter(new V2BitmapAdapter());
......
......@@ -53,6 +53,17 @@ const vmManagerHOC = function (WrappedComponent) {
return this.props.vm.loadProject(this.props.projectData)
.then(() => {
this.props.onLoadedProject(this.props.loadingState, this.props.canSave);
// If the vm is not running, call draw on the renderer manually
// This draws the state of the loaded project with no blocks running
// which closely matches the 2.0 behavior, except for monitors–
// 2.0 runs monitors and shows updates (e.g. timer monitor)
// before the VM starts running other hat blocks.
if (!this.props.isStarted) {
// Wrap in a setTimeout because skin loading in
// the renderer can be async.
setTimeout(() => this.props.vm.renderer.draw());
}
})
.catch(e => {
this.props.onError(e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment