Skip to content

Commit

Permalink
EditorWindow show/init split
Browse files Browse the repository at this point in the history
  • Loading branch information
kleber-jg committed Sep 6, 2021
1 parent 59e5ecb commit 1792d4a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 16 additions & 3 deletions src/editor.window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -40,7 +52,8 @@ export class EditorWindow {
}

private hide() {

// TODO disable everything
if (this.onhide) this.onhide();
}

private setupInspectorData() {
Expand Down
4 changes: 2 additions & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -37,7 +37,7 @@ export class Plugin extends Phaser.Plugin {
}

private enableEditor() {
this.editorWindow.show(this);
this.editorWindow.show();
}
}

Expand Down

0 comments on commit 1792d4a

Please sign in to comment.