Skip to content

Commit

Permalink
editor renamed to scene
Browse files Browse the repository at this point in the history
  • Loading branch information
kleber-jg committed Aug 31, 2021
1 parent 3e70e9c commit e443bec
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions TODO.todo
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Object Tree:

General Features:
[x] editor layout
[ ] hide panels
[ ] undo / redo
[ ] hide gizmos
[ ] toggle enabled
Expand Down
4 changes: 2 additions & 2 deletions src/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum DataOrigin {
EDITOR = 0,
SCENE = 0,
INSPECTOR = 1,
};

Expand All @@ -19,7 +19,7 @@ class DataClass {
}

private readonly onPropertyChanged: Record<DataOrigin, PropertyChangedListener> = {
[DataOrigin.EDITOR]: null,
[DataOrigin.SCENE]: null,
[DataOrigin.INSPECTOR]: null,
};

Expand Down
4 changes: 2 additions & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Data } from 'data';
import Phaser from 'phaser-ce';
import { EditorView } from './editor/editor.view';
import { SceneEditor } from './scene/scene-editor';
import './plugin.scss';
import { Stage } from './ui/stage';

Expand All @@ -13,7 +13,7 @@ export class Plugin extends Phaser.Plugin {

group = group ?? game.world;

new EditorView(game, group, game.stage);
new SceneEditor(game, group, game.stage);
stage.game = game;

Data.onSelectedObjectChanged.add(stage.selectObject, stage);
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/editor/editor.view.ts → src/scene/scene-editor.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Data, DataOrigin } from 'data';
import { DragUtil } from './drag.util';
import { EditorModel } from './editor.model';
import { SceneMovel } from './scene-model';
import { Selection } from './selection/selection';

export class EditorView extends Phaser.Group {
export class SceneEditor extends Phaser.Group {
private readonly touchArea: Phaser.Graphics;
private readonly container: Phaser.Group | Phaser.Stage;
private readonly selection: Selection;
private readonly model: EditorModel;
private readonly model: SceneMovel;

/** Whether the mouse down has already selected an object */
private _hasSelected: boolean;
Expand All @@ -23,13 +23,13 @@ export class EditorView extends Phaser.Group {

constructor(game: Phaser.Game, container: Phaser.Group | Phaser.Stage, parent: Phaser.Group | Phaser.Stage) {
super(game, parent);
this.name = '__editor';
this.name = '__scene_editor';

this.__skip = true;
game.stage.__skip = true;
game.world.__skip = true;

this.model = new EditorModel();
this.model = new SceneMovel();
this.container = container;

this.touchArea = this.createTouchArea(game);
Expand Down
2 changes: 1 addition & 1 deletion src/editor/editor.model.ts → src/scene/scene-model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class EditorModel {
export class SceneMovel {
private _lastSelectionTree: PIXI.DisplayObject[];
private _lastSelectionTreeIndex = -1;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export class ScaleHandler extends Phaser.Group {
this.scaler.scaleToPoint(pointer.x, pointer.y);

const pos = this.scaler.getObjectStopPosition();
Data.propertyChanged('scale', this.selectedObject.scale, DataOrigin.EDITOR);
Data.propertyChanged('position', pos, DataOrigin.EDITOR);
Data.propertyChanged('scale', this.selectedObject.scale, DataOrigin.SCENE);
Data.propertyChanged('position', pos, DataOrigin.SCENE);

return true;
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Data, DataOrigin } from 'data';
import { ANCHOR_COLOR, ANCHOR_STROKE, BORDER_COLOR, BORDER_STROKE, PIVOT_COLOR, PIVOT_STROKE } from '../editor.colors';
import { ANCHOR_COLOR, ANCHOR_STROKE, BORDER_COLOR, BORDER_STROKE, PIVOT_COLOR, PIVOT_STROKE } from '../scene-colors';
import { ScaleHandler } from './scale/scale.handler';

export class Selection extends Phaser.Group {
Expand Down Expand Up @@ -83,7 +83,7 @@ export class Selection extends Phaser.Group {
this.position.set(pos.x + deltaX, pos.y + deltaY);
pos = this._selectedObject.position;
this._selectedObject.position.set(pos.x + deltaX, pos.y + deltaY);
Data.propertyChanged('position', pos, DataOrigin.EDITOR);
Data.propertyChanged('position', pos, DataOrigin.SCENE);
}


Expand Down
2 changes: 1 addition & 1 deletion src/ui/properties/panel/properties-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class PropertiesPanel extends Widget {
content.classList.add('content');
this.appendChild(content);

Data.setPropertyChangedListener(DataOrigin.EDITOR, this.onPropertyChangedInsideEditor.bind(this));
Data.setPropertyChangedListener(DataOrigin.SCENE, this.onPropertyChangedInsideEditor.bind(this));
}

private onPropertyChangedInsideEditor(property: string, value: any) {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"forceConsistentCasingInFileNames": true,
"baseUrl": "src",
"paths": {
"editor/*": ["editor/*"],
"scene/*": ["scene/*"],
"ui/*": ["ui/*"],
}
},
Expand Down

0 comments on commit e443bec

Please sign in to comment.