Skip to content

Commit

Permalink
* phaser-data renamed to phaser-meta
Browse files Browse the repository at this point in the history
* phaser-meta moved to editor
  • Loading branch information
kleber-jg committed Sep 3, 2021
1 parent 0b65e3e commit 9e31101
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 47 deletions.
3 changes: 3 additions & 0 deletions src/core/editor.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { EditorData } from 'data/editor-data';
import { InspectorData } from 'data/inspector-data';
import { PhaserMeta } from 'data/phaser-meta';
import { Actions } from './actions';
import { History } from './history';
import { Preferences } from './preferences';

class EditorClass {
public data: EditorData
public inspectorData: InspectorData;
public meta: PhaserMeta;

public actions: Actions;
public history: History;
Expand All @@ -15,6 +17,7 @@ class EditorClass {
public init() {
this.data = new EditorData();
this.inspectorData = new InspectorData();
this.meta = new PhaserMeta();

this.actions = new Actions();
this.history = new History(this.data);
Expand Down
44 changes: 0 additions & 44 deletions src/data/phaser-data.ts

This file was deleted.

34 changes: 34 additions & 0 deletions src/data/phaser-meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export interface PhaserObjectType {
name: string;
icon: string;
}

export class PhaserMeta {
private readonly sceneObjects: Record<string, PhaserObjectType> = {
[Phaser.BITMAPTEXT]: { name: 'Phaser.BitmapText', icon: 'fa-font' },
[Phaser.BUTTON]: { name: 'Phaser.Button', icon: '' },
[Phaser.GRAPHICS]: { name: 'Phaser.Graphics', icon: 'fa-square' },
[Phaser.GROUP]: { name: 'Phaser.Group', icon: 'fa-dice-d6' },
[Phaser.IMAGE]: { name: 'Phaser.Image', icon: 'fa-image' },
[Phaser.RETROFONT]: { name: 'Phaser.RetroFont', icon: 'fa-font' },
[Phaser.SPRITE]: { name: 'Phaser.Sprite', icon: 'fa-image' },
[Phaser.TEXT]: { name: 'Phaser.Text', icon: 'fa-font' },
// [Phaser.EMITTER]: { name: 'Phaser.Emitter', icon: '' },
// [Phaser.SPRITEBATCH]: { name: 'Phaser.SpriteBatch', icon: 'fa-images' },
// [Phaser.TILEMAP]: { name: 'Phaser.TileMap', icon: '' },
// [Phaser.TILEMAPLAYER]: { name: 'Phaser.TileMapPlayer', icon: '' },
// [Phaser.TILESPRITE]: { name: 'Phaser.TileSprite', icon: '' },
// [Phaser.WEBGL_FILTER]: { name: 'Phaser.WebGLFilter', icon: '' },
// [Phaser.ROPE]: { name: 'Phaser.Rope', icon: '' },
// [Phaser.CREATURE]: { name: 'Phaser.Creature', icon: '' },
// [Phaser.VIDEO]: { name: 'Phaser.Video', icon: '' },
};

public addSceneObjects(objects: Record<string, PhaserObjectType>) {
Object.keys(objects).forEach(k => this.sceneObjects[k] = objects[k]);
}

private readonly defaultType: PhaserObjectType = { name: 'default', icon: 'fa-question' };

public getType(t: number) { return t in this.sceneObjects ? this.sceneObjects[t] : this.defaultType; }
}
5 changes: 3 additions & 2 deletions src/editor-view/object-tree/model/object-tree-model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PhaserData, PhaserObjectType } from 'data/phaser-data';
import { Editor } from 'core/editor';
import { PhaserObjectType } from 'data/phaser-meta';
import { IdUtil } from 'util/id.util';
import { TreeNode } from '../tree-node/tree-node';

Expand All @@ -23,7 +24,7 @@ export class ObjectTreeModel {
}

private createNode(child: PIXI.DisplayObject, map: Record<number, ObjectMapItemModel>, parent: ObjectMapItemModel, level: number) {
const type = PhaserData.getType(child.type);
const type = Editor.meta.getType(child.type);
child.__instanceId = IdUtil.genIntId();
child.__type = type.name;
const isLeaf = !(child.children && child.children.length > 0);
Expand Down
2 changes: 1 addition & 1 deletion src/editor-view/object-tree/tree-node/tree-node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PhaserObjectType } from 'data/phaser-data';
import { PhaserObjectType } from 'data/phaser-meta';
import { ObjectMapItemModel } from '../model/object-tree-model';
import './tree-node.scss';

Expand Down

0 comments on commit 9e31101

Please sign in to comment.