Skip to content

Commit

Permalink
修正官谱 hold 渲染逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
MisaLiu committed Nov 13, 2022
1 parent 80fa679 commit 50313a8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 44 deletions.
32 changes: 14 additions & 18 deletions src/chart/convert/official.js
Expand Up @@ -119,19 +119,14 @@ export default function OfficialChartConverter(_chart)
rawNote.holdTime = calcRealTime(rawNote.holdTime, rawNote.bpm);
rawNote.holdEndTime = rawNote.time + rawNote.holdTime;

if (rawNote.type == 3)
{
rawNote.speed = 1;
}

{ // 考虑到 js 精度,此处重新计算 Note 的 floorPosition 值
let noteStartSpeedEvent = rawNote.judgeline.getFloorPosition(rawNote.time);
rawNote.floorPosition = noteStartSpeedEvent ? noteStartSpeedEvent.floorPosition + noteStartSpeedEvent.value * (rawNote.time - noteStartSpeedEvent.startTime) : 0;

if (rawNote.type == 3)
{
let noteEndSpeedEvent = rawNote.judgeline.getFloorPosition(rawNote.holdEndTime);
rawNote.holdLength = (noteEndSpeedEvent ? noteEndSpeedEvent.floorPosition + noteEndSpeedEvent.value * (rawNote.holdEndTime - noteEndSpeedEvent.startTime) : 0) - rawNote.floorPosition;
rawNote.holdLength = rawNote.holdTime * rawNote.speed /*(noteEndSpeedEvent ? noteEndSpeedEvent.floorPosition + noteEndSpeedEvent.value * (rawNote.holdEndTime - noteEndSpeedEvent.startTime) : 0) - rawNote.floorPosition */;
}
else
{
Expand All @@ -140,18 +135,19 @@ export default function OfficialChartConverter(_chart)
}

return new Note({
id : rawNote.id,
lineId : rawNote.lineId,
type : rawNote.type,
time : rawNote.time,
holdTime : rawNote.holdTime,
holdLength : rawNote.holdLength,
positionX : rawNote.positionX,
floorPosition : rawNote.floorPosition,
speed : rawNote.speed,
isAbove : rawNote.isAbove,
isMulti : rawNote.isMulti,
judgeline : rawNote.judgeline
id : rawNote.id,
lineId : rawNote.lineId,
type : rawNote.type,
time : rawNote.time,
holdTime : rawNote.holdTime,
holdLength : rawNote.holdLength,
positionX : rawNote.positionX,
floorPosition : rawNote.floorPosition,
speed : rawNote.speed,
isAbove : rawNote.isAbove,
isMulti : rawNote.isMulti,
useOfficialSpeed : true,
judgeline : rawNote.judgeline
});
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/chart/convert/rephiedit.js
Expand Up @@ -110,7 +110,7 @@ export default function RePhiEditChartConverter(_chart)
let judgeline = new Judgeline({
id : judgelineIndex,
texture : _judgeline.Texture != 'line.png' ? _judgeline.Texture : null,
parentLine : _judgeline.father >= 0 ? _judgeline.father + 1 : null,
parentLine : _judgeline.father >= 0 ? _judgeline.father : null,
isCover : _judgeline.isCover == 1
});

Expand Down Expand Up @@ -424,7 +424,7 @@ export default function RePhiEditChartConverter(_chart)
{
if (judgeline.parentLine && judgeline.parentLine > 0)
{
let parentLineId = judgeline.parentLine - 1;
let parentLineId = judgeline.parentLine;
judgeline.parentLine = null;

for (const parentLine of judgelines)
Expand Down
5 changes: 3 additions & 2 deletions src/chart/index.js
Expand Up @@ -242,8 +242,9 @@ export default class Chart
{
if (note.type === 3)
{
note.sprite.children[1].height = note.holdLength * note.speed * this.renderSize.noteSpeed / this.renderSize.noteScale;
note.sprite.children[2].position.y = -(note.holdLength * note.speed * this.renderSize.noteSpeed / this.renderSize.noteScale);
let holdLength = note.holdLength * (note.useOfficialSpeed ? 1 : note.speed) * this.renderSize.noteSpeed / this.renderSize.noteScale
note.sprite.children[1].height = holdLength;
note.sprite.children[2].position.y = -holdLength;
}

note.sprite.baseScale = this.renderSize.noteScale;
Expand Down
45 changes: 23 additions & 22 deletions src/chart/note.js
Expand Up @@ -4,26 +4,27 @@ export default class Note
{
constructor(params)
{
this.id = !isNaN(Number(params.id)) ? Number(params.id) : -1;
this.type = !isNaN(Number(params.type)) ? Number(params.type) : 1;
this.time = !isNaN(parseFloat(params.time)) ? parseFloat(params.time) : -1; // Note 开始时间
this.holdTime = (this.type === 3 && !isNaN(parseFloat(params.holdTime))) ? parseFloat(params.holdTime) : 0; // Note 按住需要经过的时间,仅 Hold
this.holdTimeLength = this.type === 3 ? parseFloat(this.time + this.holdTime) : 0; // Note 按完的时间,自动计算,仅 Hold
this.speed = !isNaN(parseFloat(params.speed)) ? parseFloat(params.speed) : 1;
this.floorPosition = !isNaN(parseFloat(params.floorPosition)) ? parseFloat(params.floorPosition) : this.time;
this.holdLength = (this.type === 3 && !isNaN(parseFloat(params.holdLength))) ? parseFloat(params.holdLength) : 0;
this.endPosition = parseFloat(this.floorPosition + this.holdLength);
this.positionX = !isNaN(parseFloat(params.positionX)) ? parseFloat(params.positionX) : 0;
this.basicAlpha = (!isNaN(parseFloat(params.basicAlpha)) && parseFloat(params.basicAlpha) >= 0 && parseFloat(params.basicAlpha) <= 1) ? parseFloat(params.basicAlpha) : 1;
this.visibleTime = (!isNaN(parseFloat(params.visibleTime)) && params.visibleTime < 999999) ? parseFloat(params.visibleTime) : NaN;
this.yOffset = !isNaN(parseFloat(params.yOffset)) ? parseFloat(params.yOffset) : 0;
this.xScale = !isNaN(parseFloat(params.xScale)) ? parseFloat(params.xScale) : 1;
this.isAbove = !!params.isAbove;
this.isFake = !!params.isFake;
this.isMulti = !!params.isMulti;
this.texture = (params.texture && params.texture != '') ? params.texture : null;
this.hitsound = (params.hitsound && params.hitsound != '') ? params.hitsound : null;
this.judgeline = params.judgeline;
this.id = !isNaN(Number(params.id)) ? Number(params.id) : -1;
this.type = !isNaN(Number(params.type)) ? Number(params.type) : 1;
this.time = !isNaN(parseFloat(params.time)) ? parseFloat(params.time) : -1; // Note 开始时间
this.holdTime = (this.type === 3 && !isNaN(parseFloat(params.holdTime))) ? parseFloat(params.holdTime) : 0; // Note 按住需要经过的时间,仅 Hold
this.holdTimeLength = this.type === 3 ? parseFloat(this.time + this.holdTime) : 0; // Note 按完的时间,自动计算,仅 Hold
this.speed = !isNaN(parseFloat(params.speed)) ? parseFloat(params.speed) : 1;
this.floorPosition = !isNaN(parseFloat(params.floorPosition)) ? parseFloat(params.floorPosition) : this.time;
this.holdLength = (this.type === 3 && !isNaN(parseFloat(params.holdLength))) ? parseFloat(params.holdLength) : 0;
this.endPosition = parseFloat(this.floorPosition + this.holdLength);
this.positionX = !isNaN(parseFloat(params.positionX)) ? parseFloat(params.positionX) : 0;
this.basicAlpha = (!isNaN(parseFloat(params.basicAlpha)) && parseFloat(params.basicAlpha) >= 0 && parseFloat(params.basicAlpha) <= 1) ? parseFloat(params.basicAlpha) : 1;
this.visibleTime = (!isNaN(parseFloat(params.visibleTime)) && params.visibleTime < 999999) ? parseFloat(params.visibleTime) : NaN;
this.yOffset = !isNaN(parseFloat(params.yOffset)) ? parseFloat(params.yOffset) : 0;
this.xScale = !isNaN(parseFloat(params.xScale)) ? parseFloat(params.xScale) : 1;
this.isAbove = !!params.isAbove;
this.isFake = !!params.isFake;
this.isMulti = !!params.isMulti;
this.useOfficialSpeed = !!params.useOfficialSpeed;
this.texture = (params.texture && params.texture != '') ? params.texture : null;
this.hitsound = (params.hitsound && params.hitsound != '') ? params.hitsound : null;
this.judgeline = params.judgeline;

this.sprite = undefined;

Expand Down Expand Up @@ -167,13 +168,13 @@ export default class Note
let _yOffset = size.height * this.yOffset,
yOffset = _yOffset * (this.isAbove ? -1 : 1),
originX = size.widthPercent * this.positionX,
_originY = (this.floorPosition - this.judgeline.floorPosition) * this.speed * size.noteSpeed + _yOffset,
_originY = (this.floorPosition - this.judgeline.floorPosition) * (this.type === 3 && this.useOfficialSpeed ? 1 : this.speed) * size.noteSpeed + _yOffset,
originY = _originY * (this.isAbove ? -1 : 1),

realX = originY * this.judgeline.sinr * -1,
realY = originY * this.judgeline.cosr,

_holdLength = this.type === 3 ? (this.endPosition - this.judgeline.floorPosition) * this.speed * size.noteSpeed : _originY,
_holdLength = this.type === 3 ? (this.useOfficialSpeed ? (this.holdTimeLength - currentTime) : (this.endPosition - this.judgeline.floorPosition)) * this.speed * size.noteSpeed : _originY,
holdLength = this.type === 3 ? _holdLength * (this.isAbove ? -1 : 1) : originY;

if (!isNaN(this.judgeline.inclineSinr) && this.type !== 3)
Expand Down

0 comments on commit 50313a8

Please sign in to comment.