-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17166a1
commit ccbc93e
Showing
5 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Component, { IContainer } from "./Component"; | ||
import IMain from "./IMain"; | ||
|
||
/** | ||
* Base class for passive components. | ||
* | ||
* A base class for component types that don't affect rendering, | ||
* most notably Comment, but also unknown components in general. | ||
*/ | ||
export default abstract class Inert extends Component { | ||
protected opts: any; | ||
|
||
public init() { | ||
throw new Error("Calling init on inert component."); | ||
} | ||
public draw() { | ||
throw new Error("Calling draw on inert component."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { IContainer } from "../Component"; | ||
import IMain from "../IMain"; | ||
import Inert from "../Inert"; | ||
|
||
export interface ICommentOpts { | ||
text: string; | ||
} | ||
|
||
/** | ||
* A component containing free text. | ||
*/ | ||
export default class Comment extends Inert { | ||
public static componentName: string = "Comment"; | ||
public static componentTag: string = "misc"; | ||
protected static optUpdateHandlers = { | ||
text: "updateText", | ||
}; | ||
protected static defaultOptions: ICommentOpts = { | ||
text: "", | ||
}; | ||
|
||
protected opts: ICommentOpts; | ||
private text: string; | ||
|
||
constructor(main: IMain, parent: IContainer, opts: any) { | ||
super(main, parent, opts); | ||
} | ||
|
||
public updateText() { | ||
this.text = this.opts.text; | ||
} | ||
} |