UNPKG

blaze-2d

Version:

A fast and simple WebGL 2 2D game engine written in TypeScript

51 lines 1.66 kB
import Logger from "../../logger"; import BlazeList from "../../ui/list"; import BlazeText, { TextStyle } from "../../ui/text"; import EditorPane from "./pane"; export default class ConsolePane extends EditorPane { /** * Creates a {@link ConsolePane}. * * @param pos The top left corner of the pane in the editor grid * @param width The width of the pane in columns * @param height The height of the pane in rows */ constructor(pos, width, height) { super("console", pos, width, height); // elements this.messages = new BlazeList(); this.element.style.display = "flex"; this.element.style.flexDirection = "column"; this.messages.element.style.flexGrow = "1"; this.element.appendChild(this.messages.element); Logger.addListener((type, str) => this.addMessage(type, str)); } /** * Update console. */ update() { } addMessage(type, str) { let bold = false; let style = TextStyle.PRIMARY; switch (type) { case "log": bold = false; style = TextStyle.PRIMARY; break; case "error": bold = true; style = TextStyle.ERROR; break; case "warning": bold = false; style = TextStyle.WARNING; break; default: break; } const msg = new BlazeText(str, 0.8, bold, style); msg.element.style.marginBottom = "0.15rem"; this.messages.addItems(msg); } } //# sourceMappingURL=consolePane.js.map