Skip to content

Commit

Permalink
Export plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Aug 23, 2023
1 parent fb49870 commit b12b0e7
Show file tree
Hide file tree
Showing 110 changed files with 4,364 additions and 1,585 deletions.
106 changes: 82 additions & 24 deletions dist/rexbadgelabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1053,15 +1053,34 @@
if (descending === undefined) {
descending = false;
}
var displayList = gameObjects[0].displayList;
displayList.depthSort();
var itemList;
var gameObject = gameObjects[0];
if (gameObject.displayList) {
// Inside a scene or a layer
itemList = gameObject.displayList; // displayList
} else if (gameObject.parentContainer) {
// Inside a container
itemList = gameObject.parentContainer.list; // array
} else {
itemList = gameObject.scene.sys.displayList; // displayList
// ??
}

if (itemList.depthSort) {
// Is a displayList object
itemList.depthSort();
itemList = itemList.list;
// itemList is an array now
}

// itemList is an array
if (descending) {
gameObjects.sort(function (childA, childB) {
return displayList.getIndex(childB) - displayList.getIndex(childA);
return itemList.indexOf(childB) - itemList.indexOf(childA);
});
} else {
gameObjects.sort(function (childA, childB) {
return displayList.getIndex(childA) - displayList.getIndex(childB);
return itemList.indexOf(childA) - itemList.indexOf(childB);
});
}
return gameObjects;
Expand Down Expand Up @@ -1408,40 +1427,79 @@
}
};

var ContainerKlass = Phaser.GameObjects.Container;
var IsContainerObject = function IsContainerObject(gameObject) {
return gameObject instanceof ContainerKlass;
};

var LayerKlass = Phaser.GameObjects.Layer;
var IsLayerGameObject = function IsLayerGameObject(gameObject) {
return gameObject instanceof LayerKlass;
};

