Skip to content

Commit ba3af8d

Browse files
committed
fix: 一些小问题
1 parent e34f633 commit ba3af8d

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

‎generator/chu/C2sGenerator.cs‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ private List<string> FormatNote(ChuNote n, List<Alert> alerts)
104104
};
105105
List<string> r = [name, m.ToString(), o.ToString(), n.Cell.ToString(), n.Width.ToString()];
106106

107-
if (n.Type == ChuNoteType.Tap && n.IsEx) r.Add(ExDirections_ToUgc[n.Ex!.Value]); // CHR
107+
if (n.Type == ChuNoteType.Tap && n.IsEx) r.Add(n.Ex.ToString()!); // CHR
108108
else if (n.Type == ChuNoteType.Flick) r.Add(n.Ex == ExDirection.RS ? "R" : "L"); // FLK
109109
else if (n.IsAir)
110110
{ // AIR
111111
var targetStr = AsC2sPreviousStr(n.TargetNote);
112112
Utils.Assert(targetStr != null, "MuConvert内部错误:Air音符的TargetNote出现了不合法的类型!");
113-
r.AddRange(targetStr!, AirColor_ToUgc(n));
113+
r.AddRange(targetStr!, n.Color.ToString());
114114
}
115115

116116
results.Add(r);
@@ -130,16 +130,19 @@ private List<string> FormatNote(ChuNote n, List<Alert> alerts)
130130
};
131131

132132
var start = (n.Time, n.Cell, n.Width, n.Height);
133-
foreach (var seg in n.Segments)
133+
for (int idx = 0; idx < n.Segments.Count; idx++)
134134
{
135+
var seg = n.Segments[idx];
135136
// 必备的:name bar tick cell width
136137
var (sB, sT) = Utils.BarAndTick(start.Time, RSL);
137-
List<string> r = [name, sB.ToString(), sT.ToString(), start.Cell.ToString(), start.Width.ToString()];
138+
var hereName = n.Type == ChuNoteType.Slide && seg.C ? name[..2] + "C" : name;
139+
List<string> r = [hereName, sB.ToString(), sT.ToString(), start.Cell.ToString(), start.Width.ToString()];
138140

139141
// 前驱targetNote 或 crushInterval
140142
if (NeedsTargetNote(n))
141143
{
142-
var targetStr = AsC2sPreviousStr(n.TargetNote);
144+
// 对第一段,targetStr是TargetNote;对后面的段,TargetNote应该是前一段的名字。
145+
var targetStr = idx == 0 ? AsC2sPreviousStr(n.TargetNote) : AsC2sPreviousStr(n, n.Segments[idx-1]);
143146
Utils.Assert(targetStr != null, "MuConvert内部错误:Air音符的TargetNote出现了不合法的类型!");
144147
r.Add(targetStr!);
145148
}
@@ -166,10 +169,10 @@ private List<string> FormatNote(ChuNote n, List<Alert> alerts)
166169

167170
// 颜色
168171
if (n.IsAir) r.Add(n.Color.ToString());
169-
else if (n.Type == ChuNoteType.Slide) r.Add("SLD"); // C2S 1.13版本以上,Slide在最后,还需要加一个”SLD“后缀
172+
else if (n.Type == ChuNoteType.Slide) r.Add("SLD"); // C2S 1.10版本以上,Slide在最后,还需要加一个”SLD“后缀
170173

171174
// Ex音符的话,要加上Ex方向
172-
if (n.IsEx) r.Add(ExDirections_ToUgc[n.Ex!.Value]);
175+
if (n.IsEx) r.Add(n.Ex.ToString()!);
173176

174177
results.Add(r);
175178
start = (endTime, seg.EndCell, seg.EndWidth, seg.EndHeight);

‎generator/chu/UgcGenerator.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private List<ChuNote> SortedNotesForConnectingPrevious(ChuChart chart)
4545
// 2. 遍历 chart.Notes,对每个 ChuNote 以 DFS 方式把它本身以及它所有 Next 子孙依次加入结果。
4646
var result = new List<ChuNote>(chart.Notes.Count);
4747
var visited = new HashSet<ChuNote>();
48-
foreach (var root in chart.Notes) Dfs(root);
48+
foreach (var root in chart.Notes.Where(x=>x.TargetNote == null)) Dfs(root);
4949
return result;
5050

5151
void Dfs(ChuNote n)

‎parser/chu/UgcParser.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ private void ParseCellWidth(string code, int startIdx, ChuNote note, List<Alert>
607607
private (int, ChuNote?) ParseAirCrushNote(string[] lines, int idx, string code, ChuNote note, List<Alert> alerts, ChuChart chart)
608608
{
609609
note.Type = ChuNoteType.Crush;
610+
note.IsAir = true;
610611
ParseCellWidth(code, 1, note, alerts, idx + 1, chart);
611612
if (code.Length <= 3) alerts.Add(new Alert(Warning, "AirCrush缺少参数!", (chart, note.Time), idx+1, lines[idx]));
612613
else ParseHeightAndColor(note, code[3..], alerts, idx+1, "C");

‎utils/ChuUtils.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ public static bool AirColor_FromUgc(ChuNote n, string rawColorStr, out NoteColor
8484
public static bool TryH36ToI(string str, out int result) => Utils.TryHToI(str, 36, out result);
8585
public static string IToH36(int value) => Utils.IToH(value, 36);
8686

87-
public static string? AsC2sPreviousStr(ChuNote? n) => n?.Type switch
87+
public static string? AsC2sPreviousStr(ChuNote? n, ChuSegment? lastSegment = null) => n?.Type switch
8888
{
8989
ChuNoteType.Tap when !n.IsAir => n.IsEx ? "CHR" : "TAP",
9090
ChuNoteType.Flick => "FLK",
9191
ChuNoteType.Mine => "MNE",
9292
ChuNoteType.Hold => n.IsAir ? "AHD" : "HLD",
9393
ChuNoteType.Slide => n.IsAir ?
94-
(n.Segments.LastOrDefault()?.C == true ? "ASC" : "ASD") :
94+
(lastSegment ?? n.Segments.LastOrDefault())?.C == true ? "ASC" : "ASD" :
9595
"SLD",
9696
_ => null,
9797
};

0 commit comments

Comments
 (0)