Skip to content

Commit

Permalink
added properties panel widget
Browse files Browse the repository at this point in the history
  • Loading branch information
kleber-swf committed Aug 30, 2021
1 parent 2a10db3 commit 2dd66f5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function el(x, y, w, h, parent, name) {
const color = COLORS[_colorIndex];
const g = game.add.graphics(x, y)
.lineStyle(1, color, 1)
.beginFill(color, 0.1)
.beginFill(color, 0.2)
.drawRect(0, 0, w, h)
.endFill();
parent.addChild(g);
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class Plugin extends Phaser.Plugin {
public constructor(game: Phaser.Game, group?: Phaser.Group | Phaser.Stage) {
super(game, game.plugins);

const stage = document.createElement(Stage.eid) as Stage;
const stage = document.createElement(Stage.tagId) as Stage;
document.body.appendChild(stage);

group = group ?? game.world;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/actions.toolbar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Widget } from './widget';

export class ActionsToolbar extends Widget {
public static eid = 'phred-actions-toolbar';
public static readonly tagId = 'phred-actions-toolbar';
}

customElements.define(ActionsToolbar.eid, ActionsToolbar);
customElements.define(ActionsToolbar.tagId, ActionsToolbar);
7 changes: 7 additions & 0 deletions src/ui/properties.panel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Widget } from './widget';

export class PropertiesPanel extends Widget {
public static readonly tagId = 'phed-properties-panel';
}

customElements.define(PropertiesPanel.tagId, PropertiesPanel);
11 changes: 9 additions & 2 deletions src/ui/properties.toolbar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { PropertiesPanel } from './properties.panel';
import { Widget } from './widget';

export class PropertiesToolbar extends Widget {
public static eid = 'phred-properties-toolbar';
public static readonly tagId = 'phred-properties-toolbar';

public connectedCallback() {
super.connectedCallback();
const panel = document.createElement(PropertiesPanel.tagId);
this.appendChild(panel);
}
}

customElements.define(PropertiesToolbar.eid, PropertiesToolbar);
customElements.define(PropertiesToolbar.tagId, PropertiesToolbar);
8 changes: 4 additions & 4 deletions src/ui/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PropertiesToolbar } from './properties.toolbar';
import { Widget } from './widget';

export class Stage extends Widget {
public static eid = 'phred-stage';
public static readonly tagId = 'phred-stage';

private _game: Phaser.Game;
private _actions: ActionsToolbar;
Expand Down Expand Up @@ -32,16 +32,16 @@ export class Stage extends Widget {
content.classList.add('phred-content');
this.appendChild(content);

this._actions = document.createElement(ActionsToolbar.eid) as ActionsToolbar;
this._actions = document.createElement(ActionsToolbar.tagId) as ActionsToolbar;
content.appendChild(this._actions);

this._gameContainer = document.createElement('div');
this._gameContainer.classList.add('phred-game-container');
content.appendChild(this._gameContainer);

this._properties = document.createElement(PropertiesToolbar.eid) as PropertiesToolbar;
this._properties = document.createElement(PropertiesToolbar.tagId) as PropertiesToolbar;
this.appendChild(this._properties);
}
}

customElements.define(Stage.eid, Stage);
customElements.define(Stage.tagId, Stage);

0 comments on commit 2dd66f5

Please sign in to comment.