var GetValidChildren = function GetValidChildren(parent) {
var children = parent.getAllChildren([parent]);
children = children.filter(function (gameObject) {
return !!gameObject.displayList ||
// At scene's displayList or at a layer
!!gameObject.parentContainer; // At a container
});

return children;
};
var AddToContainer = function AddToContainer(p3Container) {
var gameObjects = GetValidChildren(this);
SortGameObjectsByDepth(gameObjects);
p3Container.add(gameObjects);
return this;
};
var RemoveFromContainer = function RemoveFromContainer(p3Container, descending, addToScene) {
var gameObjects = GetValidChildren(this);
SortGameObjectsByDepth(gameObjects, descending);
p3Container.remove(gameObjects);
if (addToScene) {
gameObjects.forEach(function (gameObject) {
gameObject.addToDisplayList();
});
}
return this;
};
var P3Container = {
addToContainer: function addToContainer(p3Container) {
if (!IsContainerObject(p3Container)) {
return this;
}
this._setParentContainerFlag = true;
var gameObjects = this.getAllChildren([this]);
SortGameObjectsByDepth(gameObjects);
p3Container.add(gameObjects);
AddToContainer.call(this, p3Container);
this._setParentContainerFlag = false;
return this;
},
addToLayer: function addToLayer(layer) {
this.addToContainer(layer);
if (!IsLayerGameObject(layer)) {
return this;
}
AddToContainer.call(this, layer);
return this;
},
removeFromContainer: function removeFromContainer() {
if (!this.parentContainer) {
return this;
}

// Will add gameObjects to scene
var gameObjects = this.getAllChildren([this]).filter(function (gameObject) {
return !!gameObject.scene;
});
if (gameObjects.length === 0) {
return this;
}
this._setParentContainerFlag = true;
if (gameObjects.length > 1) {
SortGameObjectsByDepth(gameObjects);
gameObjects.reverse();
}
this.parentContainer.remove(gameObjects);
RemoveFromContainer.call(this, this.parentContainer, true, false);
this._setParentContainerFlag = false;
return this;
},
removeFromLayer: function removeFromLayer(addToScene) {
if (addToScene === undefined) {
addToScene = true;
}
if (!IsLayerGameObject(this.displayList)) {
return this;
}
RemoveFromContainer.call(this, this.displayList, false, addToScene);
return this;
},
getParentContainer: function getParentContainer() {
if (this.parentContainer) {
return this.parentContainer;
Expand All @@ -1459,7 +1517,7 @@
return null;
},
addToParentContainer: function addToParentContainer(gameObject) {
// Don't add to layer if gameObject is not in any displayList
// Do nothing if gameObject is not in any displayList
if (!gameObject.displayList) {
return this;
}
Expand All @@ -1478,7 +1536,7 @@
}
};

var Layer = {
var RenderLayer = {
hasLayer: function hasLayer() {
return !!this.privateRenderLayer;
},
Expand Down Expand Up @@ -2032,7 +2090,7 @@
changeOrigin: ChangeOrigin,
drawBounds: DrawBounds$1
};
Object.assign(methods$4, Parent, AddChild$1, RemoveChild$1, ChildState, Transform, Position, Rotation, Scale$1, Visible, Alpha, Active, ScrollFactor, Mask, Depth, Children, Tween, P3Container, Layer, RenderTexture);
Object.assign(methods$4, Parent, AddChild$1, RemoveChild$1, ChildState, Transform, Position, Rotation, Scale$1, Visible, Alpha, Active, ScrollFactor, Mask, Depth, Children, Tween, P3Container, RenderLayer, RenderTexture);

var ContainerLite = /*#__PURE__*/function (_Base) {
_inherits(ContainerLite, _Base);
Expand Down
2 changes: 1 addition & 1 deletion dist/rexbadgelabel.min.js

Large diffs are not rendered by default.

106 changes: 82 additions & 24 deletions dist/rexboardplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12634,15 +12634,34 @@
if (descending === undefined) {
descending = false;
}
var displayList = gameObjects[0].displayList;
displayList.depthSort();
var itemList;
var gameObject = gameObjects[0];
if (gameObject.displayList) {
// Inside a scene or a layer
itemList = gameObject.displayList; // displayList
} else if (gameObject.parentContainer) {
// Inside a container
itemList = gameObject.parentContainer.list; // array
} else {
itemList = gameObject.scene.sys.displayList; // displayList
// ??
}

if (itemList.depthSort) {
// Is a displayList object
itemList.depthSort();
itemList = itemList.list;
// itemList is an array now
}

// itemList is an array
if (descending) {
gameObjects.sort(function (childA, childB) {
return displayList.getIndex(childB) - displayList.getIndex(childA);
return itemList.indexOf(childB) - itemList.indexOf(childA);
});
} else {
gameObjects.sort(function (childA, childB) {
return displayList.getIndex(childA) - displayList.getIndex(childB);
return itemList.indexOf(childA) - itemList.indexOf(childB);
});
}
return gameObjects;
Expand Down Expand Up @@ -12989,40 +13008,79 @@
}
};

var ContainerKlass = Phaser.GameObjects.Container;
var IsContainerObject = function IsContainerObject(gameObject) {
return gameObject instanceof ContainerKlass;
};

var LayerKlass = Phaser.GameObjects.Layer;
var IsLayerGameObject = function IsLayerGameObject(gameObject) {
return gameObject instanceof LayerKlass;
};

var GetValidChildren = function GetValidChildren(parent) {
var children = parent.getAllChildren([parent]);
children = children.filter(function (gameObject) {
return !!gameObject.displayList ||
// At scene's displayList or at a layer
!!gameObject.parentContainer; // At a container
});

return children;
};
var AddToContainer = function AddToContainer(p3Container) {
var gameObjects = GetValidChildren(this);
SortGameObjectsByDepth(gameObjects);
p3Container.add(gameObjects);
return this;
};
var RemoveFromContainer = function RemoveFromContainer(p3Container, descending, addToScene) {
var gameObjects = GetValidChildren(this);
SortGameObjectsByDepth(gameObjects, descending);
p3Container.remove(gameObjects);
if (addToScene) {
gameObjects.forEach(function (gameObject) {
gameObject.addToDisplayList();
});
}
return this;
};
var P3Container = {
addToContainer: function addToContainer(p3Container) {
if (!IsContainerObject(p3Container)) {
return this;
}
this._setParentContainerFlag = true;
var gameObjects = this.getAllChildren([this]);
SortGameObjectsByDepth(gameObjects);
p3Container.add(gameObjects);
AddToContainer.call(this, p3Container);
this._setParentContainerFlag = false;
return this;
},
addToLayer: function addToLayer(layer) {
this.addToContainer(layer);
if (!IsLayerGameObject(layer)) {
return this;
}
AddToContainer.call(this, layer);
return this;
},
removeFromContainer: function removeFromContainer() {
if (!this.parentContainer) {
return this;
}

// Will add gameObjects to scene
var gameObjects = this.getAllChildren([this]).filter(function (gameObject) {
return !!gameObject.scene;
});
if (gameObjects.length === 0) {
return this;
}
this._setParentContainerFlag = true;
if (gameObjects.length > 1) {
SortGameObjectsByDepth(gameObjects);
gameObjects.reverse();
}
this.parentContainer.remove(gameObjects);
RemoveFromContainer.call(this, this.parentContainer, true, false);
this._setParentContainerFlag = false;
return this;
},
removeFromLayer: function removeFromLayer(addToScene) {
if (addToScene === undefined) {
addToScene = true;
}
if (!IsLayerGameObject(this.displayList)) {
return this;
}
RemoveFromContainer.call(this, this.displayList, false, addToScene);
return this;
},
getParentContainer: function getParentContainer() {
if (this.parentContainer) {
return this.parentContainer;
Expand All @@ -13040,7 +13098,7 @@
return null;
},
addToParentContainer: function addToParentContainer(gameObject) {
// Don't add to layer if gameObject is not in any displayList
// Do nothing if gameObject is not in any displayList
if (!gameObject.displayList) {
return this;
}
Expand All @@ -13059,7 +13117,7 @@
}
};

var Layer = {
var RenderLayer = {
hasLayer: function hasLayer() {
return !!this.privateRenderLayer;
},
Expand Down Expand Up @@ -13573,7 +13631,7 @@
changeOrigin: ChangeOrigin,
drawBounds: DrawBounds
};
Object.assign(methods, Parent, AddChild, RemoveChild, ChildState, Transform, Position, Rotation, Scale, Visible, Alpha, Active, ScrollFactor, Mask, Depth, Children, Tween, P3Container, Layer, RenderTexture);
Object.assign(methods, Parent, AddChild, RemoveChild, ChildState, Transform, Position, Rotation, Scale, Visible, Alpha, Active, ScrollFactor, Mask, Depth, Children, Tween, P3Container, RenderLayer, RenderTexture);

var ContainerLite = /*#__PURE__*/function (_Base) {
_inherits(ContainerLite, _Base);
Expand Down
2 changes: 1 addition & 1 deletion dist/rexboardplugin.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit b12b0e7

Please sign in to comment.