Skip to content

Commit

Permalink
v0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lchzh3473 committed Jan 22, 2024
1 parent 163d5e1 commit f7631fe
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sim-phi/extends",
"version": "0.3.2",
"version": "0.3.3",
"description": "Third-party chart format conversion functions for sim-phi.",
"type": "module",
"main": "dist/index.js",
Expand Down Expand Up @@ -30,13 +30,13 @@
"@babel/plugin-transform-nullish-coalescing-operator": "^7.23.4",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-terser": "^0.4.4",
"@stylistic/eslint-plugin": "^1.4.1",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"eslint": "^8.54.0",
"@stylistic/eslint-plugin": "^1.5.4",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"eslint": "^8.56.0",
"eslint-plugin-rulesdir": "^0.2.2",
"typescript": "^5.3.2",
"vite": "^5.0.2",
"vite-plugin-dts": "^3.6.3"
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite-plugin-dts": "^3.7.1"
},
"files": [
"dist"
Expand Down
63 changes: 32 additions & 31 deletions src/pec/rpe2json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,41 +595,42 @@ export function parse(pec: string, filename: string): {
lineRPE.pushNote(type, time, positionX, holdTime, speed, note.above === 1, note.isFake !== 0, note.alpha === 0);
}
}
for (const e of i.eventLayers) {
if (!e) continue; // 有可能是null
for (const evts of i.eventLayers) {
if (!evts) continue; // 有可能是null
const layer = new EventLayer1();
for (const j of e.moveXEvents || []) {
const startTime = bpmList.calc2(j.startTime);
const endTime = bpmList.calc2(j.endTime);
const { fn, code } = getEasingFn(j, startTime, endTime);
getWarning(code, j);
layer.pushMoveXEvent(startTime, endTime, j.start, j.end, fn);
for (const evt of evts.moveXEvents || []) {
const startTime = bpmList.calc2(evt.startTime);
const endTime = bpmList.calc2(evt.endTime);
const { fn, code } = getEasingFn(evt, startTime, endTime);
getEasingWarning(code, evt);
layer.pushMoveXEvent(startTime, endTime, evt.start, evt.end, fn);
}
for (const j of e.moveYEvents || []) {
const startTime = bpmList.calc2(j.startTime);
const endTime = bpmList.calc2(j.endTime);
const { fn, code } = getEasingFn(j, startTime, endTime);
getWarning(code, j);
layer.pushMoveYEvent(startTime, endTime, j.start, j.end, fn);
for (const evt of evts.moveYEvents || []) {
const startTime = bpmList.calc2(evt.startTime);
const endTime = bpmList.calc2(evt.endTime);
const { fn, code } = getEasingFn(evt, startTime, endTime);
getEasingWarning(code, evt);
layer.pushMoveYEvent(startTime, endTime, evt.start, evt.end, fn);
}
for (const j of e.rotateEvents || []) {
const startTime = bpmList.calc2(j.startTime);
const endTime = bpmList.calc2(j.endTime);
const { fn, code } = getEasingFn(j, startTime, endTime);
getWarning(code, j);
layer.pushRotateEvent(startTime, endTime, j.start, j.end, fn);
for (const evt of evts.rotateEvents || []) {
const startTime = bpmList.calc2(evt.startTime);
const endTime = bpmList.calc2(evt.endTime);
const { fn, code } = getEasingFn(evt, startTime, endTime);
getEasingWarning(code, evt);
layer.pushRotateEvent(startTime, endTime, evt.start, evt.end, fn);
}
for (const j of e.alphaEvents || []) {
const startTime = bpmList.calc2(j.startTime);
const endTime = bpmList.calc2(j.endTime);
const { fn, code } = getEasingFn(j, startTime, endTime);
getWarning(code, j);
layer.pushAlphaEvent(startTime, endTime, j.start, j.end, fn);
for (const evt of evts.alphaEvents || []) {
const startTime = bpmList.calc2(evt.startTime);
const endTime = bpmList.calc2(evt.endTime);
const { fn, code } = getEasingFn(evt, startTime, endTime);
if (evt.start < 0 || evt.end < 0) warn(1, 'LineAlphaWarning', `检测到负数alpha(将被视为0)\n位于:"${JSON.stringify(evt)}"`);
getEasingWarning(code, evt);
layer.pushAlphaEvent(startTime, endTime, evt.start, evt.end, fn);
}
for (const j of e.speedEvents || []) {
const startTime = bpmList.calc2(j.startTime);
const endTime = bpmList.calc2(j.endTime);
layer.pushSpeedEvent(startTime, endTime, j.start, j.end);
for (const evt of evts.speedEvents || []) {
const startTime = bpmList.calc2(evt.startTime);
const endTime = bpmList.calc2(evt.endTime);
layer.pushSpeedEvent(startTime, endTime, evt.start, evt.end);
}
lineRPE.eventLayers.push(layer);
}
Expand All @@ -647,7 +648,7 @@ export function parse(pec: string, filename: string): {
result.numOfNotes! += judgeLine.numOfNotes;
}
return { data: result, messages: warnings, info, line, format };
function getWarning(code: EasingCode, le: LineEventRPE) {
function getEasingWarning(code: EasingCode, le: LineEventRPE) {
if (code === EasingCode.TypeNotSupported) warn(1, 'EasingTypeWarning', `未知的缓动类型:${le.easingType}(将被视为1)\n位于:"${JSON.stringify(le)}"`);
if (code === EasingCode.LeftEqualsRight) warn(1, 'EasingClipWarning', `检测到easingLeft等于easingRight(将被视为线性)\n位于:"${JSON.stringify(le)}"`);
if (code === EasingCode.ValueNotFinite) warn(1, 'EasingClipWarning', `非法的缓动函数(将被视为线性)\n位于:"${JSON.stringify(le)}"`);
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
'@stylistic/multiline-ternary': ['error', 'never'],
'@stylistic/newline-per-chained-call': 'off', // qwq
'@stylistic/no-confusing-arrow': 'off', // qwq
'@stylistic/no-extra-parens': ['error', 'all', { enforceForSequenceExpressions: false }],
'@stylistic/no-extra-parens': ['error', 'all'],
'@stylistic/no-mixed-operators': 'off', // qwq
'@stylistic/no-multiple-empty-lines': ['error', { max: 0 }],
'@stylistic/object-curly-spacing': ['error', 'always'],
Expand Down

0 comments on commit f7631fe

Please sign in to comment.