Skip to content

Commit f00582f

Browse files
committed
DrawHitObjectEffectHelper support hold judge
1 parent 50702f9 commit f00582f

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

OngekiFumenEditor/Base/OngekiObjects/Hold.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ public void CopyEntire(Hold from)
118118
}
119119
}
120120

121-
public IEnumerable<TGrid> CalculateJudgeTGrid(BpmList bpmList, int progressJudgeBpm)
121+
public IEnumerable<TGrid> CalculateJudgeTGrid(BpmList bpmList, float progressJudgeBpm)
122122
{
123123
return CalculateJudgeTGrid(TGrid, EndTGrid, bpmList, progressJudgeBpm);
124124
}
125125

126-
public IEnumerable<TGrid> CalculateJudgeTGrid(TGrid minTGrid, TGrid maxTGrid, BpmList bpmList, int progressJudgeBpm)
126+
public IEnumerable<TGrid> CalculateJudgeTGrid(TGrid minTGrid, TGrid maxTGrid, BpmList bpmList, float progressJudgeBpm)
127127
{
128128
int CalcHoldTickStepSize(double bpm)
129129
{
@@ -157,11 +157,20 @@ int CalcHoldTickStepSize(double bpm)
157157
var bpm = bpmList.GetBpm(curTGrid);
158158
var nextTGrid = bpmList.GetNextBpm(curTGrid)?.TGrid ?? TGrid.MaxValue;
159159

160+
//minTGrid is between this bpm and the next, so we could start to enumerate them from this bpm
160161
if (bpm.TGrid <= minTGrid && minTGrid <= nextTGrid)
161162
{
162163
var tickGrid = CalcHoldTickStepSize(bpm.BPM);
163-
curTGrid = holdStartTGrid + new GridOffset(0, tickGrid);
164+
curTGrid = curTGrid + new GridOffset(0, tickGrid);
164165

166+
//skip to minTGrid
167+
while (curTGrid < minTGrid)
168+
{
169+
tickGrid = CalcHoldTickStepSize(bpm.BPM);
170+
curTGrid = curTGrid + new GridOffset(0, tickGrid);
171+
}
172+
173+
//enumerate until hold end or maxTGrid
165174
while (curTGrid < holdEndTGrid && curTGrid < maxTGrid)
166175
{
167176
yield return curTGrid;
@@ -171,9 +180,11 @@ int CalcHoldTickStepSize(double bpm)
171180
curTGrid = curTGrid + new GridOffset(0, tickGrid);
172181
}
173182

183+
//finally check if need to yield hold end
174184
if (maxTGrid >= holdEndTGrid && curTGrid >= holdEndTGrid)
175185
yield return holdEndTGrid;
176186

187+
//done :D
177188
break;
178189
}
179190
else

OngekiFumenEditor/Modules/FumenVisualEditor/Graphics/Drawing/Editors/DrawHitObjectEffectHelper.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using OngekiFumenEditor.Base;
2+
using OngekiFumenEditor.Base.OngekiObjects;
23
using OngekiFumenEditor.Kernel.Graphics;
34
using OngekiFumenEditor.Utils;
45
using System;
@@ -46,7 +47,7 @@ public void Draw(IFumenEditorDrawingContext target)
4647

4748
var y = (float)target.ConvertToY_DefaultSoflanGroup(maxTGrid);
4849

49-
void drawColorCircle(float progress, Vector2 pos, Vector4 solidColor, float radius)
50+
void drawColorCircle(float progress, Vector2 pos, Vector4 solidColor, float radius, bool showHollow = true)
5051
{
5152
progress = Math.Clamp(progress, 0, 1);
5253

@@ -61,7 +62,8 @@ void drawColorCircle(float progress, Vector2 pos, Vector4 solidColor, float radi
6162
var hollowColor = new Vector4(solidColor.X, solidColor.Y, solidColor.Z, hollowCircleAlpha);
6263

6364
circleDrawing.Post(pos, solderColor, true, circleScale);
64-
circleDrawing.Post(pos, hollowColor, false, circleScale, 2);
65+
if (showHollow)
66+
circleDrawing.Post(pos, hollowColor, false, circleScale, 2);
6567
}
6668

6769
var hitObjects = Enumerable.Empty<OngekiMovableObjectBase>()
@@ -114,6 +116,26 @@ void drawColorCircle(float progress, Vector2 pos, Vector4 solidColor, float radi
114116
}
115117
circleDrawing.End();
116118

119+
var holdObjects = target.Editor.Fumen.Holds.GetVisibleStartObjects(minTGrid, maxTGrid);
120+
circleDrawing.Begin(target);
121+
foreach (var hold in holdObjects)
122+
{
123+
if (hold.ReferenceLaneStart is not { } start)
124+
continue;
125+
126+
foreach (var judgeTGrid in hold.CalculateJudgeTGrid(minTGrid, maxTGrid, target.Editor.Fumen.BpmList, target.Editor.Fumen.MetaInfo.ProgJudgeBpm))
127+
{
128+
var xGrid = start.CalulateXGrid(judgeTGrid);
129+
var x = (float)XGridCalculator.ConvertXGridToX(xGrid, target.Editor);
130+
var p = new Vector2(x, y);
131+
132+
var tGrid = judgeTGrid;
133+
var progress = (maxTGrid.TotalGrid * 1.0f - tGrid.TotalGrid) / durationTotalGrid;
134+
135+
drawColorCircle(progress, p, Vector4.One, 15, false);
136+
}
137+
}
138+
circleDrawing.End();
117139
}
118140
}
119141
}

0 commit comments

Comments
 (0)