Skip to content

Commit

Permalink
Adds the Name parameter to the Variable section of a nested prefab in…
Browse files Browse the repository at this point in the history
…stance #282
  • Loading branch information
PhaserEditor2D committed May 16, 2023
1 parent cc97994 commit c8aba01
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Auto computes the middle-private nested prefabs. It doesn't require to declare a parent of a nested prefab as nested prefab.
* Improves Outline elements tagging. It uses tahs like `#prefab_inst` `#nested_prefab_inst` `#scope_local` `#scope_nested_prefab`... So you can search for it in the Outline filter box.
* Allows enabling input in objects.
* Adds the Name parameter to the Variable section of a nested prefab instance.

## v3.60.3 - Apr 27, 2023

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ namespace phasereditor2d.scene.core.code {

private addCreateObjectCodeOfNestedPrefab(obj: ISceneGameObject, createMethodDecl: MethodDeclCodeDOM, lazyStatements: CodeDOM[]) {

const varname = this.getPrefabInstanceVarName(obj);
const varname = SceneCodeDOMBuilder.getPrefabInstanceVarName(obj);

const result = this.buildSetObjectProperties({
obj,
Expand Down Expand Up @@ -687,7 +687,7 @@ namespace phasereditor2d.scene.core.code {
&& objParent === this._scene.getPrefabObject();

parentVarName = parentIsPrefabObject ? "this"
: this.getPrefabInstanceVarName(objParent);
: SceneCodeDOMBuilder.getPrefabInstanceVarName(objParent);
}

// the script nodes require using the varname of the parents
Expand Down Expand Up @@ -881,7 +881,7 @@ namespace phasereditor2d.scene.core.code {
.join(" & ");
}

private getPrefabInstanceVarName(obj: ISceneGameObject): string {
static getPrefabInstanceVarName(obj: ISceneGameObject): string {

const objES = obj.getEditorSupport();

Expand All @@ -904,7 +904,7 @@ namespace phasereditor2d.scene.core.code {
return varName;
}

private findPrefabInstanceWhereTheGivenObjectIsDefined(obj: ui.sceneobjects.ISceneGameObject): ui.sceneobjects.ISceneGameObject {
private static findPrefabInstanceWhereTheGivenObjectIsDefined(obj: ui.sceneobjects.ISceneGameObject): ui.sceneobjects.ISceneGameObject {

const objES = obj.getEditorSupport();

Expand All @@ -919,7 +919,7 @@ namespace phasereditor2d.scene.core.code {
return this.findPrefabInstanceOfFile(parent, objPrefabFile);
}

private findPrefabInstanceOfFile(obj: ISceneGameObject, targetPrefaFile: io.FilePath): ISceneGameObject {
private static findPrefabInstanceOfFile(obj: ISceneGameObject, targetPrefaFile: io.FilePath): ISceneGameObject {

const finder = ScenePlugin.getInstance().getSceneFinder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,34 @@ namespace phasereditor2d.scene.ui.sceneobjects {

const comp = this.createGridElement(parent, 2);

const { btn } = GameObjectVariableSection.createTypeEditor(this, comp);
btn.disabled = true;
{
// Name

this.createLabel(comp, "Name", "The name of the variable associated to this object. This name is used by the compiler.");

const text = this.createText(comp, true);

this.addUpdater(() => {

text.value = this.flatValues_StringOneOrNothing(
this.getSelection()
.map(obj => this.getVarName(obj)));
})
}

{
// Type

const { btn } = GameObjectVariableSection.createTypeEditor(this, comp);
btn.disabled = true;
}
}

private getVarName(obj: ISceneGameObject) {

const varName = core.code.SceneCodeDOMBuilder.getPrefabInstanceVarName(obj);

return varName;
}

canEdit(obj: any, n: number): boolean {
Expand Down

0 comments on commit c8aba01

Please sign in to comment.