-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/one-class-to-rule-them-all' into develop
- Loading branch information
Showing
47 changed files
with
267 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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; | ||
public prefs: Preferences; | ||
|
||
public init() { | ||
this.data = new EditorData(); | ||
this.inspectorData = new InspectorData(); | ||
this.meta = new PhaserMeta(); | ||
|
||
this.actions = new Actions(); | ||
this.history = new History(this.data); | ||
this.prefs = new Preferences(); | ||
} | ||
} | ||
|
||
export const Editor = new EditorClass(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
export type InspectableTypes = 'string' | 'number' | 'boolean' | 'point' | 'default'; | ||
|
||
export interface InspectorPropertyModel { | ||
name: string; | ||
typeHint: InspectableTypes; | ||
data?: any; | ||
label?: string; | ||
} | ||
|
||
export class InspectorData { | ||
private readonly editors: Partial<Record<InspectableTypes, string>> = {}; | ||
|
||
public addEditors(editors: Partial<Record<InspectableTypes, string>>) { | ||
Object.keys(editors).forEach(e => this.editors[e] = editors[e]); | ||
} | ||
|
||
public readonly inspectableProperties: InspectorPropertyModel[] = []; | ||
|
||
public addInspectableProperties(properties: InspectorPropertyModel[]) { | ||
const iproperties = this.inspectableProperties; | ||
properties.forEach(prop => { | ||
const i = iproperties.findIndex(e => e.name === prop.name); | ||
if (i < 0) iproperties.push(prop); | ||
else iproperties.splice(i, 1, prop); | ||
}); | ||
} | ||
|
||
public findEditorFor(value: any, data: InspectorPropertyModel) { | ||
// TODO what abount null / undefined values? | ||
|
||
const editors = this.editors; | ||
|
||
// TODO this should never fail | ||
// first, it tries to find based on the type hint | ||
if (data.typeHint in editors) return editors[data.typeHint]; | ||
|
||
|
||
// next, it tries to find by its type | ||
const type = typeof value; | ||
if (type !== 'object' && type in editors) | ||
return editors[type]; | ||
|
||
// next, since it's an object, it tries to find by its contructor name | ||
const ctor = value.contructor?.name; | ||
if (ctor && ctor in editors) return editors[ctor]; | ||
|
||
return editors.default; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
phred-editor { | ||
phred-editor-view { | ||
flex: 1; | ||
display: flex; | ||
align-items: stretch; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/editor/inspector/inspector.ts → src/editor-view/inspector/inspector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...editor/object-tree/tree-node/tree-node.ts → ...r-view/object-tree/tree-node/tree-node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ditors/boolean/boolean-property-editor.ts → ...ditors/boolean/boolean-property-editor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.