mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-14 02:31:51 +00:00
Allow mods to replace builtin sub shapes
This commit is contained in:
parent
c553ee1632
commit
7e0689694c
@ -384,12 +384,20 @@ export class ShapeDefinition extends BasicSerializableObject {
|
|||||||
context.strokeStyle = THEME.items.outline;
|
context.strokeStyle = THEME.items.outline;
|
||||||
context.lineWidth = THEME.items.outlineWidth;
|
context.lineWidth = THEME.items.outlineWidth;
|
||||||
|
|
||||||
|
if (MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]) {
|
||||||
|
MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]({
|
||||||
|
context,
|
||||||
|
layerScale,
|
||||||
|
quadrantSize,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
switch (subShape) {
|
switch (subShape) {
|
||||||
case enumSubShape.rect: {
|
case enumSubShape.rect: {
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
const dims = quadrantSize * layerScale;
|
const dims = quadrantSize * layerScale;
|
||||||
context.rect(-quadrantHalfSize, quadrantHalfSize - dims, dims, dims);
|
context.rect(-quadrantHalfSize, quadrantHalfSize - dims, dims, dims);
|
||||||
|
context.fill();
|
||||||
|
context.stroke();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case enumSubShape.star: {
|
case enumSubShape.star: {
|
||||||
@ -405,6 +413,8 @@ export class ShapeDefinition extends BasicSerializableObject {
|
|||||||
context.lineTo(originX + dims - moveInwards, originY + dims);
|
context.lineTo(originX + dims - moveInwards, originY + dims);
|
||||||
context.lineTo(originX, originY + dims);
|
context.lineTo(originX, originY + dims);
|
||||||
context.closePath();
|
context.closePath();
|
||||||
|
context.fill();
|
||||||
|
context.stroke();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,6 +430,8 @@ export class ShapeDefinition extends BasicSerializableObject {
|
|||||||
context.lineTo(originX + dims, originY + dims);
|
context.lineTo(originX + dims, originY + dims);
|
||||||
context.lineTo(originX, originY + dims);
|
context.lineTo(originX, originY + dims);
|
||||||
context.closePath();
|
context.closePath();
|
||||||
|
context.fill();
|
||||||
|
context.stroke();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,25 +446,17 @@ export class ShapeDefinition extends BasicSerializableObject {
|
|||||||
0
|
0
|
||||||
);
|
);
|
||||||
context.closePath();
|
context.closePath();
|
||||||
|
context.fill();
|
||||||
|
context.stroke();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
if (MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]) {
|
|
||||||
MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]({
|
|
||||||
context,
|
|
||||||
layerScale,
|
|
||||||
quadrantSize,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw new Error("Unkown sub shape: " + subShape);
|
throw new Error("Unkown sub shape: " + subShape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.fill();
|
|
||||||
context.stroke();
|
|
||||||
|
|
||||||
context.rotate(-rotation);
|
context.rotate(-rotation);
|
||||||
context.translate(-centerQuadrantX, -centerQuadrantY);
|
context.translate(-centerQuadrantX, -centerQuadrantY);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user