From 1792d4a784328acf246275e2f4048ada94075681 Mon Sep 17 00:00:00 2001 From: Kleber Silva Date: Mon, 6 Sep 2021 18:43:44 -0300 Subject: [PATCH] EditorWindow show/init split --- src/editor.window.ts | 19 ++++++++++++++++--- src/plugin.ts | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/editor.window.ts b/src/editor.window.ts index b333309..16a4e90 100644 --- a/src/editor.window.ts +++ b/src/editor.window.ts @@ -7,12 +7,24 @@ import { PointPropertyEditor } from 'editor-view/properties/editors/point/point- import { StringPropertyEditor } from 'editor-view/properties/editors/string/string-property-editor'; import { ReferenceImage } from 'scene-view/reference-image'; import { SceneView } from 'scene-view/scene-view'; -import { Plugin } from './plugin'; export class EditorWindow { + private plugin: Phaser.Plugin; + private _initialized = false; public onhide: () => void; - public show(plugin: Plugin, group?: Container, refImage?: PIXI.Sprite) { + constructor(plugin: Phaser.Plugin) { this.plugin = plugin; } + + public show(group?: Container, refImage?: PIXI.Sprite) { + if (!this._initialized) { + this.init(group, refImage); + return; + } + // TODO just re-enable everything + } + + private init(group?: Container, refImage?: PIXI.Sprite) { + const plugin = this.plugin; const game = plugin.game; group = group ?? game.world; @@ -40,7 +52,8 @@ export class EditorWindow { } private hide() { - + // TODO disable everything + if (this.onhide) this.onhide(); } private setupInspectorData() { diff --git a/src/plugin.ts b/src/plugin.ts index 9e0a398..2eba64d 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -10,7 +10,7 @@ export class Plugin extends Phaser.Plugin { super(game, game.plugins); this.insertHead(); - this.editorWindow = new EditorWindow(); + this.editorWindow = new EditorWindow(this); this.disabledUI = new DisabledUI(); this.disabledUI.onclick = this.enableEditor.bind(this); } @@ -37,7 +37,7 @@ export class Plugin extends Phaser.Plugin { } private enableEditor() { - this.editorWindow.show(this); + this.editorWindow.show(); } }