Skip to content

Commit

Permalink
Added support for faceSizeRect on script page
Browse files Browse the repository at this point in the history
  • Loading branch information
squaresmile committed Aug 15, 2024
1 parent 1d0452f commit 49defb5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/api-connector/src/Schema/Script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface ScriptExtendData {
combineResultMultipleForm?: number;
myroomForm?: number;
faceSize?: number;
faceSizeRect?: number[];
conds?: { condType: number; value: number }[];
}

Expand Down
21 changes: 13 additions & 8 deletions packages/db/src/Component/Scene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,27 @@ const Scene = (props: {
if (props.figure && props.figure.face > 0 && script) {
let face = props.figure.face - 1,
defaultFaceSize = 256,
faceSize = script.extendData.faceSize ?? defaultFaceSize,
size = faceSize * scale,
faceSizeWidth = script.extendData.faceSizeRect
? script.extendData.faceSizeRect[0]
: (script.extendData.faceSize ?? defaultFaceSize),
faceSizeHeight = script.extendData.faceSizeRect
? script.extendData.faceSizeRect[1]
: (script.extendData.faceSize ?? defaultFaceSize),
offsetX = 0,
offsetY = faceSize === defaultFaceSize ? 1024 - defaultFaceSize : 1024,
perRow = Math.floor(figureWidth / faceSize),
offsetY = faceSizeHeight === defaultFaceSize ? 1024 - defaultFaceSize : 1024,
perRow = Math.floor(figureWidth / faceSizeWidth),
col = face % perRow,
row = Math.floor(face / perRow),
page = Math.floor(row / perRow),
rowInPage = row % perRow,
backgroundPositionX: number | string = (col * faceSize * -1 - offsetX) * scale,
backgroundPositionY: number | string = ((page * figureWidth + rowInPage * faceSize) * -1 - offsetY) * scale,
backgroundPositionX: number | string = (col * faceSizeWidth * -1 - offsetX) * scale,
backgroundPositionY: number | string =
((page * figureWidth + rowInPage * faceSizeHeight) * -1 - offsetY) * scale,
backgroundSize: number | string = scale * figureWidth,
left = script.faceX * scale + figureLeft,
top = script.faceY * scale,
height = size,
width = size;
height = faceSizeHeight * scale,
width = faceSizeWidth * scale;

faceElement = (
<div
Expand Down

0 comments on commit 49defb5

Please sign in to comment.