From bc08ec4ceb47dc1728f04059e931934314dbe363 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Wed, 16 Sep 2020 23:34:52 -0600 Subject: [PATCH] Lazy-initialize the editor (to keep the TW tileset working in the player) --- js/main.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/main.js b/js/main.js index 45be115..a523db7 100644 --- a/js/main.js +++ b/js/main.js @@ -98,11 +98,18 @@ class PrimaryView { this.conductor = conductor; this.root = root; this.active = false; + this._done_setup = false; } + setup() {} + activate() { this.root.removeAttribute('hidden'); this.active = true; + if (! this._done_setup) { + this.setup(); + this._done_setup = true; + } } deactivate() { @@ -984,9 +991,12 @@ const EDITOR_PALETTE = [{ class Editor extends PrimaryView { constructor(conductor) { super(conductor, document.body.querySelector('main#editor')); + // FIXME don't hardcode size here, convey this to renderer some other way this.renderer = new CanvasRenderer(this.conductor.tileset, 32); + } + setup() { // Level canvas and mouse handling this.root.querySelector('.level').append(this.renderer.canvas); this.mouse_mode = null;