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.lineWidth = THEME.items.outlineWidth;
|
||||
|
||||
if (MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]) {
|
||||
MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]({
|
||||
context,
|
||||
layerScale,
|
||||
quadrantSize,
|
||||
});
|
||||
} else {
|
||||
switch (subShape) {
|
||||
case enumSubShape.rect: {
|
||||
context.beginPath();
|
||||
const dims = quadrantSize * layerScale;
|
||||
context.rect(-quadrantHalfSize, quadrantHalfSize - dims, dims, dims);
|
||||
|
||||
context.fill();
|
||||
context.stroke();
|
||||
break;
|
||||
}
|
||||
case enumSubShape.star: {
|
||||
@ -405,6 +413,8 @@ export class ShapeDefinition extends BasicSerializableObject {
|
||||
context.lineTo(originX + dims - moveInwards, originY + dims);
|
||||
context.lineTo(originX, originY + dims);
|
||||
context.closePath();
|
||||
context.fill();
|
||||
context.stroke();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -420,6 +430,8 @@ export class ShapeDefinition extends BasicSerializableObject {
|
||||
context.lineTo(originX + dims, originY + dims);
|
||||
context.lineTo(originX, originY + dims);
|
||||
context.closePath();
|
||||
context.fill();
|
||||
context.stroke();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -434,25 +446,17 @@ export class ShapeDefinition extends BasicSerializableObject {
|
||||
0
|
||||
);
|
||||
context.closePath();
|
||||
context.fill();
|
||||
context.stroke();
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.fill();
|
||||
context.stroke();
|
||||
|
||||
context.rotate(-rotation);
|
||||
context.translate(-centerQuadrantX, -centerQuadrantY);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user