Skip to content

Commit b9d39fe

Browse files
committed
[R] Slide的Head属性重命名为OwnHead
1 parent 0253a12 commit b9d39fe

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

chart/Slide.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public Star(Tap inTake): this(inTake.Chart, inTake.Time) // 拷贝构造函数
2222
[DebuggerDisplay("{DebuggerDisplay(),nq}")]
2323
public class Slide : Note
2424
{
25-
public Tap? Head; // 根据simai语法,星星头既可以是普通的星星形状(1-5),也可以是Tap形状的(1@-5),也可以没有(1?-5或1!-5)
25+
public Tap? OwnHead; // 属于自己的星星头。只有在SharedHeadWith=null的那根星星上应该设置此项,否则直接通过SharedHeadWith链过去即可
26+
// PS: 根据simai语法,星星头既可以是普通的星星形状(1-5),也可以是Tap形状的(1@-5),也可以没有(1?-5或1!-5)
2627
public Slide? SharedHeadWith;
2728
public List<SlideSegment> segments = new();
2829
public Duration WaitTime;
@@ -34,14 +35,17 @@ public Slide(Chart chart, Rational time) : base(chart, time)
3435

3536
public override int Key
3637
{
37-
get => Head?.Key ?? SharedHeadWith?.Key ?? _key;
38+
get => OwnHead?.Key ?? SharedHeadWith?.Key ?? _key;
3839
set
3940
{
40-
Utils.Assert(Head == null && SharedHeadWith?.Key == null, "尝试为有头星星手动设置星星头");
41+
Utils.Assert(OwnHead == null && SharedHeadWith?.Key == null, "尝试为有头星星手动设置星星头");
4142
if (value < 1 || value > 8) throw new ArgumentException(string.Format(Locale.InvalidKey, value));
4243
_key = value;
4344
}
4445
}
46+
47+
// 所有的SharedHeadWith的连接关系,会构成一棵树,其中只有树根节点有OwnHead且SharedHeadWith为null。
48+
public Slide SharedHeadWithRoot => SharedHeadWith != null ? SharedHeadWith.SharedHeadWithRoot : this;
4549

4650
public int EndKey => segments.Count > 0 ? segments.Last().EndKey : Key;
4751

@@ -75,10 +79,12 @@ private string DebuggerDisplay()
7579
{
7680
string result;
7781
if (SharedHeadWith != null) result = "*";
78-
else if (Head != null) result = Head.DebuggerDisplay();
79-
else result = Key.ToString();
80-
if (Head != null && !(Head is Star)) result += "@"; // Tap形状的头
81-
else if (Head == null && SharedHeadWith == null) result += "?"; // 无头
82+
else if (OwnHead != null)
83+
{
84+
result = OwnHead.DebuggerDisplay();
85+
if (!(OwnHead is Star)) result += "@"; // Tap形状的头
86+
}
87+
else result = Key + "?"; // 无头
8288

8389
var segStart = Key;
8490
foreach (var s in segments)

generator/MA2Generator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private void AddTap(Tap tap, int bar, int tick)
136136
}
137137
else if (note is Slide slide)
138138
{
139-
if (slide.Head != null) AddTap(slide.Head, bar, tick);
139+
if (slide.OwnHead != null) AddTap(slide.OwnHead, bar, tick);
140140

141141
// 首先很重要的一点是,详见 https://github.com/Neskol/MaiLib/issues/46#issuecomment-3301893924 ,
142142
// 官机现在对于多段星星,是会无视掉每一段分别指定的时长,把总时长加和然后全程匀速处理的。

parser/MA2Parser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void pair()
217217
toRemove.Add(pairedTap);
218218
for (int j = 0; j < slideLists[i].Count; j++)
219219
{
220-
if (j == 0) slideLists[i][j].Head = pairedTap;
220+
if (j == 0) slideLists[i][j].OwnHead = pairedTap;
221221
else slideLists[i][j].SharedHeadWith = slideLists[i][0];
222222
}
223223
}

parser/simai/SimaiParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ public sealed override object VisitSlide(P.SlideContext context)
451451
head = null;
452452
}
453453
else if (context.STAR_TO_TAP() == null) head = new Star(head); // 除非标记了STAR_TO_TAP,否则把tap转为star
454-
result.Head = head;
454+
result.OwnHead = head;
455455

456456
currNote = result;
457457
VisitSlideBody(context.slideBody());

0 commit comments

Comments
 (0)