From e24cf819b672d86d320cae4d804d51ec2b58bd02 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Tue, 19 Dec 2023 08:04:35 -0500 Subject: [PATCH 01/23] Update version. --- source/editor/product.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/editor/product.json b/source/editor/product.json index 2fb2caf8..d89bad91 100644 --- a/source/editor/product.json +++ b/source/editor/product.json @@ -1,4 +1,4 @@ { "title": "Phaser Editor 2D", - "version": "3.65.0" + "version": "3.66.0-dev" } \ No newline at end of file From 6b93223ab193f43428daef5f2dba066c277b5005 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Fri, 22 Dec 2023 09:47:16 -0500 Subject: [PATCH 02/23] Fixes display formatting of nested prefab instances. --- .../phasereditor2d.scene/src/core/json/SceneFinder.ts | 5 ++++- .../phasereditor2d.scene/src/ui/sceneobjects/Utils.ts | 10 +++++----- .../object/properties/DynamicPrefabInstanceSection.ts | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/core/json/SceneFinder.ts b/source/editor/plugins/phasereditor2d.scene/src/core/json/SceneFinder.ts index bda924be..a59d1b40 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/core/json/SceneFinder.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/core/json/SceneFinder.ts @@ -480,7 +480,10 @@ namespace phasereditor2d.scene.core.json { if (file) { - result.push(file); + if (!this.isNestedPrefab(prefabId)) { + + result.push(file); + } const objData = this.getPrefabData(prefabId); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts index 4f2d3c54..6e14dab3 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts @@ -22,17 +22,17 @@ namespace phasereditor2d.scene.ui.sceneobjects { const finder = ScenePlugin.getInstance().getSceneFinder(); - if (objES.isPrefabInstance() && !objES.isNestedPrefabDefined()) { + if (objES.isPrefabInstance()) { - const hierarchy = finder.getPrefabHierarchy(objES.getPrefabId()); + let hierarchy = finder.getPrefabHierarchy(objES.getPrefabId()); for (const prefabFile of hierarchy) { - const { prefabObjDisplayFmt: displayFormat } = finder.getSceneSettings(prefabFile); + const { prefabObjDisplayFmt } = finder.getSceneSettings(prefabFile); - if (displayFormat !== undefined && displayFormat.trim().length > 0) { + if (prefabObjDisplayFmt !== undefined && prefabObjDisplayFmt.trim().length > 0) { - return displayFormat; + return prefabObjDisplayFmt; } } } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/DynamicPrefabInstanceSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/DynamicPrefabInstanceSection.ts index ef24f063..2a45b536 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/DynamicPrefabInstanceSection.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/DynamicPrefabInstanceSection.ts @@ -63,11 +63,11 @@ namespace phasereditor2d.scene.ui.sceneobjects { if (GameObjectEditorSupport.hasEditorSupport(obj2)) { - const editorSupport = GameObjectEditorSupport.getEditorSupport(obj2); + const objES = GameObjectEditorSupport.getEditorSupport(obj2); - if (editorSupport.isPrefabInstance()) { + if (objES.isPrefabInstance()) { - const prefabFiles = finder.getPrefabHierarchy(editorSupport.getPrefabId()); + const prefabFiles = finder.getPrefabHierarchy(objES.getPrefabId()); if (prefabFiles.indexOf(this._prefabFile) >= 0) { From 428889900bca34435235d33ac079ed21932bf324 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Fri, 22 Dec 2023 12:17:02 -0500 Subject: [PATCH 03/23] Allows setting game object display name. --- .../src/core/json/IObjectData.ts | 1 + .../src/ui/sceneobjects/EditorSupport.ts | 13 +++++- .../src/ui/sceneobjects/Utils.ts | 41 ++++++++++++++++++- .../sceneobjects/object/VariableComponent.ts | 10 +++++ .../properties/GameObjectVariableSection.ts | 8 ++++ 5 files changed, 70 insertions(+), 3 deletions(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/core/json/IObjectData.ts b/source/editor/plugins/phasereditor2d.scene/src/core/json/IObjectData.ts index cbe2dea5..890a3a9e 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/core/json/IObjectData.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/core/json/IObjectData.ts @@ -6,6 +6,7 @@ namespace phasereditor2d.scene.core.json { prefabId?: string; components?: string[], label: string; + displayName?: string; unlock?: string[]; scope?: ui.sceneobjects.ObjectScope; private_np?: boolean; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/EditorSupport.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/EditorSupport.ts index 84a9f3cc..974ea55d 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/EditorSupport.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/EditorSupport.ts @@ -6,6 +6,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { private _object: T; private _label: string; + private _displayName: string; private _useGameObjectName: boolean; private _scope: ObjectScope; private _scene: Scene; @@ -36,7 +37,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { return null; } - abstract destroy(); + abstract destroy(): void; abstract buildDependencyHash(args: IBuildDependencyHashArgs): Promise; @@ -98,6 +99,16 @@ namespace phasereditor2d.scene.ui.sceneobjects { this._label = label; } + getDisplayName() { + + return this._displayName; + } + + setDisplayName(displayName: string) { + + this._displayName = displayName; + } + isUseGameObjectName() { return this._useGameObjectName; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts index 6e14dab3..10d51c0f 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts @@ -40,8 +40,47 @@ namespace phasereditor2d.scene.ui.sceneobjects { return undefined; } + function getNestedPrefabDisplayName(prefabId: string) { + + const finder = ScenePlugin.getInstance().getSceneFinder(); + + const data = finder.getPrefabData(prefabId); + + if (data) { + + if (data.displayName) { + + return data.displayName; + } + + if (finder.isNestedPrefab(data.prefabId)) { + + return getNestedPrefabDisplayName(data.prefabId); + } + } + + return undefined; + } + export function formatObjectDisplayText(obj: ISceneGameObject): string { + const objES = obj.getEditorSupport(); + + if (objES.getDisplayName()) { + + return objES.getDisplayName(); + } + + if (objES.isNestedPrefabInstance()) { + + const displayName = getNestedPrefabDisplayName(objES.getPrefabId()); + + if (displayName) { + + return displayName; + } + } + const displayFormat = findObjectDisplayFormat(obj); if (displayFormat) { @@ -49,8 +88,6 @@ namespace phasereditor2d.scene.ui.sceneobjects { return applyFormat(obj, displayFormat); } - const objES = obj.getEditorSupport(); - return objES.getLabel(); } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/VariableComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/VariableComponent.ts index 795ab3c7..c7f661b0 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/VariableComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/VariableComponent.ts @@ -14,6 +14,15 @@ namespace phasereditor2d.scene.ui.sceneobjects { setValue: (obj, value) => obj.getEditorSupport().setLabel(value) }; + static displayName: IProperty = { + name: "displayName", + tooltip: "The name to show in the UI.", + defValue: "", + local: true, + getValue: obj => obj.getEditorSupport().getDisplayName(), + setValue: (obj, value) => obj.getEditorSupport().setDisplayName(value) + }; + static useGameObjectName: IProperty = { name: "useGameObjectName", label: "GO Name", @@ -38,6 +47,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { constructor(obj: ISceneGameObject) { super(obj, [ VariableComponent.label, + VariableComponent.displayName, VariableComponent.useGameObjectName, VariableComponent.scope ]); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/GameObjectVariableSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/GameObjectVariableSection.ts index b542d97f..540e6d66 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/GameObjectVariableSection.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/GameObjectVariableSection.ts @@ -42,6 +42,14 @@ namespace phasereditor2d.scene.ui.sceneobjects { this.createStringField(comp, VariableComponent.label, false, true); } + { + // Display Name + + this.createLabel(comp, "Display Name", "The name to display in the UI."); + + this.createStringField(comp, VariableComponent.displayName, false, true); + } + { // GameObject name From 9b263a53cf8349ef469deaf9fa6a192587a0bea0 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Fri, 22 Dec 2023 12:17:33 -0500 Subject: [PATCH 04/23] Updates changelog. --- CHANGELOG.MD | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index d1b65b18..10787e5e 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,9 @@ # Change Log +## dev + +* Allows to set a display name to game objects. + ## v3.65.0 - Dec 13, 2024 * Allows using prefabs and user components from node modules. From c5fa050e97de126fe1d26a2ee940a77f7728251b Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Fri, 22 Dec 2023 18:23:29 -0500 Subject: [PATCH 05/23] Display name formatting includes target action value. Expression #{x} expand to "x". --- CHANGELOG.MD | 2 ++ .../src/ui/sceneobjects/Utils.ts | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 10787e5e..05173996 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -3,6 +3,8 @@ ## dev * Allows to set a display name to game objects. +* The display name formatting expression #{x} expands to "x". +* The display name formatting shows prepends the `TargetActionComp.target` value, if present. ## v3.65.0 - Dec 13, 2024 diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts index 10d51c0f..f37b9529 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts @@ -76,7 +76,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { const displayName = getNestedPrefabDisplayName(objES.getPrefabId()); if (displayName) { - + return displayName; } } @@ -85,7 +85,30 @@ namespace phasereditor2d.scene.ui.sceneobjects { if (displayFormat) { - return applyFormat(obj, displayFormat); + let prefix = ""; + + const targetActionComp = objES.getUserComponentsComponent() + .getUserComponentNodes() + .find(n => n.getComponentName() === "ActionTargetComp"); + + if (targetActionComp) { + + const prop = targetActionComp.getUserComponent() + .getUserProperties() + .getProperties().find(p => p.getName() === "target"); + + if (prop) { + + const value = prop.getComponentProperty().getValue(obj); + + if (value) { + + prefix = value + " → "; + } + } + } + + return prefix + applyFormat(obj, displayFormat); } return objES.getLabel(); @@ -136,7 +159,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { const variableValue = data[k]; - return Boolean(variableValue) ? "#" + k : ""; + return Boolean(variableValue) ? `"${k}"` : ""; }); output = output.replace(/ +/g, " ").trim(); From d28e1ca5e77b27d1c42905c122347b675b8dd0a5 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Sat, 23 Dec 2023 06:27:49 -0500 Subject: [PATCH 06/23] Fixes rendering of script nodes. --- .../phasereditor2d.scene/src/ui/editor/OverlayLayer.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/OverlayLayer.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/OverlayLayer.ts index 9e1a7662..63972935 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/OverlayLayer.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/OverlayLayer.ts @@ -71,18 +71,15 @@ namespace phasereditor2d.scene.ui.editor { const selection = this._editor.getSelection(); - const gameObjectsSet = new Set(selection.filter(obj => sceneobjects.isGameObject(obj))); - for (const obj of selection) { ctx.save(); const isGameObject = sceneobjects.isGameObject(obj); - const isUserCompNode = obj instanceof sceneobjects.UserComponentNode - && !gameObjectsSet.has(obj.getObject()); + const isUserCompNode = obj instanceof sceneobjects.UserComponentNode; - const isScriptNode = obj instanceof sceneobjects.ScriptNode && !gameObjectsSet.has(obj.getParentDisplayObject()); + const isScriptNode = obj instanceof sceneobjects.ScriptNode; const isNonDisplayObject = isUserCompNode || isScriptNode; From 1e8e30266bb3e03fdb7b135116222704af3c5bee Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Sat, 23 Dec 2023 06:33:41 -0500 Subject: [PATCH 07/23] Fixes rename when paste a tree of game objects. --- .../src/ui/editor/undo/PasteOperation.ts | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts index 984a8d94..78f9e157 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts @@ -35,7 +35,7 @@ namespace phasereditor2d.scene.ui.editor.undo { await this.pastePlainObjects(items, sel); - this.pastePrefaProperties(items, sel); + this.pastePrefabProperties(items, sel); this._editor.setSelection(sel); } @@ -56,7 +56,7 @@ namespace phasereditor2d.scene.ui.editor.undo { this.setNewObjectId(data); - const obj =scene.readPlainObject(data); + const obj = scene.readPlainObject(data); if (obj) { @@ -76,7 +76,7 @@ namespace phasereditor2d.scene.ui.editor.undo { } } - private pastePrefaProperties(clipboardItems: IClipboardItem[], sel: any[]) { + private pastePrefabProperties(clipboardItems: IClipboardItem[], sel: any[]) { const scene = this._editor.getScene(); @@ -119,6 +119,8 @@ namespace phasereditor2d.scene.ui.editor.undo { private async pasteGameObjects(clipboardItems: IClipboardItem[], sel: any[]) { + console.log("pasteGamesObjects", clipboardItems.map(i => i.data)); + const scene = this._editor.getScene(); const maker = this._editor.getSceneMaker(); @@ -169,16 +171,28 @@ namespace phasereditor2d.scene.ui.editor.undo { for (const newObj of sprites) { - const oldLabel = newObj.getEditorSupport().getLabel(); - - const newLabel = nameMaker.makeName(oldLabel); - - newObj.getEditorSupport().setLabel(newLabel); + this.updateGameObjectName(newObj, nameMaker); } maker.afterDropObjects(prefabObj, sprites); } + private updateGameObjectName(obj: sceneobjects.ISceneGameObject, nameMaker: colibri.ui.ide.utils.NameMaker) { + + const objES = obj.getEditorSupport(); + + const oldLabel = objES.getLabel(); + + const newLabel = nameMaker.makeName(oldLabel); + + objES.setLabel(newLabel); + + for(const child of objES.getAppendedChildren()) { + + this.updateGameObjectName(child, nameMaker); + } + } + private setNewObjectId(data: json.IObjectData) { data.id = Phaser.Utils.String.UUID(); From 886895454507e24cebfc89c52a6c7669f530d3a4 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Sat, 23 Dec 2023 06:34:22 -0500 Subject: [PATCH 08/23] Updates changelog. --- CHANGELOG.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 05173996..d3f7b4a3 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -5,6 +5,7 @@ * Allows to set a display name to game objects. * The display name formatting expression #{x} expands to "x". * The display name formatting shows prepends the `TargetActionComp.target` value, if present. +* Fixes name collision when duplicate a tree of game objects. ## v3.65.0 - Dec 13, 2024 From a0756453256f2f5790cd4a8cd0306448dd93c187 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Sat, 23 Dec 2023 07:00:03 -0500 Subject: [PATCH 09/23] Do not repeat children objects in copy/paste. --- .../phasereditor2d.scene/src/ui/SceneMaker.ts | 6 +-- .../src/ui/editor/ClipboardManager.ts | 37 +++++++++++++++++-- .../src/ui/editor/undo/PasteOperation.ts | 2 - 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/SceneMaker.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/SceneMaker.ts index 59bbd3f2..5486ea75 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/SceneMaker.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/SceneMaker.ts @@ -80,15 +80,15 @@ namespace phasereditor2d.scene.ui { const selection = alternativeSelection || this._editorScene.getEditor().getSelectedGameObjects(); - const areDropingScriptNodes = dropObjects.filter(obj => obj instanceof sceneobjects.ScriptNode).length === dropObjects.length; + const areDroppingScriptNodes = dropObjects.filter(obj => obj instanceof sceneobjects.ScriptNode).length === dropObjects.length; for (const sprite of selection) { - const dropTarget = areDropingScriptNodes ? this.findDropScriptTargetParent(sprite) : this.findDropTargetParent(sprite); + const dropTarget = areDroppingScriptNodes ? this.findDropScriptTargetParent(sprite) : this.findDropTargetParent(sprite); if (dropTarget) { - if (areDropingScriptNodes) { + if (areDroppingScriptNodes) { dropInObj = dropTarget; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/ClipboardManager.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/ClipboardManager.ts index 2670fc6b..0ffafd9b 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/ClipboardManager.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/ClipboardManager.ts @@ -91,9 +91,38 @@ namespace phasereditor2d.scene.ui.editor { const p = new Phaser.Math.Vector2(); - const gameObjects = this._editor.getSelectedGameObjects(); + const selection = new Set(this._editor.getSelectedGameObjects()); - for (const obj of gameObjects) { + const copyObjects: sceneobjects.ISceneGameObject[] = []; + + // filter off the children of selected parents + + for(const obj of selection) { + + let include = true; + + const objES = obj.getEditorSupport(); + + const parents = objES.getAllParents(); + + for(const parent of parents) { + + if (selection.has(parent)) { + + include = false; + break; + } + } + + if (include) { + + copyObjects.push(obj); + } + } + + // record game objects positions + + for (const obj of copyObjects) { const sprite = obj as unknown as Phaser.GameObjects.Sprite; @@ -111,7 +140,9 @@ namespace phasereditor2d.scene.ui.editor { minY = Math.min(minY, p.y); } - for (const obj of gameObjects) { + // serialize objects + + for (const obj of copyObjects) { const objData = {} as any; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts index 78f9e157..f87807b7 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts @@ -119,8 +119,6 @@ namespace phasereditor2d.scene.ui.editor.undo { private async pasteGameObjects(clipboardItems: IClipboardItem[], sel: any[]) { - console.log("pasteGamesObjects", clipboardItems.map(i => i.data)); - const scene = this._editor.getScene(); const maker = this._editor.getSceneMaker(); From f0912ef45e2d8d4de929da195deb85abdb43931a Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Sat, 23 Dec 2023 07:03:26 -0500 Subject: [PATCH 10/23] Updates changelog. --- CHANGELOG.MD | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index d3f7b4a3..21bff92c 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -5,7 +5,8 @@ * Allows to set a display name to game objects. * The display name formatting expression #{x} expands to "x". * The display name formatting shows prepends the `TargetActionComp.target` value, if present. -* Fixes name collision when duplicate a tree of game objects. +* Fixes name collision when copying a game objects tree. +* Fixes duplicating children objects on a tree copy/paste. ## v3.65.0 - Dec 13, 2024 From 28f6eb01661e829e145e0c91325c4622b8e18cea Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Sat, 23 Dec 2023 08:05:55 -0500 Subject: [PATCH 11/23] Improves display name of target action comp. --- .../src/ui/sceneobjects/Utils.ts | 33 +++++++++++++++---- .../userProperties/UserPropertiesManager.ts | 5 +++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts index f37b9529..9c2dc0c1 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts @@ -93,19 +93,38 @@ namespace phasereditor2d.scene.ui.sceneobjects { if (targetActionComp) { - const prop = targetActionComp.getUserComponent() - .getUserProperties() - .getProperties().find(p => p.getName() === "target"); + const props = targetActionComp.getUserComponent() + .getUserProperties(); - if (prop) { + const targetProp = props.findPropertyByName("target"); + const targetNameProp = props.findPropertyByName("targetName"); - const value = prop.getComponentProperty().getValue(obj); + let value = ""; - if (value) { + if (targetProp) { - prefix = value + " → "; + const target = targetProp.getComponentProperty().getValue(obj); + + if (target) { + + value = target; + } + } + + if (targetNameProp) { + + const name = targetNameProp.getComponentProperty().getValue(obj); + + if (name) { + + value += " " + name; } } + + if (value) { + + prefix = value + " → "; + } } return prefix + applyFormat(obj, displayFormat); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/userProperties/UserPropertiesManager.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/userProperties/UserPropertiesManager.ts index fb099310..17b3246b 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/userProperties/UserPropertiesManager.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/userProperties/UserPropertiesManager.ts @@ -11,6 +11,11 @@ namespace phasereditor2d.scene.ui.sceneobjects { this._properties = []; } + findPropertyByName(name: string) { + + return this._properties.find(p => p.getName() === name); + } + getProperties() { return this._properties; From ae0d38bd1c7417cb8129810590ce69cf9ed99771 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Mon, 25 Dec 2023 07:19:54 -0500 Subject: [PATCH 12/23] Fixes string prop in user component section. --- .../src/ui/editor/usercomponent/UserComponentSection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponentSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponentSection.ts index 69ce454e..c64ac2c1 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponentSection.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponentSection.ts @@ -119,7 +119,7 @@ namespace phasereditor2d.scene.ui.editor.usercomponent { this.addUpdater(() => { text.value = this.flatValues_StringOneOrNothing( - this.getSelection().map(c => c["get" + prop]())); + this.getSelection().map(c => c["get" + prop]() || "")); }); if (options) { From a880c0f9207cdbaee97b5f7ef8057a0b864985e0 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Mon, 25 Dec 2023 07:32:19 -0500 Subject: [PATCH 13/23] Fixes default value display name. --- .../src/ui/editor/properties/DynamicUserSectionExtension.ts | 3 +++ .../phasereditor2d.scene/src/ui/sceneobjects/EditorSupport.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts index 5137c82a..b5015589 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts @@ -35,6 +35,7 @@ namespace phasereditor2d.scene.ui.editor.properties { } } + // add user components from prefabs for (const obj of editor.getSelectedGameObjects()) { @@ -57,6 +58,8 @@ namespace phasereditor2d.scene.ui.editor.properties { const prefabUserProps = objES.getComponent(sceneobjects.PrefabUserPropertyComponent) as sceneobjects.PrefabUserPropertyComponent; const prefabInfoList = prefabUserProps.getPropertiesByPrefab(); + console.log("properties by prefab", prefabInfoList); + // add all properties from prefabs for (const prefabInfo of prefabInfoList) { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/EditorSupport.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/EditorSupport.ts index 974ea55d..01248268 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/EditorSupport.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/EditorSupport.ts @@ -16,6 +16,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { this._object = obj; this._scene = scene; this._label = label; + this._displayName = ""; this._useGameObjectName = false; this._scope = ObjectScope.LOCAL; From 3c005e478e1baa43a406e9a3090c85f0ba4b1b60 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Mon, 25 Dec 2023 08:15:40 -0500 Subject: [PATCH 14/23] Fixes getting user components of nested prefabs. --- .../properties/DynamicUserSectionExtension.ts | 4 +-- .../object/PrefabUserPropertyComponent.ts | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts index b5015589..dfa729e5 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts @@ -35,7 +35,7 @@ namespace phasereditor2d.scene.ui.editor.properties { } } - // add user components from prefabs + // add properties from prefab for (const obj of editor.getSelectedGameObjects()) { @@ -58,8 +58,6 @@ namespace phasereditor2d.scene.ui.editor.properties { const prefabUserProps = objES.getComponent(sceneobjects.PrefabUserPropertyComponent) as sceneobjects.PrefabUserPropertyComponent; const prefabInfoList = prefabUserProps.getPropertiesByPrefab(); - console.log("properties by prefab", prefabInfoList); - // add all properties from prefabs for (const prefabInfo of prefabInfoList) { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/PrefabUserPropertyComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/PrefabUserPropertyComponent.ts index e63e54a4..f148902a 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/PrefabUserPropertyComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/PrefabUserPropertyComponent.ts @@ -43,6 +43,15 @@ namespace phasereditor2d.scene.ui.sceneobjects { if (objES.isPrefabInstance()) { + // get all from the nested prefabs chain + + if (objES.isNestedPrefabInstance()) { + + this.getNestedPrefabProperties(propertiesInObject, objES.getPrefabId()); + } + + // get all from non-nested prefab hierarchy + const nextPrefabId = finder.getFirstNonNestedPrefabId(objES.getPrefabId()); if (nextPrefabId) { @@ -59,6 +68,28 @@ namespace phasereditor2d.scene.ui.sceneobjects { return propertiesInObject; } + private getNestedPrefabProperties(propertiesInObject: IUserPropertiesInObject[], + nestedPrefabId: string) { + + const finder = ScenePlugin.getInstance().getSceneFinder(); + + const prefabFile = finder.getPrefabFile(nestedPrefabId); + + propertiesInObject.push({ + prefabFile, + properties: [] + }); + + const data = finder.getPrefabData(nestedPrefabId); + + nestedPrefabId = data.prefabId; + + if (nestedPrefabId && finder.isNestedPrefab(nestedPrefabId)) { + + this.getNestedPrefabProperties(propertiesInObject, data.prefabId); + } + } + private getPrefabProperties(propertiesInObject: IUserPropertiesInObject[], prefabFile: io.FilePath) { const finder = ScenePlugin.getInstance().getSceneFinder(); From d86a1d297fc869ea6dd0f6a6e12cd5971c7d5f75 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Mon, 25 Dec 2023 08:15:59 -0500 Subject: [PATCH 15/23] Updates changelog. --- CHANGELOG.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 21bff92c..76fa4254 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,6 +7,7 @@ * The display name formatting shows prepends the `TargetActionComp.target` value, if present. * Fixes name collision when copying a game objects tree. * Fixes duplicating children objects on a tree copy/paste. +* Fixes getting user components of nested prefabs. ## v3.65.0 - Dec 13, 2024 From ac8d30f21b06bef176fc4bfbf210315ae0047fb2 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Mon, 25 Dec 2023 08:53:31 -0500 Subject: [PATCH 16/23] Fixes getting user components from nested prefabs. --- .../properties/DynamicUserSectionExtension.ts | 10 ++++++---- .../object/UserComponentsEditorComponent.ts | 16 +++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts index dfa729e5..f946b725 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts @@ -9,7 +9,7 @@ namespace phasereditor2d.scene.ui.editor.properties { const result: GetPropertySection[] = []; - const visitedPrefabs = new Set(); + const visitedPrefabs = new Set(); const visitedComps = new Set(); const finder = ScenePlugin.getInstance().getSceneFinder(); @@ -37,6 +37,8 @@ namespace phasereditor2d.scene.ui.editor.properties { // add properties from prefab + console.log("here"); + for (const obj of editor.getSelectedGameObjects()) { const objES = obj.getEditorSupport(); @@ -46,14 +48,14 @@ namespace phasereditor2d.scene.ui.editor.properties { continue; } - const prefabFile = objES.getPrefabFile(); + const prefabId = objES.getPrefabId(); - if (visitedPrefabs.has(prefabFile)) { + if (visitedPrefabs.has(prefabId)) { continue; } - visitedPrefabs.add(prefabFile); + visitedPrefabs.add(prefabId); const prefabUserProps = objES.getComponent(sceneobjects.PrefabUserPropertyComponent) as sceneobjects.PrefabUserPropertyComponent; const prefabInfoList = prefabUserProps.getPropertiesByPrefab(); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/UserComponentsEditorComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/UserComponentsEditorComponent.ts index 0e0e86e6..01952821 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/UserComponentsEditorComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/UserComponentsEditorComponent.ts @@ -282,23 +282,13 @@ namespace phasereditor2d.scene.ui.sceneobjects { getPrefabUserComponents(): IUserComponentAndPrefab[] { - const finder = ScenePlugin.getInstance().getSceneFinder(); - const result: IUserComponentAndPrefab[] = []; - const support = this.getObject().getEditorSupport(); - - if (support.isPrefabInstance()) { - - const objData = finder.getPrefabData(support.getPrefabId()); + const objES = this.getObject().getEditorSupport(); - if (objData) { - - if (objData.components) { + if (objES.isPrefabInstance()) { - this.getUserComponentsOfPrefab(support.getPrefabId(), result); - } - } + this.getUserComponentsOfPrefab(objES.getPrefabId(), result); } return result; From b799d3d88dbdb4bd7aca9110c44fc1ae3a5f99e7 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Mon, 25 Dec 2023 10:08:11 -0500 Subject: [PATCH 17/23] Removes log messages. --- .../src/ui/editor/properties/DynamicUserSectionExtension.ts | 2 -- .../sceneobjects/userProperties/AbstractDialogPropertyType.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts index f946b725..4a7111fb 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/properties/DynamicUserSectionExtension.ts @@ -37,8 +37,6 @@ namespace phasereditor2d.scene.ui.editor.properties { // add properties from prefab - console.log("here"); - for (const obj of editor.getSelectedGameObjects()) { const objES = obj.getEditorSupport(); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/userProperties/AbstractDialogPropertyType.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/userProperties/AbstractDialogPropertyType.ts index 7406a1ef..9e599b63 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/userProperties/AbstractDialogPropertyType.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/userProperties/AbstractDialogPropertyType.ts @@ -226,8 +226,6 @@ namespace phasereditor2d.scene.ui.sceneobjects { formBuilder.createButton(comp, resources.getIcon(resources.ICON_PLAY), () => { - console.log("here"); - previewAction(); }); } From 6c7a80d4f171a8fab660da6a6237fa6e1f3334b3 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Thu, 28 Dec 2023 08:27:44 -0500 Subject: [PATCH 18/23] Allows user component object formatting. --- CHANGELOG.MD | 1 + .../ui/editor/usercomponent/UserComponent.ts | 14 +++ .../usercomponent/UserComponentSection.ts | 2 + .../src/ui/sceneobjects/Utils.ts | 105 ++++++++++++------ 4 files changed, 87 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 76fa4254..d36294a8 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -8,6 +8,7 @@ * Fixes name collision when copying a game objects tree. * Fixes duplicating children objects on a tree copy/paste. * Fixes getting user components of nested prefabs. +* Allows user component object formatting. ## v3.65.0 - Dec 13, 2024 diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponent.ts index 549ea99c..b6adc3c0 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponent.ts @@ -6,6 +6,7 @@ namespace phasereditor2d.scene.ui.editor.usercomponent { private _name: string; private _displayName: string; + private _objectDisplayFormat: string; private _baseClass: string; private _gameObjectType: string; private _properties: sceneobjects.UserPropertiesManager; @@ -15,6 +16,7 @@ namespace phasereditor2d.scene.ui.editor.usercomponent { this._name = name; this._baseClass = ""; this._displayName = ""; + this._objectDisplayFormat = ""; this._gameObjectType = "Phaser.GameObjects.Image"; this._properties = new UserComponentProperties(this); } @@ -27,6 +29,7 @@ namespace phasereditor2d.scene.ui.editor.usercomponent { const data = { name: this._name, displayName: this._displayName, + objectDisplayFormat: this._objectDisplayFormat, baseClass: this._baseClass, gameObjectType: this._gameObjectType, properties: propsData @@ -39,6 +42,7 @@ namespace phasereditor2d.scene.ui.editor.usercomponent { this._name = data.name; this._displayName = read(data, "displayName", ""); + this._objectDisplayFormat = read(data, "objectDisplayFormat", ""); this._baseClass = read(data, "baseClass", ""); this._gameObjectType = read(data, "gameObjectType", "Phaser.GameObjects.Image"); this._properties.readJSON(data.properties); @@ -54,6 +58,16 @@ namespace phasereditor2d.scene.ui.editor.usercomponent { this._name = name; } + getObjectDisplayFormat() { + + return this._objectDisplayFormat; + } + + setObjectDisplayFormat(objectDisplayFormat: string) { + + this._objectDisplayFormat = objectDisplayFormat; + } + getDisplayName() { return this._displayName; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponentSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponentSection.ts index c64ac2c1..8751cdd3 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponentSection.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/usercomponent/UserComponentSection.ts @@ -41,6 +41,8 @@ namespace phasereditor2d.scene.ui.editor.usercomponent { this.stringProp(comp, "BaseClass", "Super Class", "Name of the super class of the component. It is optional.", () => this.createSuperClassOptions()); this.stringProp(comp, "DisplayName", "Display Name", "The display name of the component."); + + this.stringProp(comp, "ObjectDisplayFormat", "Object Display Format", "The display name format to show in prefab instances."); const op = ( action: editor.properties.TUserPropertiesAction) => { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts index 9c2dc0c1..03a0a0b9 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts @@ -85,52 +85,58 @@ namespace phasereditor2d.scene.ui.sceneobjects { if (displayFormat) { - let prefix = ""; + let prefix = getTargetActionDisplayNamePrefix(objES, obj); - const targetActionComp = objES.getUserComponentsComponent() - .getUserComponentNodes() - .find(n => n.getComponentName() === "ActionTargetComp"); + return prefix + applyFormat(obj, displayFormat); + } - if (targetActionComp) { + return objES.getLabel(); + } - const props = targetActionComp.getUserComponent() - .getUserProperties(); + function getTargetActionDisplayNamePrefix(objES: GameObjectEditorSupport, obj: ISceneGameObject) { + + let prefix = ""; - const targetProp = props.findPropertyByName("target"); - const targetNameProp = props.findPropertyByName("targetName"); + const targetActionComp = objES.getUserComponentsComponent() + .getUserComponentNodes() + .find(n => n.getComponentName() === "ActionTargetComp"); - let value = ""; + if (targetActionComp) { - if (targetProp) { + const props = targetActionComp.getUserComponent() + .getUserProperties(); - const target = targetProp.getComponentProperty().getValue(obj); + const targetProp = props.findPropertyByName("target"); + const targetNameProp = props.findPropertyByName("targetName"); - if (target) { + let value = ""; - value = target; - } - } + if (targetProp) { - if (targetNameProp) { + const target = targetProp.getComponentProperty().getValue(obj); - const name = targetNameProp.getComponentProperty().getValue(obj); + if (target) { - if (name) { - - value += " " + name; - } + value = target; } + } - if (value) { + if (targetNameProp) { - prefix = value + " → "; + const name = targetNameProp.getComponentProperty().getValue(obj); + + if (name) { + + value += " " + name; } } - return prefix + applyFormat(obj, displayFormat); - } + if (value) { - return objES.getLabel(); + prefix = value + " → "; + } + } + return prefix; } function applyFormat(obj: ISceneGameObject, displayFormat: string) { @@ -141,30 +147,60 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: objES.getLabel() }; - // from user components + // from prefabs { - const comp = objES.getUserComponentsComponent(); + const comp = objES.getComponent(PrefabUserPropertyComponent) as PrefabUserPropertyComponent; const props = comp.getProperties(); for (const prop of props) { - data[prop.codeName] = prop.getValue(obj); + data[prop.name] = prop.getValue(obj); } } - // from prefabs + // from user components + let componentsSuffix = ""; { - const comp = objES.getComponent(PrefabUserPropertyComponent) as PrefabUserPropertyComponent; + const components = objES.getUserComponentsComponent(); - const props = comp.getProperties(); + const props = components.getProperties(); for (const prop of props) { - data[prop.name] = prop.getValue(obj); + data[prop.codeName] = prop.getValue(obj); + } + + for(const node of components.getUserComponentNodes()) { + + const comp = node.getUserComponent(); + + const format = comp.getObjectDisplayFormat(); + + if (format) { + + const compData = {}; + + for(const userProp of comp.getUserProperties().getProperties()) { + + const prop = userProp.getComponentProperty(); + + const value = prop.getValue(obj); + + compData[prop.codeName] = value; + } + + componentsSuffix += " " + formatString(format, compData); + } } } + let output = formatString(displayFormat, data) + componentsSuffix; + + return output; + } + + function formatString(displayFormat: string, data: any) { let output = displayFormat.replace(/\${(.*?)}/g, (match, p1) => { const variableValue = data[p1.trim()]; @@ -182,7 +218,6 @@ namespace phasereditor2d.scene.ui.sceneobjects { }); output = output.replace(/ +/g, " ").trim(); - return output; } From e5488280ded42d2d506bebd52cde22637a287aff Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Mon, 8 Jan 2024 17:26:11 -0500 Subject: [PATCH 19/23] Disable save in read-only editors. Set node_module files to read-only. --- .../colibri/src/ui/controls/TabPane.ts | 12 +++++++++ .../plugins/colibri/src/ui/ide/EditorPart.ts | 26 +++++++++++++++++++ .../src/ui/ide/FileEditorInputExtension.ts | 2 ++ .../plugins/colibri/styles/controls.css | 3 +++ .../phasereditor2d.ide/src/IDEPlugin.ts | 10 +++++++ .../src/ui/sceneobjects/Utils.ts | 4 +-- 6 files changed, 55 insertions(+), 2 deletions(-) diff --git a/source/editor/plugins/colibri/src/ui/controls/TabPane.ts b/source/editor/plugins/colibri/src/ui/controls/TabPane.ts index cee1ea58..754bb91c 100644 --- a/source/editor/plugins/colibri/src/ui/controls/TabPane.ts +++ b/source/editor/plugins/colibri/src/ui/controls/TabPane.ts @@ -509,6 +509,18 @@ namespace colibri.ui.controls { } } + setTabReadOnly(labelElement: HTMLElement, readOnly: boolean) { + + if (readOnly) { + + labelElement.classList.add("ReadOnly"); + + } else { + + labelElement.classList.remove("ReadOnly"); + } + } + closeTab(content: controls.Control) { const label = this.getLabelFromContent(content); diff --git a/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts b/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts index e21a4a65..3d253b89 100644 --- a/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts +++ b/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts @@ -6,6 +6,7 @@ namespace colibri.ui.ide { private _input: IEditorInput; private _dirty: boolean; + private _readOnly: boolean; private _embeddedMode: boolean; private _editorFactory: EditorFactory; @@ -21,6 +22,24 @@ namespace colibri.ui.ide { this._editorFactory = factory; } + setReadOnly(readOnly: boolean) { + + this._readOnly = readOnly; + + if (this.isInEditorArea()) { + + const folder = this.getPartFolder(); + const label = folder.getLabelFromContent(this); + + folder.setTabReadOnly(label, this._readOnly); + } + } + + isReadOnly() { + + return this._readOnly; + } + getEditorFactory() { return this._editorFactory; @@ -66,6 +85,13 @@ namespace colibri.ui.ide { async save() { + if (this.isReadOnly()) { + + alert("Cannot save, the editor is in read-only mode.'"); + + return; + } + await this.doSave(); } diff --git a/source/editor/plugins/colibri/src/ui/ide/FileEditorInputExtension.ts b/source/editor/plugins/colibri/src/ui/ide/FileEditorInputExtension.ts index ea736be1..d17a55f6 100644 --- a/source/editor/plugins/colibri/src/ui/ide/FileEditorInputExtension.ts +++ b/source/editor/plugins/colibri/src/ui/ide/FileEditorInputExtension.ts @@ -18,10 +18,12 @@ namespace colibri.ui.ide { } createEditorInput(state: any): IEditorInput { + return colibri.ui.ide.FileUtils.getFileFromPath(state.filePath); } getEditorInputId(input: core.io.FilePath): string { + return input.getFullName(); } } diff --git a/source/editor/plugins/colibri/styles/controls.css b/source/editor/plugins/colibri/styles/controls.css index a1de5619..f03fe35c 100644 --- a/source/editor/plugins/colibri/styles/controls.css +++ b/source/editor/plugins/colibri/styles/controls.css @@ -137,6 +137,9 @@ padding-bottom: 5px; } + .TabPaneLabel.ReadOnly span { + opacity: 0.5; + } .TabPaneLabel span { margin: 3px 0px 0px 3px; diff --git a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts index b09a4036..cafcc991 100644 --- a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts +++ b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts @@ -77,6 +77,16 @@ namespace phasereditor2d.ide { reg.addExtension(new ui.viewers.LibraryFileStyledLabelProviderExtension()); phasereditor2d.files.FilesPlugin.getInstance().setOpenFileAction(file => this.openFileFromFilesView(file)); + + colibri.Platform.getWorkbench().eventEditorActivated.addListener(editor => { + + const file = editor.getInput(); + + if (file instanceof colibri.core.io.FilePath) { + + editor.setReadOnly(ide.core.code.isNodeLibraryFile(file)); + } + }); } async compileProject() { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts index 03a0a0b9..0c60c2dc 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/Utils.ts @@ -190,12 +190,12 @@ namespace phasereditor2d.scene.ui.sceneobjects { compData[prop.codeName] = value; } - componentsSuffix += " " + formatString(format, compData); + componentsSuffix += ", " + formatString(format, compData); } } } - let output = formatString(displayFormat, data) + componentsSuffix; + const output = formatString(displayFormat, data) + componentsSuffix; return output; } From aa19b8b729010b85d25324a931c4a34ebc3cb2ea Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Mon, 8 Jan 2024 17:26:55 -0500 Subject: [PATCH 20/23] Updates changelog. --- CHANGELOG.MD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index d36294a8..6d562440 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -9,6 +9,8 @@ * Fixes duplicating children objects on a tree copy/paste. * Fixes getting user components of nested prefabs. * Allows user component object formatting. +* Allow read-only editors. +* Set read-only to editors of node_module files. ## v3.65.0 - Dec 13, 2024 From 818b8dd7d47f847978ffacb0dd88b81a9707f95e Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Wed, 10 Jan 2024 04:20:03 -0500 Subject: [PATCH 21/23] Update version. --- source/editor/product.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/editor/product.json b/source/editor/product.json index d89bad91..647decb4 100644 --- a/source/editor/product.json +++ b/source/editor/product.json @@ -1,4 +1,4 @@ { "title": "Phaser Editor 2D", - "version": "3.66.0-dev" + "version": "3.66.0" } \ No newline at end of file From 545b0a2f7897dad6210a6408219392d2867bccb4 Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Wed, 10 Jan 2024 18:45:56 -0500 Subject: [PATCH 22/23] Updates changelog. --- CHANGELOG.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 6d562440..f13af160 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,6 +1,6 @@ # Change Log -## dev +## v3.66.0 - Jan 10, 2024 * Allows to set a display name to game objects. * The display name formatting expression #{x} expands to "x". From af847bc941d9da3cfccf295fccf70aec25acb3ad Mon Sep 17 00:00:00 2001 From: PhaserEditor2D Date: Fri, 12 Jan 2024 05:07:22 -0500 Subject: [PATCH 23/23] Updates changelog. --- CHANGELOG.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index f13af160..dd8cab3b 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,6 +1,6 @@ # Change Log -## v3.66.0 - Jan 10, 2024 +## v3.66.0 - Jan 11, 2024 * Allows to set a display name to game objects. * The display name formatting expression #{x} expands to "x".