Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
PhaserEditor2D committed Aug 23, 2021
2 parents b1d1f46 + dc7d210 commit ef4b09a
Show file tree
Hide file tree
Showing 195 changed files with 2,703 additions and 7,917 deletions.
37 changes: 37 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# Change Log

## v3.20.0 - Aug 23, 2021

### Added

* Nested prefabs:
* Nested prefabs support.
* Uses nullish operator (`??`) in prefab constructors.
* Allows unlock the position of prefab instances. This change introduces a new scene format that is not compatible with previous versions of the editor.
* Good bye `prefab-awake` & `components-awake` events. Welcome `scene-awake`.
* Updates `UserComponent.js` templates.
* Scene Editor: new Show Children In Outline parameter in the Children section.
* [#136](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/136) Prefabs: `generateAwakeHandler`.
* Compiler: adds the **Fields In Constructor (JS)** flag. Allows generating field initialization code in the constructor and no as class fields. Some transpilers don't support class fields.
* NinePatch game object support, as part of the Phaser Editor 2D Extras project.

### Updated

* [#140](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/140) Scene compiler generates code with a format compatible with VS Code. It doesn't create unneeded git diffs.
* Scene Editor: the Change Texture command allows auto unlocking the texture property.
* Scene Editor: the Layout operations allows auto unlocking of the texture property.
* Scene Editor: replaces the Container section by the Children section, and applies for Layer objects too.
* [#139](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/139)[Feature Request] add type for method in typescript.
* [#136](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/136) Prefabs: constructor ordering of custom definition props and START-USER-CTR-CODE.

### Fixed

* Scene Editor (BitmapText): fixes error when the font data isn't available in the cache.
* [#134](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/134) Creating a list in the editor results in an initialized array in the generated code.
* [#135](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/135) Word wrap width does not behave correctly
* Scene Editor: fixes Move To Parent dialog in context of prefab scenes.
* Scene Editor: fixes Scene section layout when shows a prefab's instance.
* [#142](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/142) Animations Editor: fixes changing multiple properties of the same animation.

### Removed

* Removes Parcel templates.

## v3.15.0 - Jul 11, 2021

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ namespace colibri.inspector.ui.views {
this.setIcon(InspectorPlugin.getInstance().getIcon(ICON_INSPECTOR));
}

static updateInspectorView(selection: any[]) {

const win = Platform.getWorkbench().getActiveWindow();

const view = win.getView(InspectorView.VIEW_ID) as InspectorView;

if (view) {

view.getPropertyPage().setSelection(selection);
}
}

layout() {

this._propertyPage.dispatchLayoutEvent();
Expand Down
22 changes: 22 additions & 0 deletions source/editor/plugins/colibri/src/core/debug/Debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace colibri.debug {

export function getEditorSelectedObject() {

return getEditorSelection()[0];
}

export function getEditorSelection() {

return colibri.Platform.getWorkbench().getActiveEditor().getSelection();
}

export function getPartSelection() {

return colibri.Platform.getWorkbench().getActivePart().getSelection();
}

export function getPartSelectedObject() {

return getPartSelection()[0];
}
}
5 changes: 5 additions & 0 deletions source/editor/plugins/colibri/src/core/json/Serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ namespace colibri.core.json {
return defaultValue;
}

export function copy(data: any) {

return JSON.parse(JSON.stringify(data));
}

export function getDataValue(data: any, key: string) {

let result = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ namespace colibri.ui.controls.properties {

createMenuButton(
text: string,
items: Array<{ name: string, value: any, icon?: controls.IImage }>,
getItems: () => Array<{ name: string, value: any, icon?: controls.IImage }>,
callback: (value: any) => void) {

return this._formBuilder.createMenuButton(this._parent, text, items, callback);
return this._formBuilder.createMenuButton(this._parent, text, getItems, callback);
}

createText(readOnly?: boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ namespace colibri.ui.controls.properties {

createMenuButton(
parent: HTMLElement, text: string,
items: Array<{ name: string, value: any, icon?: controls.IImage }>,
getItems: () => Array<{ name: string, value: any, icon?: controls.IImage }>,
callback: (value: any) => void) {

const btn = this.createButton(parent, text, e => {

const menu = new controls.Menu();

for (const item of items) {
for (const item of getItems()) {

menu.add(new Action({
text: item.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ namespace colibri.ui.controls.properties {
public updateWithSelection(): void {

if (!this._sectionProvider) {

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ namespace colibri.ui.controls.properties {

createMenuButton(
parent: HTMLElement, text: string,
items: Array<{ name: string, value: any, icon?: controls.IImage }>,
getItems: () => Array<{ name: string, value: any, icon?: controls.IImage }>,
callback: (value: any) => void) {

const btn = this.createButton(parent, text, e => {

const menu = new controls.Menu();

for (const item of items) {
for (const item of getItems()) {

menu.add(new Action({
text: item.name,
Expand Down
2 changes: 1 addition & 1 deletion source/editor/plugins/colibri/styles/controls.css
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@

.PropertyFormArea {
display: grid;
padding: 10px 0px 10px 0px;
padding: 2px 0px 10px 0px;
}

.PropertyButtonPanel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,12 +764,17 @@ namespace phasereditor2d.animations.ui.editors {
reset(animsData: Phaser.Types.Animations.JSONAnimations, useAnimationIndexAsKey: boolean) {

let selectedIndexes: number[];
let selectedKeys: string[];

if (useAnimationIndexAsKey) {

const allAnimations = this.getAnimations();

selectedIndexes = this.getSelectedAnimations().map(anim => allAnimations.indexOf(anim));

} else {

selectedKeys = this.getSelectedAnimations().map(anim => anim.key);
}

const scene = this.getScene();
Expand All @@ -790,15 +795,23 @@ namespace phasereditor2d.animations.ui.editors {

} else {

this.setSelection(this._selectedAnimations.map(obj => {
const newAnimations = selectedKeys.map(key => {

return this.getAnimation(obj.key);
return this.getAnimation(key);

}).filter(o => {

return o !== undefined && o !== null
}));
});

this.setSelection(newAnimations);
}

// I do this here because the Inspector view at this moment
// is not listening the selection changes.
// It is like that because the active view is the Inspector
// view itself but the selection changed in the editor
colibri.inspector.ui.views.InspectorView.updateInspectorView(this.getSelection());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ namespace phasereditor2d.animations.ui.editors.properties {

anim[field] = value;
}

});
});

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ namespace phasereditor2d.ide {

/* program entry point */

export const VER = "3.15.0";
export const VER = "3.20.0";

async function main() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ namespace phasereditor2d.pack.core {

getFileFromAssetUrl(url: string) {

if (!url) {

return undefined;
}

return AssetPackUtils.getFileFromPackUrl(this.getPack(), url);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ namespace phasereditor2d.pack.ui.viewers {

const data = item.getData();

let file = item.getFileFromAssetUrl(data.url);
let file: colibri.core.io.FilePath;

if (typeof data.url === "string") {

file = item.getFileFromAssetUrl(data.url);
}

if (!file) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UserComponent {

if (listenAwake) {

gameObject.once("components-awake", this.awake, this);
this.scene.events.once("scene-awake", this.awake, this);
}

if (listenStart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class UserComponent {

if (listenAwake) {

gameObject.once("components-awake", this.awake, this);
this.scene.events.once("scene-awake", this.awake, this);
}

if (listenStart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class UserComponent {

if (listenAwake) {

gameObject.once("components-awake", this.awake, this);
this.scene.events.once("scene-awake", this.awake, this);
}

if (listenStart) {
Expand Down Expand Up @@ -46,19 +46,19 @@ export default class UserComponent {

scene: Phaser.Scene;

protected awake() {
protected awake(): void {
// override this
}

protected start() {
protected start(): void {
// override this
}

protected update() {
protected update(): void {
// override this
}

protected destroy() {
protected destroy(): void {
// override this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UserComponent {

if (listenAwake) {

gameObject.once("components-awake", this.awake, this);
this.scene.events.once("scene-awake", this.awake, this);
}

if (listenStart) {
Expand Down Expand Up @@ -44,19 +44,19 @@ class UserComponent {

scene: Phaser.Scene;

protected awake() {
protected awake(): void {
// override this
}

protected start() {
protected start(): void {
// override this
}

protected update() {
protected update(): void {
// override this
}

protected destroy() {
protected destroy(): void {
// override this
}
}
6 changes: 3 additions & 3 deletions source/editor/plugins/phasereditor2d.scene/src/ScenePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ namespace phasereditor2d.scene {
// commands

reg.addExtension(
new ide.commands.CommandExtension(ui.editor.commands.SceneEditorCommands.registerCommands));
new ide.commands.CommandExtension(m => ui.editor.commands.SceneEditorCommands.registerCommands(m)));

reg.addExtension(
new ide.commands.CommandExtension(ui.editor.usercomponent.UserComponentsEditor.registerCommands));
new ide.commands.CommandExtension(m => ui.editor.usercomponent.UserComponentsEditor.registerCommands(m)));


// compile project
Expand Down Expand Up @@ -266,7 +266,7 @@ namespace phasereditor2d.scene {
page => new ui.sceneobjects.ListVariableSection(page),
page => new ui.sceneobjects.GameObjectListSection(page),
page => new ui.sceneobjects.ParentSection(page),
page => new ui.sceneobjects.ContainerSection(page),
page => new ui.sceneobjects.ChildrenSection(page),
page => new ui.sceneobjects.TransformSection(page),
page => new ui.sceneobjects.OriginSection(page),
page => new ui.sceneobjects.FlipSection(page),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,34 @@ namespace phasereditor2d.scene.core.code {

this.internalGenerate();

this.cleanCode();

return this._text;
}

protected abstract internalGenerate(): void;


protected cleanCode() {

// clean the empty lines

const lines = this._text.split("\n").map(line => {

if (line.trim() === "") {

return "";
}

return line;
});

this._text = lines.join("\n");
}


length() {

return this._text.length;
}

Expand Down
Loading

0 comments on commit ef4b09a

Please sign in to comment.