Lazy-initialize the editor (to keep the TW tileset working in the player)
This commit is contained in:
parent
e0bfb0aadf
commit
bc08ec4ceb
10
js/main.js
10
js/main.js
@ -98,11 +98,18 @@ class PrimaryView {
|
|||||||
this.conductor = conductor;
|
this.conductor = conductor;
|
||||||
this.root = root;
|
this.root = root;
|
||||||
this.active = false;
|
this.active = false;
|
||||||
|
this._done_setup = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup() {}
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
this.root.removeAttribute('hidden');
|
this.root.removeAttribute('hidden');
|
||||||
this.active = true;
|
this.active = true;
|
||||||
|
if (! this._done_setup) {
|
||||||
|
this.setup();
|
||||||
|
this._done_setup = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deactivate() {
|
deactivate() {
|
||||||
@ -984,9 +991,12 @@ const EDITOR_PALETTE = [{
|
|||||||
class Editor extends PrimaryView {
|
class Editor extends PrimaryView {
|
||||||
constructor(conductor) {
|
constructor(conductor) {
|
||||||
super(conductor, document.body.querySelector('main#editor'));
|
super(conductor, document.body.querySelector('main#editor'));
|
||||||
|
|
||||||
// FIXME don't hardcode size here, convey this to renderer some other way
|
// FIXME don't hardcode size here, convey this to renderer some other way
|
||||||
this.renderer = new CanvasRenderer(this.conductor.tileset, 32);
|
this.renderer = new CanvasRenderer(this.conductor.tileset, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
setup() {
|
||||||
// Level canvas and mouse handling
|
// Level canvas and mouse handling
|
||||||
this.root.querySelector('.level').append(this.renderer.canvas);
|
this.root.querySelector('.level').append(this.renderer.canvas);
|
||||||
this.mouse_mode = null;
|
this.mouse_mode = null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user