Skip to content

Commit a8a89d3

Browse files
committed
[R]将clockCount参数从MA2Generator内移动到Chart内和SimaiParser的参数上。
1 parent 242c56d commit a8a89d3

5 files changed

Lines changed: 9 additions & 14 deletions

File tree

Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ private static void ConvertPlainSimai(string text, string outputDir, HashSet<int
175175

176176
private static string SimaiToMa2(string inote, int clockCount=4, bool bigTouch=false, bool isUtage=false)
177177
{
178-
var (chart, parseAlerts) = new SimaiParser(bigTouch, isUtage).Parse(inote);
179-
var (ma2, genAlerts) = new MA2Generator(clockCount).Generate(chart);
178+
var (chart, parseAlerts) = new SimaiParser(bigTouch, isUtage, clockCount).Parse(inote);
179+
var (ma2, genAlerts) = new MA2Generator().Generate(chart);
180180
var combined = new List<Alert>(parseAlerts.Count + genAlerts.Count);
181181
combined.AddRange(parseAlerts);
182182
combined.AddRange(genAlerts);

chart/Chart.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class Chart
99

1010
public string DefaultTouchSize = "M1";
1111
public bool IsUtage = false;
12+
public int ClockCount = 4;
1213

1314
public Rational ToSecond(Rational barTime) => BpmList.ToSecond(barTime);
1415

generator/MA2Generator.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@ public class MA2Generator : IGenerator
1212
private List<MA2Line> lines = [];
1313
private readonly List<Alert> alerts = [];
1414

15-
public int ClockCount = 4;
1615
// 除非你知道你在做什么,不然以下两个变量请勿修改!
1716
public int MA2Version = 105;
1817
public int RSL = 384;
19-
20-
public MA2Generator(int clockCount = 4)
21-
{
22-
ClockCount = clockCount;
23-
}
2418

2519
private string headTemplate = @"VERSION 0.00.00 {0}
2620
FES_MODE {1}
@@ -87,7 +81,7 @@ private void AddTap(Tap tap, int bar, int tick)
8781
string head = string.Format(headTemplate,
8882
$"{MA2Version / 100}.{MA2Version % 100:D2}.00", chart.IsUtage?1:0,
8983
bpmStatistics.Item1, bpmStatistics.Item2, bpmStatistics.Item3, bpmStatistics.Item4,
90-
RSL, 96*ClockCount, Utils.AppVersion);
84+
RSL, 96*chart.ClockCount, Utils.AppVersion);
9185
result.Append(head);
9286

9387
// bpm段
@@ -96,7 +90,7 @@ private void AddTap(Tap tap, int bar, int tick)
9690
var (bar, tick) = BT(bpm.Time);
9791
result.AppendLine($"BPM\t{bar}\t{tick}\t{bpm.Bpm:F3}");
9892
}
99-
result.AppendLine($"MET\t0\t0\t4\t{ClockCount}");
93+
result.AppendLine($"MET\t0\t0\t4\t{chart.ClockCount}");
10094
result.AppendLine();
10195

10296
// 主体:音符段

parser/simai/SimaiParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public class SimaiParser : SimaiBaseVisitor<object>, IParser
2121
private Note? currNote; // 用于在部分visitor之间传递额外的参数,如visitDuration、visitSlideBody等,都需要Note对象作为参数传入的情况
2222
private readonly List<string> extraModifiers = [];
2323

24-
public SimaiParser(bool bigTouch = false, bool isUtage = false)
24+
public SimaiParser(bool bigTouch = false, bool isUtage = false, int clockCount = 4)
2525
{
26-
chart = new Chart { DefaultTouchSize = bigTouch ? "L1" : "M1", IsUtage = isUtage };
26+
chart = new Chart { DefaultTouchSize = bigTouch ? "L1" : "M1", IsUtage = isUtage, ClockCount = clockCount};
2727
}
2828

2929
private void AddAlert(Alert.LEVEL level, string content, ParserRuleContext? context = null)

tests/自制谱测试.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public void TestChart(TestInput input)
5656
Assert.True(expected.Count == 1,
5757
$"Expected exactly one golden file matching '*{expectedSuffix}' in '{dir.FullName}', got {expected.Count}.");
5858

59-
var (chart, _) = new SimaiParser(bigTouch: false, isUtage: false).Parse(chartInfo.Inote);
60-
var (ma2, _) = new MA2Generator(clockCount: maidata.ClockCount).Generate(chart);
59+
var (chart, _) = new SimaiParser(bigTouch: false, isUtage: false, clockCount: maidata.ClockCount).Parse(chartInfo.Inote);
60+
var (ma2, _) = new MA2Generator().Generate(chart);
6161

6262
var expectedMa2 = File.ReadAllText(expected[0].FullName, Encoding.UTF8);
6363

0 commit comments

Comments
 (0)