소스 검색

CTRLPainter can now accept null for surfaces and will render a cleared screen if surface is null.

dev
Bryan Miller 6 년 전
부모
커밋
3d446981c8
1개의 변경된 파일15개의 추가작업 그리고 10개의 파일을 삭제
  1. +15
    -10
      app/js/ctrls/CTRLPainter.js

+ 15
- 10
app/js/ctrls/CTRLPainter.js 파일 보기

}).bind(this); }).bind(this);


var handle_change_surface = (function(surf){ var handle_change_surface = (function(surf){
if (!(surf instanceof ISurface)){
if (surf !== null && !(surf instanceof ISurface)){
console.log("WARNING: Attempted to set painter to non-surface instance."); console.log("WARNING: Attempted to set painter to non-surface instance.");
return; return;
} }
this.__surface.unlisten("data_changed", handle_surface_data_changed); this.__surface.unlisten("data_changed", handle_surface_data_changed);
} }
this.__surface = surf; this.__surface = surf;
this.__surface.listen("data_changed", handle_surface_data_changed);
if (this.__palette === null && this.__surface.palette !== null){
this.__palette = this.__surface.palette;
} else if (this.__palette !== null && this.__surface.palette !== this.__palette){
this.__surface.palette = this.__palette;
if (this.__surface !== null){
this.__surface.listen("data_changed", handle_surface_data_changed);
if (this.__palette === null && this.__surface.palette !== null){
this.__palette = this.__surface.palette;
} else if (this.__palette !== null && this.__surface.palette !== this.__palette){
this.__surface.palette = this.__palette;
}
this.scale_to_fit();
this.center_surface();
} }
this.scale_to_fit();
this.center_surface();
} }
RenderD(); RenderD();
}).bind(this); }).bind(this);
} }


render(){ render(){
if (context === null || this.__surface === null)
return;
if (context === null){return this;}
if (this.__surface === null){
Renderer.clear(context, NESPalette.Default[4]);
return this;
}


// Drawing the surface to the canvas. // Drawing the surface to the canvas.
Renderer.render( Renderer.render(

Loading…
취소
저장