File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import isString from "lodash-es/isString";
33import Component , { IComponentConstructor , IContainer } from "./Component" ;
44import ComponentRegistry from "./ComponentRegistry" ;
55import IMain from "./IMain" ;
6+ import Inert from "./Inert" ;
67import TextureSetManager from "./webgl/TextureSetManager" ;
78
89/**
@@ -49,6 +50,10 @@ export default abstract class Container extends Component implements IContainer
4950 continue ;
5051 }
5152 const component = new componentClass ( this . main , this , opts ) ;
53+ if ( component instanceof Inert ) {
54+ // tslint:disable-next-line:no-console
55+ console . warn ( `Inert Component: ${ opts . type } . Will not affect rendering.` ) ;
56+ }
5257 components . push ( component ) ;
5358 }
5459 }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import Container from "./Container";
33import CodeInstance from "./expr/CodeInstance" ;
44import compileExpr from "./expr/compileExpr" ;
55import IMain from "./IMain" ;
6+ import Inert from "./Inert" ;
67import { BlendMode } from "./utils" ;
78import TextureSetManager from "./webgl/TextureSetManager" ;
89
@@ -177,7 +178,7 @@ export default class EffectList extends Container {
177178 // render all the components
178179 // for (let i = 0; i < this.components.length; i++) {
179180 for ( const component of this . components ) {
180- if ( component . isEnabled ( ) ) {
181+ if ( component . isEnabled ( ) && ! ( component instanceof Inert ) ) {
181182 component . draw ( ) ;
182183 }
183184 }
Original file line number Diff line number Diff line change 1+ import Component , { IContainer } from "./Component" ;
2+ import IMain from "./IMain" ;
3+
4+ /**
5+ * Base class for passive components.
6+ *
7+ * A base class for component types that don't affect rendering,
8+ * most notably Comment, but also unknown components in general.
9+ */
10+ export default abstract class Inert extends Component {
11+ protected opts : any ;
12+
13+ /*tslint:disable:no-empty*/
14+ public init ( ) { }
15+ public draw ( ) {
16+ throw new Error ( "Calling draw on inert component." ) ;
17+ }
18+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import ComponentRegistry from "./ComponentRegistry";
88import EffectList from "./EffectList" ;
99import IMain from "./IMain" ;
1010import BufferSave from "./misc/BufferSave" ;
11+ import Comment from "./misc/Comment" ;
1112import GlobalVar from "./misc/GlobalVar" ;
1213import Model from "./Model" ;
1314import ClearScreen from "./render/ClearScreen" ;
@@ -403,6 +404,8 @@ export default class Main extends Model implements IMain {
403404
404405 BufferSave ,
405406 GlobalVar ,
407+
408+ Comment ,
406409 ] ) ;
407410 }
408411
Original file line number Diff line number Diff line change 1+ import { IContainer } from "../Component" ;
2+ import IMain from "../IMain" ;
3+ import Inert from "../Inert" ;
4+
5+ export interface ICommentOpts {
6+ text : string ;
7+ }
8+
9+ /**
10+ * A component containing free text.
11+ */
12+ export default class Comment extends Inert {
13+ public static componentName : string = "Comment" ;
14+ public static componentTag : string = "misc" ;
15+ protected static optUpdateHandlers = {
16+ text : "updateText" ,
17+ } ;
18+ protected static defaultOptions : ICommentOpts = {
19+ text : "" ,
20+ } ;
21+
22+ protected opts : ICommentOpts ;
23+ private text : string ;
24+
25+ constructor ( main : IMain , parent : IContainer , opts : any ) {
26+ super ( main , parent , opts ) ;
27+ }
28+
29+ public updateText ( ) {
30+ this . text = this . opts . text ;
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments